hydra-engine — complete water distribution simulation engine.
Hydra simulates the hydraulic behaviour and water quality dynamics of pressurised water distribution networks over time. Its output is the complete time history of flows, pressures, and constituent concentrations at every point in the network.
Scope
Hydra models:
- Extended-period steady-state hydraulics
- Pressure-driven and demand-driven demand models
- Conservative and reactive constituent transport (water quality, age, source tracing)
Hydra does not model pressure transients, water-hammer effects, or multi-phase (gas/liquid) flow.
Correctness criteria
- Solver convergence: head and flow residuals satisfy the GGA stopping criteria to within the configured tolerances at every hydraulic time step.
- Physical conservation: mass balance and energy balance hold across the network to within floating-point precision.
- INP compatibility: a valid EPANET 2.3
.inpfile is parsed faithfully and its network topology is represented without loss.
Agreement with EPANET's numerical output is not a correctness criterion. On well-posed networks the two will agree closely because they solve the same governing equations; where they diverge, Hydra's result is authoritative.
Crate ownership
This crate owns the WD network data model, EPANET INP/OUT format parsers and writers, unit conversion, the GGA hydraulic solver, the Lagrangian quality engine, the simulation session API, and post-simulation analytics.
It does not own interface logic (CLI, GUI) or filesystem/network I/O — callers supply bytes. all types are defined within this crate.
Internal module structure
| Module | Responsibility |
|---|---|
model |
Network data model, state types, validation |
io |
Unit conversion, INP/OUT/RPT/analysis parsers and writers |
hydraulics |
GGA Newton-Raphson solver (see ../hydraulics/spec.md) |
quality |
Lagrangian transport engine (see ../quality/spec.md) |
simulation |
Session API, controls, timestep, accounting |
analysis |
Post-simulation analytics |
Downstream crates (hydra, hydra-cli, hydra-gui) depend only on this
crate's public re-export surface; they do not depend on any internal module.