Yasser Sheikh · MSc BEng AMIChemE RITTech

Experiments · 02 · Numerical methods

Navier–Stokes, live.

The Navier–Stokes equations describe how fluids move, and they sit underneath a great deal of what chemical engineers care about, from stirred vessels to pipeline flow. They have no known general analytical solution, so we solve them numerically. Below is a real-time incompressible solver: semi-Lagrangian advection with a pressure projection, the same scheme that powers most real-time smoke and ink simulations. A jet of ink runs continuously. Drag across the field to stir it, and raise the viscosity to feel the flow thicken.

Incompressible Navier–Stokes · 128² grid

What you're looking at

The numerics

Each frame the velocity field is advected semi-Lagrangianly: rather than pushing quantities forward and risking instability, every cell traces backwards through the flow to ask where its fluid came from. Viscosity is applied implicitly, and a pressure projection (a Jacobi-iterated Poisson solve) then removes any divergence, which is what keeps the fluid incompressible and mass conserved. The splitting is unconditionally stable, so you can stir as violently as you like and the solver will bend rather than blow up. The ink is a passive scalar carried along by the velocity field it has no say in.

Where it comes from

I first taught this material through a simpler route: a 2D viscous Burgers solver, built with explicit finite differences for a lecture on end-to-end modelling of formulated products, a sector worth around £180bn a year in the UK. Vectorising that solver made it 796× faster, which taught me early that the biggest performance wins usually come from restructuring the computation, not from a faster language. The solver above is the industrial-strength cousin, and the discipline is unchanged: demonstrate consistency, stability and convergence first, then worry about making it fast.