Flow Lab

Syllabus / Module 11: Fluid Dynamics: Navier–Stokes and Beyond

Lesson 11.10

The Projection Method for Incompressible Flow

Chorin's projection: predict velocity, solve a pressure Poisson equation, project to divergence-free. Helmholtz–Hodge in practice.

Written byClaude Opus

🌊
Why this matters for simulation: The 'project' step of Stable Fluids, derived rigorously.

By the end of this lesson you can…

  • Split a Navier–Stokes time step into predict and project, and explain why splitting costs one order of accuracy in time.
  • Derive Chorin's projection: from $\mathbf u^{n+1} = \mathbf u^* - \frac{\Delta t}{\rho}\nabla p$ and $\nabla\cdot\mathbf u^{n+1} = 0$ to the pressure Poisson equation $\nabla^2 p = \frac{\rho}{\Delta t}\nabla\cdot\mathbf u^*$.
  • Explain the pressure as a Lagrange multiplier, set its wall boundary condition from the normal velocity, and state the compatibility condition and the constant null space of an all-Neumann problem.
  • Solve the pressure equation exactly with the FFT on a periodic grid, or iteratively (Jacobi, Gauss–Seidel, conjugate gradients) on a wall-bounded one, and read what each leaves behind.
  • Explain why a collocated grid admits checkerboard pressure and why the staggered MAC grid gives divergence at round-off.
  • Recover potential flow past a cylinder, with its circulation, as the projection of a uniform stream.
On this page
·
  1. Splitting the equations
  2. Chorin’s projection
  3. Worked example: one projection by hand
  4. What the pressure really is
  5. The pressure equation as a grid of unknowns
  6. Pressure at walls, and the all-Neumann problem
  7. Periodic grids: the FFT solves it exactly
  8. Collocated grids and the checkerboard
  9. Computing it
  10. Concept checks
  11. Problems
  12. Key Takeaways

Last lesson ended with a sobering count: no grid we can afford holds the wing’s eddies, and even Stam’s solver drains energy through the numerical viscosity of its interpolation. So our solver cannot be exact about turbulence. One thing it must get right anyway: at 5050 m/s the air is incompressible, so every grid cell must let out exactly as much air as it takes in. Break that and smoke inflates or vanishes, and a wing’s pressure field is nonsense. This lesson builds the step that enforces it, the pressure projection.

Tools: 11.4 Viscosity & the Navier–Stokes Equations, 2.11 The Laplacian & Vector Identities (Helmholtz–Hodge and Jacobi), 1.3 Linear Systems, Kernel & Column Space (null spaces) and 11.7 Potential Flow & Stream Functions.

