HomeFluid Dynamics & AerodynamicsFluid Lattice-Boltzmann

💨 Fluid Lattice-Boltzmann

Simulate 2D fluid flow using the Lattice-Boltzmann Method (LBM D2Q9). Watch flow past obstacles, Kármán vortex streets, and pipe flow develop from microscopic collision-streaming steps on a regular grid.

Fluid Dynamics & Aerodynamics3DModerate60 FPS
fluid-lattice-boltzmann ↗ Open standalone

About the Lattice-Boltzmann Method

Microscopic to Macroscopic

Unlike traditional Navier-Stokes solvers, LBM simulates fluid as a grid of particles streaming and colliding. Each cell holds 9 distribution functions f_i representing particle populations moving in each of the D2Q9 directions. After collision (relaxation toward equilibrium) and streaming (shifting f_i to neighbouring cells), macroscopic density ρ = Σf_i and velocity u = Σf_i·c_i/ρ emerge naturally.

Kármán Vortex Street

At Reynolds numbers between 40 and a few hundred, flow past a cylinder becomes unstable. Vortices shed alternately from either side of the obstacle, forming a regular pattern known as the Kármán vortex street. The shedding frequency f, cylinder diameter D, and flow speed U are related by the Strouhal number St = f·D/U ≈ 0.21 at Re=100. This phenomenon shook the Tacoma Narrows Bridge to destruction in 1940.

Reynolds Number

The Reynolds number Re = U·L/ν (inertial / viscous forces) determines flow character: Re < 5 gives smooth creeping flow with symmetric recirculation; Re ~ 40–200 produces the periodic Kármán vortex street; Re > 1000 leads to turbulent, chaotic wakes. In the LBM, viscosity links to the relaxation time τ = 3ν + 0.5, and stability requires τ > 0.5.

About this simulation

This simulation runs a real Lattice-Boltzmann Method (LBM) fluid solver directly on a 160×80 D2Q9 grid: every cell stores nine discrete particle-distribution functions fi, one for each lattice direction, which relax toward local equilibrium (BGK collision, relaxation time τ = 3ν + 0.5) and then stream to neighbouring cells every step. Macroscopic density ρ = Σfi and velocity u = Σfici/ρ emerge from these microscopic updates rather than being solved for directly, which is what makes LBM fundamentally different from a classic Navier–Stokes solver. A circular obstacle (or, in Pipe Flow mode, two parallel walls) applies no-slip bounce-back boundaries, and a fixed-velocity inlet on the left plus an open outlet on the right drive the flow.

🔬 What it shows

Flow past a cylindrical obstacle (or through a pipe) computed cell-by-cell with the D2Q9 lattice Boltzmann scheme. Depending on viscosity ν and inlet velocity, the wake stays smooth and symmetric (low Re), sheds an alternating Kármán vortex street (Re ≈ 40–200), or becomes chaotic and turbulent (Re > ~500). You can switch the display between speed, an approximate vorticity field, and density/pressure.

🎮 How to use

Pick a preset — Creeping (Re=5), Kármán (Re=100), Turbulent (Re=500), or Pipe Flow — or set Viscosity ν, Inlet velocity and Obstacle size yourself with the sliders. Click anywhere on the canvas to move the cylinder and watch the wake reorganise in real time. Switch the Display tabs (Speed / Vorticity / Pressure) to see different fields, and read Reynolds number, drag coefficient and Strouhal number live in the Flow Stats panel.

💡 Did you know?

The alternating vortex shedding you can trigger here at Re ≈ 100 is the same Kármán vortex street phenomenon that shook the Tacoma Narrows Bridge apart in 1940. LBM itself grew out of lattice-gas cellular automata in the 1980s and is now used in real engineering CFD codes because its local, grid-based updates parallelise extremely well on GPUs.

Frequently asked questions

What is the Lattice-Boltzmann Method and how does it differ from Navier-Stokes solvers?

LBM discretises space into a lattice (here 160×80 cells) and tracks nine particle-distribution functions per cell instead of directly solving the Navier-Stokes equations for pressure and velocity. Each simulation step alternates a local collision (relaxing f_i toward its equilibrium value f_i^eq over relaxation time τ) with a streaming step that shifts each f_i to the neighbouring cell in its lattice direction. Density and velocity are simply computed as moments of the distribution functions. This local, explicit update rule makes LBM straightforward to parallelise, unlike traditional pressure-Poisson-based Navier-Stokes solvers.

What does the D2Q9 lattice model mean?

D2Q9 means a 2-dimensional lattice with 9 discrete velocity directions per cell: one rest direction, four axis-aligned neighbours, and four diagonal neighbours, each with its own lattice weight (4/9, 1/9 or 1/36). This is the standard, minimal stencil for 2D incompressible-ish flow simulation and is exactly what this simulation implements with the CX/CY/W arrays in the code.

How do the Viscosity and Inlet velocity sliders relate to the Reynolds number?

The simulation computes the Reynolds number as Re = U·L/ν, where U is the inlet velocity, L is the obstacle diameter (twice the Obstacle size slider), and ν is the Viscosity slider value, which also sets the LBM relaxation time τ = 3ν + 0.5. Lowering viscosity or raising inlet velocity increases Re and pushes the flow from smooth creeping motion toward vortex shedding and eventually turbulence; the four presets are just pre-tuned combinations of these two sliders.

Why does a Kármán vortex street form behind the obstacle?

Once Re rises above roughly 40, the symmetric wake behind the cylinder becomes unstable to small perturbations, and vortices begin shedding alternately from the top and bottom of the obstacle instead of staying attached. This periodic shedding is the Kármán vortex street, and its frequency f obeys the Strouhal relation St = f·D/U ≈ 0.21 near Re = 100, which is the constant value the simulation reports in the Flow Stats panel.

What do the Speed, Vorticity and Pressure display modes actually show?

Speed colours each cell by the magnitude of its local velocity vector, computed from the first velocity moment of the distribution functions. Vorticity approximates the local curl of the velocity field using finite differences between neighbouring cells' momentum, highlighting the rotating cores of shed vortices in red/blue. Pressure/density mode colours cells by ρ = Σf_i, which in this near-incompressible LBM scheme is proportional to local pressure through an ideal-gas-like equation of state.

⚙ Under the hood

Lattice Boltzmann method (D2Q9) simulating Karman vortex street and computational fluid dynamics.

Lattice BoltzmannLBMD2Q9Karman vortexcomputational fluid dynamics

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)