wntr.epanet.toolkit module¶
The wntr.epanet.toolkit module is a Python extensions for the EPANET Programmers Toolkit DLLs.
Contents
|
Run an EPANET command-line simulation |
|
Wrapper class to load the EPANET DLL object, then perform operations on the EPANET object that is created when a file is loaded. |
|
- wntr.epanet.toolkit.runepanet(inpfile, rptfile=None, binfile=None)[source]¶
Run an EPANET command-line simulation
- Parameters
inpfile (str) – The input file name
- class wntr.epanet.toolkit.ENepanet(inpfile='', rptfile='', binfile='', version=2.2)[source]¶
Bases:
object
Wrapper class to load the EPANET DLL object, then perform operations on the EPANET object that is created when a file is loaded.
This simulator is thread safe only for EPANET version=2.2.
- Parameters
inpfile (str) – Input file to use
rptfile (str) – Output file to report to
binfile (str) – Results file to generate
version (float) – EPANET version to use (either 2.0 or 2.2)
- ENopen(inpfile=None, rptfile=None, binfile=None)[source]¶
Opens an EPANET input file and reads in network data
- Parameters
inpfile (str) – EPANET INP file (default to constructor value)
rptfile (str) – Output file to create (default to constructor value)
binfile (str) – Binary output file to create (default to constructor value)
- ENsaveH()[source]¶
Solves for network hydraulics in all time periods
Must be called before ENreport() if no water quality simulation made. Should not be called if ENsolveQ() will be used.
- ENinitH(iFlag)[source]¶
Initializes hydraulic analysis
- Parameters
iFlag (2-digit flag) – 2-digit flag where 1st (left) digit indicates if link flows should be re-initialized (1) or not (0) and 2nd digit indicates if hydraulic results should be saved to file (1) or not (0)
- ENrunH()[source]¶
Solves hydraulics for conditions at time t
This function is used in a loop with ENnextH() to run an extended period hydraulic simulation. See ENsolveH() for an example.
- Returns
int – Current simulation time (seconds)
- ENnextH()[source]¶
Determines time until next hydraulic event
This function is used in a loop with ENrunH() to run an extended period hydraulic simulation. See ENsolveH() for an example.
- Returns
int – Time (seconds) until next hydraulic event (0 marks end of simulation period)
- ENsavehydfile(filename)[source]¶
Copies binary hydraulics file to disk
- Parameters
filename (str) – Name of hydraulics file to output
- ENusehydfile(filename)[source]¶
Opens previously saved binary hydraulics file
- Parameters
filename (str) – Name of hydraulics file to use
- ENinitQ(iSaveflag)[source]¶
Initializes water quality analysis
- Parameters
iSaveflag (int) – EN_SAVE (1) if results saved to file, EN_NOSAVE (0) if not
- ENrunQ()[source]¶
Retrieves hydraulic and water quality results at time t
This function is used in a loop with ENnextQ() to run an extended period water quality simulation. See ENsolveQ() for an example.
- Returns
int – Current simulation time (seconds)
- ENnextQ()[source]¶
Advances water quality simulation to next hydraulic event
This function is used in a loop with ENrunQ() to run an extended period water quality simulation. See ENsolveQ() for an example.
- Returns
int – Time (seconds) until next hydraulic event (0 marks end of simulation period)
- ENgetcount(iCode)[source]¶
Retrieves the number of components of a given type in the network
- Parameters
iCode (int) – Component code (see toolkit.optComponentCounts)
- Returns
int – Number of components in network
- ENgetflowunits()[source]¶
Retrieves flow units code
- Returns
Code of flow units in use (see toolkit.optFlowUnits)
- ENgetnodeindex(sId)[source]¶
Retrieves index of a node with specific ID
- Parameters
sId (int) – Node ID
- Returns
Index of node in list of nodes
- ENgetnodevalue(iIndex, iCode)[source]¶
Retrieves parameter value for a node
- Parameters
iIndex (int) – Node index
iCode (int) – Node parameter code (see toolkit.optNodeParams)
- Returns
Value of node’s parameter
- ENgetlinkindex(sId)[source]¶
Retrieves index of a link with specific ID
- Parameters
sId (int) – Link ID
- Returns
Index of link in list of links
- ENgetlinkvalue(iIndex, iCode)[source]¶
Retrieves parameter value for a link
- Parameters
iIndex (int) – Link index
iCode (int) – Link parameter code (see toolkit.optLinkParams)
- Returns
Value of link’s parameter
- ENsetlinkvalue(iIndex, iCode, fValue)[source]¶
Set the value on a link
- Parameters
iIndex (int) – the link index
iCode (int) – the parameter enum integer
fValue (float) – the value to set on the link
- ENsetnodevalue(iIndex, iCode, fValue)[source]¶
Set the value on a node
- Parameters
iIndex (int) – the node index
iCode (int) – the parameter enum integer
fValue (float) – the value to set on the node
- ENsettimeparam(eParam, lValue)[source]¶
Set a time parameter value
- Parameters
eParam (int) – the time parameter to set
lValue (long) – the value to set, in seconds