▶ Video A time step split into predict and project, a velocity field losing its compression to a pressure gradient, a grid of unknowns each relaxing toward its neighbours, a checkerboard the collocated grid cannot see, and a uniform stream projected into flow around a cylindercaptions only
Transcript
  1. Last lesson ended with a grim count: no grid we can afford holds the wing's eddies. So the solver cannot be exact about turbulence. What it must get right is incompressibility. At 50 metres per second the air cannot be squeezed, so every cell must let out exactly what it takes in. The step that enforces it is the pressure projection.
  2. No equation says how pressure changes in time: it is whatever keeps the divergence zero. So we split the step. Operator splitting advances each piece separately, and costs first order in time: the error is one half of B A minus A B, times delta t squared, unless the pieces commute. Stam's split: add forces, advect, diffuse, then project.
  3. Chorin's method predicts u star, ignoring pressure, then projects: u new is u star minus delta t over rho times the gradient of p. Take the divergence, demand zero, and the pressure Poisson equation falls out: one elliptic solve per step. In the worked example, u star is 0.3 cosine x plus sine y. The pressure is 36 sine x, its gradient is exactly the compression, and what is left is the shear, sine y. The projection removed 8.26 percent of the energy.
  4. Why does subtracting a gradient work? By Helmholtz and Hodge, every field splits uniquely and orthogonally into a divergence-free part plus a gradient. The projection computes the gradient part and throws it away, so it never adds energy. Equivalently, the pressure is a Lagrange multiplier, one per cell: the projected velocity is the nearest divergence-free field to u star.
  5. Walls. Dot the projection with the normal, and the wall's velocity condition becomes a Neumann condition on pressure. With all-Neumann boundaries, integrating gives a compatibility condition: the net inflow must be zero. Pump air into a closed box and no pressure can make it fit. And if p is a solution, so is p plus a constant: the null space. The solver sets the mean to zero.
  6. On a periodic grid each Fourier mode is an eigenvector of the Laplacian, so the solve is one division per mode, and exact. But exact for which divergence? Project three stirred jets four ways. Spectral, wide collocated and MAC all reach round-off, about ten to the minus fifteen. Stam's collocated compact stencil leaves 2.78 times ten to the minus two, because its Laplacian is not the divergence of its gradient.
  7. The collocated central difference skips the centre cell, so a checkerboard pressure has gradient zero. The projection cannot see it. On the staggered MAC grid, pressure at centres and velocities on faces, the same checkerboard has gradient 20.37. And the MAC gradient is minus the transpose of the divergence, so the Lagrange picture is exact.
  8. Now the real test: a uniform stream in a wind tunnel, around a cylinder, 7984 unknowns. The predictor ignores the body, so beside it the divergence is 8.000. Conjugate gradients take 319 iterations to a residual of 1.9 times ten to the minus thirteen. The speed just above the cylinder is 1.5044, against 1.4906 from channel theory and 1.4096 with no walls: the walls add 6 percent.
  9. Stam's solver uses Gauss-Seidel instead, and it is slow. A sweep carries news only a cell or so, and the smoothest error dies slowest, over a number of sweeps growing like N squared. After 20 sweeps the residual is 0.238, the divergence left is 12 percent, and the speed above the cylinder is 1.0425: the cylinder's influence has barely spread.
  10. So the projection keeps the air incompressible. Put semi-Lagrangian advection, an implicit diffusion solve and a force step in front of it, and you have Stam's complete Stable Fluids solver. Next, 11.11, we build it line by line.

Splitting the equations

The incompressible Navier–Stokes equations (11.4) are

∂u∂t=−(u⋅∇)u+ν∇2u+f−1ρ∇p,∇⋅u=0.\frac{\partial\mathbf u}{\partial t} = -(\mathbf u\cdot\nabla)\mathbf u + \nu\nabla^2\mathbf u + \mathbf f - \frac{1}{\rho}\nabla p, \qquad \nabla\cdot\mathbf u = 0 .

No equation says how pp changes in time. The pressure has no dynamics of its own; it is whatever keeps ∇⋅u=0\nabla\cdot\mathbf u = 0, so a time stepper cannot march it.

Operator splitting advances each piece of a right-hand side in its own sub-step, with the method that suits it. For x˙=(A+B)x\dot{\mathbf x} = (A + B)\mathbf x the exact step is e(A+B)Δte^{(A+B)\Delta t} (7.5 The Matrix Exponential & Fundamental Matrices) and “first AA, then BB” is eBΔteAΔte^{B\Delta t}e^{A\Delta t}. Multiply out the series: both start I+(A+B)ΔtI + (A + B)\Delta t, but at order Δt2\Delta t^2 the split step has BABA where the exact one has 12(AB+BA)\tfrac12(AB + BA). That is an error 12(BA−AB)Δt2\tfrac12(BA - AB)\Delta t^2 per step, O(Δt)O(\Delta t) over T/ΔtT/\Delta t steps: splitting is first order unless the pieces commute. (Strang’s symmetric half-AA, BB, half-AA is second order; from memory.)

Stam splits each step into add forces, advect, diffuse, project. The first three make a predicted velocity u∗\mathbf u^* with no regard for incompressibility; the last repairs it.

Chorin’s projection

Chorin’s method (1968, from memory; Temam found it independently) takes the step in two parts.

Predict. Advance everything except the pressure:

u∗=un+Δt[−(un⋅∇)un+ν∇2un+f].\mathbf u^* = \mathbf u^n + \Delta t\big[-(\mathbf u^n\cdot\nabla)\mathbf u^n + \nu\nabla^2\mathbf u^n + \mathbf f\big] .

Even though ∇⋅un=0\nabla\cdot\mathbf u^n = 0, advection and forces leave ∇⋅u∗≠0\nabla\cdot\mathbf u^* \ne 0.

