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 · 8. The Burgers equation, the Cole–Hopf solution and shock speeds

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 8. 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. Perform a grid-refinement study (N∈{64,128,256,512}N \in \{64, 128, 256, 512\}) for solve_viscous_burgers_1d(..., flux='godunov', periodic=True) against cole_hopf_viscous_burgers_exact (ν=0.20,a0=1.25,t=0.6\nu = 0.20, a_0 = 1.25, t = 0.6), asserting first-order O(Δx)O(\Delta x) convergence and exact impulse conservation.


Exercise 1: Mesh Convergence of Godunov Viscous Burgers Against Exact Cole-Hopf
===============================================================================
N =  64 | steps =    63 | L2 error = 3.4048e-03 | impulse drift = 9.81e-17
N = 128 | steps =   250 | L2 error = 1.7720e-03 | impulse drift = 2.96e-16
N = 256 | steps =   997 | L2 error = 9.0130e-04 | impulse drift = 5.23e-16
N = 512 | steps =  3985 | L2 error = 4.5421e-04 | impulse drift = 3.49e-16
Observed spatial order (256 -> 512): 0.989

Explanation. Although centered viscous differencing (ui+1−2ui+ui−1)/Δx2(u_{i+1} - 2u_i + u_{i-1})/\Delta x^2 and SSP-RK2 time integration are both second-order accurate, piecewise-constant cell reconstruction in 1st-order Godunov introduces O(Δx)O(\Delta x) numerical viscosity 12∣u∣Δx uxx\frac{1}{2}|u|\Delta x\,u_{xx} that dominates truncation error as Δx→0\Delta x \to 0, motivating the 2nd-order MUSCL reconstruction in Exercise 3.


Exercise 2

Problem. Verify cole_hopf_viscous_burgers_exact input guards (ν≤0\nu \leq 0, a0≤1.0a_0 \leq 1.0) and demonstrate that unfixed Roe flux FRoe(uL,uR)=14(uL2+uR2)−12∣uL+uR2∣(uR−uL)F_{\mathrm{Roe}}(u_L, u_R) = \frac{1}{4}(u_L^2 + u_R^2) - \frac{1}{2}|\frac{u_L+u_R}{2}|(u_R - u_L) produces an unphysical stationary expansion shock on uL=−1,uR=+1u_L = -1, u_R = +1 while _burgers_godunov_flux resolves the exact rarefaction fan.


Exercise 2: Unfixed Roe Sonic Expansion Shock vs Entropy-Satisfying Godunov
===========================================================================
Unfixed Roe L1 error = 0.2000 (frozen step jump = 2.00)
Godunov     L1 error = 0.0185 (center jump = 0.0952)

Explanation. u_roe remains bit-for-bit frozen at the discontinuous step u0(x)u_0(x). At the center interface (uL=−1,uR=+1)(u_L = -1, u_R = +1), Roe’s linearized wave speed is aˉ=12(−1+1)=0\bar{a} = \frac{1}{2}(-1 + 1) = 0, so ∣aˉ∣(uR−uL)=0|\bar{a}|(u_R - u_L) = 0 and FRoe(−1,+1)=14(1+1)=0.5F_{\mathrm{Roe}}(-1, +1) = \frac{1}{4}(1 + 1) = 0.5, matching f(±1)=0.5f(\pm 1) = 0.5 on all other faces so Fi+1/2−Fi−1/2≡0F_{i+1/2} - F_{i-1/2} \equiv 0. Although s=0s = 0 satisfies Rankine–Hugoniot algebraically, it violates Lax’s entropy inequality f′(uL)>s>f′(uR)f'(u_L) > s > f'(u_R) (−1≯0≯+1-1 \ngtr 0 \ngtr +1), showing why Roe solvers require a Harten–Hyman sonic entropy fix whereas Godunov satisfies all entropy inequalities automatically.


Exercise 3

Problem. Implement solve_muscl_viscous_burgers_1d(u_init, L, nu, dt, n_steps) using periodic minmod slope reconstruction, _burgers_godunov_flux, centered viscous diffusion, and SSP-RK2. Verify O(Δx2)O(\Delta x^2) convergence on cole_hopf_viscous_burgers_exact (ν=0.12,a0=1.20,t=0.5\nu = 0.12, a_0 = 1.20, t = 0.5) and assert >8×> 8\times lower L2L_2 error than 1st-order solve_viscous_burgers_1d at N=256N = 256.


Exercise 3: Implement It Yourself — 2nd-Order MUSCL-Godunov Viscous Burgers Solver
==================================================================================
N =  64 | 1st-Order Godunov L2 = 2.046e-03 | 2nd-Order MUSCL L2 = 4.809e-04 | Speedup ratio =   4.26x
N = 128 | 1st-Order Godunov L2 = 1.067e-03 | 2nd-Order MUSCL L2 = 1.324e-04 | Speedup ratio =   8.06x
N = 256 | 1st-Order Godunov L2 = 5.433e-04 | 2nd-Order MUSCL L2 = 3.466e-05 | Speedup ratio =  15.68x
Observed MUSCL convergence rate (128 -> 256): 1.933

Summary. Reconstructing piecewise-linear interface states ui+1/2−=ui+12σiu_{i+1/2}^- = u_i + \frac{1}{2}\sigma_i, ui+1/2+=ui+1−12σi+1u_{i+1/2}^+ = u_{i+1} - \frac{1}{2}\sigma_{i+1} with minmod slope limiting eliminates the O(Δx)O(\Delta x) leading artificial viscosity of piecewise-constant Godunov, boosting spatial convergence to O(Δx2)O(\Delta x^2) and cutting error by more than an order of magnitude at N=256N = 256.