The solver is a D3Q19 lattice-Boltzmann method: each grid node carries 19 populations that collide
and stream, which reproduces the incompressible Navier–Stokes equations. It runs in a background thread
(src/sim-worker.js) so the view stays smooth. The numerics are chosen for accuracy, not looks:
curved walls by interpolated bounce-back (every lattice link knows exactly where it crosses the sphere
or the tube wall), TRT collision where the grid Reynolds number is low and regularised
collision where it is high, a velocity inlet and a pressure outlet by non-equilibrium extrapolation — so mass
is conserved without corrections and there are no hidden velocity or density clamps.
Your case, in real units. Pick a fluid, a tube and a sphere and a speed: the app computes the Reynolds
number Re = U·d/ν and maps it onto the grid at a low Mach number. Forces come out in newtons,
pressure in pascals, time in seconds. If a case needs more resolution than the grid has (air at everyday
speeds is Re in the thousands), it runs the highest Reynolds number the grid can resolve and says so, rather
than showing a flow it can't compute.
Measurements. Drag and lift on the sphere by momentum exchange on the boundary links; the drag and lift
coefficients C = F / (½ρU²·πd²/4) with U the centre-line (pipe) or sphere (moving) speed; the
Strouhal number St = f·d/U from the dominant frequency of the lift once it oscillates; the
pressure drop across the sphere; and the length of the recirculation bubble behind it on the axis. The regime
shown is measured (is there a bubble? does the lift oscillate? has the drag settled?), not looked up
from a table — confinement in a tube shifts the thresholds known for a sphere in open flow.
Validation (tests/lbm.test.js, run on every change): the pipe-flow velocity profile and
pressure gradient against Hagen–Poiseuille (0.5% and 3%), mass conservation, the Stokes drag on a sphere
moving along a tube against the Haberman–Sayre wall-corrected value (3%, with the sphere only six cells
across), a momentum balance between pressure drop and the forces on the sphere and wall, and the appearance
of the recirculation bubble with Reynolds number.
GPU. When the browser supports WebGPU, the same scheme runs on the graphics card
(src/lbm-gpu.js), on grids up to 96 cells across the tube — the sphere is then 20–30 cells across,
enough to resolve vortex shedding. tests/gpu.test.js runs both solvers on the same cases and requires
the same answer (velocity within 2·10⁻⁵, drag within 0.01%). A long GPU benchmark of a sphere in nearly unbounded
flow reproduces Johnson & Patel's measured wake length at Re 100 within 3%. Without WebGPU, the CPU solver
(6–14 cells across the sphere) still handles steady flows.
Experiments. Besides the sphere, the body can be an ellipsoid or a cylinder of any length, a face-on disc, a
cube, a bar spanning the tube, or your own shape from an STL file (any closed mesh, scaled to the chosen width;
every lattice link finds where it crosses the surface, so curved and slanted faces are not staircased). The Reynolds
number and the coefficients use the body's width and frontal area. The inflow can be developed pipe flow, a uniform
plug that develops along the tube, or pulsatile, with the flow rate swinging about its mean at a chosen
Womersley number α = R·√(ω/ν). A Reynolds sweep runs the case at several Reynolds numbers, waits
for each to settle, and plots the drag coefficient against Schiller–Naumann (open flow) and, for a body moving
through the tube at low Re, against Stokes drag with the Haberman–Sayre wall correction. Runs can be saved,
compared side by side, and exported as JSON, CSV, or VTK for ParaView. The tests check the new shapes against
their volumes, an imported STL cube cell for cell against the cube, the Stokes drag of an STL sphere against the
exact sphere (0.1%), and the uniform and pulsatile inflows; the GPU solver matches the CPU solver on these cases.
Wings. The wing section is a NACA four-digit airfoil — symmetric or cambered — at an angle of attack you set, spanning the tube wall to wall (a two-dimensional section, as in a wind tunnel) or shorter, so that tip vortices form. Chord, angle and span are geometry: the wing is rebuilt on the grid when they change, and its thin trailing edge is kept watertight (links that pass through a part thinner than a cell bounce back too). It flies through still air in the tube (the moving body frame), a uniform stream; the lift and drag coefficients use the planform area chord × span, and the Reynolds number the chord. The measurements show C_L, C_D and the lift-to-drag ratio, compared with thin-airfoil theory C_L = 2π(α − α_L0) — inviscid and two-dimensional, so at these Reynolds numbers (hundreds to about a thousand: insect and small-drone flight, not airliners) the measured lift slope is lower, while the tube's walls close above and below the wing raise it. Sweep the angle of attack for the lift curve. For a wing the view turns so its profile is seen side-on with the lift pointing up, the axial slice can be laid in the profile plane (speed, vorticity or pressure around the section), and a chart shows the pressure distribution C_p along the chord on the upper and lower surfaces at mid-span — suction peak, stagnation point, and how they move with the angle.
Labs and validation. Five guided labs (Stokes' law and the walls, separation and the wake bubble, how shape changes drag, vortex shedding, pulsatile flow and the Womersley number) walk through classic experiments step by step: each step points at the control involved, ticks itself off when you've done it, and can do it for you. The validation report shows every check the solver passes — exact solutions, published results, conservation laws, a grid-convergence study (observed order of accuracy, Richardson extrapolation and the grid convergence index), GPU/CPU parity and the sphere-wake benchmarks — and can re-run them in your browser.
Seeing the flow. Dye is carried by the same velocity field the solver computes — released from a rake of nozzles upstream or from the body's surface, the way water-tunnel experiments show wakes. Vortex surfaces are where rotation beats strain (the Q-criterion), coloured by which way the fluid turns about the tube axis. Streamlines start from a rake you can rotate. The axial slice can be time-averaged to show the mean flow of an unsteady wake, and the cross-section can be moved along the tube. Record video saves what you see as a WebM file.