Skip to content

ECRIPPEL/culvert-solver

Repository files navigation

Culvert Solver

DOI

An open-source dynamic wave solver for culvert hydraulic analysis. Solves the 1D Saint-Venant equations using explicit finite-difference schemes with Preissmann slot for pressurized flow transition.

Suitable for standard culverts (single slope) and broken-back culverts (multi-slope configurations common in steep terrain crossings).

GUI - Longitudinal Profile Real-time simulation of a broken-back culvert with road embankment fill, HGL profiles for multiple return-period storms.

About

Culvert hydraulic analysis typically relies on steady-state methods (inlet/outlet control charts) or proprietary software with limited transparency. This solver provides a free, open-source alternative that captures the full unsteady dynamics — pressure surges, flow regime transitions, overtopping, and attenuation — using the same Saint-Venant equations underlying HEC-RAS and SWMM.

The solver handles both conventional single-slope culverts and broken-back configurations, where longitudinal slope discontinuities promote internal energy dissipation and reduce outlet velocities. A built-in GUI allows engineers to set up, run, and analyze culvert simulations without writing any code.

Features

  • Full dynamic wave equations (1D Saint-Venant) with fine spatial discretization
  • Multiple numerical schemes: Lax-Friedrichs, FTCS, Leapfrog, Lax-Wendroff, FORCE
  • Preissmann slot for seamless free-surface to pressurized flow transition
  • Single-slope and broken-back geometry with configurable reaches and slopes
  • Adaptive CFL time stepping (Courant number = 0.9)
  • Smoothstep upstream BC — smooth blend between open-channel and submerged regimes, eliminating transition oscillations
  • Constant tailwater BC with drowned-jet guard — reproduces HY-8 outlet velocities when properly tuned
  • Road overtopping as a broad-crested weir (FHWA HDS-5, Q_over = Cw * L * h^1.5) coupled to the upstream mass balance
  • Design metrics: HW/D ratio, peak attenuation %, lag time, pressurization fraction, control-type classification, spill volume, overtop duration and hazard class
  • Multi-storm batch runner for comparing return-period hydrographs (obs, RP10, RP25, RP50, RP100) in a single run
  • Modern GUI built on CustomTkinter with real-time animation, comparison plots, and design summary tables

Screenshots

Hydrograph Comparison

Hydrographs Discharge, outlet velocity, and overtopping flow for all storms in a single batch run. Color-coded per return period.

Space-Time Heatmaps

Heatmaps Velocity and Froude number fields along the culvert over time. Supercritical flow (red) in the steep reach transitions to subcritical (blue) at the slope break — the hydraulic jump that drives energy dissipation in broken-back culverts. Under pressurized conditions, velocities rise and dissipation is suppressed.

Design Summary Table

Summary Core hydraulics (headwater, discharge, velocity, Froude, HW/D, control type) and overtopping analysis (spill volume, hazard class, overtop duration) for each storm.

Validation

The solver was validated against SWMM 5.1 and HY-8 (FHWA Culvert Analysis Program) for a rectangular broken-back culvert (2 x 2 m), with a 15 m reach at 17% slope followed by a 25 m reach at 2% slope, under a hydrograph with 50 m³/s peak discharge.

Parameter Culvert Solver SWMM 5.1 HY-8
Upstream headwater (m) 5.4 5.01 6.53
Velocity - Reach 1 (m/s) 5.6 6.11 6.12
Velocity - Reach 2 (m/s) 5.4 6.12 6.12
Outlet discharge (m³/s) 22.5 24.46 24.16

With tailwater BC enabled (TW = constant depth), the solver reproduces HY-8 outlet velocities within 0.1% (6.114 vs 6.12 m/s).

Inlet headwater comparison Inlet headwater over time: Culvert Solver vs HY-8 vs SWMM 5.1.

Installation

Pre-built executable (Windows)

Download the latest release from the Releases page. No Python installation required — just extract and run CulvertSolver.exe.

From source (requires Python 3.10+)

pip install numpy matplotlib pyyaml numba customtkinter

Optional (for running the test suite):

pip install pytest

Usage

GUI mode

python culvert_gui.py

The GUI loads parameters from culvert_config.yaml automatically. Use the top menubar:

  • Project > Open Project / Save Project / Export CSV / Save Figures
  • Hydrology > Open Hydrograph
  • Hydraulic > Run Simulation (F5) / Stop (Esc) / Plot Culvert Geometry
  • Help > About / GitHub

Command-line mode

python culvert_solver.py hydrograph.txt

Parameters are read from culvert_config.yaml if present, otherwise defaults are used.

Setting up a single-slope culvert

For a standard culvert with a single slope, set both reaches to the same slope by adjusting the invert elevations:

