phyz_lbm/lib.rs
1//! Lattice Boltzmann Method (LBM) for emergent fluid dynamics.
2//!
3//! Implements D2Q9 (2D) and D3Q19 (3D) lattice Boltzmann models with BGK collision operator.
4//! At macroscopic scales, LBM recovers incompressible Navier-Stokes equations.
5//!
6//! # Example
7//!
8//! ```
9//! use phyz_lbm::LatticeBoltzmann2D;
10//! use phyz_math::Vec3;
11//!
12//! // Lid-driven cavity flow
13//! let mut lbm = LatticeBoltzmann2D::new(64, 64, 0.1); // 64x64 grid, nu=0.1
14//! lbm.initialize_uniform(1.0, [0.0, 0.0]);
15//!
16//! // Set boundary conditions
17//! for x in 0..64 {
18//! lbm.set_velocity_bc(x, 63, [0.1, 0.0]); // lid velocity
19//! lbm.set_no_slip_bc(x, 0); // bottom wall
20//! }
21//!
22//! // Simulate
23//! for _ in 0..1000 {
24//! lbm.collide_and_stream();
25//! }
26//!
27//! let u = lbm.velocity(32, 32);
28//! println!("Center velocity: [{:.4}, {:.4}]", u[0], u[1]);
29//! ```
30
31pub mod d2q9;
32pub mod d3q19;
33pub mod equation_free;
34
35pub use d2q9::LatticeBoltzmann2D;
36pub use d3q19::LatticeBoltzmann3D;
37pub use equation_free::{CoarseProjector, EquationFreeWrapper, FineSolver, effective_information};
38
39/// Lattice sound speed: c_s = 1/sqrt(3)
40pub const C_S: f64 = 0.577350269189626;
41
42/// Lattice sound speed squared
43pub const C_S_SQ: f64 = 1.0 / 3.0;