Skip to content

Merge of EPANET and EPANET-MSX, incl. a Python interface and some additional useful functions

License

Notifications You must be signed in to change notification settings

HammerLabML/EPANET-PLUS

 
 

Repository files navigation

pypi License: MIT PyPI - Python Version build Documentation Status Downloads Downloads

EPANET-PLUS

EPANET-PLUS is a C library that merges EPANET and EPANET-MSX into a single library. Most importantly, it also provides a Python package with a high-performance interface (i.e., C extension) to the C library, together with additional helper functions for an easier use of EPANET and EPANET-MSX.

Unique Features

Unique features of EPANET-PLUS that make it superior to other Python interfaces of EPANET are the following:

  • High-performance (single) interface to the latest version of EPANET and EPANET-MSX
  • Additional C-functions to extend EPANET and EPANET-MSX
  • Python toolkit with handy functions for working with EPANET and EPANET-MSX

Installation

Note that EPANET-PLUS supports Python 3.9 - 3.13. The Python package contains the the C library as a C extension and is already pre-build for all major platforms.

PyPI

pip install epanet-plus

Git

Download or clone the repository:

git clone https://github.com/WaterFutures/EPANET-PLUS.git
cd EPANET-PLUS

Install all requirements as listed in REQUIREMENTS.txt:

pip install -r REQUIREMENTS.txt

Build and install the package:

pip install .

Quick Example

from epanet_plus import EPyT, EpanetConstants

if __name__ == "__main__":
    # Load an .inp file in EPANET using the toolkit class
    epanet_api = EPyT("net2-cl2.inp")

    # Print some general information
    print(f"All nodes: {epanet_api.get_all_nodes_id()}")
    print(f"All links: {epanet_api.get_all_links_id()}")
    
    print(f"Simulation duration in seconds: {epanet_api.get_simulation_duration()}")
    print(f"Hydraulic time step in seconds: {epanet_api.get_hydraulic_time_step()}")
    print(f"Demand model: {epanet_api.get_demand_model()}")

    # Run hydraulic simulation and output pressure at each node (at every simulation step)
    epanet_api.openH()
    epanet_api.initH(EpanetConstants.EN_NOSAVE)

    tstep = 1
    r = []
    while tstep > 0:
        t = epanet_api.runH()

        print(epanet_api.getnodevalues(EpanetConstants.EN_PRESSURE))

        tstep = epanet_api.nextH()

    epanet_api.closeH()

    # Close EPANET
    epanet_api.close()

Documentation

Documentation is available on readthedocs: https://epanet-plus.readthedocs.io/en/latest/

License

MIT license -- see LICENSE

How to Cite?

If you use this software, please cite it as follows:

@misc{github:epanetplus,
        author = {André Artelt},
        title = {{EPANET-PLUS}},
        year = {2025},
        publisher = {GitHub},
        journal = {GitHub repository},
        howpublished = {https://github.com/WaterFutures/EPANET-PLUS}
}

How to get Support?

If you come across any bug or need assistance please feel free to open a new issue if non of the existing issues answers your questions.

How to Contribute?

Contributions (e.g. creating issues, pull-requests, etc.) are welcome -- please make sure to read the code of conduct and follow the developers' guidelines.

About

Merge of EPANET and EPANET-MSX, incl. a Python interface and some additional useful functions

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 90.7%
  • Python 9.3%