-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_leakages.py
108 lines (85 loc) · 4.91 KB
/
test_leakages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""
Module provides test to test different types of leakages.
"""
import math
import numpy as np
from epyt.epanet import ToolkitConstants
from epyt_flow.data.networks import load_hanoi
from epyt_flow.simulation import ScenarioSimulator, IncipientLeakage, AbruptLeakage, Leakage
from epyt_flow.utils import to_seconds
from .utils import get_temp_folder
def test_abrupt_leakage():
hanoi_network_config = load_hanoi(download_dir=get_temp_folder(),
include_default_sensor_placement=True,
flow_units_id=ToolkitConstants.EN_CMH)
with ScenarioSimulator(scenario_config=hanoi_network_config) as sim:
sim.set_general_parameters(simulation_duration=to_seconds(days=2),
demand_model={"type": "PDA",
"pressure_min": 0,
"pressure_required": 0.1,
"pressure_exponent": 0.5})
leak = AbruptLeakage(link_id="12", diameter=0.1, start_time=7200, end_time=100800)
sim.add_leakage(leak)
res = sim.run_simulation()
res.get_data()
def test_abrupt_leakage_area():
hanoi_network_config = load_hanoi(download_dir=get_temp_folder(),
include_default_sensor_placement=True,
flow_units_id=ToolkitConstants.EN_CMH)
with ScenarioSimulator(scenario_config=hanoi_network_config) as sim:
sim.set_general_parameters(simulation_duration=to_seconds(days=2),
demand_model={"type": "PDA",
"pressure_min": 0,
"pressure_required": 0.1,
"pressure_exponent": 0.5})
leak = AbruptLeakage(link_id="12", area=0.79, start_time=7200, end_time=100800)
sim.add_leakage(leak)
res = sim.run_simulation()
res.get_data()
def test_incipient_leakage():
hanoi_network_config = load_hanoi(download_dir=get_temp_folder(),
include_default_sensor_placement=True,
flow_units_id=ToolkitConstants.EN_CMH)
with ScenarioSimulator(scenario_config=hanoi_network_config) as sim:
sim.set_general_parameters(simulation_duration=to_seconds(days=2),
demand_model={"type": "PDA",
"pressure_min": 0,
"pressure_required": 0.1,
"pressure_exponent": 0.5})
leak = IncipientLeakage(link_id="12", diameter=0.01,
start_time=7200, end_time=100800, peak_time=54000)
sim.add_leakage(leak)
res = sim.run_simulation()
res.get_data()
def test_incipient_leakage_area():
hanoi_network_config = load_hanoi(download_dir=get_temp_folder(),
include_default_sensor_placement=True,
flow_units_id=ToolkitConstants.EN_CMH)
with ScenarioSimulator(scenario_config=hanoi_network_config) as sim:
sim.set_general_parameters(simulation_duration=to_seconds(days=2),
demand_model={"type": "PDA",
"pressure_min": 0,
"pressure_required": 0.1,
"pressure_exponent": 0.5})
leak = IncipientLeakage(link_id="12", area=0.79,
start_time=7200, end_time=100800, peak_time=54000)
sim.add_leakage(leak)
res = sim.run_simulation()
res.get_data()
def test_custom_leakage_profile():
hanoi_network_config = load_hanoi(download_dir=get_temp_folder(),
include_default_sensor_placement=True,
flow_units_id=ToolkitConstants.EN_CMH)
with ScenarioSimulator(scenario_config=hanoi_network_config) as sim:
sim.set_general_parameters(simulation_duration=to_seconds(days=2),
demand_model={"type": "PDA",
"pressure_min": 0,
"pressure_required": 0.1,
"pressure_exponent": 0.5})
hyd_time_step = sim.epanet_api.getTimeHydraulicStep()
n_leaky_time_steps = math.ceil((100800 - 7200) / hyd_time_step)
profile = np.array([.1, .2, .5, .7, .9] + [1.] * (n_leaky_time_steps - 5))
leak = Leakage(link_id="12", area=0.79, profile=profile, start_time=7200, end_time=100800)
sim.add_leakage(leak)
res = sim.run_simulation()
res.get_data()