Chlorine Injection 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/chlorine_injection.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>'))
This example demonstrates how to add a chlorine injection to a scenario simulation.
[2]:
%pip install epyt-flow --quiet
Note: you may need to restart the kernel to use updated packages.
[3]:
import numpy
from epyt_flow.data.networks import load_hanoi
from epyt_flow.simulation import ScenarioSimulator, EpanetConstants
from epyt_flow.utils import to_seconds
Load the Hanoi network by calling load_hanoi():
[4]:
network_config = load_hanoi(verbose=False)
Create a new simulation:
[5]:
sim = ScenarioSimulator(scenario_config=network_config)
Set simulation duration to 12 hours:
[6]:
sim.set_general_parameters(simulation_duration=to_seconds(hours=12))
Enable chemical analysis by calling enable_chemical_analysis():
[7]:
sim.enable_chemical_analysis()
Sets the concentration at node “1” (reservoir) to 1.0 for all time steps by calling add_quality_source() – this creates a new source of the chemical being analyzed:
[8]:
sim.add_quality_source(node_id="1",
pattern=numpy.array([1.]),
source_type=EpanetConstants.EN_CONCEN)
Places quality sensors at all nodes – i.e. measuring the chemical concentration at all nodes:
[9]:
sim.set_node_quality_sensors(sensor_locations=sim.sensor_config.nodes)
Run the entire simulation:
[10]:
scada_data = sim.run_simulation()
Retrieve and how the simulated chemical concentrations at the first 5 nodes – note the transport delay!
[11]:
scada_data.plot_nodes_quality()
[11]:
<Axes: xlabel='Time (60min steps)', ylabel='$mg/L$'>
Do not forget to close the simulation!
[12]:
# Close simulator
sim.close()