Interactive Simulator · 2D Incompressible LBMs

LBM Flow Solver

A browser-based GPU lattice Boltzmann solver for 2D incompressible blood flow at the vessel scale. Explore pulsatile flow through stenoses, aneurysms, bifurcations, and user-drawn vasculature in real time. Toggle between Newtonian and shear-thinning (Carreau–Yasuda) rheology, add gravity, switch between velocity and pressure inlets, and watch recirculation zones develop downstream of plaques. Full mathematical derivation and numerical theory below.

D2Q9 Lattice Boltzmann BGK Collision Bounce-back No-slip Carreau–Yasuda Rheology ρ = 1060 kg/m³ WebGL2 MRT KaTeX Equations
9
Velocity States (D2Q9)
Re ≤ 2000
Reynolds Range
640×240
Max Grid
8
Vessel Presets
Inlet Velocity
0.30 m/s
Viscosity Model
Dynamic Viscosity μ
3.5 mPa·s
Display Field
Grid Resolution
Color Scale
Transform
Options
Sim Speed
×3
 
Vessel Preset
Inlet BC
Inlet profile
Outlet BC
Draw Tool
Brush Radius
3 px
✏ Left-drag → draw  |  right-drag → erase
2D Incompressible LBMs · D2Q9 LBM · WebGL2 GPU Solver ● running
Re: τ: Step: 0 FPS: Mcells/s: ΔKE:
0 1.0 m/s
← Inlet  |  Outlet →  |  No-slip walls (bounce-back)
⚠ WEBGL2 + FLOAT RENDER TARGETS REQUIRED
This solver needs WebGL 2.0 with the EXT_color_buffer_float extension. Recent Chrome, Firefox, Edge, or Safari on desktop or modern mobile should all work.
Quick Start Guide
1Select a vessel preset — try Stenosis at the default 0.30 m/s first
2Watch the velocity jet accelerate through the throat and decelerate downstream
3Switch Display Field to Pressure to see the pre-stenotic peak and post-stenotic drop
4Toggle Non-Newtonian to watch apparent viscosity drop in high-shear regions
5Use the Wall pencil to draw your own geometry; right-drag to erase
6Crank Inlet Velocity to ≈1.0 m/s to push Re past 2000 and see shedding
Space Pause / Resume  ·  R Reset flow  ·  C Clear walls  ·  W Wall tool  ·  E Erase tool  ·  S Toggle streamlines  ·  1–3 Display field

Background & Mathematical Foundation

1. Why the Lattice Boltzmann Method for Hemodynamics?

