Pump State Events 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/pump_states.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>'))
This example demonstrates how to add pump state events to a scenario simulation – more information about actuator events 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_net1
from epyt_flow.simulation import ScenarioSimulator
from epyt_flow.utils import to_seconds
from epyt_flow.simulation.events import PumpStateEvent, ActuatorConstants
Create new simulation based on Net1:
[4]:
sim = ScenarioSimulator(scenario_config=load_net1(verbose=False))
Set simulation duration to 40 hours:
[5]:
sim.set_general_parameters(simulation_duration=to_seconds(hours=40))
Monitor states of tank “2” and pump “9”:
[6]:
sim.set_tank_sensors(sensor_locations=["2"])
sim.set_pump_state_sensors(sensor_locations=["9"])
Remove all existing controls:
[7]:
sim.remove_all_simple_controls()
sim.remove_all_complex_controls()
Deactivate pump “9” at 14h after simulation start by creating an actuator event PumpStateEvent and adding to the simulation by calling add_actuator_event():
[8]:
sim.add_actuator_event(PumpStateEvent(pump_id="9",
pump_state=ActuatorConstants.EN_CLOSED,
time=to_seconds(hours=14)))
Re-activate pump “9” at 25h after simulation start:
[9]:
sim.add_actuator_event(PumpStateEvent(pump_id="9",
pump_state=ActuatorConstants.EN_OPEN,
time=to_seconds(hours=25)))
Run the entire simulation and show sensor readings over time:
[10]:
scada_data = sim.run_simulation()
scada_data.plot_pumps_state()
scada_data.plot_tanks_water_volume()
[10]:
<Axes: xlabel='Time (60min steps)', ylabel='Water volume in $feet^3$'>
Do not forget to close the simulation!
[11]:
sim.close()