Skip to main content
Sandbox Physics

Fluid dynamics · a manipulable numerical field

Interactive Jet

A two-dimensional incompressible velocity field is extruded into luminous depth inside a transparent flow chamber. Tune viscosity, dye diffusion, pressure iterations, and vorticity enhancement to compare entrainment and the wake behind a cylinder; arm the fluid brush to inject dye and momentum by dragging through the test section.

Interactive modelInteractive Jet
Simulation time0.00s0.00\,\mathrm{s}
Before projection u2\lVert\nabla\cdot\boldsymbol{u}\rVert_20.0000.000
After projection u2\lVert\nabla\cdot\boldsymbol{u}\rVert_20.0000.000
Divergence reduction1.0×1.0\times
Mean kinetic energy K/ρK/\rho0.00Jkg10.00\,\mathrm{J\,kg^{-1}}
Peak vorticity ωmax\lvert\omega\rvert_{\max}0.00s10.00\,\mathrm{s^{-1}}

Physics tutorial

Interactive Jet: what advection, diffusion, and projection each do

BackgroundA real-time fluid canvas stores velocity and dye on a fixed grid. Each time step transports the fields, diffuses small-scale structure, then solves for pressure and removes the compressible component.

Why it mattersSeparating the solver stages turns swirling motion into more than an effect: divergence can be measured before and after pressure projection, exposing the exchange between stability and numerical dissipation.

Start with the essentials

Focus question
Why can one pressure projection return an arbitrarily pushed velocity field toward incompressibility?
One-sentence intuition
An intermediate velocity splits into a divergence-free component and a pressure gradient. Solve one Poisson equation and subtract p\nabla p to suppress divergence.

Core mathematical model

Incompressible velocity evolution

ut+(u)u=p+ν2u+f,u=0\frac{\partial\boldsymbol{u}}{\partial t}+\left(\boldsymbol{u}\cdot\nabla\right)\boldsymbol{u}=-\nabla p+\nu\nabla^2\boldsymbol{u}+\boldsymbol{f},\qquad \nabla\cdot\boldsymbol{u}=0

Advection transports momentum, viscosity diffuses velocity gradients, the nozzle and brush supply force, and pressure enforces incompressibility.

Semi-Lagrangian backtrace

ϕn+1(x)ϕn ⁣(xΔtun(x))\phi^{n+1}(\boldsymbol{x})\approx\phi^n\!\left(\boldsymbol{x}-\Delta t\,\boldsymbol{u}^n(\boldsymbol{x})\right)

Trace backward from each grid point and interpolate the old field. The step is robust, but repeated interpolation smooths detail.

Pressure projection

2p=1Δtu,un+1=uΔtp\nabla^2p=\frac{1}{\Delta t}\nabla\cdot\boldsymbol{u}^{*},\qquad \boldsymbol{u}^{n+1}=\boldsymbol{u}^{*}-\Delta t\,\nabla p

The Poisson equation finds the gradient component to remove; more complete iteration usually leaves less residual divergence.

Common difficulties

Stable does not mean accurate

Typical misconceptionIf the algorithm never blows up, every small vortex must be preserved correctly.

Better mental modelSemi-Lagrangian advection remains stable at large time steps but introduces interpolation dissipation. Vorticity enhancement restores visual detail, not the true scales that were lost.

Spatial particles do not make a three-dimensional solve

Typical misconceptionBecause particles occupy depth, the solver must resolve three-dimensional turbulence.

Better mental modelEvery particle samples the same two-dimensional velocity section. Depth makes structure easier to inspect but cannot create three-dimensional vortex stretching.

Run the experiment

  1. 01

    Build a cylinder wake

    Choose Cylinder wake and let the dye pass the obstacle.

    What to observe: The jet slows and splits upstream of the cylinder, leaving a low-speed wake and alternating rotational structure downstream.
  2. 02

    Inspect pressure projection

    Enable Divergence diagnostic, then raise pressure iterations while comparing the two norms.

    What to observe: The post-projection divergence norm drops sharply; with too few iterations the residual is easier to see on the field sheet.
  3. 03

    Add momentum by hand

    Arm the fluid brush, drag sideways through the wake, then disable it to orbit the chamber.

    What to observe: Local dye and velocity change together; the new disturbance is advected, diffused, and projected again.