Traditional CFD discretizes the Navier–Stokes equations directly on body-fitted meshes. That approach is excellent for well-defined engineering geometries but carries two burdens that matter enormously for blood flow: mesh generation becomes a bottleneck when the vessel geometry is drawn, segmented from a scan, or changes interactively, and parallelization requires domain decomposition that does not map cleanly onto GPU fragment shaders. The Lattice Boltzmann Method (LBM) was developed in the late 1980s and early 1990s (Higuera & Jiménez 1989; Qian, d'Humières, Lallemand 1992) and has since become a workhorse for vascular CFD because:

2. The D2Q9 Lattice

In two dimensions we discretize velocity space with nine lattice vectors — one at rest plus eight directions connecting a cell to its Moore neighbourhood:

D2Q9 Discrete Velocity Set
$$\mathbf{c}_0 = \mathbf{0}, \quad \mathbf{c}_{1,3} = (\pm 1, 0), \quad \mathbf{c}_{2,4} = (0, \pm 1), \quad \mathbf{c}_{5,6,7,8} = (\pm 1, \pm 1)$$

Each cell stores nine distribution functions $f_i(\mathbf{x}, t)$, $i = 0 \ldots 8$, representing the density of particles at position $\mathbf{x}$ moving with velocity $\mathbf{c}_i$. The associated lattice weights $w_i$ follow from requiring isotropy and the correct moments of the Gauss–Hermite quadrature:

Lattice Weights
$$w_0 = \tfrac{4}{9}, \qquad w_{1,2,3,4} = \tfrac{1}{9}, \qquad w_{5,6,7,8} = \tfrac{1}{36}$$

Macroscopic density and momentum emerge as moments of the distribution:

Density
$$\rho(\mathbf{x},t) = \sum_{i=0}^{8} f_i$$
Momentum
$$\rho \mathbf{u}(\mathbf{x},t) = \sum_{i=0}^{8} \mathbf{c}_i f_i$$

3. The Lattice Boltzmann Equation: Stream + Collide

Each timestep splits into two substeps. In collision, distributions at each cell relax toward local equilibrium; in streaming, they translate to their neighbours along their respective velocity directions.

3a. BGK Collision

The Bhatnagar–Gross–Krook (BGK) single-relaxation-time collision operator is (Qian et al. 1992):

BGK Collision
$$f_i^{*}(\mathbf{x}, t) = f_i(\mathbf{x}, t) - \frac{1}{\tau}\!\left[f_i(\mathbf{x}, t) - f_i^{eq}(\rho, \mathbf{u})\right]$$

The discrete equilibrium $f_i^{eq}$ is the Maxwell–Boltzmann distribution expanded to second order in velocity:

Equilibrium Distribution
$$f_i^{eq} = w_i\, \rho\!\left[\,1 + 3(\mathbf{c}_i \cdot \mathbf{u}) + \tfrac{9}{2}(\mathbf{c}_i \cdot \mathbf{u})^2 - \tfrac{3}{2}\,|\mathbf{u}|^2\,\right]$$

The dimensionless relaxation time $\tau$ controls how quickly distributions relax toward equilibrium; it directly sets the kinematic viscosity.

3b. Streaming

Post-collision distributions translate one cell in the direction of their lattice velocity:

Streaming Step
$$f_i(\mathbf{x} + \mathbf{c}_i\,\Delta t,\; t + \Delta t) = f_i^{*}(\mathbf{x}, t)$$

This simulator uses the pull formulation: each cell fetches $f_i$ from its upstream neighbour at $\mathbf{x} - \mathbf{c}_i$. Pull streaming maps to a single fragment-shader pass with nine texel fetches per cell, which is exactly what WebGL2 is good at.

4. Recovery of Incompressible Navier–Stokes

A Chapman–Enskog expansion shows that in the limit of small Mach number ($|\mathbf{u}| \ll c_s$, where $c_s^2 = 1/3$ is the lattice speed of sound), the above evolves macroscopic fields obeying the incompressible Navier–Stokes equations with kinematic viscosity:

Viscosity – Relaxation Relation
$$\nu = c_s^2\!\left(\tau - \tfrac{1}{2}\right) = \tfrac{1}{3}\!\left(\tau - \tfrac{1}{2}\right) \quad\text{(lattice units)}$$

The constraint $\tau > \tfrac{1}{2}$ is thus a physical requirement: negative effective viscosity is unstable. At $\tau \to \tfrac{1}{2}$ the scheme approaches the inviscid (Euler) limit but loses stability. Practically we keep $\tau \in [0.51, 1.5]$; this simulator clamps in that range.

5. Boundary Conditions

5a. No-slip Walls: Full-way Bounce-back

At a wall cell, the post-streaming distributions are swapped pairwise with their opposites:

Bounce-back at Wall
$$f_i(\mathbf{x}_{\text{wall}}, t + \Delta t) = f_{\bar{i}}^{*}(\mathbf{x}_{\text{wall}}, t), \qquad \bar{i} \text{ is the direction opposite to } i$$

On the next timestep, fluid cells adjacent to the wall stream in these reversed distributions, producing zero velocity at the halfway point between the last fluid cell and the wall cell — this is the half-way bounce-back interpretation, which is second-order accurate at the wall interface (Ladd 1994).

5b. Velocity Inlet (Plug Flow)

On inlet cells we prescribe $\mathbf{u} = (U_{\text{in}}, 0)$, set $\rho = 1$, and overwrite all nine distributions with their equilibrium values $f_i = f_i^{eq}(\rho, \mathbf{u})$. The bounce-back walls downstream enforce the no-slip condition and the flow develops the characteristic Poiseuille profile over the entry length $L_e \approx 0.06\, \text{Re}\, D$. Students can observe this entry-flow development directly.

5c. Pressure Outlet / Inlet

When pressure is prescribed, density is fixed at the target value and velocity is extrapolated from the nearest interior fluid cell. In LBM, pressure and density are linked through the isothermal equation of state:

LBM Pressure–Density Relation
$$p = c_s^2 \rho = \tfrac{1}{3}\rho \quad\text{(lattice units)}$$

6. Non-Newtonian Blood: Carreau–Yasuda

Blood is a non-Newtonian shear-thinning fluid due to reversible erythrocyte aggregation at low shear. The Carreau–Yasuda model (Yasuda et al. 1981) captures this over the full physiological range:

Carreau–Yasuda Viscosity
$$\mu(\dot\gamma) = \mu_\infty + (\mu_0 - \mu_\infty)\!\left[\,1 + (\lambda\,\dot\gamma)^a\,\right]^{(n-1)/a}$$

Recommended parameters for human blood at 37 °C (Cho & Kensey 1991):

$\mu_0$
56 mPa·s (zero-shear viscosity, dominated by RBC aggregates)
$\mu_\infty$
3.45 mPa·s (infinite-shear viscosity, dispersed RBCs)
$\lambda$
3.313 s (relaxation time)
$n$
0.3568 (shear-thinning exponent)
$a$
2.0 (Yasuda transition exponent)

In LBM we need the local shear rate $\dot\gamma$ at each cell. The Chapman–Enskog expansion provides this directly from the non-equilibrium part of the distribution — the momentum-flux tensor $\Pi_{\alpha\beta}^{\text{neq}}$ — without any finite differences of $\mathbf{u}$:

Local Shear Rate (Chapman–Enskog)
$$\Pi_{\alpha\beta}^{\text{neq}} = \sum_i c_{i\alpha} c_{i\beta} (f_i - f_i^{eq}), \qquad S_{\alpha\beta} = -\frac{3}{2\rho\tau}\Pi_{\alpha\beta}^{\text{neq}}, \qquad \dot\gamma = \sqrt{2\, S_{\alpha\beta} S_{\alpha\beta}}$$

The Chapman–Enskog shear rate is then fed back into Carreau–Yasuda to produce a local $\mu(\dot\gamma)$, which sets a local relaxation time $\tau_{\text{local}} = \tfrac{1}{2} + 3\nu_{\text{local}}$. This closes the loop: each cell collides with its own effective viscosity every step.

7. Lattice-to-Physical Unit Mapping

The simulator runs internally in lattice units (everything dimensionless, grid spacing $\Delta x = 1$, timestep $\Delta t = 1$). Physical SI quantities are recovered on the fly through a chosen length scale and lattice velocity:

$\rho_0$
1060 kg/m³ (blood density, fixed)
$L$
1 cm (characteristic vessel width = grid height $N_y$)
$\Delta x$
$L / N_y$ m per lattice cell
$U_{\text{lat}}$
0.05 (fixed, keeps lattice Mach $\ll$ 1)
$\Delta t$
$U_{\text{lat}}\cdot \Delta x / U_{\text{phys}}$ s per lattice step
$\nu_{\text{lat}}$
$\nu_{\text{phys}}\cdot \Delta t / \Delta x^2$
$\tau$
$\tfrac{1}{2} + 3\,\nu_{\text{lat}}$
$p_{\text{phys}}$
$\rho_0\, (\Delta x / \Delta t)^2 \cdot (\rho_{\text{lat}} - 1) / 3$ Pa

8. Reynolds Regimes in the Vasculature

Reynolds number is the dimensionless ratio of inertial to viscous forces — it determines whether flow is dominated by friction (low Re, Stokes) or momentum (high Re, inertial, turbulent):

Reynolds Number
$$\text{Re} = \frac{\rho U L}{\mu} = \frac{U L}{\nu}$$

Typical values across the circulation:

VesselDiameterVelocityReynoldsRegime
Ascending aorta25 mm30–100 cm/s≈3000–10000Transitional / pulsatile turbulent in systole
Common carotid6 mm20–40 cm/s≈400–800Laminar, inertial
Coronary arteries3 mm15–25 cm/s≈150–300Laminar, developing
Arterioles30–100 μm1–10 mm/s≈0.1–3Viscous-dominated
Capillaries5–10 μm0.3–1 mm/s≈0.001–0.01Stokes flow (Re → 0)

This simulator's default preset (sphere in channel, U=0.30 m/s, μ=3.5 mPa·s, L=1 cm) gives Re ≈ 909, squarely in the arterial regime. Drop μ to 1 mPa·s and raise U to 1.0 m/s to push toward vortex shedding around Re ≈ 3000.

9. Preset Scenarios

10. Numerical Limitations & Known Behavior

References

  1. Qian, Y. H., d'Humières, D., & Lallemand, P. (1992). Lattice BGK models for Navier-Stokes equation. Europhysics Letters, 17(6), 479–484. (Original D2Q9/BGK paper.)
  2. Succi, S. (2001). The Lattice Boltzmann Equation for Fluid Dynamics and Beyond. Oxford University Press. Chapters 3–5 (Chapman-Enskog, BCs, forcing).
  3. Ladd, A. J. C. (1994). Numerical simulations of particulate suspensions via a discretized Boltzmann equation. Part 1. Theoretical foundation. Journal of Fluid Mechanics, 271, 285–309. (Half-way bounce-back analysis.)
  4. Cho, Y. I., & Kensey, K. R. (1991). Effects of the non-Newtonian viscosity of blood on flows in a diseased arterial vessel. Part 1: Steady flows. Biorheology, 28(3-4), 241–262. (Carreau-Yasuda for blood.)
  5. Yasuda, K., Armstrong, R. C., & Cohen, R. E. (1981). Shear flow properties of concentrated solutions of linear and star branched polystyrenes. Rheologica Acta, 20(2), 163–178.
  6. Chen, S., & Doolen, G. D. (1998). Lattice Boltzmann method for fluid flows. Annual Review of Fluid Mechanics, 30, 329–364. (Canonical review.)
  7. Cebral, J. R. et al. (2005). Characterization of cerebral aneurysms for assessing risk of rupture by using patient-specific computational hemodynamics models. American Journal of Neuroradiology, 26(10), 2550–2559.
  8. Lagrava, D. et al. (2012). Advances in multi-domain lattice Boltzmann grid refinement. Journal of Computational Physics, 231(14), 4808–4822. (AMR in LBM.)
Accessibility & Display
Color Scheme
Dark Mode
Font Size
Font Style