← tomás.erdmannsdörffer ● live simulation · 120×120 grid

The Fluid Playground

A real-time incompressible Navier-Stokes solver: Jos Stam's Stable Fluids (1999) - running in pure JavaScript, no libraries. Drag anywhere on the canvas to stir ink into the velocity field; the solver advects it, keeps the field divergence-free (∇·u = 0), and adds vorticity confinement so the small swirls don't dissipate.

ink color cycles on its own · works with touch
semi-Lagrangian advection · Gauss-Seidel pressure projection (20 iters) · vorticity confinement - fps

How it works

Each frame solves the incompressible Navier-Stokes equations on a 120×120 staggered-ish grid:

  • Add forces: your pointer injects momentum and three dye channels (RGB).
  • Vorticity confinement: measures the curl and pushes energy back into swirls lost to numerical diffusion.
  • Advect: semi-Lagrangian backtrace, unconditionally stable (the "stable" in Stable Fluids).
  • Project: solves a pressure Poisson equation with Gauss-Seidel to make the field divergence-free.

Why I built it

My undergrad thesis trained and compressed PINN surrogates for non-Newtonian (Carbopol) fluid simulation: so classical CFD solvers and their costs are close to home.

This is the other end of the spectrum: a coarse but fully interactive solver at 60 fps, the kind of resolution/speed trade-off that makes learned surrogates (PINNs, neural operators) so attractive for the expensive cases. See the FNO vs. Solver demo for that story.