pub struct PyLbmSimulation { /* private fields */ }Expand description
A 2-D D2Q9 Lattice-Boltzmann fluid simulation.
Supports:
- BGK collision operator (single relaxation time)
- Periodic streaming
- No-slip bounce-back walls via boundary map
- Velocity and density field extraction
- Lid-driven velocity boundary on top row
Implementations§
Source§impl PyLbmSimulation
impl PyLbmSimulation
Sourcepub fn new(config: &PyLbmConfig) -> Self
pub fn new(config: &PyLbmConfig) -> Self
Create a new LBM simulation from configuration.
All cells are initialised to equilibrium at the configured density and velocity.
Sourcepub fn step_count(&self) -> u64
pub fn step_count(&self) -> u64
Number of completed steps.
Sourcepub fn set_boundary(&mut self, x: usize, y: usize, btype: LbmBoundary)
pub fn set_boundary(&mut self, x: usize, y: usize, btype: LbmBoundary)
Set the boundary type of cell (x, y).
Sourcepub fn get_boundary(&self, x: usize, y: usize) -> Option<LbmBoundary>
pub fn get_boundary(&self, x: usize, y: usize) -> Option<LbmBoundary>
Get the boundary type of cell (x, y).
Sourcepub fn add_top_wall(&mut self)
pub fn add_top_wall(&mut self)
Mark all cells along the top row as NoSlipWall.
Sourcepub fn add_bottom_wall(&mut self)
pub fn add_bottom_wall(&mut self)
Mark all cells along the bottom row as NoSlipWall.
Sourcepub fn add_enclosing_walls(&mut self)
pub fn add_enclosing_walls(&mut self)
Mark all four enclosing walls as NoSlipWall (cavity setup).
Sourcepub fn set_lid_velocity(&mut self, vel: Option<[f64; 2]>)
pub fn set_lid_velocity(&mut self, vel: Option<[f64; 2]>)
Set a lid velocity applied to the top row every step.
Pass None to disable.
Sourcepub fn velocity_at(&self, x: usize, y: usize) -> [f64; 2]
pub fn velocity_at(&self, x: usize, y: usize) -> [f64; 2]
Get macroscopic velocity [ux, uy] at cell (x, y).
Returns [0, 0] for out-of-bounds or wall cells.
Sourcepub fn density_at(&self, x: usize, y: usize) -> f64
pub fn density_at(&self, x: usize, y: usize) -> f64
Get macroscopic density at cell (x, y). Returns 0 if out of bounds.
Sourcepub fn get_velocity_field(&self) -> Vec<f64>
pub fn get_velocity_field(&self) -> Vec<f64>
Return the full velocity field as a flat Vecf64of[ux, uy]pairs, row-major (y outer, x inner). Length =width * height * 2`.
Sourcepub fn get_density_field(&self) -> Vec<f64>
pub fn get_density_field(&self) -> Vec<f64>
Return the full density field as a flat Vecf64, row-major. Length = width * height`.
Source§impl PyLbmSimulation
impl PyLbmSimulation
Sourcepub fn mean_density(&self) -> f64
pub fn mean_density(&self) -> f64
Mean macroscopic density over all non-wall cells.
Sourcepub fn vorticity_field(&self) -> Vec<f64>
pub fn vorticity_field(&self) -> Vec<f64>
Vorticity field (z-component of curl) as a flat Vecf64.
Uses central differences. Length = width * height.
Sourcepub fn reynolds_number(&self, omega: f64) -> f64
pub fn reynolds_number(&self, omega: f64) -> f64
Reynolds number estimate: Re = L * U / ν (characteristic length = height/2).
Sourcepub fn speed_field(&self) -> Vec<f64>
pub fn speed_field(&self) -> Vec<f64>
Return the velocity magnitude field as a flat Vecf64.
Sourcepub fn reset_to_equilibrium(&mut self, rho: f64, ux: f64, uy: f64)
pub fn reset_to_equilibrium(&mut self, rho: f64, ux: f64, uy: f64)
Reset all cells to equilibrium at given density and velocity.
Sourcepub fn add_circular_obstacle(&mut self, cx: usize, cy: usize, r: usize)
pub fn add_circular_obstacle(&mut self, cx: usize, cy: usize, r: usize)
Set a circular obstacle (no-slip) at (cx, cy) with integer radius r.
Sourcepub fn fluid_cell_count(&self) -> usize
pub fn fluid_cell_count(&self) -> usize
Count of fluid (non-wall) cells.
Sourcepub fn wall_cell_count(&self) -> usize
pub fn wall_cell_count(&self) -> usize
Count of wall cells.
Source§impl PyLbmSimulation
impl PyLbmSimulation
Sourcepub fn collect_stats(&self) -> LbmStats
pub fn collect_stats(&self) -> LbmStats
Collect per-step statistics.
Trait Implementations§
Source§impl Clone for PyLbmSimulation
impl Clone for PyLbmSimulation
Source§fn clone(&self) -> PyLbmSimulation
fn clone(&self) -> PyLbmSimulation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PyLbmSimulation
impl RefUnwindSafe for PyLbmSimulation
impl Send for PyLbmSimulation
impl Sync for PyLbmSimulation
impl Unpin for PyLbmSimulation
impl UnsafeUnpin for PyLbmSimulation
impl UnwindSafe for PyLbmSimulation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.