oxirs-physics
Physics-informed digital twin simulation bridge for OxiRS semantic web platform.
Overview
oxirs-physics bridges the gap between semantic RDF knowledge graphs and SciRS2-powered physics simulations, enabling physics-informed AI reasoning and digital twin synchronization.
Key Capabilities:
- Extract simulation parameters from RDF graphs and SAMM Aspect Models
- Run physics simulations using SciRS2 (thermal, mechanical, fluid, electrical, etc.)
- Validate results against physics constraints (conservation laws, dimensional analysis)
- Inject simulation results back to RDF with full provenance tracking
- Synchronize physical asset state with digital twin representations
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ RDF Knowledge Graph │
│ • Entity properties (mass, dimensions, material) │
│ • Initial conditions (temperature, pressure, velocity) │
│ • Boundary conditions (constraints, forces, heat flux) │
│ • SAMM Aspect Models (structured domain ontologies) │
└───────────────┬─────────────────────────────────────────────────┘
│ extract_parameters
▼
┌─────────────────────────────────────────────────────────────────┐
│ Parameter Extractor (SPARQL queries) │
│ • Parse RDF properties → SimulationParameters │
│ • SAMM model interpretation → structured data │
│ • Unit conversion & validation │
└───────────────┬─────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ SciRS2 Simulation Engine │
│ │
│ Thermal: Heat diffusion (scirs2-integrate ODE) │
│ Mechanical: Structural FEM (scirs2-linalg) │
│ Fluid: Navier-Stokes CFD (scirs2-neural) │
│ Electrical: Circuit analysis (scirs2-optimize) │
│ Coupled: Multi-physics (scirs2-parallel) │
│ │
│ Features: │
│ • GPU acceleration (scirs2-core::gpu) │
│ • SIMD vectorization (scirs2-core::simd) │
│ • Parallel execution (scirs2-core::parallel) │
└───────────────┬─────────────────────────────────────────────────┘
│ SimulationResult
▼
┌─────────────────────────────────────────────────────────────────┐
│ Physics Constraint Validation │
│ • Conservation laws (energy, momentum, mass) │
│ • Dimensional analysis (unit consistency) │
│ • Physical bounds (temperature, pressure limits) │
│ • Numerical stability (convergence checks) │
└───────────────┬─────────────────────────────────────────────────┘
│ validated results
▼
┌─────────────────────────────────────────────────────────────────┐
│ Result Injector (SPARQL UPDATE) │
│ • Insert state trajectory to RDF │
│ • Add derived quantities (stress, strain, flow rate) │
│ • Record provenance (software version, parameters hash) │
│ • Link to simulation run metadata (timestamp, convergence) │
└───────────────┬─────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Updated RDF Knowledge Graph │
│ • Simulation results (time series data) │
│ • Provenance trail (reproducibility) │
│ • Digital twin state synchronized │
└─────────────────────────────────────────────────────────────────┘
Features
Core Features (Implemented)
- Simulation Orchestration:
SimulationOrchestratorcoordinates extract → run → inject workflow - Thermal Simulation: 1D heat diffusion using SciRS2 ODE solvers (Runge-Kutta 4)
- Conservation Laws: Energy conservation validation for physics results
- Provenance Tracking: Full simulation metadata (software version, parameters hash, execution time)
- Error Handling: Comprehensive error types for physics operations
Planned Features
See TODO.md for detailed roadmap.
- Additional Simulation Types: Mechanical, fluid dynamics, electrical, multi-physics
- RDF Integration: Full SPARQL parameter extraction and result injection
- SAMM Support: Parse SAMM Aspect Models for structured parameters
- Advanced Constraints: Full dimensional analysis with type-safe units
- GPU Acceleration: Large-scale simulations using scirs2-core::gpu
- Streaming: Real-time simulation updates via oxirs-stream
- Hybrid Physics-ML: Neural network corrections using oxirs-embed
Installation
Add to your Cargo.toml:
[]
= { = "0.1.0", = ["simulation"] }
Feature Flags
| Feature | Description | Dependencies |
|---|---|---|
simulation |
SciRS2-based physics simulations | scirs2-integrate, scirs2-optimize, uom |
embeddings |
Neural network hybrid models | scirs2-neural, oxirs-embed |
samm |
SAMM Aspect Model support | oxirs-samm |
streaming |
Real-time simulation updates | oxirs-stream |
full |
All features enabled | All of the above |
Usage
Basic Thermal Simulation
use ;
use Arc;
async
Custom Simulation with Full Control
use ;
use HashMap;
async
Conservation Law Validation
use ;
use HashMap;
Code Statistics
===============================================================================
===============================================================================
|
()
===============================================================================
Project Structure
oxirs-physics/
├── src/
│ ├── lib.rs # Public API and module declarations
│ ├── error.rs # Error types (PhysicsError)
│ ├── simulation/
│ │ ├── mod.rs # SimulationOrchestrator
│ │ ├── parameter_extraction.rs # RDF → SimulationParameters
│ │ ├── result_injection.rs # SimulationResult → RDF
│ │ ├── simulation_runner.rs # PhysicsSimulation trait
│ │ └── scirs2_thermal.rs # Thermal simulation (SciRS2 ODE)
│ ├── constraints/
│ │ ├── mod.rs # Physics constraint API
│ │ ├── conservation_laws.rs # Energy/momentum/mass conservation
│ │ └── dimensional_analysis.rs # Unit checking (WIP)
│ └── digital_twin/
│ └── mod.rs # Digital twin management (WIP)
├── Cargo.toml # Dependencies and features
├── README.md # This file
└── TODO.md # Development roadmap
SciRS2 Integration
oxirs-physics is built on the SciRS2 foundation and follows the SciRS2 Integration Policy.
Core Dependencies
| SciRS2 Crate | Usage in oxirs-physics |
|---|---|
scirs2-core |
Array operations, random, SIMD, GPU, parallel |
scirs2-integrate |
ODE/PDE solvers for thermal/mechanical sims |
scirs2-optimize |
Parameter optimization, inverse problems |
scirs2-neural |
Neural network corrections for simulations |
scirs2-linalg |
Linear algebra for FEM/structural analysis |
scirs2-stats |
Statistical validation of simulation results |
Full SciRS2 Usage Examples
// Arrays and numerical operations
use ;
use mean;
// Random number generation
use ;
// Performance optimization
use simd_dot_product;
use par_chunks;
use ;
// Memory efficiency for large RDF datasets
use MemoryMappedArray;
use BufferPool;
// Profiling and metrics
use Profiler;
use Timer;
// Error handling
use ;
Development
Build & Test
# Build with all features
# Run tests (use nextest)
# Run with specific feature
# Lint (no warnings policy)
# Format check
Benchmarking
# Run benchmarks (when implemented)
Digital Twin Definition Language (DTDL)
oxirs-physics will support Azure Digital Twins' DTDL for standardized twin definitions. See TODO.md for implementation roadmap.
Example DTDL integration:
Contributing
See the main OxiRS README for contribution guidelines.
Development Guidelines:
- SciRS2 First: Use SciRS2 crates instead of direct
ndarrayorrandimports - No Warnings: All code must compile without warnings (
cargo clippy -- -D warnings) - Physics Validation: All simulations must validate results against conservation laws
- Provenance: All results must include full provenance metadata
- Testing: Use
std::env::temp_dir()for temporary files in tests - Naming: Use
snake_casefor variables,PascalCasefor types
References
Physics Simulation
- SciRS2:
~/work/scirs/- Scientific computing foundation - Apache Jena:
~/work/jena/- RDF/SPARQL reference - Oxigraph:
~/work/oxigraph/- RDF triple store reference
Digital Twins
- Azure DTDL: Digital Twins Definition Language
- ISO 23247: Digital Twin Framework for Manufacturing
Standards
- SAMM: Semantic Aspect Meta Model
- W3C PROV: Provenance Ontology
License
Same as OxiRS parent project (see repository root).
Version
Current version: 0.1.0
Part of the OxiRS semantic web platform.