Previous post: Quiet Gears: The Search Finds Helical Next post: Pole Held Upright on a Cart

Wind Tunnel in the Browser

A live fluid solver on a 200 by 80 grid: draw walls, stir flow, and watch wakes shift from calm to shedding.

Overview

A true D2Q9 fluid solver steps live in the page: 200 × 80 cells, a small line block near Re 85 at start, draw and erase and stir tools, held edges all round. Draw walls one cell at a time, grab fluid itself to stir, shift speed from calm flow into shedding wakes, and watch the tail answer. The line shows live Reynolds number and flow type.

None is baked and none is faked: a real BGK scheme steps in real time, nudged by a one-shot puff so the street forms in seconds not minutes.

Method in One Minute

The solver tracks puff groups, not Navier–Stokes directly. Each cell holds nine packs: rest, four straight, four slant. Each step streams packs to neighbors then eases them toward local rest shape. Repeat stream plus ease and large-scale flow follows Navier–Stokes.

That build gives two wins. Walls turn trivial: a wall cell just flips packs back (wall sits between cells, no slip gaps), so a hand-drawn block needs no mesh. Each step stays local, which is why the whole tunnel runs fast in a tab.

Space and time live in grid units. Only pure ratios carry to real life. Reynolds number Re=UD/ν is the whole manual: same Re, same flow. The widget reports it live from inflow speed, viscosity, and block size.

Proof the Sim Holds Water

A demo solver must still prove itself. “Looks right” is not proof. Two test layers ship with code:

  • Straight-channel check (Poiseuille benchmark). A ring channel with push drive regains the bow profile to ~0.04% at mid-line (gate 1%), with crawl speed at walls. Stock D2Q9 check case.
  • Bluff checks. A flat plate at Re 100 sheds at Strouhal number 0.15 (beat rate) over 0.14–0.15 guide band, with drag coefficient 2.25 over ~2 guide. Both are fixed regression tests with guide bands. A solver with wrong viscosity, broken walls, or bad rims cannot land both at once — and an early 25%-blocked run that overshot both proved the rig can catch true slips.
  • Exact traits. Hits keep mass per cell, ring stream keeps total mass, rest shape matches weights, flat flow shows zero spin, and a spin probe pins screen sense (plus spin reads counter-clockwise).
  • Rim trials, logged. Mirror rims ring instead of sliding. Zero-slope rims ease the wake sideways until no street forms. Outlet slope guess bought nil over pinned rest. All rejects are probe-traced. Shipped all-edges-pinned won on numbers: inlet plus outlet plus top and bottom lock to rest.
  • Run guard. A bad-number check runs in the draw loop. A spoiled state rebuilds from current walls and settings instead of confetti.

Read the Picture

Five views share one map, with stock tunnel scales: density, x and y speed, speed, and spin (start view). Contrast lifts each scale by 1.2c. Ranges below assume zero:

View Maps Full span
Density (ρ−1)⋅6 1±0.08
X / Y speed u⋅2 ±0.25
Speed |u|⋅4 0 to 0.25
Spin ω⋅5 ±0.10

The map uses a jet look: bright calm field, hot swirl cores, black walls. Jet bends sense and is not color-blind safe — it draws edges where data runs smooth — so read it for shape, never for gauge. It ships for one cause: the classic tunnel look. That trade is stated, not hid.

Controls

Three mouse tools in a menu: Draw and Erase paint one grid cell per event with two-cell margins at the pinned edges — thin hand lines stay thin, dotted at fast drags. Drag-fluid pins a 21-cell stencil (5 × 3 block plus two 3-cell flanking rows) around the cursor to pointer speed each step, capped at ±0.1, so you can stir the wake itself. Pointer speed is (mouse minus last drag) over steps-per-frame, which the text before left out.

Shape menu holds eleven shapes: lines, shallow slant, right angle, rings, spoiler shapes, wedge, wing, and more. It resets after place. Run, Step, Reset fluid, and Clear walls are buttons. Sliders act at once with no restart:

  • Flow speed (inflow) 0.02–0.12
  • Viscosity 0.005–0.2
  • Contrast −10–10
  • Anim speed (steps per frame) 1–40

Flow speed and viscosity morph live traits while the street adapts. Step moves steps-per-frame steps, not one. Start puff is fixed at (45, 0.01, 16). Hand draws puff at (8, 0.005, 16). Reset puffs anew. Erase reopens with calm fluid (code note says a stock port would leave stale packs — this build clears them).

Reynolds uses box-max size, so slant blocks inflate D. Type tags are rough cylinder guide: calm below 50, shed below 180, wild above. Hover probe shows t/x/y/speed/spin/density plus step count. Reduced-motion starts paused. Letterbox keeps cells square.

Default Re ≈ 85 comes from a 17-long line times 0.1 speed over 0.02 viscosity.

Honest Limits

This is a class tunnel, not shop CFD: flat, slow BGK with stepped walls, Re near 10–200, no churn model, no gauged body push in UI. Type tag is a rough cylinder guide, not a sorter. True tunnels (and true CFD) fill the third way, where stretch shifts all above Re ~200.

References

  • Chen, Shiyi, and Gary D. Doolen. 1998. “Lattice Boltzmann Method for Fluid Flows.” Annual Review of Fluid Mechanics 30: 329–364. https://doi.org/10.1146/annurev.fluid.30.1.329
  • Crameri, Fabio, Grace E. Shephard, and Philip J. Heron. 2020. “The Misuse of Colour in Science Communication.” Nature Communications 11: 5444. https://doi.org/10.1038/s41467-020-19160-7
  • Krüger, Timm, Halim Kusumaatmaja, Alexandr Kuzmin, Orest Shardt, Goncalo Silva, and Erlend Magnus Viggen. 2017. The Lattice Boltzmann Method: Principles and Practice. Springer.
  • Succi, Sauro. 2001. The Lattice Boltzmann Equation for Fluid Dynamics and Beyond. Oxford University Press.
  • Zou, Qisu, and Xiaoyi He. 1997. “On Pressure and Velocity Boundary Conditions for the Lattice Boltzmann BGK Model.” Physics of Fluids 9 (6): 1591–1598. https://doi.org/10.1063/1.869307