3.4 EPANET Control Rules using the Toolkit#

Purpose#

Installation#

Examples#

The script below manipulates the Net1.inp example.

## simple rules
import epamodule as em  # import the package
#Open the EPANET toolkit & hydraulics solver   
em.ENopen("./ex1-cr/Net1.inp", "./ex1-cr/Net1-tk.rpt")
# build report command strings Keyword  Action see user manual
command0 = "Status     Yes"
command1 = "Summary            	Yes"
command2 = "Nodes            	ALL"
command3 = "Links            	ALL"
#em.ENsetstatusreport(2) # full status report
em.ENsetreport(command0)
em.ENsetreport(command1)
em.ENsetreport(command2)
em.ENsetreport(command3)
em.ENsaveinpfile("./ex1-cr/Net1-tk.inp") #overwrite the input file
nodej = em.ENgetnodeindex("2")
linkp = em.ENgetlinkindex("9")
print("Control Sensor Node: ",nodej,"Controlled Link: ",linkp)
outstr = em.ENgetcontrol(1)
print("Control Type: ",outstr[0]," Controlled Link: ",\
      outstr[1]," Control Action: ",outstr[2]," Control Sensor Node: ",\
      outstr[3],"Control Value: ",outstr[4])
outstr = em.ENgetcontrol(2)
print("Control Type: ",outstr[0]," Controlled Link: ",\
      outstr[1]," Control Action: ",outstr[2]," Control Sensor Node: ",\
      outstr[3],"Control Value: ",outstr[4])
#print(outstr)
em.ENclose()
# now run from the new file
# now run from the new file
em.ENopen("./ex1-cr/Net1-tk.inp", "./ex1-cr/Net1-tk.rpt")
em.ENopenH()
em.ENsolveH()
em.ENsaveH() # need to save to a binary file before write
em.ENcloseH()
em.ENopenQ()
em.ENsolveQ()
em.ENreport() # now write report
# Close hydraulics solver & toolkit */
em.ENclose()
! cat ./ex1-cr/Net1-tk.rpt
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
/tmp/ipykernel_219767/2499849801.py in <module>
      1 ## simple rules
----> 2 import epamodule as em  # import the package
      3 #Open the EPANET toolkit & hydraulics solver
      4 em.ENopen("./ex1-cr/Net1.inp", "./ex1-cr/Net1-tk.rpt")
      5 # build report command strings Keyword  Action see user manual

~/ects-epanet/ects-epanet-notes/lessons/lesson03/epamodule.py in <module>
     10 _plat= platform.system()
     11 if _plat=='Linux':
---> 12   _lib = ctypes.CDLL("./libepanet2.so") # For My Raspberry Pi
     13 ##  _lib = ctypes.CDLL("./en2tools.so.1.5.0")
     14 ##  _lib = ctypes.CDLL("./epanet2toolkit.so")

/usr/lib/python3.8/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 
    372         if handle is None:
--> 373             self._handle = _dlopen(self._name, mode)
    374         else:
    375             self._handle = handle

OSError: ./libepanet2.so: cannot open shared object file: No such file or directory

Videos#

  1. Looped Network by GUI and Toolkit

  2. Simple Toolkit Examples

  3. Complex System by GUI

  4. Pumps by Toolkit