Sensor Fault 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/sensor_fault.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>'))
This example demonstrates how add sensor faults 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, SENSOR_TYPE_NODE_PRESSURE
from epyt_flow.simulation.events import SensorFaultStuckZero
from epyt_flow.utils import to_seconds
Load the Hanoi network with default sensor configuration:
[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 simulaton duration to two days:
[6]:
sim.set_general_parameters(simulation_duration=to_seconds(days=2))
Add a pressure sensor fault (i.e. power failure, sensor readings are set to zero) at node “16” that is active for 90min (i.e. starts at 150min after simulation begin and ends at 240min after simulation start).
This is done by creating a new instance of the SensorFaultStuckZero class and adding this sensor fault to the scenario by calling add_sensor_fault():
[7]:
sensor_fault = SensorFaultStuckZero(sensor_id="16",
sensor_type=SENSOR_TYPE_NODE_PRESSURE,
start_time=to_seconds(minutes=150),
end_time=to_seconds(minutes=240))
sim.add_sensor_fault(sensor_fault)
Run the entire simulation:
[8]:
scada_data = sim.run_simulation()
Retrieve pressure readings at node “16”:
[9]:
scada_data.plot_pressures(sensor_locations=["16"])
[9]:
<Axes: xlabel='Time (60min steps)', ylabel='Pressure in $meter$'>
Do not forget to close the simulator!
[10]:
sim.close()