EPANET-RS
An extremely fast, modern and safe re-implementation of the EPANET2 hydraulic solver, written in Rust.
Background
The EPANET2 solver has been the industry standard for hydraulic network simulation for decades due to its robustness, numerical stability, and extensive validation. Its algorithms and results are widely trusted in both academic and industrial applications. The core EPANET2 codebase, however, is several decades old and written in C, making it difficult to maintain, extend, and optimize using modern software engineering practices. In addition, the original implementation predates modern CPU architectures and therefore does not fully exploit multi-core processors or SIMD (Single Instruction, Multiple Data) capabilities.
Modern applications of the EPANET solver, such as monte-carlo simulations, leak detection algorithms and real-time digital twins of huge networks require a more modern implementation, with better performance and maintainability.
epanet-rs is a modern reimplementation of the EPANET2 hydraulic solver written in Rust, designed to preserve the original algorithms and numerical behavior while enabling safer memory management, improved maintainability, and performance optimizations through multi-threading and SIMD acceleration.
epanet-rs runs about as fast as the original EPANET2_3 solver in sequential mode, and up to 5 times faster in parallel mode for extended period simulations for supported networks (no tanks/controls)!
Design Goals
- Numerical Parity with EPANET2_3 solver (hyd_2_3 branch), ensuring identical or equivalent results for the same input
- High Performance through multi-threading, SIMD acceleration and a modern, faer based sparse solver
- Parallelization of the solver loop by rewriting the solver to return vectors of heads and flows instead of in-place assignment
- Memory Safety through Rust's ownership and borrowing system
- Modern API with a focus on ease of use and parallelization
- Backwards Compatibility with EPANET2_3 network API methods
Usage
# Run simulation
# Run with output file (.json format)
# Run with parallel solving (for extended period simulations without tanks/controls)
# Convert network to different format (JSON or MessagePack)
# Validate results against EPANET
Building
# Debug build
# Release build (optimized)
Testing
# Run all tests
# Run solver tests
Supported Features and To-Do
- INP file support
- Parallel Hydraulic Solver for extended period simulations
- Quality simulations
- Pressure dependent demand simulation
- CONTROLS and RULES
- EMITTERS and LEAKAGE
- ENERGY
- Backwards compatibility with EPANET2_3 network API methods
Dependencies
- faer - Sparse linear algebra
- rayon - Parallel iteration
- hashbrown - Fast hash maps
- serde - Serialization
- clap - Command line parsing
License
EPANET-RS is licensed under the MIT License.
Acknowledgments
EPANET-RS is heavily inspired by EPANET 2.3 and implements the same hydraulic algorithms and models, with slight modifications to improve performance and memory safety. We acknowledge the original EPANET developers, the OpenWaterAnalytics team and the broader water distribution modeling community for their decades of work establishing these foundations.
Author
Abel Heinsbroek (Vitens N.V.)