| Crates.io | oxirs-physics |
| lib.rs | oxirs-physics |
| version | 0.1.0 |
| created_at | 2025-12-26 15:32:03.471989+00 |
| updated_at | 2026-01-20 22:16:40.186133+00 |
| description | Physics-informed digital twin simulation bridge for OxiRS |
| homepage | https://github.com/cool-japan/oxirs |
| repository | https://github.com/cool-japan/oxirs |
| max_upload_size | |
| id | 2005865 |
| size | 284,632 |
Physics-informed digital twin simulation bridge for OxiRS semantic web platform.
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:
┌─────────────────────────────────────────────────────────────────┐
│ 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 │
└─────────────────────────────────────────────────────────────────┘
SimulationOrchestrator coordinates extract → run → inject workflowSee TODO.md for detailed roadmap.
Add to your Cargo.toml:
[dependencies]
oxirs-physics = { version = "0.1.0", features = ["simulation"] }
| 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 |
use oxirs_physics::simulation::{SimulationOrchestrator, SciRS2ThermalSimulation};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create orchestrator
let mut orchestrator = SimulationOrchestrator::new();
// Register thermal simulation
let thermal_sim = Arc::new(SciRS2ThermalSimulation::default());
orchestrator.register("thermal", thermal_sim);
// Execute workflow: extract parameters from RDF → run simulation → inject results
let result = orchestrator.execute_workflow(
"urn:example:battery:001", // Entity IRI
"thermal" // Simulation type
).await?;
println!("Simulation completed: {} states", result.state_trajectory.len());
println!("Converged: {}", result.convergence_info.converged);
Ok(())
}
use oxirs_physics::simulation::{
ParameterExtractor, SimulationParameters, PhysicalQuantity,
SciRS2ThermalSimulation, PhysicsSimulation, ResultInjector
};
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Step 1: Setup parameters manually
let mut initial_conditions = HashMap::new();
initial_conditions.insert("temperature".to_string(), PhysicalQuantity {
value: 300.0,
unit: "K".to_string(),
uncertainty: None,
});
let params = SimulationParameters {
entity_iri: "urn:example:battery:thermal".to_string(),
simulation_type: "thermal".to_string(),
initial_conditions,
boundary_conditions: Vec::new(),
time_span: (0.0, 100.0),
time_steps: 50,
material_properties: HashMap::new(),
constraints: Vec::new(),
};
// Step 2: Run simulation
let sim = SciRS2ThermalSimulation::new(
237.0, // Thermal conductivity (W/m·K) - Aluminum
900.0, // Specific heat (J/kg·K) - Aluminum
2700.0 // Density (kg/m³) - Aluminum
);
let result = sim.run(¶ms).await?;
// Step 3: Validate physics constraints
sim.validate_results(&result)?;
// Step 4: Inject results to RDF
let injector = ResultInjector::new();
injector.inject(&result).await?;
Ok(())
}
use oxirs_physics::constraints::{ConservationChecker, ConservationLaw};
use std::collections::HashMap;
fn validate_energy_conservation() -> Result<(), Box<dyn std::error::Error>> {
let checker = ConservationChecker::new();
let mut initial_state = HashMap::new();
initial_state.insert("kinetic_energy".to_string(), 100.0);
initial_state.insert("potential_energy".to_string(), 50.0);
let mut final_state = HashMap::new();
final_state.insert("kinetic_energy".to_string(), 75.0);
final_state.insert("potential_energy".to_string(), 75.0);
// Check energy conservation (should pass)
checker.check(
ConservationLaw::Energy,
&initial_state,
&final_state,
1e-6 // tolerance
)?;
Ok(())
}
$ tokei .
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
Rust 11 906 725 20 161
|- Markdown 11 128 12 103 13
(Total) 1034 737 123 174
===============================================================================
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
oxirs-physics is built on the SciRS2 foundation and follows the SciRS2 Integration Policy.
| 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 |
// Arrays and numerical operations
use scirs2_core::ndarray_ext::{Array2, ArrayView2, array};
use scirs2_core::ndarray_ext::stats::mean;
// Random number generation
use scirs2_core::random::{Random, rng};
// Performance optimization
use scirs2_core::simd_ops::simd_dot_product;
use scirs2_core::parallel_ops::par_chunks;
use scirs2_core::gpu::{GpuContext, GpuBuffer};
// Memory efficiency for large RDF datasets
use scirs2_core::memory_efficient::MemoryMappedArray;
use scirs2_core::memory::BufferPool;
// Profiling and metrics
use scirs2_core::profiling::Profiler;
use scirs2_core::metrics::Timer;
// Error handling
use scirs2_core::error::{CoreError, Result};
# Build with all features
cargo build --all-features
# Run tests (use nextest)
cargo nextest run --all-features
# Run with specific feature
cargo nextest run --features simulation
# Lint (no warnings policy)
cargo clippy --workspace --all-targets -- -D warnings
# Format check
cargo fmt --all -- --check
# Run benchmarks (when implemented)
cargo bench --features simulation
oxirs-physics will support Azure Digital Twins' DTDL for standardized twin definitions. See TODO.md for implementation roadmap.
Example DTDL integration:
{
"@context": "dtmi:dtdl:context;2",
"@id": "dtmi:oxirs:Battery;1",
"@type": "Interface",
"contents": [
{
"@type": "Telemetry",
"name": "temperature",
"schema": "double",
"unit": "kelvin"
},
{
"@type": "Command",
"name": "runThermalSimulation",
"request": {
"@type": "CommandPayload",
"name": "parameters",
"schema": "dtmi:oxirs:ThermalSimParams;1"
}
}
]
}
See the main OxiRS README for contribution guidelines.
Development Guidelines:
ndarray or rand importscargo clippy -- -D warnings)std::env::temp_dir() for temporary files in testssnake_case for variables, PascalCase for types~/work/scirs/ - Scientific computing foundation~/work/jena/ - RDF/SPARQL reference~/work/oxigraph/ - RDF triple store referenceSame as OxiRS parent project (see repository root).
Current version: 0.1.0
Part of the OxiRS semantic web platform.