Project. Add the pressure term on its own, un+1=u∗−Δtρ∇p\mathbf u^{n+1} = \mathbf u^* - \frac{\Delta t}{\rho}\nabla p, and choose pp so that ∇⋅un+1=0\nabla\cdot\mathbf u^{n+1} = 0. The divergence of both sides gives

0=∇⋅u∗−Δtρ∇2p⟹∇2p=ρΔt∇⋅u∗,0 = \nabla\cdot\mathbf u^* - \frac{\Delta t}{\rho}\nabla^2 p \qquad\Longrightarrow\qquad \nabla^2 p = \frac{\rho}{\Delta t}\nabla\cdot\mathbf u^* ,

the pressure Poisson equation: one elliptic solve per step. Adding the two parts gives a first-order time discretization of Navier–Stokes with the pressure at the new time, which is why these are called fractional-step methods. Second-order versions keep the old pressure gradient in the predictor and solve for the correction pn+1−pnp^{n+1} - p^n (from memory); the projection is unchanged.

Worked example: one projection by hand

On the periodic square [0,2π]2[0, 2\pi]^2, air (ρ=1.2\rho = 1.2 kg/m3^3), Δt=0.01\Delta t = 0.01 s, the predictor gave u∗=(0.3cos⁡x+sin⁡y, 0)\mathbf u^* = (0.3\cos x + \sin y,\ 0). Project it.

  1. Divergence: ∇⋅u∗=−0.3sin⁡x\nabla\cdot\mathbf u^* = -0.3\sin x.
  2. Poisson: ∇2p=1.20.01(−0.3sin⁡x)=−36sin⁡x\nabla^2 p = \frac{1.2}{0.01}(-0.3\sin x) = -36\sin x. Since ∇2sin⁡x=−sin⁡x\nabla^2\sin x = -\sin x, p=36sin⁡xp = 36\sin x Pa, plus any constant.
  3. Correct: Δtρ∇p=0.011.2(36cos⁡x,0)=(0.3cos⁡x,0)\frac{\Delta t}{\rho}\nabla p = \frac{0.01}{1.2}(36\cos x, 0) = (0.3\cos x, 0), so un+1=(sin⁡y, 0)\mathbf u^{n+1} = (\sin y,\ 0).

The compression wave is removed; the shear sin⁡y\sin y, already divergence-free, passes untouched. The pressure peaks at x=π/2x = \pi/2, where u∗u^* falls fastest along xx and air piles up. Energy: ∬∣u∗∣2=2π2(0.09+1)\iint|\mathbf u^*|^2 = 2\pi^2(0.09 + 1) (the cross term integrates to zero), and the projection removes 2π2(0.09)2\pi^2(0.09), or 8.26%8.26\%.

Halve Δt\Delta t and pp doubles to 72sin⁡x72\sin x Pa for the same u∗\mathbf u^*. A thermodynamic pressure is set by density and temperature; this one by how much compression must be removed, and how fast.

What the pressure really is

By Helmholtz–Hodge (2.11 The Laplacian & Vector Identities) every field splits uniquely and orthogonally as u∗=u+∇ϕ\mathbf u^* = \mathbf u + \nabla\phi with ∇⋅u=0\nabla\cdot\mathbf u = 0. The projection is that split, with ϕ=Δtρp\phi = \frac{\Delta t}{\rho}p: compute the gradient part, throw it away. Orthogonality gives ∣u∗∣2=∣u∣2+∣∇ϕ∣2|\mathbf u^*|^2 = |\mathbf u|^2 + |\nabla\phi|^2, so projection never adds energy.

