go-shallow-water-well-balanced-roe-dry-bed
Done. The verified solution is at ~/solution.md (working code in ~/swe/).
A 1-D finite-volume SWE solver that meets all the stated requirements:
| Requirement | Implementation |
|---|---|
| Hydrostatic reconstruction | b* = max(b_L,b_R), h* = max(0, η − b*), HLL on the reduced states |
| Riemann solver | HLL with Einfeldt/Roe wave speeds, dry-state safe |
| 2nd-order MUSCL | MC TVD limiter on water surface η and momentum hu |
| Well-balanced source | Audusse source with the correct sign: g/2[(h*₊)²−(h⁻)²] + g/2[(h⁺)²−(h*₋)²] |
| Positivity | slope limit |σ_η| ≤ 2h/Δx, first-order fallback at dry faces, adaptive Δt backtracking (mass-conservative, no state clamping) |
| Time integration | SSP-RK2 |
The classic failure is the bed-source sign. When the momentum flux uses the reduced depth h*, the pressure g/2 h_cell² must be restored on the cell. The commonly copied g/2(h_cell² − h*²) double-counts and does not cancel the flux divergence — the correct terms are g/2(h*² − h_cell²) on the right face and g/2(h_cell² − h*²) on the left. Combined with reconstructing η (not h), lake-at-rest becomes bit-exact.
max|η−η₀| ≈ 3e-16, dMass, dMom ≈ 1e-15 → exactly well-balanced.~2e-15.hL=1, hR=0.1, t=2): L1: 1.16e-1 → 1.31e-2 under refinement, dMass ≤ 2.7e-13, and |dMom − ½g(h_L²−h_R²)t| ≤ 5e-14.min h > 0 at every resolution.~1.65–1.77 (2nd-order MUSCL reduced at limiter extrema), as expected for a TVD limiter.The markdown is fully self-contained: complete main.go/run.go/go.mod, build commands, the derivation of the sign fix, and the raw verification output with interpretation.
# Evidence - Problem class: go-shallow-water-well-balanced-roe-dry-bed - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-18T17:05:40.708Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement a 1-D finite-volume solver for the shallow water equations over non-uniform bed topography using hydrostatic reconstruction with a Roe (or HLL) approximate Riemann solver and second-order MUSCL reconstruction with a TVD slope limiter. The scheme must preserve lake-at-rest steady states to machine precision on arbitrary bed profiles, keep depth non-negative across wet/dry fronts near Froude number 1, and accurately resolve the Stoker dam-break solution including rarefaction, contact discontinuity and shock. Report L1/L2 error against the analytic solution and the maximum drift in total mass and momentum over the run.", "environment": "go1.26", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-shallow-water-well-balanced-roe-dry-bed", "provider": "openrouter", "solved_at": "2026-09-18T17:05:40.708Z", "version": "1.26"}Done. The verified solution is at ~/solution.md (working code in ~/swe/).
A 1-D finite-volume SWE solver that meets all the stated requirements:
| Requirement | Implementation |
|---|---|
| Hydrostatic reconstruction | b* = max(b_L,b_R), h* = max(0, η − b*), HLL on the reduced states |
| Riemann solver | HLL with Einfeldt/Roe wave speeds, dry-state safe |
| 2nd-order MUSCL | MC TVD limiter on water surface η and momentum hu |
| Well-balanced source | Audusse source with the correct sign: g/2[(h*₊)²−(h⁻)²] + g/2[(h⁺)²−(h*₋)²] |
| Positivity | slope limit |σ_η| ≤ 2h/Δx, first-order fallback at dry faces, adaptive Δt backtracking (mass-conservative, no state clamping) |
| Time integration | SSP-RK2 |
The classic failure is the bed-source sign. When the momentum flux uses the reduced depth h*, the pressure g/2 h_cell² must be restored on the cell. The commonly copied g/2(h_cell² − h*²) double-counts and does not cancel the flux divergence — the correct terms are g/2(h*² − h_cell²) on the right face and g/2(h_cell² − h*²) on the left. Combined with reconstructing η (not h), lake-at-rest becomes bit-exact.
max|η−η₀| ≈ 3e-16, dMass, dMom ≈ 1e-15 → exactly well-balanced.~2e-15.hL=1, hR=0.1, t=2): L1: 1.16e-1 → 1.31e-2 under refinement, dMass ≤ 2.7e-13, and |dMom − ½g(h_L²−h_R²)t| ≤ 5e-14.min h > 0 at every resolution.~1.65–1.77 (2nd-order MUSCL reduced at limiter extrema), as expected for a TVD limiter.The markdown is fully self-contained: complete main.go/run.go/go.mod, build commands, the derivation of the sign fix, and the raw verification output with interpretation.
# Evidence - Problem class: go-shallow-water-well-balanced-roe-dry-bed - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-18T17:05:40.708Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement a 1-D finite-volume solver for the shallow water equations over non-uniform bed topography using hydrostatic reconstruction with a Roe (or HLL) approximate Riemann solver and second-order MUSCL reconstruction with a TVD slope limiter. The scheme must preserve lake-at-rest steady states to machine precision on arbitrary bed profiles, keep depth non-negative across wet/dry fronts near Froude number 1, and accurately resolve the Stoker dam-break solution including rarefaction, contact discontinuity and shock. Report L1/L2 error against the analytic solution and the maximum drift in total mass and momentum over the run.", "environment": "go1.26", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-shallow-water-well-balanced-roe-dry-bed", "provider": "openrouter", "solved_at": "2026-09-18T17:05:40.708Z", "version": "1.26"}