visualstudiocode crs_pipe2.pdf
I am writing code for attaching complementary reservoirs (CRS) to pressure deficient nodes based on follwoing steps.
(1) Simulate the network for a given pipe isolation condition;
(2) Find CN. If the negative pressure is greater than the difference in HGL of source and HGLmin of CN, then set demand at that node as zero and simulate the network;
(3) Find the node having maximum negative pressure, if the negative pressure is greater than the difference in HGL of source and HGLmin of CN, then go to
step 2, else attach an complementing reservoir with pipe size 300 mm, length of 0.1 m and CHW of 130 (Ang and Jowitt 2006). The HGL of CR should be set as HGLmin of that node. Simulate the network;
(4) If supply from CR is greater than the demand at that node, then set demand as zero to that node and disconnect CR and simulate the network; else of flow from CR is shortage to that node;
(5) If any node shows negative pressure, then add CR to the node having maximum negative pressure, simulate the network and go to step 4;
(6) If no negative pressure appears in any of the demand nodes, then supply from CR is shortage to that node. Else go to step 5;
(7) Check whether any node for which demand is set zero by step 2 show the pressure greater than Hmin. If so, then attach CR and set the base demand to
that node and simulate the network. Supply from CR is shortage to that node.
I am able to get the desired output till i get to attach CRS for 2 critical nodes [found.](visualstudiocode crs_pipe2.pdf)
getting output :
PS C:\Users\lab\Desktop\Prachi\epanet_pratcice files> & C:/Users/lab/AppData/Local/Microsoft/WindowsApps/python3.11.exe "c:/Users/lab/Desktop/Prachi/epanet_pratcice files/crs_pipe2.py"
EPANET version 20200 loaded (EPyT version v1.2.0 - Last Update: 01/08/2024).
Input File singlesourcenetwork.inp loaded successfully.
Now, Running Hydraulic Analysis.
The network consisits of 7 nodes of which 6 are Junction Nodes having Node ID ['2', '3', '4', '5', '6', '7'] along with 8 pipes.
The Initial Pressure for all 7 nodes are as follows:
Node 2: 3.57 m
Node 3: 1.40 m
Node 4: 2.31 m
Node 5: 1.65 m
Node 6: 1.43 m
Node 7: 1.42 m
The Initial Status for all 8 pipes are as follows:
Pipe 1: 1: 150.00 lps
Pipe 2: 1: 55.66 lps
Pipe 3: 1: 69.34 lps
Pipe 4: 1: 30.66 lps
Pipe 5: 1: 18.11 lps
Pipe 6: 1: 26.23 lps
Pipe 7: 1: 23.77 lps
Pipe 8: 1: 1.23 lps
After Initial hydraulic Analysis. Now next STEP 1 - ISOLATE THE PIPE
Pipe 3 is successfully isolated with Current Status as 0: Closed
Nodes connected to pipe 3: [['2' '4']]
Node 2 is valid.
Node 4 is valid.
C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: WARNING: System has negative pressures.
warnings.warn(errmssg.value.decode())
C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: Error 203: function call contains undefined node
warnings.warn(errmssg.value.decode())
The Nodes having Negative Pressures after Isolating Pipe 3 are as follows:
Node 3 has a negative pressure: -6.14
Node 4 has a negative pressure: -23.17
Node 5 has a negative pressure: -19.76
Node 6 has a negative pressure: -22.31
Node 7 has a negative pressure: -22.06
Pipe 3 status after simulation: 0
Iteration 1...
C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: Error 203: function call contains undefined node
warnings.warn(errmssg.value.decode())
The Critical node is identified as Node ID 4 having coordinates (4251.969, 5849.269) with maximum negative pressure: -23.17
The excluded nodes: [4]
Next step is to check the Pressure at the Critical Node identified....
HGL Source: 100.0, HGL min at Critical Node 4: 88.0
The HGL difference is :-12.00
Max pressure deficiency of -23.17 at critical node 4 is greater than the HGL difference -12.00. Set demand at critical node 4 as zero.
Unable to attach CR at iteration 1
Starting Iteration 2...
Setting demand to zero for Critical Node 4 and running analysis again.
The index of the critical node is 4
Nodes with their base demands before adjustments:
Node 2: 25.00 lps
Node 3: 25.00 lps
Node 4: 25.00 lps
Node 5: 25.00 lps
Node 6: 25.00 lps
Node 7: 25.00 lps
The base demand at critical node 4 is 25.0 lps
Demand at critical node 4 has been set to zero.
C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: WARNING: System has negative pressures.
warnings.warn(errmssg.value.decode())
Nodes with their base demands after adjustments:
Node 2: Base Demand = 25.00 lps
Node 3: Base Demand = 25.00 lps
Node 4: Base Demand = 0.00 lps
Node 5: Base Demand = 25.00 lps
Node 6: Base Demand = 25.00 lps
Node 7: Base Demand = 25.00 lps
C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: Error 203: function call contains undefined node
warnings.warn(errmssg.value.decode())
The Nodes having Negative Pressures after setting demand as zero to critical Node 4 are as follows:
Node 3 has a negative pressure: -1.01
Node 5 has a negative pressure: -8.18
Node 6 has a negative pressure: -9.28
Node 7 has a negative pressure: -9.25
Node ID 6 is the next Critical Node with a Negative Pressure: -9.28 with Coordinates: (4375.703, 4589.426)
The excluded node : [4, 6]
HGL Source: 100.0, HGL min at Critical Node 6: 85.0
The HGL difference is :-15.00
Max pressure deficiency of -9.28 at critical node 6 is less than the HGL difference -15.00. Attaching CR to critical node 6.
Attaching complementary reservoir to Node 6 with elevation of 85.0.
The coordinates for critical node 6 are : (4375.703, 4589.426)
Reservoir will be placed at coordinates with offset: [4425.703, 4639.426] at elevation 85.0
Reservoir CR_6 successfully added with index 8.
Pipe 9 was successfully added with length 0.10 m, dia 350.0mm and roughness 130.0.
Nodes connected to pipe 9 : [['CR_6' '6']]
Pipe 9 is present in the model with ID 9.
C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: WARNING: System has negative pressures.
warnings.warn(errmssg.value.decode())
The Supply from CR through Pipe 9 is: 18.03 lps to meet shortage.
Base demand at node 6 is: 25.00 lps
Hence, Actual supply of 6.97 is possible from critical node 6 with required HGL of the critical node as 85.00 m
Flow from CRS is shortage to critical node 6.
Check for Negative pressures in the network if any.....
C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: Error 203: function call contains undefined node
warnings.warn(errmssg.value.decode())
Node 2 has positive pressure: 6.56
Node 3 has positive pressure: 2.12
Node 5 has negative pressure: -1.39
Node 6 has negative pressure: -0.00, allowed to be negative as CR is attached.
Node 7 has negative pressure: -0.33
Starting Iteration 3...as negative pressure is present...
The next critical node to add a CR is Node 5 with the maximum negative pressure: -1.39.
The excluded node : [4, 6, 5]
The elevation is 88.0
Coordinates for Critical Node 5: (2688.414, 5793.026)
Attaching complementary reservoir to Node 5 with elevation of 88.0.
The coordinates for critical node 5 are : (2688.414, 5793.026)
Reservoir will be placed at coordinates with offset: [2738.414, 5843.026] at elevation 88.0
Reservoir CR_5 successfully added with index 9.
Pipe 10 was successfully added with length 0.10 m, dia 350.0mm and roughness 130.0.
Nodes connected to pipe 10 : [['CR_5' '5']]
Pipe 10 is present in the model with ID 10.
Traceback (most recent call last):
File "c:\Users\lab\Desktop\Prachi\epanet_pratcice files\crs_pipe2.py", line 749, in
run_simulation(HGL_Source,PipeIsolate)
File "c:\Users\lab\Desktop\Prachi\epanet_pratcice files\crs_pipe2.py", line 586, in run_simulation
d.openHydraulicAnalysis()
File "C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py", line 9973, in openHydraulicAnalysis
self.api.ENopenH()
File "C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py", line 15212, in ENopenH
self.errcode = self._lib.ENopenH()
^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF
Using python 3.11.9 epanet 2.2
Desktop (please complete the following information):
Processor 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz 2.50 GHz
Installed RAM 32.0 GB (31.7 GB usable)
System type 64-bit operating system, x64-based processor
Edition Windows 11 Pro
Version 23H2
Installed on 26-12-2023
OS build 22631.4317
Experience Windows Feature Experience Pack 1000.22700.1041.0
visualstudiocode crs_pipe2.pdf I am writing code for attaching complementary reservoirs (CRS) to pressure deficient nodes based on follwoing steps.
(1) Simulate the network for a given pipe isolation condition; (2) Find CN. If the negative pressure is greater than the difference in HGL of source and HGLmin of CN, then set demand at that node as zero and simulate the network; (3) Find the node having maximum negative pressure, if the negative pressure is greater than the difference in HGL of source and HGLmin of CN, then go to step 2, else attach an complementing reservoir with pipe size 300 mm, length of 0.1 m and CHW of 130 (Ang and Jowitt 2006). The HGL of CR should be set as HGLmin of that node. Simulate the network; (4) If supply from CR is greater than the demand at that node, then set demand as zero to that node and disconnect CR and simulate the network; else of flow from CR is shortage to that node; (5) If any node shows negative pressure, then add CR to the node having maximum negative pressure, simulate the network and go to step 4; (6) If no negative pressure appears in any of the demand nodes, then supply from CR is shortage to that node. Else go to step 5; (7) Check whether any node for which demand is set zero by step 2 show the pressure greater than Hmin. If so, then attach CR and set the base demand to that node and simulate the network. Supply from CR is shortage to that node.
I am able to get the desired output till i get to attach CRS for 2 critical nodes [found.](visualstudiocode crs_pipe2.pdf)
getting output : PS C:\Users\lab\Desktop\Prachi\epanet_pratcice files> & C:/Users/lab/AppData/Local/Microsoft/WindowsApps/python3.11.exe "c:/Users/lab/Desktop/Prachi/epanet_pratcice files/crs_pipe2.py" EPANET version 20200 loaded (EPyT version v1.2.0 - Last Update: 01/08/2024). Input File singlesourcenetwork.inp loaded successfully.
Now, Running Hydraulic Analysis.
The network consisits of 7 nodes of which 6 are Junction Nodes having Node ID ['2', '3', '4', '5', '6', '7'] along with 8 pipes.
The Initial Pressure for all 7 nodes are as follows: Node 2: 3.57 m Node 3: 1.40 m Node 4: 2.31 m Node 5: 1.65 m Node 6: 1.43 m Node 7: 1.42 m
The Initial Status for all 8 pipes are as follows: Pipe 1: 1: 150.00 lps Pipe 2: 1: 55.66 lps Pipe 3: 1: 69.34 lps Pipe 4: 1: 30.66 lps Pipe 5: 1: 18.11 lps Pipe 6: 1: 26.23 lps Pipe 7: 1: 23.77 lps Pipe 8: 1: 1.23 lps After Initial hydraulic Analysis. Now next STEP 1 - ISOLATE THE PIPE
Pipe 3 is successfully isolated with Current Status as 0: Closed
Nodes connected to pipe 3: [['2' '4']] Node 2 is valid. Node 4 is valid. C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: WARNING: System has negative pressures. warnings.warn(errmssg.value.decode()) C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: Error 203: function call contains undefined node warnings.warn(errmssg.value.decode())
The Nodes having Negative Pressures after Isolating Pipe 3 are as follows:
Node 3 has a negative pressure: -6.14 Node 4 has a negative pressure: -23.17 Node 5 has a negative pressure: -19.76 Node 6 has a negative pressure: -22.31 Node 7 has a negative pressure: -22.06 Pipe 3 status after simulation: 0 Iteration 1... C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: Error 203: function call contains undefined node warnings.warn(errmssg.value.decode()) The Critical node is identified as Node ID 4 having coordinates (4251.969, 5849.269) with maximum negative pressure: -23.17 The excluded nodes: [4]
Next step is to check the Pressure at the Critical Node identified....
HGL Source: 100.0, HGL min at Critical Node 4: 88.0 The HGL difference is :-12.00
Max pressure deficiency of -23.17 at critical node 4 is greater than the HGL difference -12.00. Set demand at critical node 4 as zero.
Unable to attach CR at iteration 1
Starting Iteration 2...
Setting demand to zero for Critical Node 4 and running analysis again. The index of the critical node is 4 Nodes with their base demands before adjustments: Node 2: 25.00 lps Node 3: 25.00 lps Node 4: 25.00 lps Node 5: 25.00 lps Node 6: 25.00 lps Node 7: 25.00 lps The base demand at critical node 4 is 25.0 lps Demand at critical node 4 has been set to zero. C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: WARNING: System has negative pressures. warnings.warn(errmssg.value.decode()) Nodes with their base demands after adjustments: Node 2: Base Demand = 25.00 lps Node 3: Base Demand = 25.00 lps Node 4: Base Demand = 0.00 lps Node 5: Base Demand = 25.00 lps Node 6: Base Demand = 25.00 lps Node 7: Base Demand = 25.00 lps C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: Error 203: function call contains undefined node warnings.warn(errmssg.value.decode()) The Nodes having Negative Pressures after setting demand as zero to critical Node 4 are as follows: Node 3 has a negative pressure: -1.01 Node 5 has a negative pressure: -8.18 Node 6 has a negative pressure: -9.28 Node 7 has a negative pressure: -9.25
Node ID 6 is the next Critical Node with a Negative Pressure: -9.28 with Coordinates: (4375.703, 4589.426) The excluded node : [4, 6]
HGL Source: 100.0, HGL min at Critical Node 6: 85.0 The HGL difference is :-15.00
Max pressure deficiency of -9.28 at critical node 6 is less than the HGL difference -15.00. Attaching CR to critical node 6. Attaching complementary reservoir to Node 6 with elevation of 85.0. The coordinates for critical node 6 are : (4375.703, 4589.426) Reservoir will be placed at coordinates with offset: [4425.703, 4639.426] at elevation 85.0 Reservoir CR_6 successfully added with index 8. Pipe 9 was successfully added with length 0.10 m, dia 350.0mm and roughness 130.0. Nodes connected to pipe 9 : [['CR_6' '6']] Pipe 9 is present in the model with ID 9. C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: WARNING: System has negative pressures. warnings.warn(errmssg.value.decode()) The Supply from CR through Pipe 9 is: 18.03 lps to meet shortage. Base demand at node 6 is: 25.00 lps Hence, Actual supply of 6.97 is possible from critical node 6 with required HGL of the critical node as 85.00 m Flow from CRS is shortage to critical node 6.
Check for Negative pressures in the network if any..... C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py:14336: UserWarning: Error 203: function call contains undefined node warnings.warn(errmssg.value.decode()) Node 2 has positive pressure: 6.56 Node 3 has positive pressure: 2.12 Node 5 has negative pressure: -1.39 Node 6 has negative pressure: -0.00, allowed to be negative as CR is attached.
Node 7 has negative pressure: -0.33
Starting Iteration 3...as negative pressure is present...
The next critical node to add a CR is Node 5 with the maximum negative pressure: -1.39. The excluded node : [4, 6, 5] The elevation is 88.0 Coordinates for Critical Node 5: (2688.414, 5793.026) Attaching complementary reservoir to Node 5 with elevation of 88.0. The coordinates for critical node 5 are : (2688.414, 5793.026) Reservoir will be placed at coordinates with offset: [2738.414, 5843.026] at elevation 88.0 Reservoir CR_5 successfully added with index 9. Pipe 10 was successfully added with length 0.10 m, dia 350.0mm and roughness 130.0. Nodes connected to pipe 10 : [['CR_5' '5']] Pipe 10 is present in the model with ID 10. Traceback (most recent call last): File "c:\Users\lab\Desktop\Prachi\epanet_pratcice files\crs_pipe2.py", line 749, in
run_simulation(HGL_Source,PipeIsolate)
File "c:\Users\lab\Desktop\Prachi\epanet_pratcice files\crs_pipe2.py", line 586, in run_simulation
d.openHydraulicAnalysis()
File "C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py", line 9973, in openHydraulicAnalysis
self.api.ENopenH()
File "C:\Users\lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\epyt\epanet.py", line 15212, in ENopenH
self.errcode = self._lib.ENopenH()
^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF
Using python 3.11.9 epanet 2.2 Desktop (please complete the following information):
Processor 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz 2.50 GHz Installed RAM 32.0 GB (31.7 GB usable) System type 64-bit operating system, x64-based processor
Edition Windows 11 Pro Version 23H2 Installed on 26-12-2023 OS build 22631.4317 Experience Windows Feature Experience Pack 1000.22700.1041.0