#!/usr/bin/env python
"""This example illustrates how the Toolkit could be used
to develop a hydrant rating curve used in fire flow studies.
This curve shows the amount of flow available at a node in 
the system as a function of pressure. 

The curve is generated by running a number of steady state 
hydraulic analyses with the node of interest subjected to a 
different demand in each analysis. 

For this example we assume that the ID label of the node of 
interest is MyNode and that N different demand levels stored 
in the array Demands need to be examined.
The corresponding pressures will be returned.
To keep the code more readable no exception handling is made."""

import epamodule as em

def HydrantRating( MyNode, Demands):
   #Open the EPANET toolkit & hydraulics solver
   em.ENopen("example2.inp", "example2.rpt")
   em.ENopenH()

   # Get the index of the node of interest
   nodeindex= em.ENgetnodeindex(MyNode);

   rating= []
   # Iterate over all demands
   for dem in Demands:
      em.ENsetnodevalue(nodeindex, em.EN_BASEDEMAND, dem)
      em.ENinitH(em.EN_NOSAVE)
      em.ENrunH()
      pressure= em.ENgetnodevalue(nodeindex, em.EN_PRESSURE)
      rating.append(pressure)

   # Close hydraulics solver & toolkit */
   em.ENcloseH()
   em.ENclose()
   return rating
   
if __name__=='__main__':
  print  (HydrantRating('3', [0.0, 10.0, 20.0, 50.0, 100.0]  ))

#!/usr/bin/env python
"""This example illustrates how the Toolkit could be used
to develop a hydrant rating curve used in fire flow studies.
This curve shows the amount of flow available at a node in 
the system as a function of pressure. 

The curve is generated by running a number of steady state 
hydraulic analyses with the node of interest subjected to a 
different demand in each analysis. 

For this example we assume that the ID label of the node of 
interest is MyNode and that N different demand levels stored 
in the array Demands need to be examined.
The corresponding pressures will be returned.
To keep the code more readable no exception handling is made."""

import epamodule as em

def HydrantRating( MyNode, Demands):
   #Open the EPANET toolkit & hydraulics solver
   em.ENopen("example2.inp", "example2.rpt")
   em.ENopenH()

   # Get the index of the node of interest
   nodeindex= em.ENgetnodeindex(MyNode);

   rating= []
   # Iterate over all demands
   for dem in Demands:
      em.ENsetnodevalue(nodeindex, em.EN_BASEDEMAND, dem)
      em.ENinitH(em.EN_NOSAVE)
      em.ENrunH()
      pressure= em.ENgetnodevalue(nodeindex, em.EN_PRESSURE)
      rating.append(pressure)

   # Close hydraulics solver & toolkit */
   em.ENcloseH()
   em.ENclose()
   return rating
   
if __name__=='__main__':
  print  (HydrantRating('3', [0.0, 10.0, 20.0, 50.0, 100.0]  ))

#!/usr/bin/env python This example illustrates how the Toolkit could be used to develop a hydrant rating curve used in fire flow studies. This curve shows the amount of flow available at a node in  the system as a function of pressure.   The curve is generated by running a number of steady state  hydraulic analyses with the node of interest subjected to a  different demand in each analysis.   For this example we assume that the ID label of the node of  interest is MyNode and that N different demand levels stored  in the array Demands need to be examined. The corresponding pressures will be returned. To keep the code more readable no exception handling is made. #Open the EPANET toolkit & hydraulics solver # Get the index of the node of interest # Iterate over all demands # Close hydraulics solver & toolkit */