culvert:
  L1: 20.0      # Length of reach 1 (m)
  L2: 20.0      # Length of reach 2 (m)
  W: 2.0        # Culvert width (m)
  H: 2.0        # Culvert height (m)
  Z1: 10.0      # Inlet invert elevation (m)
  Z2: 9.4       # Junction invert elevation (m) - same slope as reach 1
  Z3: 8.8       # Outlet invert elevation (m) - same slope as reach 2

For a broken-back culvert, set different slopes for each reach (e.g., steep inlet reach + mild outlet reach).

Hydrograph input format

The input file can be either:

  1. One discharge value per line (m³/s)
  2. Tab-separated columns with a header row — supports multi-storm files

Example (multi-storm):

time	obs	RP10	RP25	RP50	RP100
0	0.1	0.1	0.1	0.1	0.1
60	5.0	3.5	5.0	6.3	7.5
120	50.0	35.1	50.1	62.6	75.1
180	25.0	17.5	25.0	31.3	37.6

Parameters

Parameter Default Description
L1 15.0 m Length of reach 1
L2 25.0 m Length of reach 2
W 2.0 m Culvert width
H 2.0 m Culvert height
Z1 10.0 m Inlet invert elevation
Z2 7.5 m Junction invert elevation
Z3 7.0 m Outlet invert elevation
N 0.01 Manning's roughness coefficient
road_elevation 16.0 m Top of road embankment (overtopping ceiling)
road_length 10.0 m Crest length of road perpendicular to flow (weir length)
weir_coef 1.5 Broad-crested weir coefficient Cw (FHWA HDS-5, range 1.4-1.7)
tw_depth 0.5 m Constant tailwater depth above outlet invert (0 = free discharge)
Ai 10000 m² Upstream ineffective storage area
nodes_reach1 5 Number of nodes in reach 1
nodes_reach2 10 Number of nodes in reach 2
tq 60.0 s Time interval between hydrograph data points
ts 12000.0 s Total simulation time

Design outputs

Every run produces a set of derived metrics shown in the GUI summary table:

  • Max headwater Hm and HW/D ratio
  • Peak inflow / outflow and attenuation % (routing performance)
  • Lag time between inflow and outflow peaks
  • Pressurization fraction (share of timesteps with Hm >= H)
  • Control type (inlet / outlet / transitional)
  • Max Q_over, h_over, v_over (overtopping flow over the road)
  • Spill volume and overtop duration
  • Depth-velocity hazard class (None / Low / Moderate / High / Extreme)

Tests

pytest tests/                             # smoke and regression tests (9 tests)
python validation/fhwa_rating_curve.py    # rebuild the FHWA rating-curve figure

Theory

The solver uses the 1D Saint-Venant equations in conservative form (area and discharge as dependent variables):

  • Continuity: dA/dt + dQ/dx = 0
  • Momentum: dQ/dt + d(Q²/A + gA·hc)/dx = gA(So - Sf)

The equations are discretized using the Lax-Friedrichs scheme, an explicit first-order finite-difference method. The Preissmann slot concept (narrow slot of width W/20 above the culvert crown) allows seamless transition between free-surface and pressurized flow regimes.

The upstream boundary condition uses a smoothstep blend across a transition band to smoothly interpolate between the characteristic-based open-channel equation and the orifice equation, preventing discontinuities at the regime switch.

Roadmap

  • YAML configuration file for input parameters
  • Road overtopping as broad-crested weir
  • Design-metrics post-processing (HW/D, attenuation, lag, hazard, ...)
  • Multi-storm batch runner (return-period comparison)
  • Smoothstep upstream BC transition (eliminates oscillations)
  • Constant tailwater BC with drowned-jet guard
  • Real-time playback speed control
  • Circular cross-section support
  • Q-dependent tailwater (Manning channel method)

Citation

If you use this solver in your research, please cite:

Rippel, E. C., Martin, V. T., Vasconcelos, J. G., & Piccilli, D. G. A. (2026). Hydraulic Transient Modeling in Broken-Back Culverts: SWMM vs HY-8 vs A Full Dynamic Wave Solver. XXXII Congreso Latinoamericano de Hidráulica, Valparaíso and Viña del Mar, Chile.

References

  • Chaudhry, M. H. Open Channel Flow. Springer, 2nd edition, 2008.
  • FHWA. Hydraulic Design of Highway Culverts (HDS-5). Federal Highway Administration, 2012.
  • Rossman, L. A. Storm Water Management Model User's Manual Version 5.0. U.S. EPA, 2010.
  • Shafer, J., Hotchkiss, R. Hydraulic Analysis of Broken-Back Culverts. Transportation Research Board, 1998.

License

MIT License. See LICENSE for details.

About

Open-source Saint-Venant solver for broken-back culverts. Available as Python source code or a ready-to-use GUI executable for quick simulations.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors