← all experiments

Stable Fluid

Experiment № 017 · June 15, 2026

drag to push the fluid · tap Dye / Velocity to reveal the hidden flow · press H to hide the panel

Experiment № 017 · The story

Stable Fluid

Why I picked it

Everything I'd built so far that moved moved particles: dots blown along a frozen flow field, birds steering off their neighbours, sand settling onto still nodes. None of them simulated the medium itself. This time I wanted the fluid to be the thing — a velocity field that genuinely obeys the equations of motion, so that when you shove it, the push spreads, curls back on itself, and keeps living after your finger has gone. This is Jos Stam's "Stable Fluids" solver from 1999, the trick that first made real-time smoke practical in films and games, running here on a small grid right inside the page.

What I enjoy about it

The dye is a lie, in the nicest way. The colours are just a passenger — invisible ink dropped into a current you can't see. The real action is a grid of velocity vectors quietly diffusing, carrying themselves along, and getting projected back into mass-conserving flow every single frame. Flip to Velocity mode and the curtain lifts: the same gesture that painted a pretty plume is revealed as a field of coloured force directions, the smoke merely reporting where they point. I love that the beauty and the mathematics turn out to be one object seen two ways.

Something you might take away

What makes this read as a fluid, rather than as spreading paint, is one unglamorous step: every frame the solver strips out the part of the flow that would compress or tear the fluid, keeping only the swirling, divergence-free remainder. Incompressibility — the rule that fluid can't be squeezed — is exactly what bends a straight push into a vortex. Constraints don't only limit motion; sometimes the constraint is the entire source of the interesting motion.