A Lagrange multiplier. Picture the grid velocities as one long list. The projected list is the one nearest u∗\mathbf u^* subject to one constraint per cell: its discrete divergence (Du)c=0(D\mathbf u)_c = 0. Lagrange’s trick attaches a multiplier λc\lambda_c to each constraint and minimizes 12∣u−u∗∣2+∑cλc(Du)c\tfrac12|\mathbf u - \mathbf u^*|^2 + \sum_c\lambda_c(D\mathbf u)_c freely; setting the derivative with respect to each velocity to zero gives u=u∗−DTλ=u∗+Gλ\mathbf u = \mathbf u^* - D^{\mathsf T}\lambda = \mathbf u^* + G\lambda, because on the MAC grid below DT=−GD^{\mathsf T} = -G. So λ=−Δtρp\lambda = -\frac{\Delta t}{\rho}p: the pressure is the multiplier enforcing incompressibility cell by cell, like the tension that holds a pendulum bob on its circle (11.3). It has no equation of state, is defined only up to a constant, and responds instantly everywhere: an incompressible fluid has an infinite speed of sound.

The pressure equation as a grid of unknowns

With the 5-point Laplacian the Poisson equation becomes one equation per cell:

pE+pW+pN+pS−4pCh2=bC⟺pC=pE+pW+pN+pS4−h24bC,\frac{p_E + p_W + p_N + p_S - 4p_C}{h^2} = b_C \qquad\Longleftrightarrow\qquad p_C = \frac{p_E + p_W + p_N + p_S}{4} - \frac{h^2}{4}b_C ,

with b=ρΔt∇⋅u∗b = \frac{\rho}{\Delta t}\nabla\cdot\mathbf u^*. In plain words: every unknown equals the average of its neighbours, minus a source. The cylinder sim below has 79847984 such equations, each with at most five unknowns. Elimination would waste effort on a matrix that is almost all zeros, so we iterate:

  • Jacobi: replace every pCp_C by the right side computed from the old values (the Jacobi relaxation of 2.11 The Laplacian & Vector Identities, plus a source).
  • Gauss–Seidel: the same, but each new value is used at once. Stam’s lin_solve does 20 sweeps of this.
  • Conjugate gradients (CG): each step takes the best combination of the residuals so far; for a symmetric matrix like this it is far faster (stated, not derived). Multigrid is faster still (from memory).

Why are the first two slow? A Jacobi sweep moves information one cell; Gauss–Seidel carries it further in its sweep direction but one cell against it, weakening at each hop. The cylinder’s top is 2424 cells from the wall, and once the news arrives the smoothest error dies slowest, over a number of sweeps growing like N2N^2.

Pressure at walls, and the all-Neumann problem

At a solid wall the air must not pass through: un+1⋅n=uwall⋅n\mathbf u^{n+1}\cdot\mathbf n = \mathbf u_{\text{wall}}\cdot\mathbf n. Dot the projection with n\mathbf n:

un+1⋅n=u∗⋅n−Δtρ∂p∂n⟹∂p∂n=ρΔt(u∗−uwall)⋅n.\mathbf u^{n+1}\cdot\mathbf n = \mathbf u^*\cdot\mathbf n - \frac{\Delta t}{\rho}\frac{\partial p}{\partial n} \qquad\Longrightarrow\qquad \frac{\partial p}{\partial n} = \frac{\rho}{\Delta t}\big(\mathbf u^* - \mathbf u_{\text{wall}}\big)\cdot\mathbf n .

The wall condition on velocity becomes a Neumann condition on pressure. If the predictor already set the wall’s normal velocity (Stam does; on the MAC grid the wall face is simply not an unknown), ∂p/∂n=0\partial p/\partial n = 0, and the grid equation drops the missing neighbour: a cell beside a wall averages its three fluid neighbours. A prescribed inflow or outflow is Neumann too; p=0p = 0 at an outflow (Dirichlet) is a common alternative. Since ∂p/∂n=0\partial p/\partial n = 0 is a numerical artifact rather than a law of the real pressure, the projected pressure is only first-order accurate in a thin layer at walls (from memory).

Compatibility. If every boundary is Neumann, integrate the Poisson equation and apply the divergence theorem to both sides: ∮∂p/∂n ds=ρΔt∮u∗⋅n ds\oint\partial p/\partial n\,ds = \frac{\rho}{\Delta t}\oint\mathbf u^*\cdot\mathbf n\,ds. With the wall condition the left side is ρΔt∮(u∗−uwall)⋅n ds\frac{\rho}{\Delta t}\oint(\mathbf u^* - \mathbf u_{\text{wall}})\cdot\mathbf n\,ds, so a solution exists only if ∮uwall⋅n ds=0\oint\mathbf u_{\text{wall}}\cdot\mathbf n\,ds = 0: the prescribed boundary velocities must add up to zero net inflow. Pump air into a closed incompressible box and no pressure can make it fit. On the grid, each interior face enters two cell equations with opposite signs, so the sum of all bCh2b_Ch^2 is the net boundary inflow.

