Skip to main content

vibe/physics/
mod.rs

1//! Physics & Creator Physics module (Fields, Materials, Interaction Laws, Continuant WorldLines, and Frame Morphisms).
2//!
3//! Provides first-class physical domain primitives for VibeScript without consuming
4//! or reallocating the ten manifold axes (XYZD+T Option A).
5
6pub mod domain_facets;
7pub mod fields;
8pub mod laws;
9pub mod materials;
10pub mod morphism;
11pub mod nbody_3d;
12pub mod quantum_3d;
13pub mod trajectory;
14
15pub use domain_facets::{
16    AllometricBranchLaw, BondGraphPort, FatigueCorrosionLaw, HillMuscleFacet, PortDomain,
17};
18pub use fields::{AnalyticFieldProfile, FieldDeclaration, FieldQuantity, FieldUnit};
19pub use laws::{
20    evaluate_field_interactions, evaluate_pairwise_interactions, ContinuantState, InteractionEvent,
21};
22pub use materials::{
23    is_game_water_form, is_living_kingdom, AcousticFacet, ChemicalFacet, FacetField,
24    MaterialSignature, MechanicalFacet, OpticalFacet, PartBindError, PartContinuant,
25    SignatureFacet, SpectrumReading, ThermalFacet, GAME_WATER_FORMS,
26};
27pub use morphism::{transform_frame, GalileanMorphism, LorentzMorphism};
28pub use nbody_3d::{
29    step_nbody_3d_verlet, total_angular_momentum, total_mechanical_energy, CelestialBody3D,
30    GRAVITATIONAL_CONSTANT, MAX_STACK_BODIES, SPEED_OF_LIGHT,
31};
32pub use quantum_3d::{
33    associated_laguerre, associated_legendre, evaluate_hydrogenic_orbital_3d,
34    hydrogenic_radial_wavefunction, real_spherical_harmonic,
35};
36pub use trajectory::{Waypoint, WorldLineTrajectory};
37
38#[cfg(test)]
39mod tests {
40    use super::*;
41    use crate::value::Pose;
42
43    fn make_test_pose(x: f64, y: f64) -> Pose {
44        Pose {
45            position: vec![x, y, 0.0],
46            orientation: vec![1.0, 0.0, 0.0, 0.0],
47            frame: None,
48        }
49    }
50
51    #[test]
52    fn test_physics_module_integration() {
53        let mut sugar = ContinuantState {
54            id: "sugar_01".to_string(),
55            pose: make_test_pose(0.0, 0.0),
56            material: MaterialSignature::sugar_cube(),
57            mass_kg: 0.01,
58            is_solid: true,
59            is_crushed: false,
60            current_temperature_k: 293.0,
61        };
62
63        let atm = FieldDeclaration::standard_atmosphere();
64        let mut events = Vec::new();
65        evaluate_field_interactions(&mut sugar, &[atm], &mut events);
66
67        // Standard atmosphere (101.325 kPa > 50 kPa) crushes unreinforced sugar cube
68        assert!(sugar.is_crushed);
69    }
70}