← Simulating on a Lattice

Lattice Boltzmann & the D2Q9 Stencil

Part 5 of 6. Nine velocities on a square lattice, weighted so the fluid they make looks the same in every direction and in every moving frame, to the order that matters.

Part 4 ended with HPP failing because four axis velocities cannot build an isotropic rank-4 tensor. Lattice Boltzmann keeps the square lattice with real-valued populations fi on nine velocities (McNamara and Zanetti 1988; Qian, d'Humières and Lallemand 1992), weighted so the fluid respects two continuum symmetries: rotations and Galilean boosts.

What do the weights have to satisfy?

The nine velocities form three orbits of the point group D4, so there are three weights, one fixed by normalisation. The rank-4 moment Σwi(ci·n)4 must not depend on the direction n, and must equal the Maxwellian's 3cs4, where cs2 = Σwicix2.

preset

Figure 1. On the purple line the rank-4 moment is isotropic; on the orange curve its average over directions equals 3cs4. The polar plot is the moment over 3cs4; the Maxwellian is the dashed circle. Drag the point or use arrow keys.

The axes-only set matches along the axes and has half the moment on the diagonals. The eight moving vectors are isotropic at r = 1/4 but too small; the rest weight supplies the size, and the two curves cross only at 4/9, 1/9, 1/36.

Collide, then stream

Each step relaxes every population toward a local equilibrium with one time τ (the BGK collision), then shifts it one cell along its velocity. A Chapman–Enskog expansion turns this into incompressible Navier–Stokes with the viscosity below.

Figure 2 sums the equilibrium's moments. Through rank 2 they match the Maxwellian. At rank 3 they cannot, because cx3 = cx when every component is −1, 0 or 1.

ux
0.15
uy
0.08
momentlatticeMaxwelliandiff

Figure 2. fieq(ρ = 1, u) for the rest, axis and diagonal channels; ticks mark the weights at u = 0. The rank-3 rows miss by ρux3 and ρuxuy2.

Is the viscosity the same in every direction?

Figure 3 lays a small shear wave on a periodic 32 × 32 lattice at seven orientations, fits the exponential decay of each amplitude and divides the rate by k2. The curves are the Chapman–Enskog prediction for general weights, ν(θ) = (τ − ½)(wa sin22θ + 4wd cos22θ)/cs2.

compare D2Q9 with
τ
0.80
measured viscosity by wave direction
amplitude decay

Figure 3. Points measured, curves predicted; the second chart is the selected direction's decay with its fit. With axes only, a wave along an axis never decays, as in HPP.

Does the wave move with the fluid?

The eight-moving set passes that test. Figure 4 adds a uniform flow U along x to the shear wave, on a 32-cell periodic row,: a Galilean-invariant fluid carries the pattern at exactly U.

compare D2Q9 with
boost U
0.10
wave uy, position (up) against step (across)
measured drift speed / U, and viscosity

Figure 4. Heatmaps: the wave over 300 steps, columns rescaled; dashed, a crest moving at U. Lines: drift speed over U and shear viscosity, τ = 0.8.

The eight-moving set carries the wave at 5/9 of U, the radius of its circle in Figure 1. The axes-only set has no channel that moves y-momentum along x, so the wave stays put. D2Q9 drifts at exactly U, but its viscosity in the moving frame falls as U grows: the cubic error of Figure 2, and the reason runs are kept at low Mach number.

Flow past a cylinder

Walls are bounce-back: a population entering a solid site returns the way it came, so the wall velocity is zero. Figure 5 runs a 300 × 90 channel with a cylinder of diameter 22. Everything is mirror-symmetric about the centreline except a seeded random perturbation of 1% of U in the initial velocity.

vorticity −
+
Reynolds
120
inflow U
0.080
steps/frame
8

Figure 5. τ comes from Re = UD/ν, floored at 0.52 for stability. The inlet imposes (U, 0), the outlet fixes density. St = fD/U counts zero crossings of uy four radii downstream.

The cylinder fills a quarter of the channel width. The measured Strouhal number sits above the unconfined value of about 0.2, and shedding starts above the free-stream Re ≈ 47: at 60 the wake stays symmetric, at 70 it sheds.

How does the mirror symmetry break?

Figure 6 tracks the wake's mirror defect, the RMS difference between the flow and its reflection through the centreline, divided by U. It grows exponentially, then saturates, a Hopf bifurcation seen from inside: a complex pair of eigenvalues of the symmetric wake has crossed into the unstable half-plane.

mirror defect / U, log scale, against step
mismatch after a time shift, probe line

Figure 6. From the run above. Dashed: the growth fit before the defect passes 0.05. The second chart compares velocities on a vertical probe line with themselves a time shift earlier, directly (grey) or reflected (pink); unrelated fields score about 1.

No snapshot of the street is symmetric, but reflection plus a shift of half a period maps it onto itself, so the Z2 symmetry survives as a space-time symmetry. A new seed changes only the phase of the street.

Where D2Q9 stops

Practitioners keep the Mach number U/cs near 0.1; the slider here reaches 0.21. Compressible and thermal flows need larger velocity sets such as D2Q17 or D2Q37. Part 6 turns to the Ising model, where a Z2 symmetry breaks with no flow at all.