The null space. If pp solves an all-Neumann problem, so does p+Cp + C: the constant vector is in the matrix’s kernel (1.3 Linear Systems, Kernel & Column Space). Solvers pin one cell or, as the sim does, set the mean to zero.

The sim does this in a wind-tunnel channel 16a16a long and 8a8a high, h=a/8h = a/8, 79847984 fluid cells around a staircase cylinder. Step 1 shows max⁡∣∇⋅u∗∣=8.000\max|\nabla\cdot\mathbf u^*| = 8.000: a closed face beside one carrying U=1U = 1 gives (0−1)/h=−8(0 - 1)/h = -8. The net boundary inflow prints 00: solvable. Conjugate gradients take 319319 iterations to a relative residual of 1.9×10−131.9\times10^{-13}, and step 3 leaves max⁡∣∇⋅u∣\max|\nabla\cdot\mathbf u| near 5×10−135\times10^{-13}.

◆ Interactive Project a uniform stream around a cylinder in a channel: u* and its divergence, the pressure solve, the projected flow against potential flow

Loading simulation…

The numbers. At (0,1.5625)(0, 1.5625), just over half a radius above the cylinder, the grid speed is 1.50441.5044. Potential flow without walls gives 1.40961.4096; with the channel walls (image doublets, our construction, checked numerically in the sim’s source), 1.49061.4906. The walls add 6%6\%: the blockage a wind-tunnel engineer corrects for. The remaining 0.9%0.9\% is the staircase, a body wrong by up to half a cell.

Stam’s 20 sweeps. With Gauss–Seidel at 20 sweeps the relative residual is 0.2380.238, max⁡∣∇⋅u∣=0.992\max|\nabla\cdot\mathbf u| = 0.992 is 12%12\% of u∗\mathbf u^*‘s, and the speed above the cylinder is 1.04251.0425: the cylinder’s influence has barely spread. At 2000 sweeps: 1.41251.4125, residual 1.66×10−21.66\times10^{-2}. A running smoke solver removes only the divergence one step created, so 20 sweeps fare better there, but the leftover accumulates as volume loss.

The light wing. The button sets G=Γ/(2πUa)=0.159G = \Gamma/(2\pi Ua) = 0.159, 11.7’s light-aircraft analog. The clockwise loop integral around ∣x∣,∣y∣≤1.94|x|, |y| \le 1.94 reads 1.0001101.000110 for u∗\mathbf u^* (a Γ=1\Gamma = 1 vortex summed on a grid) and the same 1.0001101.000110 after projection, so the Kutta–Joukowski lift ρUΓ\rho U\Gamma is kept. The air above is faster (1.61121.6112; channel theory 1.59911.5991), below slower (1.39761.3976; 1.38211.3821).

The ϕ\phi painted in step 2 is not the pressure a wing feels. It is the pressure impulse, divided by ρ\rho, that would turn the bare stream into this flow in one step: high in front, where oncoming air must be stopped, equally low behind, where air must be pulled in, near zero on top. The steady surface pressure comes from Bernoulli on the projected velocity (11.3).

Periodic grids: the FFT solves it exactly

On a periodic grid each Fourier mode ei(mx+ny)e^{i(mx + ny)} is an eigenvector of the discrete Laplacian: the 5-point stencil returns it multiplied by λmn=−4h2(sin⁡2mh2+sin⁡2nh2)\lambda_{mn} = -\frac{4}{h^2}\big(\sin^2\frac{mh}{2} + \sin^2\frac{nh}{2}\big). So the FFT (11.9’s tool) turns the linear system into one division per mode: transform bb, divide by λmn\lambda_{mn}, transform back. It is exact and costs O(N2log⁡N)O(N^2\log N); the null space is λ00=0\lambda_{00} = 0, the constant mode, and compatibility is automatic because a periodic divergence has zero mean. The price: a box with no walls and no wing.

Collocated grids and the checkerboard

The obvious grid, collocated, stores uu, vv and pp at cell centres with central differences, (pi+1−pi−1)/2h(p_{i+1} - p_{i-1})/2h. That stencil skips the centre, so a checkerboard p=(−1)i+jp = (-1)^{i+j} has central gradient zero: the projection cannot see it, nor a sawtooth velocity. Then:

  • With Stam’s compact Laplacian, D(Gp)=(pi+2−2pi+pi−2)/4h2+…D(Gp) = (p_{i+2} - 2p_i + p_{i-2})/4h^2 + \dots is a wide stencil, not the compact one: even an exact solve leaves divergence.
  • With the wide Laplacian DGDG the divergence vanishes, but the grid splits into four uncoupled sub-grids, and the null space holds three checkerboards besides the constant (Problem 3).

The MAC grid (marker-and-cell; Harlow and Welch, 1965, from memory) staggers: pp at centres, uu on vertical faces, vv on horizontal faces. A cell’s divergence uses its own four faces, a face’s gradient its two cells, (pi+1−pi)/h(p_{i+1} - p_i)/h. Then DGDG is exactly the compact Laplacian, and the checkerboard has gradient 2/h2/h. Summation by parts gives

∑cellsp (Du)=−∑faces(Gp)⋅u,\sum_{\text{cells}} p\,(D\mathbf u) = -\sum_{\text{faces}}(Gp)\cdot\mathbf u ,

the discrete ∬p ∇⋅u=−∬∇p⋅u\iint p\,\nabla\cdot\mathbf u = -\iint\nabla p\cdot\mathbf u, i.e. G=−DTG = -D^{\mathsf T}. This adjointness makes the Lagrange picture exact and the projection orthogonal on the grid.

◆ Interactive One stirred field projected four ways on a periodic 64 by 64 grid with exact FFT solves: divergence before, pressure, divergence after

Loading simulation…

Three Gaussian jets, each method judged by its own divergence (the sim and the lab below):

methodmax⁡∣Du∗∣\max\lvert D\mathbf u^*\rvertafter an exact solve
spectral1.21731.2173about 10−1510^{-15}
collocated, compact (Stam)1.19861.19862.78×10−22.78\times10^{-2}
collocated, wide1.19861.1986about 10−1510^{-15}
MAC1.21261.2126about 10−1510^{-15}

The spectral result is divergence-free in its own derivative; measured with central differences (the sim’s readout), 4.44×10−34.44\times10^{-3} appears. “Divergence-free” always means “for this DD”. Stam’s mismatch leaves 2.3%2.3\% after a perfect solve. Tick the sawtooth 0.1(−1)i0.1(-1)^i: spectral, compact and wide leave its amplitude at 0.10000.1000 (their derivatives cannot see it); MAC removes it (0.00000.0000).

Computing it

🐍 PythonLab: one field projected four ways with exact FFT solves; the checkerboard; MAC adjointness
⌘/Ctrl + Enter

Each discretization is three Fourier symbols, DD, GG and a Laplacian, and a projection is exact for its own DD precisely when the Laplacian equals D⋅GD\cdot G. The lab also prints the checkerboard’s gradient (00 central, 20.37=2/h20.37 = 2/h MAC) and both sides of the adjointness identity, equal to all ten decimals (108.3432906514108.3432906514).

The exercise. Build the MAC projection on a periodic grid, in physical units. The test field has a known answer: a discretely divergence-free part from a stream function at the cell corners, plus the gradient of a known qq. A correct projection returns the first part exactly, with pressure ρΔt(q−qˉ)\frac{\rho}{\Delta t}(q - \bar q).

🧪 Coding exerciseExercise: Chorin's projection on a periodic MAC grid with an FFT Poisson solve
⌘/Ctrl + Enter

Graded: divergence at round-off, the divergence-free part returned unchanged and the pressure ρΔt(q−qˉ)\frac{\rho}{\Delta t}(q - \bar q). The solution then projects pure noise: max⁡∣Du∗∣=251.880\max|D\mathbf u^*| = 251.880 before, 8.70×10−148.70\times10^{-14} after, 51.48%51.48\% of the energy kept. About half is expected: each 2D Fourier mode has one direction along its wave vector (compression, removed) and one across it (swirl, kept).

Concept checks

✅ Concept check

In the worked example, $\mathbf u^* = (0.3\cos x + \sin y, 0)$ and $\rho = 1.2$ kg/m$^3$. With $\Delta t = 0.005$ s instead of $0.01$ s, what is the amplitude of the projection pressure $p$, in Pa?

✅ Concept check

Why can a collocated grid with central differences carry a checkerboard pressure $(-1)^{i+j}$ that the projection never removes?

✅ Concept check

A closed box with walls on all sides has a fan blowing air in through one wall, and no outlet. What does the all-Neumann pressure Poisson equation do?

✅ Concept check

Project $\mathbf u^* = $ uniform stream plus a point vortex of circulation $\Gamma$, with the velocity zeroed on the faces touching a cylinder. What does the projection do to the circulation around the cylinder?

Problems

✏️ Pen & paperThe pressure equation and its boundary condition●○○

Starting from un+1=u∗−Δtρ∇p\mathbf u^{n+1} = \mathbf u^* - \frac{\Delta t}{\rho}\nabla p, derive the pressure Poisson equation and the wall condition for ∂p/∂n\partial p/\partial n. Then show that if u∗\mathbf u^* is already divergence-free and satisfies the wall condition, pp is constant and the projection does nothing.

Show worked solution

Divergence: ∇⋅un+1=∇⋅u∗−Δtρ∇2p\nabla\cdot\mathbf u^{n+1} = \nabla\cdot\mathbf u^* - \frac{\Delta t}{\rho}\nabla^2p; setting it to zero gives ∇2p=ρΔt∇⋅u∗\nabla^2 p = \frac{\rho}{\Delta t}\nabla\cdot\mathbf u^*. Normal component at the wall: un+1⋅n=u∗⋅n−Δtρ∂p/∂n\mathbf u^{n+1}\cdot\mathbf n = \mathbf u^*\cdot\mathbf n - \frac{\Delta t}{\rho}\partial p/\partial n must equal uwall⋅n\mathbf u_{\text{wall}}\cdot\mathbf n, so ∂p/∂n=ρΔt(u∗−uwall)⋅n\partial p/\partial n = \frac{\rho}{\Delta t}(\mathbf u^* - \mathbf u_{\text{wall}})\cdot\mathbf n. In the special case, ∇2p=0\nabla^2 p = 0 with ∂p/∂n=0\partial p/\partial n = 0; multiply by pp and integrate by parts: ∬∣∇p∣2=∮p ∂p/∂n−∬p∇2p=0\iint|\nabla p|^2 = \oint p\,\partial p/\partial n - \iint p\nabla^2p = 0, so ∇p=0\nabla p = 0: pp is constant and un+1=u∗\mathbf u^{n+1} = \mathbf u^*.

✏️ Pen & paperA one-dimensional projection by hand●●○

A periodic 1D MAC grid has four cells (h=1h = 1, and take ρ/Δt=1\rho/\Delta t = 1, so ϕ=p\phi = p). Face velocities uiu_i sit on the right face of cell ii: u∗=(1,3,2,2)\mathbf u^* = (1, 3, 2, 2). The divergence of cell ii is ui−ui−1u_i - u_{i-1} (indices mod 4), the gradient on face ii is pi+1−pip_{i+1} - p_i. Solve for pp with mean zero, project, and check the energy split. Why must the answer be a constant?

Show worked solution

Divergence: (u0−u3,u1−u0,u2−u1,u3−u2)=(−1,2,−1,0)(u_0 - u_3, u_1 - u_0, u_2 - u_1, u_3 - u_2) = (-1, 2, -1, 0); it sums to zero (compatibility). In 1D the only divergence-free periodic field is a constant, and the projection keeps the mean, 22, so we need pi+1−pi=ui∗−2=(−1,1,0,0)p_{i+1} - p_i = u^*_i - 2 = (-1, 1, 0, 0). Then p1=p0−1p_1 = p_0 - 1, p2=p0p_2 = p_0, p3=p0p_3 = p_0; mean zero gives 4p0−1=04p_0 - 1 = 0, so p=(0.25,−0.75,0.25,0.25)p = (0.25, -0.75, 0.25, 0.25). Check cell 1: p2−2p1+p0=0.25+1.5+0.25=2p_2 - 2p_1 + p_0 = 0.25 + 1.5 + 0.25 = 2. ✓ Projected: u=(2,2,2,2)\mathbf u = (2, 2, 2, 2). Energy: ∑u∗2=18=16+2\sum u^{*2} = 18 = 16 + 2, with ∑(Gp)2=1+1=2\sum(Gp)^2 = 1 + 1 = 2. ✓

✏️ Pen & paperThe null space of the wide Laplacian●●●

On an N×NN\times N periodic grid (NN even), the collocated central-difference operators give the wide Laplacian (pi+2,j+pi−2,j+pi,j+2+pi,j−2−4pij)/4h2(p_{i+2,j} + p_{i-2,j} + p_{i,j+2} + p_{i,j-2} - 4p_{ij})/4h^2. Find all pp in its null space, and compare with the compact Laplacian’s. What does this mean for a collocated pressure solve?

Show worked solution

Use Fourier modes: the wide stencil multiplies ei(mx+ny)e^{i(mx + ny)} by −(sin⁡2mh+sin⁡2nh)/h2-(\sin^2 mh + \sin^2 nh)/h^2, which vanishes when sin⁡mh=sin⁡nh=0\sin mh = \sin nh = 0, i.e. m,n∈{0,N/2}m, n \in \{0, N/2\} (with h=2π/Nh = 2\pi/N, sin⁡(N2h)=sin⁡π=0\sin(\tfrac N2 h) = \sin\pi = 0). Four modes: 11, (−1)i(-1)^i, (−1)j(-1)^j, (−1)i+j(-1)^{i+j}. The compact symbol −4h2(sin⁡2mh2+sin⁡2nh2)-\frac4{h^2}(\sin^2\frac{mh}2 + \sin^2\frac{nh}2) vanishes only at m=n=0m = n = 0: constants. So a collocated wide solve leaves three grid-scale oscillations undetermined; any can grow in the pressure without touching the velocity: the checkerboard. On the MAC grid (−1)i+j(-1)^{i+j} has gradient ±2/h\pm2/h, so the solve pins it.

Key Takeaways

  • Incompressible pressure has no evolution equation. Split the step: predict u∗\mathbf u^* ignoring pressure, then project; splitting is first order in Δt\Delta t unless the pieces commute.
  • Chorin: un+1=u∗−Δtρ∇p\mathbf u^{n+1} = \mathbf u^* - \frac{\Delta t}{\rho}\nabla p with ∇2p=ρΔt∇⋅u∗\nabla^2p = \frac{\rho}{\Delta t}\nabla\cdot\mathbf u^*: Helmholtz–Hodge, discarding the gradient part, never adding energy.
  • The pressure is a Lagrange multiplier, one per cell, scaling with 1/Δt1/\Delta t, fixed up to a constant. Walls give ∂p/∂n=ρΔt(u∗−uwall)⋅n\partial p/\partial n = \frac{\rho}{\Delta t}(\mathbf u^* - \mathbf u_{\text{wall}})\cdot\mathbf n; an all-Neumann problem needs zero net inflow.
  • Each unknown is its neighbours’ average minus a source. Twenty Gauss–Seidel sweeps leave 12%12\% of the cylinder’s divergence; CG reached 10−1310^{-13} in 319319 iterations; on a periodic grid the FFT is exact.
  • “Divergence-free” means for a particular DD. Collocated grids hide checkerboards, and Stam’s stencil leaves 2.3%2.3\% after an exact solve; MAC has G=−DTG = -D^{\mathsf T}, DGDG = compact Laplacian, and round-off divergence.
  • Projecting a uniform stream around a body gives potential flow; add a vortex and its circulation survives (1.0001101.000110 before and after): the lifting cylinder.
  • Next, 11.11: the projection is the step that keeps the air incompressible; put semi-Lagrangian advection, an implicit diffusion solve and a force step in front of it, and you have Stam’s complete Stable Fluids solver, which we will build line by line.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.

Where this leads

These later lessons build directly on this one: