MSXepanet#
module wntr.epanet.msx.toolkit
- class MSXepanet[source]#
Bases:
ENepanet
- ENaddcontrol(iType, iLinkIndex, dSetting, iNodeIndex, dLevel)#
Add a new simple control
- ENcloseH()#
Frees data allocated by hydraulics solver
- ENcloseQ()#
Frees data allocated by water quality solver
- ENdeletecontrol(iControlIndex)#
Delete a control.
- Parameters:
iControlIndex (int) – the simple control to delete
- ENgetcontrol(iIndex)#
Get values defined by a control.
- Parameters:
iIndex (int) – the control number
- ENgetcount(iCode)#
Retrieves the number of components of a given type in the network
- ENgetflowunits()#
Retrieves flow units code
- Return type:
Code of flow units in use (see toolkit.optFlowUnits)
- ENgetlinkindex(sId)#
Retrieves index of a link with specific ID
- Parameters:
sId (int) – Link ID
- Return type:
Index of link in list of links
- ENgetlinktype(iIndex)#
Retrieves a link’s type given its index.
- ENgetlinkvalue(iIndex, iCode)#
Retrieves parameter value for a link
- ENgetnodeid(iIndex)#
Gets the ID name of a node given its index.
- ENgetnodeindex(sId)#
Retrieves index of a node with specific ID
- Parameters:
sId (int) – Node ID
- Return type:
Index of node in list of nodes
- ENgetnodetype(iIndex)#
Retrieves a node’s type given its index.
- ENgetnodevalue(iIndex, iCode)#
Retrieves parameter value for a node
- ENgettimeparam(eParam)#
Get a time parameter value
- Parameters:
eParam (int) – the time parameter to get
- Returns:
the value of the time parameter, in seconds
- Return type:
long
- ENinitH(iFlag)#
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)
- ENinitQ(iSaveflag)#
Initializes water quality analysis
- Parameters:
iSaveflag (int) – EN_SAVE (1) if results saved to file, EN_NOSAVE (0) if not
- ENnextH()#
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:
Time (seconds) until next hydraulic event (0 marks end of simulation period)
- Return type:
- ENnextQ()#
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:
Time (seconds) until next hydraulic event (0 marks end of simulation period)
- Return type:
- ENopen(inpfile=None, rptfile=None, binfile=None)[source]#
Opens an EPANET input file and reads in network data
- ENopenH()#
Sets up data structures for hydraulic analysis
- ENopenQ()#
Sets up data structures for water quality analysis
- ENreport()#
Writes report to report file
- ENrunH()#
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:
Current simulation time (seconds)
- Return type:
- ENrunQ()#
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:
Current simulation time (seconds)
- Return type:
- ENsaveH()#
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.
- ENsavehydfile(filename)#
Copies binary hydraulics file to disk
- Parameters:
filename (str) – Name of hydraulics file to output
- ENsetcontrol(iIndex, iType, iLinkIndex, dSetting, iNodeIndex, dLevel)#
Change values on a simple control
- Parameters:
Warning
There is an error in EPANET 2.2 that sets the dLevel parameter to 0.0 on Macs regardless of the value the user passes in. This means that to use this toolkit functionality on a Mac, the user must delete and create a new control to change the level.
- ENsetlinkvalue(iIndex, iCode, fValue)#
Set the value on a link
- ENsetnodevalue(iIndex, iCode, fValue)#
Set the value on a node
- ENsettimeparam(eParam, lValue)#
Set a time parameter value
- Parameters:
eParam (int) – the time parameter to set
lValue (long) – the value to set, in seconds
- ENsolveH()#
Solves for network hydraulics in all time periods
- ENsolveQ()#
Solves for network water quality in all time periods
- ENusehydfile(filename)#
Opens previously saved binary hydraulics file
- Parameters:
filename (str) – Name of hydraulics file to use
- MSXaddpattern(patternid)[source]#
Add a new, empty MSX source time pattern to an MSX project.
- Parameters:
patternid (str) – Name of the new pattern
- MSXgetIDlen(_type, index)[source]#
Get the number of characters in the ID name of an MSX object given its internal index number.
- MSXgetconstant(constant_index)[source]#
Get the value of a particular reaction constant
- Parameters:
constant_index (int) – Index to the constant
- Returns:
Value of the constant
- Return type:
- Raises:
EpanetMsxException – Toolkit error occurred
- MSXgetcount(_type)[source]#
Get the number of objects of a specified type.
- Parameters:
- Returns:
Number of objects of specified type
- Return type:
- Raises:
MSXKeyError – If the _type is invalid
- MSXgeterror(errcode, len=100)[source]#
Get the text for an error message given its error code
- Parameters:
- Returns:
String decoded from the DLL
- Return type:
Warning
Getting string parameters in this way is not recommended, because it requires setting up string arrays that may or may not be the correct size. Use the wntr.epanet.msx.enums package to get error information.
- MSXgetindex(_type, name)[source]#
Gets the internal index of an MSX object given its name.
- Parameters:
- Returns:
Internal index
- Return type:
- Raises:
MSXKeyError – If an invalid str is passed for _type
MSXValueError – If _type is not a valid MSX object type
- MSXgetinitqual(_type, node_link_index, species_index)[source]#
Get the initial concentration of a particular chemical species assigned to a specific node or link of the pipe network
- Parameters:
- Returns:
Initial quality value for that node or link
- Return type:
- Raises:
MSXKeyError – Type passed in for
_type
is not validMSXValueError – Value for
_type
is not validEpanetMsxException – Any other error from the C-API
- MSXgetparameter(_type, node_link_index, param_index)[source]#
Get the value of a particular reaction parameter for a given TANK or PIPE.
- Parameters:
- Returns:
Parameter value
- Return type:
- Raises:
MSXKeyError – If there is no such _type
MSXValueError – If the _type is improper
EpanetMsxException – Any other error
- MSXgetpatternvalue(pat, period)[source]#
Get the multiplier at a specific time period for a given SOURCE time pattern
- MSXgetqual(_type, node_link_index, species_index)[source]#
Get a chemical species concentration at a given node or the average concentration along a link at the current simulation time step
- Parameters:
- Returns:
Current quality value for that node or link
- Return type:
- Raises:
MSXKeyError – Type passed in for
_type
is not validMSXValueError – Value for
_type
is not validEpanetMsxException – Any other error from the C-API
- MSXgetsource(node_index, species_index)[source]#
Get information on any external source of a particular chemical species assigned to a specific node of the pipe network
- Parameters:
- Returns:
[source type, level, and pattern] where level is the baseline concentration (or mass flow rate) of the source and pattern the index of the time pattern used to add variability to the source’s baseline level (0 if no pattern defined for the source)
- Return type:
- MSXgetspecies(species_index)[source]#
Get the attributes of a chemical species given its internal index number.
- MSXinit(saveFlag=0)[source]#
Initializes the MSX system before solving for water quality results in step-wise fashion set saveFlag to 1 if water quality results should be saved to a scratch binary file, or to 0 is not saved to file
- MSXopen(msxfile)[source]#
Opens the MSX Toolkit to analyze a particular distribution system.
- Parameters:
msxfile (str) – Name of the MSX input file
- MSXreport()[source]#
Writes water quality simulations results as instructed by the MSX input file to a text file
- MSXsavemsxfile(filename)[source]#
Saves the data associated with the current MSX project into a new MSX input file
- Parameters:
filename (str) – Name of the MSX input file to create
- MSXsaveoutfile(filename)[source]#
Saves water quality results computed for each node, link and reporting time period to a named binary file
- Parameters:
filename (str) – Save a binary results file
- MSXsetinitqual(_type, ind, spe, value)[source]#
Set the initial concentration of a particular chemical species assigned to a specific node or link of the pipe network.
- MSXsetparameter(_type, ind, param, value)[source]#
Set a value to a particular reaction parameter for a given TANK or PIPE
- Parameters:
- Raises:
MSXKeyError – If there is no such _type
MSXValueError – If the _type is invalid
- MSXsetpattern(pat, mult)[source]#
Set multipliers to a given MSX SOURCE time pattern
- Parameters:
pat (int) – Pattern index
mult (list-like) – Pattern multipliers
- MSXsetpatternvalue(pat, period, value)[source]#
Set the multiplier factor for a specific period within a SOURCE time pattern.
- MSXsetsource(node, spe, _type, level, pat)[source]#
Set the attributes of an external source of a particular chemical species in a specific node of the pipe network
- MSXsolveH()[source]#
Runs a complete hydraulic simulation with results for all time periods written to the binary Hydraulics file.
- MSXsolveQ()[source]#
Solves for water quality over the entire simulation period and saves the results to an internal scratch file
- MSXstep()[source]#
Advances the water quality simulation one water quality time step. The time remaining in the overall simulation is returned as tleft, the current time as t.
- MSXusehydfile(filename)[source]#
Uses the contents of the specified file as the current binary hydraulics file
- Parameters:
filename (str) – Name of the hydraulics file to use
- isOpen()#
Checks to see if the file is open