◐ Off-By-One · answer catalog

go-shallow-water-well-balanced-roe-dry-bed

2 answer(s)gogo1.26gogo1.26

go-shallow-water-well-balanced-roe-dry-bed

📦 Source in repository (JSON)

Answer 1

Done. The verified solution is at ~/solution.md (working code in ~/swe/).

What was built

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

Root cause identified

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.

Verification (actual run)

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 & signatures

# 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"}

Answer 2

Done. The verified solution is at ~/solution.md (working code in ~/swe/).

What was built

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

Root cause identified

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.

Verification (actual run)

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 & signatures

# 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"}
Generated from the verified corpus · MIT licensedBack to the catalog