epyt-flow 0.2.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- epyt_flow/EPANET/compile_macos.sh +4 -0
- epyt_flow/VERSION +1 -1
- epyt_flow/__init__.py +6 -2
- epyt_flow/data/benchmarks/leakdb.py +7 -12
- epyt_flow/data/networks.py +404 -40
- epyt_flow/rest_api/base_handler.py +14 -0
- epyt_flow/rest_api/scada_data/handlers.py +42 -0
- epyt_flow/rest_api/server.py +3 -1
- epyt_flow/simulation/events/leakages.py +28 -18
- epyt_flow/simulation/parallel_simulation.py +7 -7
- epyt_flow/simulation/scada/scada_data.py +543 -12
- epyt_flow/simulation/scada/scada_data_export.py +38 -5
- epyt_flow/simulation/scenario_config.py +7 -5
- epyt_flow/simulation/scenario_simulator.py +81 -48
- epyt_flow/simulation/sensor_config.py +342 -47
- epyt_flow/topology.py +313 -11
- epyt_flow/uncertainty/model_uncertainty.py +26 -19
- epyt_flow/utils.py +1 -1
- {epyt_flow-0.2.0.dist-info → epyt_flow-0.4.0.dist-info}/METADATA +18 -6
- {epyt_flow-0.2.0.dist-info → epyt_flow-0.4.0.dist-info}/RECORD +23 -22
- {epyt_flow-0.2.0.dist-info → epyt_flow-0.4.0.dist-info}/LICENSE +0 -0
- {epyt_flow-0.2.0.dist-info → epyt_flow-0.4.0.dist-info}/WHEEL +0 -0
- {epyt_flow-0.2.0.dist-info → epyt_flow-0.4.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
mkdir -p "../customlibs/"
|
|
3
|
+
gcc-12 -w -O3 -march=native -dynamiclib -fPIC -install_name libepanet2_2.dylib -o "../customlibs/libepanet2_2.dylib" EPANET/SRC_engines/*.c -IEPANET/SRC_engines/include -lc -lm -pthread
|
|
4
|
+
gcc-12 -w -O3 -march=native -dynamiclib -fPIC -install_name libepanetmsx2_2_0.dylib -o "../customlibs/libepanetmsx2_2_0.dylib" -fopenmp -Depanetmsx_EXPORTS -IEPANET-MSX/Src/include -IEPANET/SRC_engines/include EPANET-MSX/Src/*.c -L'../customlibs' -lepanet2_2 -lm -lgomp -lpthread
|
epyt_flow/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.4.0
|
epyt_flow/__init__.py
CHANGED
|
@@ -8,7 +8,8 @@ with open(os.path.join(os.path.dirname(__file__), 'VERSION'), encoding="utf-8")
|
|
|
8
8
|
VERSION = f.read().strip()
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def compile_libraries_unix(lib_epanet_name, compile_script_name
|
|
11
|
+
def compile_libraries_unix(lib_epanet_name: str, compile_script_name: str,
|
|
12
|
+
gcc_name: str = "gcc") -> None:
|
|
12
13
|
"""Compile EPANET and EPANET-MSX libraries if needed."""
|
|
13
14
|
path_to_custom_libs = os.path.join(os.path.dirname(__file__), "customlibs")
|
|
14
15
|
path_to_lib_epanet = os.path.join(path_to_custom_libs, lib_epanet_name)
|
|
@@ -20,7 +21,7 @@ def compile_libraries_unix(lib_epanet_name, compile_script_name):
|
|
|
20
21
|
update = True
|
|
21
22
|
|
|
22
23
|
if not os.path.isfile(path_to_lib_epanet) or update:
|
|
23
|
-
if shutil.which(
|
|
24
|
+
if shutil.which(gcc_name) is not None:
|
|
24
25
|
print("Compiling EPANET and EPANET-MSX...")
|
|
25
26
|
try:
|
|
26
27
|
subprocess.check_call(f"cd \"{path_to_epanet}\"; bash {compile_script_name}",
|
|
@@ -28,6 +29,7 @@ def compile_libraries_unix(lib_epanet_name, compile_script_name):
|
|
|
28
29
|
print("Done")
|
|
29
30
|
except subprocess.CalledProcessError as ex:
|
|
30
31
|
print(f"Compilation failed\n{ex}")
|
|
32
|
+
warnings.warn("Falling back to pre-compiled library shipped by EPyT.")
|
|
31
33
|
else:
|
|
32
34
|
warnings.warn("GCC is not available to compile the required libraries.\n" +
|
|
33
35
|
"Falling back to pre-compiled library shipped by EPyT.")
|
|
@@ -35,3 +37,5 @@ def compile_libraries_unix(lib_epanet_name, compile_script_name):
|
|
|
35
37
|
|
|
36
38
|
if sys.platform.startswith("linux"):
|
|
37
39
|
compile_libraries_unix("libepanet2_2.so", "compile_linux.sh")
|
|
40
|
+
elif sys.platform.startswith("darwin"):
|
|
41
|
+
compile_libraries_unix("libepanet2_2.dylib", "compile_macos.sh", gcc_name="gcc-12")
|
|
@@ -475,12 +475,10 @@ def load_scenarios(scenarios_id: list[int], use_net1: bool = True,
|
|
|
475
475
|
(int(week_year_pat.shape[0]), int(week_year_pat.shape[1])))
|
|
476
476
|
|
|
477
477
|
# Create demand
|
|
478
|
-
|
|
479
|
-
base = 1
|
|
480
|
-
else:
|
|
481
|
-
base = 0.3 # Avoid negative pressure in Hanoi
|
|
478
|
+
base = 1
|
|
482
479
|
variation = 0.75 + np.random.normal(0, 0.07) # from 0 to 1
|
|
483
480
|
dem = base * (year_offset+1) * (week_year_pat*variation+1) * (random+1)
|
|
481
|
+
|
|
484
482
|
dem = dem.tolist()
|
|
485
483
|
dem_final = []
|
|
486
484
|
for d in dem:
|
|
@@ -508,6 +506,7 @@ def load_scenarios(scenarios_id: list[int], use_net1: bool = True,
|
|
|
508
506
|
wdn.epanet_api.setTimeHydraulicStep(general_params["hydraulic_time_step"])
|
|
509
507
|
wdn.epanet_api.setTimeSimulationDuration(general_params["simulation_duration"])
|
|
510
508
|
wdn.epanet_api.setTimePatternStep(general_params["hydraulic_time_step"])
|
|
509
|
+
wdn.epanet_api.setFlowUnitsCMH()
|
|
511
510
|
|
|
512
511
|
wdn.epanet_api.deletePatternsAll()
|
|
513
512
|
|
|
@@ -542,14 +541,10 @@ def load_scenarios(scenarios_id: list[int], use_net1: bool = True,
|
|
|
542
541
|
upper = data + z
|
|
543
542
|
return lower + np.random.uniform() * (upper - lower)
|
|
544
543
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
pipe_roughness_uncertainty=MyUniformUncertainty(low=0,
|
|
550
|
-
high=0.25),
|
|
551
|
-
demand_base_uncertainty=MyUniformUncertainty(low=0,
|
|
552
|
-
high=0.25))
|
|
544
|
+
my_uncertainties = {"pipe_length_uncertainty": MyUniformUncertainty(low=0, high=0.25),
|
|
545
|
+
"pipe_roughness_uncertainty": MyUniformUncertainty(low=0, high=0.25),
|
|
546
|
+
"base_demand_uncertainty": MyUniformUncertainty(low=0, high=0.25)}
|
|
547
|
+
model_uncertainty = ModelUncertainty(**my_uncertainties)
|
|
553
548
|
|
|
554
549
|
# Create sensor config (place pressure and flow sensors everywhere)
|
|
555
550
|
sensor_config = network_config.sensor_config
|