Flow Lab

Syllabus / Module 10: Numerical Methods for PDEs

Lesson 10.5

Wave Equation Numerics & the CFL Condition

Leapfrog for waves, the Courant–Friedrichs–Lewy condition, numerical dispersion, and absorbing boundaries.

Written byClaude Sonnet

🌊
Why this matters for simulation: The CFL number dictates the time step in essentially every explicit CFD code.

By the end of this lesson you can…

  • Push a plane wave through the leapfrog scheme and derive its numerical dispersion relation $\sin(\omega\Delta t/2) = \nu\sin(k\Delta x/2)$.
  • Show that $\lvert\nu\rvert \le 1$ is both the von Neumann stability condition and the domain-of-dependence condition, and say why it is necessary but not sufficient in general.
  • Compute the numerical phase and group speed, explain why short waves lag, and predict how far a wave packet's envelope falls behind the exact one.
  • Choose points per wavelength for a given travel distance and phase-error budget, and say what a fourth-order stencil buys and costs.
  • Explain why $\nu = 1$ is exact in 1D but not in 2D, where the 5-point stencil allows only $\nu \le 1/\sqrt2$.
  • Compare Dirichlet, Neumann and first-order absorbing ends, and write the staggered $(p, u)$ acoustics scheme that avoids the collocated grid's group-velocity reversal.
On this page
·
  1. Leapfrog and its plane waves
  2. Stability: ν≤1\nu \le 1ν≤1, from two directions
  3. Phase error and group error: short waves lag
  4. The packet experiment
  5. Points per wavelength
  6. Why ν=1\nu = 1ν=1 is special in 1D and not in 2D
  7. Boundaries: reflect or absorb
  8. First-order form and the staggered grid
  9. Check your understanding
  10. Problems
  11. Computation
  12. Key Takeaways
  13. What comes next

9.9 Infinite Domains & the Fourier Transform ended on a promise: run the plane-wave test on a finite-difference scheme and out comes a numerical ω(k)\omega(k). This lesson keeps it. The leapfrog scheme of 9.4 The Wave Equation & Vibrating Strings was exact at a Courant number ν=c Δt/Δx=1\nu = c\,\Delta t/\Delta x = 1, off by 0.0220.022 at 0.80.8 and a blow-up at 1.051.05. Why those three? The plane-wave test answers all of it, and shows something heat never did: a wave packet run through a grid arrives late. For an acoustics simulator, where waves travel many wavelengths, that lateness is the whole game.

▶ Video A plane wave through leapfrog, the numerical dispersion curve, a packet falling behind, the CFL limit in 1D and 2D, and the staggered acoustics gridcaptions only
Transcript
  1. Leapfrog replaces both second derivatives of the wave equation by central differences. Try a single plane wave, G to the n times e to the i j theta. Two roots appear, one per direction, and when they have modulus 1, writing G as e to the minus i omega delta t gives the numerical dispersion relation: sine of omega delta t over 2 equals nu times sine of k delta x over 2. The exact relation is omega equals c k, and at nu equal to 1 the two coincide. Otherwise the grid has its own curve.
  2. The roots have modulus exactly 1 when nu times sine theta over 2 is at most 1, and the worst case is a wave of 2 points per wavelength. So leapfrog is stable if and only if nu is at most 1. At 1.05 the worst mode grows by 1.877 per step, and waves shorter than 2.49 points per wavelength all grow. Geometry agrees: after n steps the grid sees n cells, but the wave needs nu times n. That is the CFL condition. It is necessary, not sufficient: centred advection with Euler satisfies it and is unstable.
  3. The modified equation has a fourth derivative, which is dispersion. The phase speed, how fast crests move, falls below c by 1 minus nu squared times theta squared over 24. The group speed, how fast a packet's energy moves, falls by three times as much. At nu equal to 0.5 and 10 points per wavelength: slow by 1.24% and 3.74%. At theta equal to pi the group speed is 0. At nu equal to 1 every error vanishes.
  4. Run a Gaussian packet of 8 points per wavelength to time 0.5. The exact packet sits at 0.7500. At nu equal to 0.5 the numerical one arrives at 0.7205, late by 0.0295; the group-speed deficit times the distance predicts 0.0294. At 16 points the lag is 0.0074, at 4 points 0.1222. At nu equal to 0.8 it is 0.0149, and at nu equal to 1 it is exactly 0: leapfrog simply shifts the data.
  5. How many points per wavelength? Accept 0.05 cycles of phase error over D wavelengths, and points per wavelength grow like the square root of D. For 10 wavelengths you need 15.7 at nu equal to 0.5 and 11.0 at 0.8; for 100 wavelengths, 49.7. A fourth-order stencil gives a phase ratio of 0.99916 against 0.98363 at 10 points, but the limit tightens to nu at most 0.866.
  6. In 2D the worst mode is the checkerboard, which needs 2 nu squared at most 1, so nu is at most 0.7071; in 3 dimensions, 0.5774. The geometry agrees: the 5-point stencil reaches a diamond, and the wave must stay inside the circle that fits in it. Past that the checkerboard grows: 1.4643 per step at 0.72, 2.7573 at 0.80. Even below the limit the speed depends on direction: at 10 points and nu 0.7, 0.99147 along an axis, 0.99983 along the diagonal.
  7. At a Dirichlet end a pulse returns inverted: minus 1.000. At a Neumann end it returns upright, 1.000. An absorbing end uses the characteristic: an outgoing wave obeys u t plus c u x equals zero, discretised one-sidedly. At nu equal to 1 it just copies the neighbour and is exact. For a pulse of width 0.2 the reflection is 0.0050 at nu equal to 0.5, 0.0025 at 0.75, and nothing at 1.
  8. A worse error hides in the first-order system for pressure p and velocity u: p t equals minus u x, u t equals minus p x. Centred differences on one grid give omega h over c equals sine theta, so the group speed is cosine theta: 0 at 4 points per wavelength and minus 0.5 at 3. Grid-scale energy travels backwards. Leapfrog's group speed only falls to 0, and the staggered grid, pressure at centres and velocity on faces, avoids the reversal.
  9. In the staggered scheme each field is updated from a difference of the other across half a cell. Eliminate u and you get leapfrog for p, so the dispersion and the limit are identical. What is new is a conservation law: the discrete energy is conserved at walls to round-off, with drift below 1.4 times 10 to the minus 16 on an energy of 0.075 over 300 steps, for nu equal to 0.5, 0.8 and 1. A scheme that can neither amplify nor damp suffers only dispersion error.
  10. To recap. Plane waves give the dispersion relation, exact at nu equal to 1. Stability needs nu at most 1. Short waves lag, and a packet arrives late by the group deficit times the distance. In 2D the limit drops to 0.7071, and the staggered grid conserves energy. Next, multigrid: relaxation kills rough error quickly and leaves smooth error, so multigrid hands the smooth part to a coarser grid, where it is rough again.

Leapfrog and its plane waves

The scheme for utt=c2uxxu_{tt} = c^2u_{xx} replaces both derivatives by central differences:

ujn+1−2ujn+ujn−1=ν2(uj+1n−2ujn+uj−1n).u_j^{n+1} - 2u_j^n + u_j^{n-1} = \nu^2\bigl(u_{j+1}^n - 2u_j^n + u_{j-1}^n\bigr).

It is linear with constant coefficients, so, as in 10.3 Von Neumann Stability Analysis, a single wave is an eigenvector. Try ujn=Gneijθu_j^n = G^n e^{ij\theta} with θ=k Δx\theta = k\,\Delta x. Dividing out the common factor, and using eiθ+e−iθ−2=−4sin⁡2(θ/2)e^{i\theta} + e^{-i\theta} - 2 = -4\sin^2(\theta/2):

G+1G−2=−4ν2sin⁡2θ2.G + \frac1G - 2 = -4\nu^2\sin^2\frac\theta2 .

This quadratic in GG has root product 11: one root per direction of travel. If they are complex they have modulus 11 and can be written G=e∓iωΔtG = e^{\mp i\omega\Delta t}. Then G+1/G=2cos⁡ωΔtG + 1/G = 2\cos\omega\Delta t, and cos⁡ωΔt−1=−2sin⁡2(ωΔt/2)\cos\omega\Delta t - 1 = -2\sin^2(\omega\Delta t/2) gives the numerical dispersion relation

sin⁡ω Δt2=ν sin⁡k Δx2.\sin\frac{\omega\,\Delta t}{2} = \nu\,\sin\frac{k\,\Delta x}{2}.

The exact relation is ω=ck\omega = ck. Set ν=1\nu = 1 and the two coincide, because ωΔt=kΔx\omega\Delta t = k\Delta x. For any other ν\nu the grid has its own ω(k)\omega(k), and everything below is a reading of it.

Stability: ν≤1\nu \le 1, from two directions

Algebra. The roots are complex conjugates, with ∣G∣=1\lvert G\rvert = 1 exactly, when ∣2−4ν2sin⁡2(θ/2)∣≤2\lvert 2 - 4\nu^2\sin^2(\theta/2)\rvert \le 2, that is νsin⁡(θ/2)≤1\nu\sin(\theta/2) \le 1. This must hold for every θ\theta, and the worst is θ=π\theta = \pi (a wave of two points per wavelength, alternating sign from cell to cell). So leapfrog is stable if and only if ν≤1\nu \le 1. Then ∣G∣=1\lvert G\rvert = 1: no wave decays or grows, and the only error is in phase. For ν=1.05\nu = 1.05 the worst mode has G+1/G=−2.41G + 1/G = -2.41 and the larger root is ∣G∣=1.877\lvert G\rvert = 1.877 per step. Over 190190 steps that is 105210^{52}, and 9.5 d'Alembert's Solution & Characteristics measured about 104810^{48} from a start with a little grid-scale content: consistent, not a coincidence. Only waves shorter than 2.492.49 points per wavelength grow at 1.051.05; the corner of the plucked string supplies a little of them.

Geometry. After nn steps ujnu_j^n depends on data within nn cells either side. The physical solution depends on data within distance c n Δt=ν n Δxc\,n\,\Delta t = \nu\,n\,\Delta x. If ν>1\nu \gt 1 the physical interval is wider than the numerical one, so the scheme cannot see data that the answer needs. No scheme with that stencil can converge. That is the CFL condition, and for leapfrog it agrees with the algebra exactly.

Necessary, not sufficient. The domain-of-dependence argument is a necessary condition only. Centred differences for advection, ut+aux=0u_t + a u_x = 0, with Euler in time, satisfy it for any ∣ν∣≤1\lvert\nu\rvert \le 1 yet are unstable for every step size, with ∣G∣2=1+ν2sin⁡2θ\lvert G\rvert^2 = 1 + \nu^2\sin^2\theta (10.3 Von Neumann Stability Analysis). CFL tells you what a scheme cannot do, never that it works. Leapfrog is a lucky case where the two conditions meet, and in 2D below the geometric argument alone will give the right limit.

Phase error and group error: short waves lag

Expand the truncation error. By Taylor, δt2u/Δt2=utt+112Δt2utttt\delta_t^2u/\Delta t^2 = u_{tt} + \tfrac1{12}\Delta t^2u_{tttt} and δx2u/Δx2=uxx+112Δx2uxxxx\delta_x^2u/\Delta x^2 = u_{xx} + \tfrac1{12}\Delta x^2u_{xxxx}. Use utttt=c4uxxxxu_{tttt} = c^4u_{xxxx} for the exact solution:

utt=c2uxx+c2Δx212 (1−ν2) uxxxx+⋯u_{tt} = c^2u_{xx} + \frac{c^2\Delta x^2}{12}\,(1 - \nu^2)\,u_{xxxx} + \cdots

This modified equation (10.6 Advection Schemes: Upwind, Lax–Wendroff & Beyond) has a fourth derivative, which is dispersion: ω2=c2k2−112c2Δx2(1−ν2)k4\omega^2 = c^2k^2 - \tfrac1{12}c^2\Delta x^2(1-\nu^2)k^4. It vanishes at ν=1\nu = 1. In terms of θ=kΔx\theta = k\Delta x:

vpc≈1−(1−ν2)θ224,vgc≈1−(1−ν2)θ28.\frac{v_p}{c} \approx 1 - \frac{(1-\nu^2)\theta^2}{24},\qquad \frac{v_g}{c} \approx 1 - \frac{(1-\nu^2)\theta^2}{8}.

The phase speed vp=ω/kv_p = \omega/k is how fast crests move; the group speed vg=dω/dkv_g = d\omega/dk is how fast a packet’s envelope, and so the energy, moves (9.9 Infinite Domains & the Fourier Transform). Both are below cc, so short waves lag, and the group error is three times the phase error. The exact formulas, from the dispersion relation, are

vpc=2νθarcsin⁡ ⁣(νsin⁡θ2),vgc=cos⁡(θ/2)1−ν2sin⁡2(θ/2).\frac{v_p}{c} = \frac{2}{\nu\theta}\arcsin\!\bigl(\nu\sin\tfrac\theta2\bigr),\qquad \frac{v_g}{c} = \frac{\cos(\theta/2)}{\sqrt{1 - \nu^2\sin^2(\theta/2)}} .

At θ=π\theta = \pi the group speed is 00: the grid’s shortest wave goes nowhere. It does not reverse in this scheme. The sim and an independent numpy script give, at ν=0.5\nu = 0.5 and 0.80.8 (the reach is how many wavelengths a wave can travel before it is a tenth of a wavelength out of phase):

points per wavelengthν=0.5\nu = 0.5: vpv_p error, vgv_g error, reachν=0.8\nu = 0.8: vpv_p error, vgv_g error, reach
200.31%, 0.93%, 320.15%, 0.45%, 67
101.24%, 3.74%, 8.10.61%, 1.85%, 16.5
55.05%, 15.4%, 2.02.61%, 8.33%, 3.8
47.98%, 24.4%, 1.34.31%, 14.3%, 2.3

The small-angle formulas give 0.31%0.31\% and 0.93%0.93\% for the first row. Pushing ν\nu toward 11 helps every row because the time and space truncation errors cancel, until the error vanishes.

A bigger step is more accurate. With Δt→0\Delta t \to 0 (time exact, space centred) the phase ratio is sin⁡(θ/2)/(θ/2)\sin(\theta/2)/(\theta/2), which is 0.983630.98363 at 1010 points per wavelength, worse than every ν>0\nu \gt 0 row above. The time error has the opposite sign to the space error, so a step near the limit is cheaper and more accurate.

The packet experiment

Take a Gaussian envelope of width 0.040.04 times a cosine, centred at x0=0.25x_0 = 0.25, with λ=8\lambda = 8 cells on a 400400-cell grid, started as an exactly right-moving wave. The exact solution is the same packet shifted by ctct, undistorted. Run leapfrog to t=0.5t = 0.5, so the exact packet is centred at 0.75000.7500, and measure where the numerical packet (the centroid of u2u^2, over x≥0.4x \ge 0.4) has got to. The sim and an independent numpy script agree on every entry:

ν\nupoints per wavelengthnumerical centroidlag(1−vg/c) ct(1 - v_g/c)\,ct
1.080.750000
0.880.73510.01490.0148
0.580.72050.02950.0294
0.5160.74260.00740.0073
0.540.62780.12220.1220

The measured lag is the group-speed deficit times the distance, to about one percent. At ν=1\nu = 1 the error is 10−1410^{-14}: leapfrog shifts the data. At ν=0.5\nu = 0.5 and eight points per wavelength the packet is late by 1.51.5 wavelengths and its pointwise error is 1.71.7 for a packet of height 11: a different wave. Halving the wavelength in cells (from 1616 to 88 points) multiplies the lag by 44, as the θ2\theta^2 law says.

Crests against the envelope. At ν=0.5\nu = 0.5 and 88 points per wavelength, vp/c=0.98054v_p/c = 0.98054 and vg/c=0.94127v_g/c = 0.94127. The crests outrun their envelope, by 0.0393×0.5=0.01960.0393\times0.5 = 0.0196, which is 0.980.98 of a wavelength over the run: each crest appears at the back of the packet, slides forward through it and dies at the front. The sim shows it.

◆ Interactive Dispersion curves, the packet and pulse against exact, the end conditions, and the 2D limit

Loading simulation…

What to try. Packet at ν=0.5\nu = 0.5, 0.80.8, 11; 44 points per wavelength; ν=1.05\nu = 1.05. Then the pulse with the three end conditions, and the 2D box at ν=0.70\nu = 0.70 and 0.720.72.

Points per wavelength

A rule of thumb needs a budget: how many wavelengths DD must the wave travel, and how many cycles ε\varepsilon of phase error can you accept? The phase lag after DD wavelengths is D (1−vp/c)D\,(1 - v_p/c) cycles. With the small-angle formula and θ=2π/ppw\theta = 2\pi/\text{ppw}:

ppw≈2πD (1−ν2)24 ε.\text{ppw} \approx 2\pi\sqrt{\frac{D\,(1-\nu^2)}{24\,\varepsilon}} .

Points per wavelength grow like the square root of the distance. For D=10D = 10 wavelengths and ε=0.05\varepsilon = 0.05 cycles: 15.715.7 at ν=0.5\nu = 0.5 (15.7315.73 from the exact formula) and 11.011.0 at ν=0.8\nu = 0.8; for D=100D = 100 at ν=0.5\nu = 0.5 it is 49.749.7. In 3D doubling the ppw costs a factor 1616 in work (cells times steps), which is why the usual rule for second-order acoustics is only 1010 to 2020 points per wavelength (from memory).

Higher order. A fourth-order central second difference has symbol (30−32cos⁡θ+2cos⁡2θ)/12(30 - 32\cos\theta + 2\cos2\theta)/12 in place of 2−2cos⁡θ2 - 2\cos\theta, and a phase error of order θ4\theta^4. In the time-exact limit the phase ratio at 1010 points per wavelength is 0.999160.99916 against 0.983630.98363, and at 55 points 0.987890.98789 against 0.935490.93549. The price is a stricter limit: ν≤3/2=0.866\nu \le \sqrt3/2 = 0.866 with leapfrog (confirmed from the spectrum of the stepping matrix: spectral radius 1.01.0 at 0.8660.866 and 1.2071.207 at 0.870.87), a wider stencil that complicates boundaries, and the time error left unchanged. Compact (Padé) stencils buy accuracy per stencil width with a tridiagonal solve, and dispersion-relation-preserving schemes tune weights to the dispersion curve (both from memory). Spectral methods, 10.12 Spectral Methods & the FFT, are the limit of this ladder.

Why ν=1\nu = 1 is special in 1D and not in 2D

In 1D at ν=1\nu = 1 the numerical and real characteristics coincide. In 2D, utt=c2(uxx+uyy)u_{tt} = c^2(u_{xx} + u_{yy}) with the 5-point Laplacian and spacing hh in both directions, the plane-wave test gives

sin⁡2ωΔt2=ν2[sin⁡2θx2+sin⁡2θy2],ν=c Δth.\sin^2\frac{\omega\Delta t}{2} = \nu^2\Bigl[\sin^2\frac{\theta_x}2 + \sin^2\frac{\theta_y}2\Bigr],\qquad \nu = \frac{c\,\Delta t}{h}.

The worst mode is the checkerboard, θx=θy=π\theta_x = \theta_y = \pi, which needs 2ν2≤12\nu^2 \le 1:

ν≤12=0.7071.\nu \le \frac1{\sqrt2} = 0.7071 .

In dd dimensions the limit is 1/d1/\sqrt d, so 0.57740.5774 in 3D. The geometry says the same. After nn steps the 5-point stencil reaches the diamond ∣i∣+∣j∣≤n\lvert i\rvert + \lvert j\rvert \le n, whose inscribed circle has radius nh/2nh/\sqrt2, while the wave reaches a circle of radius νnh\nu nh. Inside needs ν≤1/2\nu \le 1/\sqrt2: here the necessary condition is also sufficient.

The checkerboard growth rates (the sim steps the scalar recurrence and an independent script finds the eigenvalues of the companion matrix) are 1.46431.4643 per step at ν=0.72\nu = 0.72 and 2.75732.7573 at 0.800.80, against 11 at 0.70710.7071 and below.

Accuracy changes shape too. At 1010 points per wavelength and ν=0.7\nu = 0.7 the phase ratio is 0.991470.99147 along an axis but 0.999830.99983 along the diagonal: the numerical speed depends on direction, so a circular wave turns slightly diamond-shaped. At the limit ν=1/2\nu = 1/\sqrt2 the diagonal is exact (1.000001.00000) and the axis is not (0.991630.99163); at ν=0.5\nu = 0.5 the axis gives the 1D value 0.987590.98759 and the diagonal 0.995850.99585. No stable ν\nu makes both exact, so the 1D trick does not carry over.

Boundaries: reflect or absorb

At a Dirichlet end (u=0u = 0) the scheme keeps the end node at zero, and the incoming pulse returns inverted; at a Neumann end (ux=0u_x = 0) the ghost node mirrors the interior, and the pulse returns upright (9.4 The Wave Equation & Vibrating Strings). The sim gives −1.000-1.000 and +1.000+1.000 at three digits for ν=0.5\nu = 0.5, 0.750.75 and 11.

Absorbing needs the characteristic idea of 9.5 d'Alembert's Solution & Characteristics. At the right end an outgoing wave satisfies ut+c ux=0u_t + c\,u_x = 0. Discretize this by one-sided upwind: uNn+1=uNn−ν (uNn−uN−1n)u_N^{n+1} = u_N^n - \nu\,(u_N^n - u_{N-1}^n). At ν=1\nu = 1 this just copies the neighbor and is exact for a right-moving wave. For a pulse of width 0.20.2 (8080 cells) the reflected pulse has height 0.00500.0050 at ν=0.5\nu = 0.5, 0.00250.0025 at 0.750.75 and 00 at 11. The condition is exact only head-on: in 2D oblique waves partly reflect, hence absorbing layers (from memory).

First-order form and the staggered grid

For acoustics, write the physics as a first-order system for pressure pp and velocity uu, with density and sound speed set to 11: pt=−uxp_t = -u_x and ut=−pxu_t = -p_x. Eliminating uu gives ptt=pxxp_{tt} = p_{xx}. Put pp at cell centres and uu at the cell faces, and also stagger in time, with uu at the half steps:

pjn+1=pjn−ν (uj+1/2n+1/2−uj−1/2n+1/2),uj+1/2n+3/2=uj+1/2n+1/2−ν (pj+1n+1−pjn+1).p_j^{n+1} = p_j^n - \nu\,\bigl(u_{j+1/2}^{n+1/2} - u_{j-1/2}^{n+1/2}\bigr),\qquad u_{j+1/2}^{n+3/2} = u_{j+1/2}^{n+1/2} - \nu\,\bigl(p_{j+1}^{n+1} - p_j^{n+1}\bigr).

Each field is updated from a difference of the other across half a cell. Eliminating uu returns the leapfrog scheme for pp, so the dispersion relation, the CFL limit ν≤1\nu \le 1 and the ν=1\nu = 1 exactness are identical. What is new: no group-velocity reversal, and a conservation law. The quantity 12Δx[∑pj2+∑un−1/2un+1/2]\tfrac12\Delta x\bigl[\sum p_j^2 + \sum u^{n-1/2}u^{n+1/2}\bigr] is conserved by the scheme at walls, to round-off: the drift is below 1.4×10−161.4\times10^{-16} on an energy of 0.0750.075 over 300300 steps (ν=0.5\nu = 0.5, 0.80.8 and 11). Such a scheme cannot amplify or damp, so a pulse suffers only dispersion error. The velocity sits on faces, as in the MAC grid of 10.11 2D Grids, Boundary Conditions & Staggered (MAC) Grids, and the pressure in cells, as in the finite-volume cells of 10.10 The Finite Volume Method. A rigid wall is u=0u = 0 at a face (an upright reflection of pp), and u=pu = p at the end absorbs the outgoing wave. In the sim, choose the staggered scheme and compare.

Check your understanding

✅ Concept check

A scheme satisfies the CFL condition, so its numerical domain of dependence contains the physical one. What does that guarantee?

✅ Concept check

Leapfrog runs at $\nu = 0.5$ with $8$ points per wavelength. Compared with the exact wave, the numerical packet is

✅ Concept check

A 2D grid has $h = 1$ and $c = 1$. What is the largest stable time step for the 5-point leapfrog scheme?

Problems

✏️ Pen & paperDispersion by hand●○○

At ν=0.8\nu = 0.8 and four points per wavelength (θ=π/2\theta = \pi/2) find ωΔt\omega\Delta t, vp/cv_p/c and vg/cv_g/c.

Show worked solution

sin⁡(ωΔt/2)=0.8sin⁡(π/4)=0.5657\sin(\omega\Delta t/2) = 0.8\sin(\pi/4) = 0.5657, so ωΔt/2=0.6011\omega\Delta t/2 = 0.6011 and ωΔt=1.2021\omega\Delta t = 1.2021. Then ωh/c=1.2021/0.8=1.5026\omega h/c = 1.2021/0.8 = 1.5026, against θ=1.5708\theta = 1.5708 exactly, so vp/c=0.9569v_p/c = 0.9569. The group speed is 0.7071/1−0.64⋅0.5=0.7071/0.8246=0.85750.7071/\sqrt{1 - 0.64\cdot0.5} = 0.7071/0.8246 = 0.8575. The table’s last row gives 4.31%4.31\% and 14.3%14.3\% errors.

✏️ Pen & paperSound in three dimensions●○○

A 3D acoustic grid has h=1h = 1 cm and c=340c = 340 m/s. Find the largest stable Δt\Delta t for the 7-point leapfrog scheme, whose limit is 1/31/\sqrt3.

Show worked solution

The worst mode has θx=θy=θz=π\theta_x = \theta_y = \theta_z = \pi and gives 3ν2≤13\nu^2 \le 1. So ν≤0.5774\nu \le 0.5774 and Δt≤0.5774×0.01/340=1.70×10−5\Delta t \le 0.5774\times0.01/340 = 1.70\times10^{-5} s. In 1D the limit would be 2.94×10−52.94\times10^{-5} s: the extra dimensions cost a factor of 1.731.73.

✏️ Pen & paperSizing a sound grid●●○

A 11 kHz tone in air (c=340c = 340 m/s) travels 1010 wavelengths. Using ν=0.8\nu = 0.8 and a phase budget of 0.050.05 cycles, find the cell size and time step.

