Skip to main content

ringkernel_wavesim3d/
lib.rs

1//! RingKernel WaveSim3D - 3D Acoustic Wave Simulation
2//!
3//! A comprehensive 3D acoustic wave simulation with realistic physics,
4//! binaural audio, and GPU acceleration.
5//!
6//! # Features
7//!
8//! - **3D FDTD Simulation**: Full 3D wave propagation using finite-difference
9//!   time-domain methods with a 7-point stencil
10//!
11//! - **Realistic Physics**:
12//!   - Temperature-dependent speed of sound
13//!   - Humidity-dependent atmospheric absorption
14//!   - Frequency-dependent damping (ISO 9613-1)
15//!   - Multiple media: air, water, steel, aluminum
16//!
17//! - **Binaural Audio**:
18//!   - Virtual head with configurable ear spacing
19//!   - Interaural Time Difference (ITD) simulation
20//!   - Interaural Level Difference (ILD) / head shadow
21//!   - Real-time stereo output
22//!
23//! - **Audio Sources**:
24//!   - Point impulses and spherical impulses
25//!   - Continuous tones (sinusoidal)
26//!   - Noise (white/pink)
27//!   - Chirp (frequency sweep)
28//!   - Gaussian pulses
29//!   - Audio file playback
30//!
31//! - **GPU Acceleration**:
32//!   - CUDA backend for NVIDIA GPUs
33//!   - 3D stencil operations
34//!   - Efficient packed buffer layout
35//!   - **Actor-based computation**: Cell-as-actor paradigm with message-based halo exchange
36//!
37//! - **3D Visualization**:
38//!   - Slice rendering (XY, XZ, YZ planes)
39//!   - Interactive camera controls
40//!   - Source and listener markers
41//!   - Real-time pressure field display
42//!
43//! # Example
44//!
45//! ```rust,no_run
46//! use ringkernel_wavesim3d::prelude::*;
47//!
48//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
49//! // Create simulation with default parameters
50//! let config = SimulationConfig::small_room();
51//! let mut engine = config.build();
52//!
53//! // Inject an impulse at the center
54//! let (w, h, d) = engine.dimensions();
55//! engine.inject_impulse(w/2, h/2, d/2, 1.0);
56//!
57//! // Run simulation steps
58//! for _ in 0..100 {
59//!     engine.step();
60//! }
61//!
62//! println!("Simulated {} seconds", engine.time());
63//! # Ok(())
64//! # }
65//! ```
66//!
67//! # Modules
68//!
69//! - [`simulation`]: Core simulation engine, physics, and grid
70//! - [`audio`]: Audio sources and binaural microphone
71//! - [`visualization`]: 3D rendering and camera controls
72
73pub mod audio;
74pub mod gui;
75pub mod simulation;
76pub mod visualization;
77
78/// Re-exports for convenient access.
79pub mod prelude {
80    pub use crate::audio::{
81        AudioConfig, AudioSource, AudioSystem, BinauralMicrophone, BinauralProcessor,
82        SourceManager, SourceType, VirtualHead,
83    };
84    pub use crate::simulation::{
85        AcousticParams3D, CellType, ComputationMethod, Environment, Medium, MediumProperties,
86        Orientation3D, Position3D, SimulationConfig, SimulationEngine, SimulationGrid3D,
87    };
88    pub use crate::visualization::{
89        Camera3D, CameraController, ColorMap, RenderConfig, SliceRenderer, VisualizationMode,
90    };
91
92    // Actor-based computation (CUDA feature only)
93    #[cfg(feature = "cuda")]
94    pub use crate::simulation::{
95        ActorBackendConfig, ActorError, ActorStats, CellActorState, Direction3D, HaloMessage,
96    };
97}
98
99pub use prelude::*;