Skip to main content

oxirs_physics/
lib.rs

1//! # OxiRS Physics - Physics-Informed Digital Twin Bridge
2//!
3//! [![Version](https://img.shields.io/badge/version-0.2.2-blue)](https://github.com/cool-japan/oxirs/releases)
4//!
5//! **Status**: Production Release (v0.2.2)
6//!
7//! Connects RDF knowledge graphs with SciRS2 physics simulations.
8//!
9//! # Features
10//!
11//! - **Parameter Extraction**: Extract simulation parameters from RDF graphs and SAMM Aspect Models
12//! - **Result Injection**: Write simulation results back to RDF with provenance
13//! - **Physics Constraints**: Validate results against conservation laws
14//! - **Digital Twin Sync**: Synchronize physical asset state with digital representation
15//! - **SPARQL Integration**: Build and execute SPARQL queries for entity properties
16//! - **RDF Literal Parsing**: Parse typed literals with full SI unit conversion
17//! - **SAMM Bridge**: Parse SAMM Aspect Model TTL and bridge to simulation types
18//!
19//! # Architecture
20//!
21//! ```text
22//! [RDF Graph] ──extract──> [Simulation Params]
23//!                               │
24//!                               ▼
25//!                      [SciRS2 Simulation]
26//!                               │
27//!                               ▼
28//!                     [Simulation Results]
29//!                               │
30//!          ┌────────────────────┴────────────────┐
31//!          ▼                                     ▼
32//! [Physics Validation]              [Provenance Tracking]
33//!          │                                     │
34//!          ▼                                     ▼
35//! [Result Injection] ─────────────> [RDF Graph Updated]
36//! ```
37//!
38//! # Examples
39//!
40//! ```rust,no_run
41//! use oxirs_physics::simulation::SimulationOrchestrator;
42//! use oxirs_physics::digital_twin::DigitalTwin;
43//!
44//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
45//! // Create orchestrator
46//! let orchestrator = SimulationOrchestrator::new();
47//!
48//! // Extract parameters from RDF
49//! let params = orchestrator.extract_parameters(
50//!     "urn:example:battery:001",
51//!     "thermal_simulation"
52//! ).await?;
53//!
54//! // Run simulation
55//! let result = orchestrator.run("thermal_simulation", params).await?;
56//!
57//! // Inject results back to RDF
58//! orchestrator.inject_results(&result).await?;
59//! # Ok(())
60//! # }
61//! ```
62//!
63//! # SPARQL / RDF Integration
64//!
65//! ```rust
66//! use oxirs_physics::rdf::sparql_builder::{PhysicsPropertyQuery, PhysicsProperty};
67//! use oxirs_physics::rdf::literal_parser::{parse_rdf_literal, PhysicalUnit, convert_unit};
68//!
69//! // Build a SPARQL SELECT query
70//! let query = PhysicsPropertyQuery::new("urn:example:motor:42")
71//!     .with_property(PhysicsProperty::Mass)
72//!     .with_property(PhysicsProperty::Temperature)
73//!     .build_select_query();
74//!
75//! assert!(query.contains("SELECT"));
76//!
77//! // Parse a typed RDF literal
78//! let value = parse_rdf_literal("9.80665 m/s^2", None).expect("parse failed");
79//! assert_eq!(value.unit, PhysicalUnit::MetersPerSecondSquared);
80//!
81//! // Convert units
82//! let in_g = convert_unit(&value, &PhysicalUnit::StandardGravity).expect("convert failed");
83//! assert!((in_g.value - 1.0).abs() < 1e-5);
84//! ```
85
86pub mod conservation;
87pub mod constraints;
88pub mod digital_twin;
89pub mod error;
90pub mod fem;
91pub mod modal_analysis;
92pub mod predictive_maintenance;
93pub mod rdf;
94pub mod rdf_extraction;
95pub mod samm;
96pub mod simulation;
97
98// v1.1.0 Material property database
99pub mod material_database;
100
101// v1.1.0: Thermal finite-element analysis (CST elements, Dirichlet/Neumann/Robin BCs)
102pub mod thermal_analysis;
103
104// v1.1.0 round 5: Adaptive mesh refinement for FEM
105pub mod mesh_refinement;
106
107// v1.1.0 round 6: Heat transfer simulation (Fourier / Newton / Stefan-Boltzmann)
108pub mod heat_transfer;
109
110// v1.1.0 round 7: Basic computational fluid dynamics (pipe flow, Bernoulli, drag)
111pub mod fluid_dynamics;
112
113// v1.1.0 round 11: Structural vibration and modal analysis (mass-spring-damper systems)
114pub mod vibration_analysis;
115
116// v1.1.0 round 12: Lumped-capacity thermal analysis (Fourier / Newton / Stefan-Boltzmann)
117pub mod thermal_system;
118
119// v1.1.0 round 13: 1D/2D wave propagation simulation (FDTD, standing/traveling/attenuated waves)
120pub mod wave_propagation;
121
122// v1.1.0 round 11: Basic quantum mechanics (particle-in-box, QHO, tunneling, spin, density matrices)
123pub mod quantum_mechanics;
124
125// v1.1.0 round 12: Optical physics (Snell, Fresnel, thin lens, diffraction, prism)
126pub mod optics;
127
128// v1.1.0 round 13: Statistical mechanics (Maxwell-Boltzmann, partition function, Fermi-Dirac, Bose-Einstein, mean free path)
129pub mod statistical_mechanics;
130
131// v1.1.0 round 14: Orbital mechanics and N-body simulation (Newtonian gravity, Kepler, vis-viva)
132pub mod celestial_mechanics;
133
134// v1.1.0 round 15: PID and cascade control system simulation
135pub mod control_systems;
136
137// v1.1.0 round 16: Kinematic equations for linear and rotational motion
138pub mod kinematics;
139
140pub use error::{PhysicsError, PhysicsResult};
141
142/// Physics simulation bridge version
143pub const VERSION: &str = env!("CARGO_PKG_VERSION");