---
title: "Push a Numerical Jet by Hand Interactive Lab | Sandbox Physics"
description: "What do advection, diffusion and pressure projection each do in a fluid simulation?"
canonical_url: "https://sandboxphysics.com/labs/interactive-jet/"
language: "en"
page_type: "lab"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/labs/interactive-jet/"
last_modified: "2026-10-27"
---

Fluid dynamics · a numerical flow you can push

# Interactive Jet

**What do advection, diffusion and pressure projection each do in a fluid simulation?** Advection carries dye and vortices along with the flow, and diffusion smooths them out. Pressure projection subtracts the gradient of a pressure field, which removes divergence so the fluid neither piles up nor thins out anywhere. That pressure is found by iteration, and with a limited number of iterations a small, measurable divergence remains.

Inside a transparent flow chamber, a two-dimensional incompressible velocity field is drawn as glowing particles spread through a shallow depth. Adjust viscosity, dye diffusion, pressure iterations and vorticity enhancement to see how the jet entrains surrounding fluid and leaves a wake behind a cylinder. Drag through the test section with the fluid brush to inject dye and momentum.

> Interactive simulation: open this page in a web browser to change the parameters and run the model.

The solver uses Stable Fluids-style semi-Lagrangian advection, diffusion and pressure projection, with a Poisson solve that brings the field to $\nabla\cdot\boldsymbol{u}\approx0$. Finite iterations on a collocated grid leave a residual, and the readouts show its actual size. Backtrace interpolation dissipates detail, and vorticity confinement is a nonphysical correction. The particles spread one two-dimensional solution through a shallow depth. This is not a three-dimensional Navier–Stokes solve, not DNS and not resolved turbulence.

Physics tutorial

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

**Background** The simulation stores velocity and dye on a fixed grid. Each time step alternates velocity diffusion, advection and pressure projection, then carries the dye along. The horizontal and vertical cell spacings are used separately, and slow playback does not change the time units of the readouts.

**Why it matters** Taking the solver apart step by step makes the swirls more than a visual effect. You can measure the divergence before and after pressure projection and see the trade-off between stability and numerical dissipation.

Start with the essentials

- **Focus question**: After you push the velocity field around at will, why does one pressure projection bring it back close to incompressible?
- **One-sentence intuition**: Projection subtracts the gradient of a potential from the intermediate velocity. Paint while paused and project only, and you compare the same field before and after. Finite iterations on a collocated grid leave a residual you can measure, so the field does not satisfy $\nabla_h\cdot\boldsymbol{u}=0$ exactly.

### Core mathematical model

#### Incompressible velocity evolution

$$
\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 carries momentum along, viscosity diffuses velocity gradients, the nozzle and brush supply force, and pressure keeps the flow incompressible.

#### Semi-Lagrangian backtrace

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

From each grid point, trace backward along the velocity and interpolate the old field at the landing point. The step is robust, but repeated interpolation smooths out detail.

#### Pressure projection

$$
\nabla_h^2\varphi=\nabla_h\cdot\boldsymbol{u}^{*},\qquad \boldsymbol{u}'=\boldsymbol{u}^{*}-\nabla_h\varphi
$$

The stored quantity is a velocity potential with the time step and density folded in, so it is not a pressure in pascals. The grid cells are rectangular, so the Poisson relaxation weights the horizontal and vertical directions differently. With a finite number of iterations, the projection does not guarantee zero divergence.

#### Root-mean-square divergence of the current field

$$
D_{\mathrm{live}}=\sqrt{\frac{1}{N_f}\sum_{i\in\mathrm{fluid}}\left(\nabla_h\cdot\boldsymbol{u}\right)_i^2},\qquad R=\frac{D_{\mathrm{before}}}{D_{\mathrm{after}}}
$$

The live value is recomputed from the current velocity. The before and after values from the last projection are a saved pair, marked stale once you paint or change a parameter. When the field is zero, the reduction ratio is undefined.

### Common difficulties

#### Stable does not mean accurate

**Typical misconception** If the algorithm never blows up, every small vortex must be right.

**Better mental model** Semi-Lagrangian advection stays stable at large time steps, but its interpolation adds numerical dissipation. Vorticity enhancement puts back visual detail; it cannot recover the true scales that were lost.

#### Particles in depth do not make the solver three-dimensional

**Typical misconception** Because the particles fill a depth, the solver must resolve three-dimensional turbulence.

**Better mental model** Every particle samples the same two-dimensional velocity slice. The depth makes the structure easier to see, but it cannot produce 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 in front of the cylinder. Behind it is a slow wake with vortices that alternate in rotation.

2. 02

   #### Inspect pressure projection

   Pause, arm the brush and paint a disturbance. Enable Divergence diagnostic and click Project only. Change the iteration count, then project again.

   **What to observe:** The before value equals the live divergence just before the click, and the after value equals the new live divergence. Time and dye do not advance. More iterations usually shrink the residual, but that still does not prove exact incompressibility.

3. 03

   #### Add momentum by hand

   Arm the fluid brush and drag sideways through the wake. Turn it off when you want to orbit the chamber.

   **What to observe:** Dye and velocity change together where you drag. The new disturbance is then advected, diffused and projected again.

Physical conclusion

A real-time fluid is not a smoke texture. Every time step repeats advection, diffusion, forcing and pressure projection.

Conceptual inspiration: [FluidMotion](http://www.bugman123.com/FluidMotion/index.html). Original simulations and graphics; the model limits are described above.

Fields & matter · Starter path

## From a field to an electron microscope

Map an electric field and steer a charged particle. Then find the electron's wavelength and use electron beams to see a crystal and a surface.

[Start here → **Make an Electric Field Visible** Move the probe around a dipole and check that the field always points downhill on the potential landscape. Observe · 8 min](https://sandboxphysics.com/labs/electric-field/)

1. [1 Make an Electric Field Visible](https://sandboxphysics.com/labs/electric-field/)
2. [2 A Charge Bending through Fields](https://sandboxphysics.com/labs/charged-particle/)
3. [3 Electron Wavelength & Voltage](https://sandboxphysics.com/labs/electron-wavelength/)
4. [4 Electron Diffraction & Reciprocal Space](https://sandboxphysics.com/labs/electron-diffraction/)
5. [5 TEM Bright Field, Dark Field & SAED](https://sandboxphysics.com/labs/tem-mode-selector/)
6. [6 SEM Secondary-Electron Topography](https://sandboxphysics.com/labs/sem-topography/)

[View the full path →](https://sandboxphysics.com/topics/fields-and-matter/#starter-path)
