Wonderlab

Liquid Light

Paint with luminous fluid.

Move to stir · drag to paint · Space splash · S kaleidoscope Drag with one or more fingers to paint

Liquid Light

What you're stirring is a real fluid simulation. Your GPU solves the Navier–Stokes equations, written down by Claude-Louis Navier in 1822 and George Gabriel Stokes in 1845, on a grid of tens of thousands of cells, sixty times a second.

How a frame works. Every cell's velocity is carried along by the flow itself (advection). Then the solver makes the fluid incompressible: it measures how much each cell is gaining or losing fluid, solves for the pressure that would cancel it with twenty-odd Jacobi iterations, and subtracts that pressure's gradient. This is Jos Stam's "Stable Fluids" method from 1999, which stays stable at any time step.

Why it keeps swirling. Numerical grids blur small eddies away. Vorticity confinement (Fedkiw, Stam & Jensen, 2001) spins them back up, which is what gives the smoke its curls. The Swirl slider controls it.

The light. The coloured dye rides on the flow at a much finer resolution than the velocity grid. It's shaded as if it were a glossy liquid surface, then given a soft glow. In Ink mode the dye absorbs light instead of emitting it, so colours mix like real watercolour: overlap blue and yellow and you get green.

Fun fact: nobody has proved that smooth solutions to these equations always exist in 3D. It's one of the Clay Institute's million-dollar Millennium Prize problems.

Controls