Skip to content

Commit db1c993

Browse files
committed
Create example2.py
1 parent 0f1551b commit db1c993

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

example2.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""This example illustrates how the Toolkit could be used
2+
to develop a hydrant rating curve used in fire flow studies.
3+
This curve shows the amount of flow available at a node in
4+
the system as a function of pressure.
5+
6+
The curve is generated by running a number of steady state
7+
hydraulic analyses with the node of interest subjected to a
8+
different demand in each analysis.
9+
10+
For this example we assume that the ID label of the node of
11+
interest is MyNode and that N different demand levels stored
12+
in the array Demands need to be examined.
13+
The corresponding pressures will be returned.
14+
To keep the code more readable no exception handling is made."""
15+
16+
import epamodule as em
17+
18+
def HydrantRating( MyNode, Demands):
19+
#Open the EPANET toolkit & hydraulics solver
20+
em.ENopen("example2.inp", "example2.rpt")
21+
em.ENopenH()
22+
23+
# Get the index of the node of interest
24+
nodeindex= em.ENgetnodeindex(MyNode);
25+
26+
rating= []
27+
# Iterate over all demands
28+
for dem in Demands:
29+
em.ENsetnodevalue(nodeindex, em.EN_BASEDEMAND, dem)
30+
em.ENinitH(em.EN_NOSAVE)
31+
em.ENrunH()
32+
pressure= em.ENgetnodevalue(nodeindex, em.EN_PRESSURE)
33+
rating.append(pressure)
34+
35+
# Close hydraulics solver & toolkit */
36+
em.ENcloseH()
37+
em.ENclose()
38+
return rating
39+
40+
if __name__=='__main__':
41+
print HydrantRating('3', [0.0, 10.0, 20.0, 50.0, 100.0] )

0 commit comments

Comments
 (0)