Skip to main content

EPyT-Flow -- EPANET Python Toolkit - Flow

Project description

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

EPyT-Flow -- EPANET Python Toolkit - Flow

EPyT-Flow is a Python package building on top of EPyT for providing easy access to water distribution network simulations. It aims to provide a high-level interface for the easy generation of hydraulic and water quality scenario data. However, it also provides access to low-level functions by EPANET and EPANET-MSX.

EPyT-Flow provides easy access to popular benchmark data sets for event detection and localization. Furthermore, it also provides an environment for developing and testing control algorithms.

Unique Features

Unique features of EPyT-Flow that make it superior to other (Python) toolboxes are the following:

  • High-performance hydraulic and (advanced) water quality simulation
  • High- and low-level interface
  • Object-orientated design that is easy to extend and customize
  • Sensor configurations
  • Wide variety of pre-defined events (e.g. leakages, sensor faults, actuator events, cyber-attacks, etc.)
  • Wide variety of pre-defined types of uncertainties (e.g. model uncertainties)
  • Step-wise simulation and environment for training and evaluating control strategies
  • Serialization module for easy exchange of data and (scenario) configurations
  • REST API to make EPyT-Flow accessible in other applications
  • Access to many WDNs and popular benchmarks (incl. their evaluation)

Installation

EPyT-Flow supports Python 3.9 - 3.12

Note that EPANET and EPANET-MSX sources are compiled and overwrite the binaries shipped by EPyT IF EPyT-Flow is installed on a Unix system and the gcc compiler is available. By this, we not only aim to achieve a better performance of the simulations but also avoid any compatibility issues of pre-compiled binaries.

Prerequisites for macOS users

The "true" gcc compiler (version 12) is needed which is not the clang compiler that is shipped with Xcode and is linked to gcc!

The correct version of the "true" gcc can be installed via brew:

brew install gcc@12

PyPI

pip install epyt-flow

Git

Download or clone the repository:

git clone https://github.com/WaterFutures/EPyT-Flow.git
cd EPyT-Flow

Install all requirements as listed in REQUIREMENTS.txt:

pip install -r REQUIREMENTS.txt

Install the toolbox:

pip install .

Quick Example

Open In Colab
from epyt_flow.data.benchmarks import load_leakdb_scenarios
from epyt_flow.simulation import ScenarioSimulator
from epyt_flow.utils import to_seconds, plot_timeseries_data


if __name__ == "__main__":
    # Load first Hanoi scenario from LeakDB
    network_config, = load_leakdb_scenarios(scenarios_id=["1"], use_net1=False)

    # Create scenario
    with ScenarioSimulator(scenario_config=network_config) as sim:
        # Set simulation duration to two days
        sim.set_general_parameters(simulation_duration=to_seconds(days=2))

        # Place pressure sensors at nodes "13", "16", "22", and "30"
        sim.set_pressure_sensors(sensor_locations=["13", "16", "22", "30"])

        # Place a flow sensor at link/pipe "1"
        sim.set_flow_sensors(sensor_locations=["1"])

        # Run entire simulation
        scada_data = sim.run_simulation()

        # Print & plot sensor readings over the entire simulation
        print(f"Pressure readings: {scada_data.get_data_pressures()}")
        plot_timeseries_data(scada_data.get_data_pressures().T,
                             labels=[f"Node {n_id}" for n_id in
                                     scada_data.sensor_config.pressure_sensors],
                             x_axis_label="Time (30min steps)",
                             y_axis_label="Pressure in $m$")

        print(f"Flow readings: {scada_data.get_data_flows()}")
        plot_timeseries_data(scada_data.get_data_flows().T,
                             x_axis_label="Time (30min steps)",
                             y_axis_label="Flow rate in $m^3/h$")

Generated plots

Documentation

Documentation is available on readthedocs: https://epyt-flow.readthedocs.io/en/latest/

How to Get Started?

EPyT-Flow is accompanied by an extensive documentation https://epyt-flow.readthedocs.io/en/latest/ (including many examples).

If you are new to water distribution networks, we recommend first to read the chapter on Modeling of Water Distribution Networks. You might also want to check out some lecture notes on Smart Water Systems.

If you are already familiar with WDNs (and software such as EPANET), we recommend checking out our WDSA CCWI 2024 tutorial which not only teaches you how to use EPyT and EPyT-Flow but also contains some examples of applying Machine Learning in WDNs. Besides that, you can read in-depth about the different functionalities of EPyT-Flow in the In-depth Tutorial of the documentation -- we recommend reading the chapters in the order in which they are presented; you might decide to skip some of the last chapters if their content is not relevant to you.

License

MIT license -- see LICENSE

How to Cite?

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

@misc{github:epytflow,
        author = {André Artelt, Marios S. Kyriakou, Stelios G. Vrachimis, Demetrios G. Eliades, Barbara Hammer, Marios M. Polycarpou},
        title = {EPyT-Flow -- EPANET Python Toolkit - Flow},
        year = {2024},
        publisher = {GitHub},
        journal = {GitHub repository},
        howpublished = {\url{https://github.com/WaterFutures/EPyT-Flow}}
    }

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epyt_flow-0.7.1.tar.gz (433.1 kB view details)

Uploaded Source

Built Distribution

epyt_flow-0.7.1-py3-none-any.whl (493.9 kB view details)

Uploaded Python 3

File details

Details for the file epyt_flow-0.7.1.tar.gz.

File metadata

  • Download URL: epyt_flow-0.7.1.tar.gz
  • Upload date:
  • Size: 433.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for epyt_flow-0.7.1.tar.gz
Algorithm Hash digest
SHA256 05450bf0616d46e5557872bcb37cb78dd29dcc24c6bb11fe5144095e3e15bfe7
MD5 466992a7bb1c6c178a970013449577fd
BLAKE2b-256 73b2f65e92beaaf4223302459d7232c315152343a3315ea68af82440549ec972

See more details on using hashes here.

File details

Details for the file epyt_flow-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: epyt_flow-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 493.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for epyt_flow-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 50f53f52ecb62626af7e27dd6c2433e8cf6359787c82e8e87d907b075b0cc5e5
MD5 d67de9e0a769ec7994d2b7e806f0621b
BLAKE2b-256 4c452d9e4e59ae42129e1cef0f5665e030ea86af1f77592ca8a79d0d5758cb79

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page