Skip to main content

Crate phyz_lbm

Crate phyz_lbm 

Source
Expand description

Lattice Boltzmann Method (LBM) for emergent fluid dynamics.

Implements D2Q9 (2D) and D3Q19 (3D) lattice Boltzmann models with BGK collision operator. At macroscopic scales, LBM recovers incompressible Navier-Stokes equations.

§Example

use phyz_lbm::LatticeBoltzmann2D;
use phyz_math::Vec3;

// Lid-driven cavity flow
let mut lbm = LatticeBoltzmann2D::new(64, 64, 0.1);  // 64x64 grid, nu=0.1
lbm.initialize_uniform(1.0, [0.0, 0.0]);

// Set boundary conditions
for x in 0..64 {
    lbm.set_velocity_bc(x, 63, [0.1, 0.0]);  // lid velocity
    lbm.set_no_slip_bc(x, 0);                 // bottom wall
}

// Simulate
for _ in 0..1000 {
    lbm.collide_and_stream();
}

let u = lbm.velocity(32, 32);
println!("Center velocity: [{:.4}, {:.4}]", u[0], u[1]);

Re-exports§

pub use d2q9::LatticeBoltzmann2D;
pub use d3q19::LatticeBoltzmann3D;
pub use equation_free::CoarseProjector;
pub use equation_free::EquationFreeWrapper;
pub use equation_free::FineSolver;
pub use equation_free::effective_information;

Modules§

d2q9
D2Q9 Lattice Boltzmann solver for 2D incompressible flow.
d3q19
D3Q19 Lattice Boltzmann solver for 3D incompressible flow.
equation_free
Equation-free simulation and coarse projective integration.

Constants§

C_S
Lattice sound speed: c_s = 1/sqrt(3)
C_S_SQ
Lattice sound speed squared