The Python library for water engineering — from Excel to elegant code.
Project description
HydroFlow
The Python library for water engineering — from Excel to elegant code.
HydroFlow replaces the Excel spreadsheets and $20k/year proprietary software that water engineers depend on daily. Manning's equation, SCS hydrology, culvert sizing, detention pond routing — all in clean, tested, AI-friendly Python.
Quick Start
pip install hydroflow
import hydroflow as hf
# Size a drainage channel in 4 lines
channel = hf.TrapezoidalChannel(
bottom_width=3.0, side_slope=2.0, slope=0.001, roughness="concrete"
)
print(channel.normal_flow(depth=1.5)) # 20.81 m³/s
print(channel.normal_depth(flow=20.81)) # 1.50 m
print(channel.flow_regime(depth=1.5)) # FlowRegime.SUBCRITICAL
No memorizing coefficients. Type "concrete" instead of n=0.013.
Works in Imperial Too
hf.set_units("imperial")
channel = hf.TrapezoidalChannel(
bottom_width=20, side_slope=1.5, slope=0.0016, roughness=0.025
)
print(channel.normal_flow(depth=4.0)) # 516.7 cfs
All internal math uses SI. The imperial constant 1.49 never appears in the codebase — an entire class of bugs, eliminated.
Channel Shapes
# Trapezoidal — roadside ditches, irrigation canals
hf.TrapezoidalChannel(bottom_width=3.0, side_slope=2.0, slope=0.001, roughness="earth_clean")
# Rectangular — concrete-lined channels
hf.RectangularChannel(width=5.0, slope=0.002, roughness="concrete")
# Triangular — roadside gutters, small swales
hf.TriangularChannel(side_slope=3.0, slope=0.01, roughness="earth_gravelly")
# Circular — storm sewers, sanitary sewers
pipe = hf.CircularChannel(diameter=0.6, slope=0.005, roughness="pvc")
pipe.full_flow_capacity() # 0.514 m³/s
pipe.max_flow_capacity() # 0.551 m³/s (at y/D ≈ 0.938, not at full!)
Every channel computes:
normal_flow(depth)— discharge at a given depth (Manning's equation)normal_depth(flow)— iterative solve for depth at a given dischargecritical_depth(flow)— depth where Froude number = 1froude_number(depth)— dimensionless flow regime indicatorflow_regime(depth)—SUBCRITICAL,CRITICAL, orSUPERCRITICAL
Designed for Optimization
Every channel exposes its SI parameters for zero-overhead inner loops:
from hydroflow.channels import _manning_flow
from hydroflow.geometry import _trap_apr
from scipy.optimize import minimize_scalar
channel = hf.TrapezoidalChannel(
bottom_width=3.0, side_slope=2.0, slope=0.001, roughness="concrete"
)
b, z, S, n = channel.si_params # extract once, use millions of times
def cost(depth):
A, P, R = _trap_apr(depth, b, z)
Q = _manning_flow(n, A, R, S)
return (Q - 15.0) ** 2 # target 15 m³/s
result = minimize_scalar(cost, bounds=(0.01, 10.0), method="bounded")
print(f"Optimal depth: {result.x:.3f} m") # finds it in milliseconds
The public API handles units. The kernel functions are pure math — fast enough for Monte Carlo, calibration, and AI agents.
Material Lookup
No more memorizing roughness coefficients:
hf.resolve_roughness("concrete") # 0.013
hf.resolve_roughness("pvc") # 0.010
hf.resolve_roughness("corrugated_metal") # 0.024
hf.resolve_roughness("earth_clean") # 0.022
# Typo? We'll help.
hf.resolve_roughness("concrte")
# ValueError: Unknown material 'concrte'. Did you mean: 'concrete', 'concrete_smooth', 'concrete_rough'?
30+ materials from Chow (1959) and FHWA HEC-22 built in.
Explicit Units When You Need Them
# Global setting
hf.set_units("imperial")
channel = hf.TrapezoidalChannel(bottom_width=10, ...) # feet
# Or tag individual values — overrides global setting
channel = hf.TrapezoidalChannel(bottom_width=hf.ft(10), ...) # feet, even in metric mode
channel = hf.TrapezoidalChannel(bottom_width=hf.m(3), ...) # meters, even in imperial mode
Roadmap
HydroFlow is built in layers — each independently useful:
| Layer | Status | What It Does |
|---|---|---|
| Foundation | ✅ Done | Units, materials, geometry engine |
| L0: Core Calculations | 🔨 Building | Manning's, SCS hydrology, culverts, pond routing |
| L1: Solver Wrappers | 📋 Planned | Clean APIs over EPANET, SWMM, MODFLOW |
| L2: Workflows | 📋 Planned | Chain models: rain → drainage → river |
| L3: AI & Optimization | 📋 Planned | Parameter sweeps, calibration, LLM-ready schemas |
| L4: Reporting | 📋 Planned | One-script PDF/HTML engineering reports |
See ROADMAP.md for the full plan.
Requirements
- Python 3.11+
- NumPy, SciPy (the only dependencies for core calculations)
Development
# Clone and install with dev dependencies
git clone https://github.com/your-username/hydroflow.git
cd hydroflow
uv sync --all-extras
# Run tests, linting, type checking
uv run pytest
uv run ruff check src/ tests/
uv run mypy src/hydroflow/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hydroflow_py-0.1.0.tar.gz.
File metadata
- Download URL: hydroflow_py-0.1.0.tar.gz
- Upload date:
- Size: 139.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ccac4e8f3642c25fcd0f2b7ddb04b03774854bef503e21d156eec0a82639dbc
|
|
| MD5 |
a3fd517a49abf4a729b94354aab02f3f
|
|
| BLAKE2b-256 |
460efaaa6a89d9b884066f35a6db91cfcbbf00ff1ecd76cfe28118f9ab3fd9fc
|
Provenance
The following attestation bundles were made for hydroflow_py-0.1.0.tar.gz:
Publisher:
publish.yml on christianWissmann85/hydroflow-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hydroflow_py-0.1.0.tar.gz -
Subject digest:
8ccac4e8f3642c25fcd0f2b7ddb04b03774854bef503e21d156eec0a82639dbc - Sigstore transparency entry: 959695080
- Sigstore integration time:
-
Permalink:
christianWissmann85/hydroflow-py@aa01e72ffbae02c60109ba34109c2f82836bd939 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/christianWissmann85
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aa01e72ffbae02c60109ba34109c2f82836bd939 -
Trigger Event:
release
-
Statement type:
File details
Details for the file hydroflow_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hydroflow_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68faff98428b16cebafbee8c8c2ed909b955598dc28be44a4c1be35d199e2bc1
|
|
| MD5 |
f2808a4342c544953385a4f47ef8652d
|
|
| BLAKE2b-256 |
2ee7ebbe8d906424fc50763167605a3a4cce9456d8995f5799ac6986465fb277
|
Provenance
The following attestation bundles were made for hydroflow_py-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on christianWissmann85/hydroflow-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hydroflow_py-0.1.0-py3-none-any.whl -
Subject digest:
68faff98428b16cebafbee8c8c2ed909b955598dc28be44a4c1be35d199e2bc1 - Sigstore transparency entry: 959695137
- Sigstore integration time:
-
Permalink:
christianWissmann85/hydroflow-py@aa01e72ffbae02c60109ba34109c2f82836bd939 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/christianWissmann85
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aa01e72ffbae02c60109ba34109c2f82836bd939 -
Trigger Event:
release
-
Statement type: