Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

5. Von Neumann stability, numerical dispersion and numerical diffusion

School of Engineering, Nazarbayev University

A common first reaction when an explicit time-stepping code blows up is: ‘Just cut Δt\Delta t by 10×10\times!’ Try that on explicit Forward-Time Central-Space (FTCS) pure advection ∂tϕ+u ∂xϕ=0\partial_t \phi + u\,\partial_x \phi = 0, and find that FTCS is unstable for every Δt>0\Delta t > 0, even at CFL=10−4\mathrm{CFL} = 10^{-4}, because its complex Fourier amplification factor has magnitude ∣G(θ)∣=1+CFL2sin⁡2θ>1|G(\theta)| = \sqrt{1 + \mathrm{CFL}^2\sin^2\theta} > 1. Yet add just enough physical viscosity (2rdiff≥CFL22r_{\mathrm{diff}} \geq \mathrm{CFL}^2), and FTCS suddenly becomes conditionally stable. In this lecture, we cover von Neumann Fourier analysis (von_neumann_advection_diffusion_amp), contrast amplitude dissipation vs. dispersive phase-speed errors across "ftcs", "upwind", "lax_friedrichs", and "lax_wendroff", and verify modified-equation truncation physics on live wave packets.

Learning objectives

  1. Derive and evaluate complex Fourier amplification factors G(θ)G(\theta) across dimensionless wavenumber θ=kΔx∈[0,π]\theta = k\Delta x \in [0, \pi] using von_neumann_advection_diffusion_amp.

  2. Prove why explicit FTCS pure advection is unconditionally unstable (∣G(π/2)∣=1+CFL2>1|G(\pi/2)| = \sqrt{1 + \mathrm{CFL}^2} > 1), yet stabilizes when physical diffusion satisfies CFL2≤2rdiff≤1\mathrm{CFL}^2 \leq 2 r_{\mathrm{diff}} \leq 1.

  3. Distinguish diffusive amplitude damping (∣G(θ)∣<1|G(\theta)| < 1 in "upwind" and "lax_friedrichs") from dispersive phase-velocity lag (trailing oscillations in "lax_wendroff").

  4. Verify modified-equation numerical viscosity Γmod=12uΔx(1−CFL)\Gamma_{\mathrm{mod}} = \frac{1}{2}u\Delta x(1 - \mathrm{CFL}) and show via np.fft.fft that G(θ)G(\theta) equals the exact single-step spectral multiplier.

Time: about 60 min

1. Discrete Fourier Modes & Exact vs. Numerical Amplification Factors

1.1 Von Neumann Normal-Mode Ansatz

On a periodic uniform grid xj=jΔxx_j = j\Delta x, any square-integrable error or wave profile decomposes into discrete Fourier modes ϕjn=ϕ^neikjΔx=ϕ^neijθ\phi_j^n = \hat{\phi}^n e^{i k j \Delta x} = \hat{\phi}^n e^{i j \theta}, where θ=kΔx∈[0,π]\theta = k\Delta x \in [0, \pi] is the dimensionless grid wavenumber (θ≪1\theta \ll 1 for well-resolved long waves; θ=π\theta = \pi for the shortest 2Δx2\Delta x Nyquist sawtooth (−1)j(-1)^j).

For linear advection–diffusion ∂tϕ+u ∂xϕ=Γ ∂xxϕ\partial_t\phi + u\,\partial_x\phi = \Gamma\,\partial_{xx}\phi with Courant number C=uΔt/Δx≥0C = u\Delta t/\Delta x \geq 0 and mesh Fourier number r=ΓΔt/Δx2≥0r = \Gamma\Delta t/\Delta x^2 \geq 0, one exact PDE step Δt\Delta t multiplies mode θ\theta by:

Gexact(θ)=e−rθ2 e−iCθ  ⟹  ∣Gexact(θ)∣=e−rθ2,Φexact(θ)=−Cθ(1.1)G_{\mathrm{exact}}(\theta) = e^{-r\theta^2}\,e^{-i C\theta} \implies |G_{\mathrm{exact}}(\theta)| = e^{-r\theta^2}, \quad \Phi_{\mathrm{exact}}(\theta) = -C\theta \tag{1.1}

A linear explicit finite-difference/FVM scheme multiplies ϕ^n\hat{\phi}^n by G(θ)G(\theta) (constants.von_neumann_advection_diffusion_amp), and is von Neumann stable if and only if ∣G(θ)∣≤1|G(\theta)| \leq 1 for all θ∈[0,π]\theta \in [0, \pi].


Demonstration 1: Amplification Factors at C = 0.6, r = 0 Across All 4 Schemes
=============================================================================
Scheme           |  |G(pi/4)| |  |G(pi/2)| |    |G(pi)| |    max |G| |  Stable?
------------------------------------------------------------------------------
ftcs             |    1.08628 |    1.16619 |    1.00000 |    1.16619 |    False
upwind           |    0.92704 |    0.72111 |    0.20000 |    1.00000 |     True
lax_friedrichs   |    0.82462 |    0.60000 |    1.00000 |    1.00000 |     True
lax_wendroff     |    0.99007 |    0.87727 |    0.28000 |    1.00000 |     True

What Demonstration 1 shows. At C=0.6,r=0C = 0.6, r = 0:

  • "ftcs" has ∣G(π/2)∣=1+0.62=1.16619>1|G(\pi/2)| = \sqrt{1 + 0.6^2} = 1.16619 > 1: every 4Δx4\Delta x wave grows by 16.6%16.6\% per time step (stable == False).

  • "upwind", "lax_friedrichs", and "lax_wendroff" all satisfy ∣G(θ)∣≤1|G(\theta)| \leq 1 (stable == True), though "lax_friedrichs" heavily damps mid-wavenumbers (∣G(π/2)∣=C=0.60|G(\pi/2)| = C = 0.60) while "lax_wendroff" preserves long/mid waves much closer to 1 (∣G(π/4)∣=0.990|G(\pi/4)| = 0.990).


2. Why Pure-Advection FTCS Always Explodes, and How Physical Diffusion Saves It

For explicit "ftcs", substituting (eiθ−e−iθ)/(2Δx)=isin⁡θ/Δx(e^{i\theta} - e^{-i\theta})/(2\Delta x) = i\sin\theta/\Delta x and (eiθ−2+e−iθ)/Δx2=−4sin⁡2(θ/2)/Δx2(e^{i\theta} - 2 + e^{-i\theta})/\Delta x^2 = -4\sin^2(\theta/2)/\Delta x^2 gives:

GFTCS(θ)=[1−4rsin⁡2(θ/2)]−iCsin⁡θ(2.1)G_{\mathrm{FTCS}}(\theta) = \left[1 - 4 r \sin^2(\theta/2)\right] - i C \sin\theta \tag{2.1}

Setting s=sin⁡2(θ/2)∈[0,1]s = \sin^2(\theta/2) \in [0, 1] yields an exact quadratic in ss:

∣GFTCS(θ)∣2=1+4s(C2−2r)+4s2(4r2−C2)(2.2)|G_{\mathrm{FTCS}}(\theta)|^2 = 1 + 4s\left(C^2 - 2r\right) + 4s^2\left(4r^2 - C^2\right) \tag{2.2}
  • When r=0r = 0 (pure advection), ∣G(θ)∣2=1+C2sin⁡2θ>1|G(\theta)|^2 = 1 + C^2\sin^2\theta > 1 for every C>0C > 0.

  • When r>0r > 0 (advection–diffusion), ∣G(θ)∣≤1|G(\theta)| \leq 1 for all s∈[0,1]s \in [0, 1] if and only if both slope at s=0s=0 and endpoint at s=1s=1 are bounded:

C2≤2rdiff  ⟺  CFL⋅∣PeΔx∣≤2,and0≤rdiff≤12(2.3)C^2 \leq 2 r_{\mathrm{diff}} \iff \mathrm{CFL}\cdot|\mathrm{Pe}_{\Delta x}| \leq 2, \qquad \text{and} \qquad 0 \leq r_{\mathrm{diff}} \leq \frac{1}{2} \tag{2.3}

Demonstration 2: Pure-Advection FTCS Instability & Peclet-Diffusion Stabilization
=================================================================================
Pure-advection FTCS at C = 1e-01, r = 0: max |G| = 1.0049875621 (= sqrt(1+C^2) = 1.0049875621) -> stable = False
Pure-advection FTCS at C = 1e-02, r = 0: max |G| = 1.0000499988 (= sqrt(1+C^2) = 1.0000499988) -> stable = False
Pure-advection FTCS at C = 1e-04, r = 0: max |G| = 1.0000000050 (= sqrt(1+C^2) = 1.0000000050) -> stable = False
FTCS at C = 0.40, r = 0.075 (2r - C^2 = -0.010): max |G| = 1.000363, stable = False
FTCS at C = 0.40, r = 0.080 (2r - C^2 = -0.000): max |G| = 1.000000, stable = True
FTCS at C = 0.40, r = 0.250 (2r - C^2 = +0.340): max |G| = 1.000000, stable = True
FTCS at C = 0.40, r = 0.500 (2r - C^2 = +0.840): max |G| = 1.000000, stable = True
FTCS at C = 0.40, r = 0.510 (2r - C^2 = +0.860): max |G| = 1.040000, stable = False
<Figure size 704x462 with 1 Axes>

Figure 5.1. Stability region of the forward-time, centered-space scheme for advection with diffusion (shaded), found by evaluating the amplification factor on a grid of Courant and diffusion numbers. It lies between the parabola r=C2/2r = C^2/2 and the line r=1/2r = 1/2.

What Demonstration 2 shows. The output follows Equation (2.3): for C=0.4C = 0.4, FTCS flips from unstable (r = 0.075) to strictly stable at the exact parabola r∗=C2/2=0.080r^* = C^2 / 2 = 0.080, stays stable up to r=0.500r = 0.500, and then goes unstable again at r=0.510r = 0.510 due to Nyquist diffusion overshoot at θ=π\theta = \pi.


3. Amplitude Dissipation vs. Dispersive Phase-Speed Lag

Stability (∣G∣≤1|G| \leq 1) only prevents blowup, accuracy requires both ∣G(θ)∣≈∣Gexact(θ)∣|G(\theta)| \approx |G_{\mathrm{exact}}(\theta)| (low numerical dissipation) and numerical phase Φ(θ)=arg⁡G(θ)≈−Cθ\Phi(\theta) = \arg G(\theta) \approx -C\theta (low numerical dispersion, i.e., relative wave speed cnum/u=−Φ(θ)/(Cθ)≈1c_{\mathrm{num}}/u = -\Phi(\theta)/(C\theta) \approx 1). We plot ∣G(θ)∣|G(\theta)| and cnum(θ)/uc_{\mathrm{num}}(\theta)/u across θ∈(0,π]\theta \in (0, \pi] at C=0.5,r=0C = 0.5, r = 0.


Demonstration 3: Polar/Spectral Portrait of Dissipation |G(theta)| & Relative Phase Speed
=========================================================================================
<Figure size 1254x473 with 2 Axes>
At C = 0.5: Upwind max phase error across (0, pi) = 1.38e-14 rad
Lax-Wendroff at theta = pi/2, C = 0.5: relative speed = 0.7487 (< 1 => phase lag)

Figure 5.2. Von Neumann analysis of pure advection at Courant number 0.5. (a) Magnitude of the amplification factor against the wavenumber for four schemes; the exact value is 1. (b) Numerical phase speed relative to the exact one.

What Demonstration 3 shows. Two points:

  1. Why Lax–Wendroff grows trailing wiggles behind shocks: Its amplitude ∣G∣|G| stays near 1, so short waves survive, but its relative phase speed −Φ/(Cθ)-\Phi/(C\theta) drops steeply below 1 at high θ\theta, causing short-wavelength Fourier components to lag behind the main front.

  2. Exact symmetry of Upwind at C=0.5C = 0.5: Because Gup(θ;0.5)=cos⁡(θ/2) e−iθ/2G_{\mathrm{up}}(\theta; 0.5) = \cos(\theta/2)\,e^{-i\theta/2}, first-order upwind has identically zero phase dispersion at C=0.5C = 0.5, suffering purely from amplitude damping cos⁡(θ/2)\cos(\theta/2).


4. Modified-Equation Truncation Analysis & Live Wave-Packet Propagation

Expanding ϕjn+1\phi_j^{n+1} and ϕj−1n\phi_{j-1}^n in Taylor series around (xj,tn)(x_j, t^n) and replacing ∂ttϕ=u2∂xxϕ+…\partial_{tt}\phi = u^2\partial_{xx}\phi + \dots shows what PDE first-order upwind actually solves:

∂ϕ∂t+u∂ϕ∂x=uΔx2(1−C)⏟Γmod∂2ϕ∂x2+O(Δx2)(4.1)\frac{\partial \phi}{\partial t} + u\frac{\partial \phi}{\partial x} = \underbrace{\frac{u\Delta x}{2}(1 - C)}_{\Gamma_{\mathrm{mod}}}\frac{\partial^2 \phi}{\partial x^2} + O(\Delta x^2) \tag{4.1}

We propagate a Gaussian pulse ϕ(x,0)=exp⁡ ⁣(−(x−0.3)2/σ02)\phi(x, 0) = \exp\!\left(-(x - 0.3)^2 / \sigma_0^2\right) for one full periodic revolution on [0,1)[0, 1) (N=160,u=1,C=0.5  ⟹  320N = 160, u = 1, C = 0.5 \implies 320 steps) and verify that "upwind" peak decay matches exact diffusive spreading σ(T)=σ02+4ΓmodT\sigma(T) = \sqrt{\sigma_0^2 + 4\Gamma_{\mathrm{mod}} T}.


Demonstration 4: Periodic Gaussian Wave-Packet Evolution & Modified-Equation Peak Verification
==============================================================================================
Initial Gaussian peak = 1.0000 | Exact T=1.0 peak = 1.0000
Upwind peak after 1 period       = 0.6044 vs Modified-Eq prediction = 0.6046
Lax-Wendroff peak after 1 period = 0.9814 (2nd-order preservation)

Inside the algorithm

We check in NumPy that constants.von_neumann_advection_diffusion_amp is the eigenvalue, in the discrete Fourier basis (np.fft.fft), of one explicit time step applied to an arbitrary random vector on a periodic mesh.

Check against the library


Inside the Algorithm: G(theta) == Exact FFT Single-Step Multiplier Across All 4 Schemes
=======================================================================================
def von_neumann_advection_diffusion_amp(
    theta_rad: float | np.ndarray,
    cfl: float,
    r_diff: float = 0.0,
    scheme: str = "upwind",
) -> dict:
    """Evaluate complex von Neumann amplification factor G(theta) for explicit 1-D advection-diffusion schemes."""
    th = np.asarray(theta_rad, dtype=float)
    key = scheme.strip().lower()
    visc = 2.0 * r_diff * (np.cos(th) - 1.0)
    if key == "upwind":
        g_val = 1.0 - cfl * (1.0 - np.cos(th)) + visc - 1j * cfl * np.sin(th)
    elif key == "ftcs":
        g_val = 1.0 + visc - 1j * cfl * np.sin(th)
    elif key == "lax_wendroff":
        g_val = 1.0 - (cfl**2) * (1.0 - np.cos(th)) + visc - 1j * cfl * np.sin(th)
    elif key == "lax_friedrichs":
        g_val = np.cos(th) + visc - 1j * cfl * np.sin(th)
    else:
        raise ValueError(f"Unsupported von Neumann scheme: {scheme!r}.")

    mag = np.abs(g_val)
    exact_phase = -cfl * th
    num_phase = np.angle(g_val)
    if np.ndim(theta_rad) == 0:
        return {
            "G": complex(g_val),
            "magnitude": float(mag),
            "phase_rad": float(num_phase),
            "exact_phase_rad": float(exact_phase),
            "stable": bool(mag <= 1.0 + 1e-12),
        }
    return {
        "G": g_val,
        "magnitude": mag,
        "phase_rad": num_phase,
        "exact_phase_rad": exact_phase,
        "stable": bool(np.all(mag <= 1.0 + 1e-12)),
    }

Scheme upwind         : max |FFT(u^1)/FFT(u^0) - G_lib(theta)| = 1.04e-15
Scheme ftcs           : max |FFT(u^1)/FFT(u^0) - G_lib(theta)| = 1.54e-15
Scheme lax_wendroff   : max |FFT(u^1)/FFT(u^0) - G_lib(theta)| = 6.66e-16
Scheme lax_friedrichs : max |FFT(u^1)/FFT(u^0) - G_lib(theta)| = 1.79e-15

Exercises

Worked solutions are in 05_solutions.ipynb. The cell below the list is a short self-check to start from.

  1. Verify a result. Verify that at C=1.0,r=0C = 1.0, r = 0, "upwind", "lax_wendroff", and "lax_friedrichs" all satisfy G(θ)=e−iθG(\theta) = e^{-i\theta} across θ∈[0,π]\theta \in [0, \pi], and confirm ∣GLW(θ)∣2=1−4C2(1−C2)sin⁡4(θ/2)|G_{\mathrm{LW}}(\theta)|^2 = 1 - 4 C^2(1 - C^2)\sin^4(\theta/2) to <10−14< 10^{-14} for C∈{0.35,0.70}C \in \{0.35, 0.70\}.

  2. Find how it fails. Quantify over one periodic transit (Nx=100N_x = 100 cells, Nt=Nx/CN_t = N_x / C steps, r=0r = 0) both (a) total mode amplification ∣G(π/2)∣Nt|G(\pi/2)|^{N_t} in "ftcs" at C∈{0.5,0.1,0.02}C \in \{0.5, 0.1, 0.02\}, and (b) the damping ∣G(π/8)∣Nt|G(\pi/8)|^{N_t} of a 16-cell wave in "lax_friedrichs" when Δt\Delta t is shrunk from C=0.9C = 0.9 down to C=0.02C = 0.02. Verify ValueError on unknown scheme names.

  3. Implement it yourself. Implement ftcs_advection_diffusion_limits(pe_cell) returning exact (Cmax⁡,rmax⁡)(C_{\max}, r_{\max}) for explicit 1-D "ftcs" given ∣PeΔx∣=C/r>0|\mathrm{Pe}_{\Delta x}| = C / r > 0, and verify across ∣PeΔx∣∈{0.5,1.0,2.0,5.0,10.0}|\mathrm{Pe}_{\Delta x}| \in \{0.5, 1.0, 2.0, 5.0, 10.0\} that 0.99 (Cmax⁡,rmax⁡)0.99\,(C_{\max}, r_{\max}) is stable == True while 1.02 (Cmax⁡,rmax⁡)1.02\,(C_{\max}, r_{\max}) is stable == False.


Self-check for the exercises
============================
Unit-CFL shift identity and 4th-order Lax-Wendroff modulus verified