Skip to content
    Engineering / Lattice Boltzmann Mesoscopic Flow Core

    Lattice Boltzmann Method (LBM) Flow Calculator

    Simulate a 2D D2Q9 lattice Boltzmann Taylor-Green vortex and check it against the exact viscous decay. Explore relaxation time, viscosity and Mach number, free.

    ToolCalculatorExecutionIn browserCategoryEngineering
    ZorvLabs Fluid Dynamics LabD2Q9 BGK · Taylor-Green benchmark

    Lattice Boltzmann flow simulator

    Lattice
    9
    D2Q9 population set
    Viscosity ν
    0.04000
    ν = c_s²(τ−1/2)
    Mach
    0.139
    Low-Mach regime check
    Mass Drift
    -5.73e-11
    Σρ final − initial
    Velocity L2
    3.33e-2
    Relative error vs exact
    Energy Err.
    6.97e-3
    Parseval-like diagnostic
    2D Field View

    Mesoscopic field map + velocity vectors

    field min 1.215e-16field max 0.0543mean 0.0368
    3D Isometric Model

    Surface extrusion of the selected mesoscopic field

    xyz3D field surface · SPEED · downsample 1×1Isometric projection of the 2D D2Q9 mesoscopic fieldexact Taylor–Green comparison remains analytic, not visual approximation
    Validation

    Kinetic energy decay vs exact

    Average kinetic energy densityBenchmark: Taylor–Green vortex (periodic, exact decay)0.00070.00090.00110.00130.0015energy density
    Exact decay rate
    0.001371
    Energy relative error
    6.97e-3
    Centerline

    ux(x, y = L/2)

    Centerline streamwise velocityNumeric (solid) vs exact (dashed)-0.0632-0.0360-0.00870.01850.0458u_x
    L2 relative error: 3.33e-2 · max error: 1.82e-3
    Vorticity

    ω(x, y = L/2)

    Centerline vorticityNumeric (solid) vs exact (dashed)-0.08000.17000.42000.67000.9200ω_z
    Summary

    Simulation metrics and exact benchmark

    Initial mass
    2.304 K
    Final mass
    2.304 K
    Initial energy
    0.001600
    Final energy
    0.000737
    Benchmark summary
    u = U0 sin(kx)cos(ky)e^{-2νk²t}, v = -U0 cos(kx)sin(ky)e^{-2νk²t}
    Exact decay: exp(−2νk²t), with k = 2π/N and ν = cs2(τ−1/2)
    The field is periodic and low-Mach, matching a standard analytical test case for LBM validation.
    D2Q9 stencil
    e0=(0,0), e1=(1,0), e2=(0,1), e3=(-1,0), e4=(0,-1), e5=(1,1), e6=(-1,1), e7=(-1,-1), e8=(1,-1)
    w0=4/9, w1..4=1/9, w5..8=1/36
    Reference history

    Sampled benchmark convergence trace

    steptimeenergy num.energy exactrel. err.
    001.6000e-31.6000e-38.27e-15
    111.5819e-31.5956e-38.61e-3
    221.5859e-31.5913e-33.35e-3
    331.5765e-31.5869e-36.55e-3
    441.5752e-31.5825e-34.67e-3
    551.5689e-31.5782e-35.92e-3
    661.5654e-31.5739e-35.41e-3
    771.5600e-31.5696e-36.08e-3
    881.5556e-31.5653e-36.22e-3
    991.5503e-31.5610e-36.85e-3
    10101.5453e-31.5567e-37.37e-3
    11111.5399e-31.5525e-38.13e-3
    ●Lattice Boltzmann flow simulator//D2Q9 BGK//cs² = 0.333333//Ma = 0.139//ν = 0.040000//Exact Taylor–Green benchmark
    engineering methodology

    A clear path from inputs to results.

    Run a two-dimensional lattice Boltzmann (D2Q9) simulation of a decaying Taylor-Green vortex directly in your browser and compare it against the exact analytical solution. The lattice Boltzmann method tracks particle-distribution functions on a grid rather than solving the Navier-Stokes equations directly, and it recovers the same incompressible flow in the low-Mach limit. This tool is for CFD students and researchers who want to see how relaxation time, resolution, and Mach number control accuracy and stability.

    Step-by-step methodWorked exampleAssumptions explained

    How to use

    1. Set the grid resolution N (the lattice is N x N); larger N resolves the vortex more finely and reduces discretization error.
    2. Set the BGK relaxation time tau (must stay above 0.5 for stability). This fixes the kinematic viscosity through nu = cs^2 (tau - 1/2) with cs^2 = 1/3 in lattice units.
    3. Set the initial velocity amplitude u0; the lattice Mach number is u0/cs = u0 x sqrt(3), which should stay well below 1 to keep compressibility error small.
    4. Set the fluid density rho0 (reference density, typically 1.0 in lattice units) and the number of time steps to advance.
    5. Run the simulation and read the diagnostics: kinematic viscosity, lattice Mach number, mass-conservation drift, the L2 velocity error against the exact Taylor-Green field, and the relative error in total kinetic energy versus the analytical exp(-2 nu k^2 t) decay.

    The formula

    Reference: Kruger et al., The Lattice Boltzmann Method: Principles and Practice (Springer, 2017); Bhatnagar, Gross & Krook, Phys. Rev. 94 (1954); Taylor & Green, Proc. R. Soc. A 158 (1937).

    Worked example

    Decaying Taylor-Green vortex on a 48 x 48 lattice

    Inputs
    • Resolution N = 48; relaxation time tau = 0.62; initial velocity amplitude u0 = 0.08; reference density rho0 = 1.0; 280 time steps (all in lattice units).
    Calculation path
    1. 1

      The kinematic viscosity is nu = cs^2 (tau - 1/2) = (1/3)(0.62 - 0.5) = (1/3)(0.12) = 0.040000. The lattice sound speed is cs = 1/sqrt(3) = 0.5774, so the Mach number is u0/cs = 0.08 x sqrt(3) = 0.1386 — safely incompressible. The vortex wavenumber is k = 2 pi / N = 2 pi / 48 = 0.130900, giving an exact energy decay rate 2 nu k^2 = 2 x 0.04 x 0.130900^2 = 0.001371 per step. Starting from E0 = 1.6000e-3, the analytical kinetic energy after 280 steps is E0 x exp(-0.001371 x 280) = 7.4257e-4. The simulated field finishes at E = 7.3740e-4, an energy relative error of 6.97e-3, with an L2 velocity error of 3.33e-2 and a maximum pointwise velocity error of 1.82e-3.

    Result

    nu = 0.0400, Mach = 0.1386; simulated final kinetic energy 7.374e-4 versus exact 7.426e-4 (relative error 0.70%); L2 velocity error 3.3% against the analytical Taylor-Green solution.

    Interpreting the result

    The small energy and velocity errors confirm the solver reproduces the exact viscous decay of the Taylor-Green vortex: this is the standard verification benchmark for an incompressible lattice Boltzmann code. The L2 velocity error is dominated by discretization on a coarse 48 x 48 grid and shrinks as resolution increases; the energy error reflects the combined effect of grid resolution and the small residual compressibility set by the Mach number. If you push tau toward 0.5 (very low viscosity) or raise u0 toward sonic, errors grow and the simulation can become unstable.

    Assumptions & limitations

    • The model is the single-relaxation-time (BGK) D2Q9 lattice Boltzmann scheme; it is only second-order accurate and the single relaxation time couples viscosity to numerical stability more tightly than multi-relaxation-time models.
    • The flow is the periodic 2D Taylor-Green vortex, which has a known closed-form solution; the tool is a verification sandbox, not a general-geometry solver with walls or obstacles.
    • All quantities are in lattice units (grid spacing and time step equal 1); mapping to physical units requires your own choice of reference length, time, and velocity scales.
    • The method recovers incompressible Navier-Stokes only in the low-Mach limit; a weak compressibility error of order Mach^2 is always present and grows if u0 is pushed up.
    • Stability requires tau > 0.5; values close to 0.5 give very low viscosity and high Reynolds number but make the simulation prone to numerical instability.

    Frequently asked questions

    What is the lattice Boltzmann method, in plain terms?

    Instead of solving the Navier-Stokes equations for velocity and pressure directly, LBM tracks populations of fictitious particles streaming and colliding on a regular grid. On the D2Q9 lattice each cell holds nine distribution functions (rest plus eight directions). After each stream-and-collide step the fluid density and velocity are recovered as moments of those distributions, and in the low-Mach limit the scheme provably reproduces incompressible flow.

    Why compare against the Taylor-Green vortex?

    The 2D Taylor-Green vortex is one of the few unsteady flows with an exact analytical solution: every Fourier mode decays as exp(-2 nu k^2 t). That makes it the canonical benchmark for verifying an incompressible solver, because any discrepancy between the simulated energy decay and the closed-form curve is pure numerical error you can quantify, as this tool does.

    What does the mass-conservation drift tell me?

    A correct lattice Boltzmann scheme on a periodic domain conserves total mass exactly up to round-off. The reported mass drift should therefore be essentially zero; a non-trivial drift would signal a bug or a numerical instability rather than a physical effect, so it serves as a sanity check on the run.

    How does the relaxation time tau set the viscosity?

    Through nu = cs^2 (tau - 1/2) with cs^2 = 1/3. At tau = 0.62 the viscosity is 0.04 lattice units; as tau approaches 0.5 the viscosity approaches zero (and the Reynolds number diverges), while larger tau means a more viscous, more stable, but less interesting flow. Choosing tau is therefore the main way you set the Reynolds number of a lattice Boltzmann run.

    Why does the lattice Mach number matter if the flow is incompressible?

    LBM is intrinsically a weakly compressible method, so it only approximates incompressible flow when the Mach number u0/cs is small. The compressibility error scales roughly with the square of the Mach number. Keeping Mach around 0.1-0.15, as in the worked example (0.1386), keeps that error negligible while still allowing a reasonable time step.

    Can I use this for flow around an object or in a duct?

    Not in this tool. It is deliberately restricted to the periodic Taylor-Green vortex so it can be checked against an exact solution. Real engineering geometries need boundary conditions (bounce-back walls, inlets, outlets) and usually multi-relaxation-time or regularized collision operators for stability, which are beyond this verification-focused sandbox.

    Methodology last reviewed 2026-10-06. Results are informational and not financial or engineering advice — see our disclaimer.