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 · 9. Shallow-water equations, the HLL flux and the dam-break problem

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 9. 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. Find the critical tailwater ratio (hR/hL)crit(h_R / h_L)_{\mathrm{crit}} where Fr∗=u∗/gh∗=1\mathrm{Fr}^* = u^* / \sqrt{g h^*} = 1 using exact_dam_break_dry_or_wet, and check numerically across hR/hL∈{0.01,0.05,0.10}h_R / h_L \in \{0.01, 0.05, 0.10\} that depth and Froude number at x=xdamx = x_{\mathrm{dam}} lock onto h=49hLh = \frac{4}{9}h_L and Fr=1.0\mathrm{Fr} = 1.0.


Exercise 1: Critical Tailwater Ratio (Fr* == 1) & Sonic Choking at the Dam Site
===============================================================================
Critical tailwater ratio (h_R / h_L)_crit = 0.138270
h_R/h_L = 0.01 < r_crit | h(x_dam) = 1.20000 vs (4/9)*h_L = 1.20000 | Fr(x_dam) = 1.00000
h_R/h_L = 0.05 < r_crit | h(x_dam) = 1.20000 vs (4/9)*h_L = 1.20000 | Fr(x_dam) = 1.00000
h_R/h_L = 0.10 < r_crit | h(x_dam) = 1.20000 vs (4/9)*h_L = 1.20000 | Fr(x_dam) = 1.00000

Explanation. Inside the centered rarefaction fan, ξ=(x−xdam)/t=u−c\xi = (x - x_{\mathrm{dam}})/t = u - c and u+2c=2cLu + 2c = 2c_L. At the dam location ξ=0\xi = 0, u=c  ⟹  Fr=1u = c \implies \mathrm{Fr} = 1 and 3c=2cL  ⟹  c=23cL  ⟹  h(xdam,t)=49hL3c = 2c_L \implies c = \frac{2}{3}c_L \implies h(x_{\mathrm{dam}}, t) = \frac{4}{9}h_L. Whenever hR/hL<0.13827h_R / h_L < 0.13827, the rarefaction tail ξtail=u∗−c∗>0\xi_{\mathrm{tail}} = u^* - c^* > 0 lies downstream of ξ=0\xi = 0, so downstream tailwater depth can no longer signal upstream past the critical section at xdamx_{\mathrm{dam}}; this is the shallow-water analogue of a choked nozzle.


Exercise 2

Problem. Verify exact_dam_break_dry_or_wet raises ValueError for invalid inputs (hL≤hRh_L \leq h_R, hR≤0h_R \leq 0, t≤0t \leq 0), and show that centered forward-Euler fluxes without HLL wave-speed viscosity produce severe TV blow-up / non-physical depths on the dam break.


Exercise 2: input guards & Unconditional FTCS Shallow-Water Instability
=======================================================================
Centered FTCS after <=80 steps: initial TV(h) = 1.50 -> TV(h) = 4.73, min(h) = -0.059

Explanation. For any hyperbolic system with real eigenvalues λk\lambda_k, forward-Euler centered differencing has amplification eigenvalues Gk(θ)=1−i CFLksin⁡θG_k(\theta) = 1 - i\,\mathrm{CFL}_k \sin\theta, giving ∣Gk(θ)∣=1+CFLk2sin⁡2θ>1|G_k(\theta)| = \sqrt{1 + \mathrm{CFL}_k^2 \sin^2\theta} > 1 for all θ∉{0,π}\theta \notin \{0, \pi\}. HLL’s term SLSRSR−SL(qR−qL)\frac{S_L S_R}{S_R - S_L}(\mathbf{q}_R - \mathbf{q}_L) (with SL<0<SRS_L < 0 < S_R, so SLSR<0S_L S_R < 0) supplies the exact upwind signal-cone numerical viscosity required to keep ∣Gk(θ)∣≤1|G_k(\theta)| \leq 1 and hin>0h_i^n > 0.


Exercise 3

Problem. Implement shallow_water_1d_muscl_hll(h_init, hu_init, L, dt, n_steps, g) using minmod piecewise-linear interface reconstruction, HLL Riemann fluxes, and SSP-RK2 time stepping. Benchmark at N=200N = 200 against 1st-order shallow_water_1d_hll on the Stoker dam break (hL=2.0,hR=0.5,t=0.6h_L = 2.0, h_R = 0.5, t = 0.6), asserting exact volume conservation and lower L1L_1 depth and velocity errors.


Exercise 3: Implement It Yourself — 2nd-Order MUSCL-HLL Shallow-Water Solver
============================================================================
1st-Order HLL   (N=200): L1(h) = 1.5246e-02 m | L1(u) = 4.4340e-02 m/s
2nd-Order MUSCL (N=200): L1(h) = 5.3892e-03 m | L1(u) = 1.6619e-02 m/s | Vol drift = 3.55e-16

Summary. Upgrading shallow_water_1d_hll with minmod MUSCL reconstruction and SSP-RK2 cuts dam-break L1L_1 depth and velocity errors by >40%> 40\% at N=200N = 200, sharpening both the rarefaction corners and the advancing hydraulic bore without introducing spurious ripples.