Fluid Simulator: Navier-Stokes in 2D
A free 2D fluid simulator that solves the Navier-Stokes equations live in your browser: Karman vortex streets behind a cylinder, lid-driven cavity, rising hot plumes, Kelvin-Helmholtz rolls and merging vortices. Change the Reynolds number, stir with your finger, draw walls.
What this simulates
This is a real fluid solver running in your browser. It steps the incompressible Navier–Stokes equations forward in time on a grid: the equations that describe how water, air, oil and most other fluids move. Every swirl you see (the vortices curling off the cylinder, the rolls where two layers slide past each other, the plume of hot air) comes from the equations, not from an animation.
u is the velocity of the fluid at each point, p the pressure, ρ the density, ν the viscosity ("thickness") and f any push on the fluid, such as your finger, gravity acting on hot fluid, or a moving lid. The first line is Newton's second law for a small blob of fluid: its acceleration (left) comes from pressure differences, internal friction and outside forces (right). The second line says the fluid cannot be squeezed.
What happens in each step
- Forces: add your stirring, buoyancy of hot fluid and, if you like, a little extra swirl.
- Advect: carry the flow, the smoke and the heat along the flow itself (the (u·∇)u term), using a second-order "MacCormack" scheme so edges stay sharp.
- Diffuse: viscosity smooths velocity differences (the ν∇²u term).
- Project: solve a Poisson equation for the pressure and subtract its gradient, which removes the compression so ∇·u = 0 again. Walls and obstacles are treated as solid: the flow cannot go through them.
The Reynolds number
One number decides how a flow behaves: Re = U·L/ν, the speed times the size of the obstacle divided by the viscosity. It is the ratio of inertia (the fluid wanting to keep going) to viscosity (friction smoothing it out). Below Re ≈ 1 the flow oozes. Around 10 to 40 it wraps smoothly around a cylinder with two steady eddies behind it. Above Re ≈ 47 the wake wobbles and starts to shed alternating vortices (a Kármán vortex street). By a few thousand it is turbulent. Slide the Reynolds number on the cylinder scenario and watch the change. The page reports the Strouhal number St = f·D/U (the shedding frequency made dimensionless); for a cylinder it settles near 0.2, as measured in real wind tunnels.
How accurate is it?
It is a teaching-grade simulator, not a research code. It is two-dimensional (real turbulence is three-dimensional, where vortices stretch and break into smaller ones, which 2D flows cannot do), the grid is coarse (a few thousand to ten thousand cells), and the numerical method adds a little artificial viscosity, so the effective Reynolds number is somewhat lower than the slider says at high settings. The solver is checked against known answers: the cylinder sheds at St ≈ 0.2, the Taylor–Green vortex decays at close to its exact rate (see that scenario), and the lid-driven cavity flows the right way round. Supercomputer weather and aircraft simulations solve the same equations in 3D on grids with billions of cells, with models for the turbulence they cannot resolve.
Things people ask
- Why is Navier–Stokes famous? Nobody has proved that smooth solutions always exist in 3D, or that they can never blow up. It is one of the seven Clay Millennium Prize problems, with a US$1 million prize. Engineers get by anyway, because the numerical solutions work well in practice.
- What is vorticity? How fast a tiny paddle placed in the flow would spin. The Spin view colours it: orange one way, blue the other. Vortex streets show up beautifully there.
- Why does the flow behind the block start steady and then wobble? At moderate Re a steady wake is unstable: any tiny disturbance grows until the wake swings from side to side. The simulator nudges the flow slightly to start it off, as real roughness would.
- Can I use this for homework or a demo? Yes. It is free, runs offline once loaded and the Copy link button saves your exact setup.
Everything runs on your device; nothing is uploaded. 2D graphing calculator · 3D graphing calculator · More MES tools
