Itikela Bhaskar
← Notes
·Computation

Simulating Fluid Dynamics with Lattice Boltzmann Methods

A practical, code-first introduction to LBM for engineering students who already know Navier–Stokes but haven't simulated anything.

Why LBM is friendlier than Navier–Stokes

Direct Navier–Stokes is unforgiving. Boundary conditions are subtle, the pressure Poisson solve is brittle, and small bugs blow up silently. Lattice Boltzmann replaces the macroscopic PDE with a collide-and-stream loop over a discrete velocity set. It's not magic — it's just easier to debug.

The whole algorithm

for step in range(n_steps):
    # 1. Collide
    f_eq = equilibrium(rho, u)
    f = f - (1.0 / tau) * (f - f_eq)

    # 2. Stream
    for i in range(9):
        f[:, :, i] = np.roll(f[:, :, i], shift=c[i], axis=(0, 1))

    # 3. Bounce-back at walls
    apply_no_slip(f, mask)

    # 4. Recover macroscopics
    rho = f.sum(axis=-1)
    u = (f @ c) / rho[..., None]

That's it. The whole solver is a hundred lines once you wire up the lattice constants.

Where it gets hard

  • Turbulence. Stable but not always physical. Use LES-style subgrid models.
  • Multi-phase. Shan-Chen and free-energy approaches both work; both have artifacts.
  • High Reynolds. Lattice resolution scales painfully.

For coursework-level problems — channel flow, lid-driven cavity, flow around a cylinder — LBM is the fastest path from "I understand the physics" to "I have a picture."