Lattice Gases and Physics Simulation

So far this module has used reversible cellular automata to imitate computers. Flip the telescope around: use them to imitate physics. If the deep features of physical law — locality, exact reversibility, conservation of particle number and momentum — can be built into a CA by construction, then running that CA is running a tiny, perfectly honest universe: a wind tunnel made of bits. This is the world of lattice gases, reversible CA whose particles hop and collide like molecules, and whose coarse-grained behaviour flows like a real fluid. They gave rise to methods used industrially today — and, better still for our purposes, they let you watch the second law of thermodynamics emerge inside a machine that provably never forgets anything. The universality page showed reversible CA can compute anything; this one shows they can be something: a gas.

HPP: a gas on graph paper

The first lattice gas, the HPP model (Hardy, Pomeau and de Pazzis, 1973), lives on a square lattice. Each site has four channels, one per direction — north, east, south, west — and each channel holds at most one particle (an exclusion rule), so a site's state is 4 bits. All particles have the same speed; a time step has two phases:

Both phases are invertible (streaming is a shift; the collision rule swaps two site-states and fixes the rest), so HPP is a reversible CA. And the collision rule was chosen with an agenda. A head-on pair has total momentum (+1) + (-1) = 0; the rotated pair has momentum 0 too, and both have two particles. So at every site, at every step,

\text{particle number and total momentum are conserved — exactly, by construction.}

Not "conserved on average", not "up to rounding error" — the dynamics is integer-exact, so the conservation laws hold to infinitely many decimal places, forever. Try asking a floating-point fluid solver for that.

The collision, drawn

The entire "physics engine" of HPP is this one exchange (any site not holding an exact head-on pair — a lone particle, a perpendicular pair, three particles — just streams straight through):

FHP: why hexagons beat squares

HPP has a flaw you can see in its own conservation laws: on a square lattice, momentum along the x-axis and along the y-axis are conserved separately (the collision never mixes them), which a real gas does not do. The macroscopic consequence is anisotropy: HPP "fluid" behaves differently along the lattice axes than along the diagonals — vortices come out square-ish, and the equations it approximates are not quite the equations of any isotropic fluid. The fix (Frisch, Hasslacher and Pomeau, 1986) is pure geometry: move to a hexagonal lattice with six velocity directions. Six-fold symmetry is enough — a classical result about symmetric tensors — to make the coarse-grained equations fully isotropic, and richer collisions (head-on pairs scatter into either rotated pair, three-body collisions) do genuine momentum mixing. The FHP lattice gas was a sensation: a two-state-per-channel toy whose large-scale limit provably approximates the Navier–Stokes equations of fluid dynamics.

HPP (1973)FHP (1986)
latticesquarehexagonal
velocity directions46
conserves particles + momentumyes (exactly)yes (exactly)
large-scale flow isotropic?no — square artefactsyes — Navier–Stokes-like

The descendants of FHP — lattice-Boltzmann methods, which replace the single-bit channels by real-valued averages but keep the stream-and-collide structure — are used industrially today for aerodynamics, porous-media flow and acoustics. When a simulation of airflow over a car body runs on a stream-collide grid, it is running the great-grandchild of a reversible cellular automaton.

The experiment Loschmidt could never run

Now for the philosophical jackpot. Start an HPP gas with all its particles crammed into one corner and let it run. It spreads: within a few hundred steps the gas looks uniformly mixed, and it never spontaneously un-mixes. Macroscopic irreversibility — entropy increase, the second law — from microdynamics we have proved is a bijection. In 1876 Josef Loschmidt needled Boltzmann with exactly this tension: if the laws are reversible, the reversed motion is equally lawful, so how can disorder only ever increase? For a real gas the rebuttal experiment — turn every molecule around — is impossible. In a lattice gas it is one line of code: invert every velocity (swap the east/west and north/south channels), run the same rule forward, and because the dynamics is discrete and exact, the gas marches flawlessly backwards and un-mixes into its corner. No rounding error, no drift: bits don't blur. Try it:

// A 1-D toy lattice gas: each site has a right-mover channel and a left-mover channel. const W = 24, T = 18; let r: number[] = new Array(W).fill(0); let l: number[] = new Array(W).fill(0); for (let i = 0; i < 6; i++) { r[i] = 1; l[i] = 1; } // gas bunched at the left end // Site legend: · empty > right-mover < left-mover X both const show = (): string => r.map((ri, i) => "·><X"[ri + 2 * l[i]]).join(""); const stream = (): void => { // periodic (wrap-around) world r = r.map((_, i) => r[(i + W - 1) % W]); // right-movers hop right l = l.map((_, i) => l[(i + 1) % W]); // left-movers hop left }; const start = show(); console.log(start + " t = 0"); for (let t = 1; t <= T; t++) { stream(); if (t % 6 === 0) console.log(show() + " t = " + t); } // Loschmidt's demon: invert every velocity... [r, l] = [l, r]; for (let t = 1; t <= T; t++) { stream(); if (t % 6 === 0) console.log(show() + " reversing, t = " + (T + t)); } [r, l] = [l, r]; // relabel back to compare with the start console.log(show() + " after full reversal"); console.log("un-mixed back to the start? " + (show() === start));

(Our 1-D toy has only trivial collisions — head-on particles pass through, which in one dimension is indistinguishable from bouncing. HPP adds the 90° scatter, and the reversal works just as exactly there.) Now the sting in the tail: this perfect rewind is precisely what a physical gas can never do. Flip one single bit before reversing — one particle nudged — and the reversed run diverges from the true history, the error spreading at lattice speed in a growing cone; the gas "un-mixes" into the wrong past and just stays mixed. Physical reversal fails not because the laws forbid it but because it demands every velocity inverted to infinite precision, and any noise — thermal, quantum, a wall vibrating — plays the role of that flipped bit. The lattice gas, being noiseless, is the one place Loschmidt's experiment actually works.

It is tempting to conclude that the mixing gas has "lost information", contradicting reversibility. It has lost nothing: the mixed-looking configuration still encodes the entire past (the reversal experiment proves it — the corner configuration was recovered from it). What increases is not missing information in the configuration but our coarse-grained ignorance: the number of microstates compatible with the macrostate "looks uniformly spread" is astronomically larger than the number compatible with "all in one corner", so a bijective dynamics wandering the state space spends essentially all its time in mixed-looking states. That counting argument is the resolution of Loschmidt's paradox: the second law is statistics, not dynamics — a statement about overwhelmingly probable behaviour, not a new microscopic law. (On a finite lattice the bijection even forces Poincaré recurrence: wait long enough and the corner configuration returns. "Long enough" is exponential in the particle count — the second law's fine print.) This is the same marriage of information and physics we began the course with — information is physical — now witnessed from the physics side: entropy is what information looks like when you squint.

In the late 1980s, lattice gases were briefly tipped to dethrone conventional computational fluid dynamics: exact conservation, perfect stability (no floating point to blow up), and absurd parallelism — Margolus and Toffoli built dedicated "CA machines" (the CAM series) that stepped millions of cells at video rate on 1980s hardware. Pure lattice gases lost the industrial race to their own offspring: single-bit channels are noisy (you must average over big regions to read off smooth velocities), and replacing bits with real-valued channel averages — the lattice-Boltzmann method — keeps the stream-and-collide skeleton while shedding the statistical noise. Lattice-Boltzmann solvers now simulate airflow over vehicles and through lungs, at the cost of surrendering exact reversibility to floating point. The trade is worth savouring: engineering traded away the very property that made the model philosophically perfect — and kept the architecture a reversible CA discovered.