Show worked solution

λ=340/1000=0.34\lambda = 340/1000 = 0.34 m. By the small-angle rule, ppw=2π10⋅0.36/(24⋅0.05)=2π3=10.88\text{ppw} = 2\pi\sqrt{10\cdot0.36/(24\cdot0.05)} = 2\pi\sqrt3 = 10.88 (the exact dispersion relation gives 10.9910.99). With 1111 points, h=0.0309h = 0.0309 m and Δt=νh/c=0.8×0.0309/340=7.3×10−5\Delta t = \nu h/c = 0.8\times0.0309/340 = 7.3\times10^{-5} s. In 3D the domain of 1010 wavelengths is 110110 cells across, about 1.31.3 million cells.

Computation

First the phase and group speed from the dispersion relation, and the points-per-wavelength rule built on them.

🧪 Coding exerciseExercise: numerical phase and group speed of leapfrog
⌘/Ctrl + Enter

Now run the packet through leapfrog yourself.

🐍 PythonLab: the late packet
⌘/Ctrl + Enter

Change the packet to 44 points per wavelength and compare the measured lag with the prediction. Then set ν=1.05\nu = 1.05 and watch the maximum of ∣u∣\lvert u\rvert.

Key Takeaways

  • Plane waves through leapfrog give sin⁡(ωΔt/2)=νsin⁡(kΔx/2)\sin(\omega\Delta t/2) = \nu\sin(k\Delta x/2): exactly ω=ck\omega = ck at ν=1\nu = 1, a grid dispersion otherwise.
  • ν≤1\nu \le 1 is both the von Neumann condition (∣G∣=1\lvert G\rvert = 1, nothing damped) and the dependence condition. At 1.051.05 the worst mode grows 1.8771.877 per step, about 105210^{52} in 190190 steps. CFL alone is necessary, not sufficient.
  • Short waves lag: vp/c≈1−(1−ν2)θ2/24v_p/c \approx 1 - (1-\nu^2)\theta^2/24, vg/c≈1−(1−ν2)θ2/8v_g/c \approx 1 - (1-\nu^2)\theta^2/8. At ν=0.5\nu = 0.5 and 88 points per wavelength a packet is 0.02950.0295 late over 0.50.5 (predicted 0.02940.0294).
  • Points per wavelength grow like D\sqrt D: 15.715.7 for 1010 wavelengths, 49.749.7 for 100100 (ν=0.5\nu = 0.5). A fourth-order stencil cuts the phase error from 1.6%1.6\% to 0.08%0.08\% at 1010 points but lowers the limit to 0.8660.866.
  • In 2D the 5-point scheme needs ν≤1/2\nu \le 1/\sqrt2 (1/31/\sqrt3 in 3D), and the wave speed depends on direction.
  • Dirichlet returns a pulse inverted and Neumann upright; the characteristic end condition leaves 0.00500.0050 at ν=0.5\nu = 0.5 and nothing at ν=1\nu = 1.
  • The staggered (p,u)(p, u) scheme has the same dispersion and limit, conserves a discrete energy to round-off, and avoids the collocated grid’s reversed group velocity.

What comes next

Grid-scale waves, the ones a grid represents worst, are where schemes go wrong: they lag, carry nothing at θ=π\theta = \pi, and blow up first past the limit. The next lesson, 10.9 Multigrid, uses the same decomposition by wavelength in a different way, and the mechanism is not the same as the one here. For the iterative solvers of 10.8 Elliptic Solvers: Jacobi, Gauss–Seidel & SOR, relaxation kills rough error quickly and leaves smooth error for many sweeps. Multigrid hands the smooth part to a coarser grid, where it is rough again, and recurses. I have not yet computed any of that, so I only claim the structure, not the numbers. Production flow solvers lean on it for the pressure solve (from memory).

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: