Fluid Dynamics
A wind tunnel on your screen. Fluid enters from the left, flows around whatever you place in its path, and turbulence emerges. Draw obstacles with your mouse. Adjust the viscosity and watch laminar flow dissolve into vortex streets. The simulation uses the Lattice Boltzmann Method — instead of solving the Navier-Stokes equations directly, it models billions of imaginary particles colliding and streaming on a lattice. From these simple local rules, the full complexity of fluid dynamics emerges.
The Navier-Stokes Equations
The motion of every fluid — water in a river, air over a wing, blood through an artery — is governed by the Navier-Stokes equations, written down independently by Claude-Louis Navier in 1822 and George Gabriel Stokes in 1845. They express Newton’s second law for a continuous medium: the acceleration of each parcel of fluid equals the sum of pressure gradients, viscous diffusion, and external forces. In vector form for an incompressible fluid:
These equations are deceptively simple to write and impossibly difficult to solve. The nonlinear convective term u·∇u couples every point in the flow to every other point. Exact analytical solutions exist only for a handful of idealized geometries. Whether smooth solutions always exist in three dimensions is one of the seven Millennium Prize Problems — a million-dollar question that remains open. This simulation sidesteps the problem entirely by never solving the equations at all.
The Lattice Boltzmann Method
Instead of discretizing the Navier-Stokes equations on a grid (as finite-difference or finite-element methods do), the Lattice Boltzmann Method works at a deeper level. It tracks distribution functions — the probability of finding a particle moving in each of nine directions at each lattice node. The simulation alternates between two steps: collision, where distributions at each node relax toward a local equilibrium (the BGK approximation), and streaming, where distributions propagate to neighboring nodes along their velocity directions.
The remarkable result, proved through Chapman-Enskog analysis, is that this simple lattice-gas automaton reproduces the Navier-Stokes equations in the macroscopic limit. The relaxation time τ maps directly to kinematic viscosity: ν = (2τ - 1)/6. No pressure Poisson equation, no implicit solves, no staggered grids. The algorithm is embarrassingly parallel — every node’s collision step is independent — which is why LBM runs beautifully on GPUs and, as you can see, in a web browser.
Reynolds Number
The Reynolds number Re = UL/ν is the single most important dimensionless quantity in fluid dynamics. It measures the ratio of inertial forces (the fluid’s tendency to keep moving) to viscous forces (the fluid’s tendency to resist deformation). At low Reynolds numbers, viscosity dominates: the flow is smooth, predictable, laminar. A spoon stirring honey. At high Reynolds numbers, inertia dominates: the flow becomes chaotic, turbulent. Smoke rising from a cigarette.
In this simulation, try setting viscosity high and flow speed low — you’ll see smooth streamlines wrapping symmetrically around obstacles. Now lower the viscosity or raise the speed. Watch the symmetric wake destabilize. Vortices begin to shed alternately from the top and bottom of the obstacle, forming the von Kármán vortex street. The transition typically occurs around Re ≈ 40–200 for a cylinder. The same physics explains why telephone wires hum in the wind and why tall chimneys need helical strakes.
Vortex Shedding
When fluid flows past a bluff body — a cylinder, a bridge pier, a flagpole — the boundary layer separates from the surface and rolls up into vortices. Above a critical Reynolds number, these vortices detach alternately from each side, forming a periodic, staggered pattern called the von Kármán vortex street, named after Theodore von Kármán who analyzed it mathematically in 1911.
The shedding frequency is governed by the Strouhal number, St = fD/U ≈ 0.2 for a wide range of Reynolds numbers. This means the frequency is predictable: double the flow speed and the shedding frequency roughly doubles. Load the cylinder preset and watch. The wake starts symmetric, then a tiny asymmetry grows, and suddenly the flow locks into a beautiful oscillation. This is a Hopf bifurcation — the steady-state solution becomes unstable and the system spontaneously begins to oscillate. Switch to vorticity mode to see the alternating red and blue vortices trailing downstream like a zipper.
Boundary Conditions
How fluid interacts with solid surfaces is the crux of most fluid dynamics problems. In the Lattice Boltzmann framework, solid boundaries are implemented through bounce-back: when a distribution function streams into a solid node, it reverses direction. This enforces the no-slip condition — the fundamental observation that fluid velocity drops to zero at a solid surface. Every boundary layer, every wake, every vortex originates from this constraint.
The inlet (left boundary) maintains a fixed velocity profile, constantly injecting fluid into the domain. The outlet (right boundary) uses an extrapolation scheme that allows vortices to pass through without reflection. The top and bottom walls use bounce-back, creating a channel flow. When you draw an obstacle, you’re marking lattice nodes as solid — bounce-back nodes where the no-slip condition forces the fluid to decelerate and separate, creating the pressure gradients that drive vortex formation.
Applications
Computational fluid dynamics (CFD) is everywhere. Aerospace engineers simulate airflow over wings to optimize lift and reduce drag — a modern aircraft wing is tested in simulation thousands of times before a physical prototype is built. Automotive engineers model underbody flow, cooling systems, and aerodynamic drag. Weather services run massive CFD simulations to predict atmospheric flow patterns days in advance.
In medicine, CFD models blood flow through arteries to predict aneurysm risk and optimize stent design. In architecture, wind simulations determine structural loads and pedestrian comfort around tall buildings. In electronics, thermal CFD predicts how heat dissipates from processor chips. The Lattice Boltzmann Method specifically has found a niche in modeling flows through complex geometries — porous media, blood vessels, industrial filters — where its simple boundary handling and natural parallelism outperform traditional methods. The same algorithm running in your browser, scaled to millions of nodes and hundreds of GPUs, simulates the aerodynamics of Formula 1 cars and the hemodynamics of the human heart.