Abrupt Leakage Example

[1]:
from IPython.display import display, HTML
display(HTML('<a target="_blank" href="https://colab.research.google.com/github/WaterFutures/EPyT-Flow/blob/main/docs/examples/abrupt_leakage.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>'))
Open In Colab

This example demonstrates how add an abrupt leakage to a scenario – more information can be found in the documentation.

[2]:
%pip install epyt-flow --quiet
Note: you may need to restart the kernel to use updated packages.
[3]:
from epyt_flow.data.networks import load_hanoi
from epyt_flow.simulation import ScenarioSimulator, AbruptLeakage, EpanetConstants
from epyt_flow.utils import to_seconds

Load the Hanoi network with a default sensor placement:

[4]:
hanoi_network_config = load_hanoi(include_default_sensor_placement=True, verbose=False)

Create a new simulation:

[5]:
sim = ScenarioSimulator(scenario_config=hanoi_network_config)

Set simulation duration to 7 days:

[6]:
sim.set_general_parameters(simulation_duration=to_seconds(days=7))

Note that leakages are only modeled for two flow units. We therefore change the flow units to cubic meter per hour by calling set_general_parameters() – could also be done when loading the network!

[7]:
sim.set_general_parameters(flow_units_id=EpanetConstants.EN_CMH)

Add an abrupt leakage at link/pipe “14” – the leakage is active for 18 hours and starts at 10 hours after simulation begin – recall that the time arguments are seconds!

We create an abrupt leakage by creating an instance of the AbruptLeakage class and add the leakage to the scenario by calling add_leakage():

[8]:
leak = AbruptLeakage(link_id="14", diameter=0.1,
                     start_time=to_seconds(hours=10),
                     end_time=to_seconds(hours=28))

sim.add_leakage(leak)

Run the entire simulation:

[9]:
scada_data = sim.run_simulation()

Retrieve and show pressure at node “13” over time:

[10]:
scada_data.plot_pressures(sensor_locations=['13'])
../_images/examples_abrupt_leakage_18_0.png
[10]:
<Axes: xlabel='Time (60min steps)', ylabel='Pressure in $meter$'>

Do not forget to close the simulator!

[11]:
sim.close()
[ ]: