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.

Solutions · 5. Von Neumann stability, numerical dispersion and numerical diffusion

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 5. Each solution is computed here and checked with assert statements against an exact identity or an independent calculation. The first code cell sets up the notebook and runs Demonstration 1 of the lecture without showing its output, because some of the solutions use its variables.

Exercise 1

Problem. 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\}.


Exercise 1: Exact Unit-Courant Shift Property & Lax-Wendroff Fourth-Order Modulus
=================================================================================
C = 1.0 (upwind        ): max |G(theta) - exp(-i*theta)| = 1.11e-16
C = 1.0 (lax_wendroff  ): max |G(theta) - exp(-i*theta)| = 1.11e-16
C = 1.0 (lax_friedrichs): max |G(theta) - exp(-i*theta)| = 0.00e+00
Lax-Wendroff C = 0.35: max ||G|^2 - [1 - 4C^2(1-C^2)sin^4(theta/2)]| = 4.44e-16
Lax-Wendroff C = 0.70: max ||G|^2 - [1 - 4C^2(1-C^2)sin^4(theta/2)]| = 3.61e-16

Explanation. At C=uΔt/Δx=1C = u\Delta t/\Delta x = 1, characteristics starting at grid point xj−1x_{j-1} land exactly on grid point xjx_j one step later (ϕjn+1=ϕj−1n\phi_j^{n+1} = \phi_{j-1}^n), eliminating spatial interpolation error across all three stable stencils. For 0<C<10 < C < 1, ∣GLW∣=1−18C2(1−C2)θ4+O(θ6)|G_{\mathrm{LW}}| = 1 - \frac{1}{8}C^2(1-C^2)\theta^4 + O(\theta^6) is fourth-order weakly dissipative.


Exercise 2

Problem. 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.


Exercise 2: Tiny-dt Pathologies in FTCS & Lax-Friedrichs
========================================================
C = 0.50 (Nt =  200 steps/period) | FTCS |G(pi/2)|^Nt =   4.909e+09 (>1) | Lax-Friedrichs |G(pi/8)|^Nt =   8.852e-06
C = 0.10 (Nt = 1000 steps/period) | FTCS |G(pi/2)|^Nt =   1.448e+02 (>1) | Lax-Friedrichs |G(pi/8)|^Nt =   9.718e-35
C = 0.02 (Nt = 5000 steps/period) | FTCS |G(pi/2)|^Nt =   2.718e+00 (>1) | Lax-Friedrichs |G(pi/8)|^Nt =  1.417e-172

Explanation. Because Lax–Friedrichs replaces ϕjn\phi_j^n with the neighbor average 12(ϕj+1n+ϕj−1n)\frac{1}{2}(\phi_{j+1}^n + \phi_{j-1}^n) every step regardless of how small Δt\Delta t is, its modified viscosity ΓLF=Δx22Δt(1−C2)\Gamma_{\mathrm{LF}} = \frac{\Delta x^2}{2\Delta t}(1 - C^2) scales inversely with Δt\Delta t. Taking 5000 small steps (C=0.02C = 0.02) damps even a smooth 16-cell wave by 10-173.


Exercise 3

Problem. 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.


Exercise 3: Implement It Yourself — Exact FTCS Advection-Diffusion Stability Boundary
=====================================================================================
|Pe_dx| =  0.5 -> C_max = 0.2500, r_max = 0.5000 | 0.99*limit stable=True | 1.02*limit stable=False
|Pe_dx| =  1.0 -> C_max = 0.5000, r_max = 0.5000 | 0.99*limit stable=True | 1.02*limit stable=False
|Pe_dx| =  2.0 -> C_max = 1.0000, r_max = 0.5000 | 0.99*limit stable=True | 1.02*limit stable=False
|Pe_dx| =  5.0 -> C_max = 0.4000, r_max = 0.0800 | 0.99*limit stable=True | 1.02*limit stable=False
|Pe_dx| = 10.0 -> C_max = 0.2000, r_max = 0.0200 | 0.99*limit stable=True | 1.02*limit stable=False

Summary. Explicit FTCS advection–diffusion achieves its maximum allowable Courant number Cmax⁡=1.0C_{\max} = 1.0 at the cell Péclet number ∣PeΔx∣=2|\mathrm{Pe}_{\Delta x}| = 2 (rmax⁡=0.5r_{\max} = 0.5, where FTCS algebraically simplifies to exact upwind shifting ϕjn+1=ϕj−1n\phi_j^{n+1} = \phi_{j-1}^n), and shrinks as Cmax⁡=2/∣PeΔx∣C_{\max} = 2/|\mathrm{Pe}_{\Delta x}| at higher Péclet numbers.