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 · 7. Advection in two dimensions by Strang splitting, with diffusion and reaction

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 7. 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 fvm_convection_diffusion_2d_steady (u=v=0u=v=0, Γ=0.08\Gamma = 0.08, k=2.5k = 2.5, homogeneous Dirichlet walls on [0,1]2[0, 1]^2) against the exact eigenfunction ϕexact(x,y)=sin⁡(πx)sin⁡(πy)2π2Γ+k\phi_{\mathrm{exact}}(x, y) = \frac{\sin(\pi x)\sin(\pi y)}{2\pi^2 \Gamma + k} across N∈{16,32,64}N \in \{16, 32, 64\}, asserting O(h2)O(h^2) error convergence.


Exercise 1: Exact 2-D Reaction-Diffusion Eigenmode & O(h^2) Mesh Convergence
============================================================================
Grid 16x16 | SOR iters =  120 | max |phi - phi_exact| = 3.0196e-04
Grid 32x32 | SOR iters =  420 | max |phi - phi_exact| = 7.6041e-05
Grid 64x64 | SOR iters = 1580 | max |phi - phi_exact| = 1.9045e-05
Observed convergence orders: 1.990 (16->32), 1.997 (32->64)

Explanation. Applying −Γ(∂xx+∂yy)+k-\Gamma(\partial_{xx} + \partial_{yy}) + k to sin⁡(πx)sin⁡(πy)\sin(\pi x)\sin(\pi y) multiplies the eigenmode by the positive Helmholtz eigenvalue 2π2Γ+k2\pi^2 \Gamma + k. Our FVM enforces Dirichlet walls via linear half-cell extrapolation (Db=2Γ/ΔxD_b = 2\Gamma/\Delta x), which matches the interior 5-point central Laplacian to O(h2)O(h^2) across the entire domain.


Exercise 2

Problem. Demonstrate cell-Péclet breakdown of scheme='central' at PeΔx=5.0>2\mathrm{Pe}_{\Delta x} = 5.0 > 2: show direct-solve unphysical undershoots in fvm_convection_diffusion_1d (bounded_no_overshoot == False) and iterative SOR divergence in fvm_convection_diffusion_2d_steady(..., max_iter=80), while power_law and exponential converge monotonically in [0,1][0, 1].


Exercise 2: Central Differencing Breakdown at Cell Peclet = 5 > 2
=================================================================
1-D Pe_cell = 5.0 | Central min(phi) = -0.1111 (bounded=False) | PowerLaw min(phi) = +0.0000
2-D Central SOR residual: iter 1 = 4.49e-03 -> iter 80 = 4.75e+36 (diverged)
2-D Power-Law SOR residual: iter 20 = 9.45e-13, range = [-0.0000, 0.0867]

Explanation. In central differencing, A(∣PeΔ∣)=1−12∣PeΔ∣A(|\mathrm{Pe}_{\Delta}|) = 1 - \frac{1}{2}|\mathrm{Pe}_{\Delta}| turns negative for ∣PeΔ∣>2|\mathrm{Pe}_{\Delta}| > 2. Consequently, aE<0a_E < 0 while aP=aW+aE=(D+F/2)+(D−F/2)=2Da_P = a_W + a_E = (D + F/2) + (D - F/2) = 2D, so ∣aW∣+∣aE∣=F>2D=∣aP∣|a_W| + |a_E| = F > 2D = |a_P|. Violating Scarborough’s diagonal-dominance condition ∣aP∣≥∑∣anb∣|a_P| \geq \sum |a_{nb}| destroys the M-matrix property, producing alternating-sign spatial oscillations in direct solvers and unstable spectral radius ρ(GSOR)>1\rho(\mathbf{G}_{\mathrm{SOR}}) > 1 in iterative solvers.


Exercise 3

Problem. Implement advect_2d_swirl_reversible(q_init, dx, dy, T, n_steps, limiter) using midpoint-evaluated Strang splitting for u(y,t)=sin⁡(2πy)cos⁡(πt/T)u(y, t) = \sin(2\pi y)\cos(\pi t / T) and v(x,t)=sin⁡(2πx)cos⁡(πt/T)v(x, t) = \sin(2\pi x)\cos(\pi t / T) on [0,1)2[0, 1)^2. Verify strong filament deformation at t=T/2t = T/2 and compare t=Tt = T unmixing error across upwind, van_leer, and superbee.


Exercise 3: Implement It Yourself — 2-D Time-Reversible Swirling Shear Deformation
==================================================================================
Mid-cycle filament deformation ||q(T/2) - q(0)||_2 = 0.1622
Full-cycle recovery L2 error: Upwind = 0.0738 vs van Leer = 0.0207 vs Superbee = 0.0109

Summary. LeVeque’s time-reversible swirling flow is a benchmark for front-tracking and VOF/level-set interface transport: even after severe shear stretching at t=T/2t = T/2, midpoint-evaluated Strang TVD splitting recovers the original circular patch with >3×>3\times smaller L2L_2 error than upwind while conserving tracer mass to <10−15< 10^{-15}.