EPANET  2.1
epanet2.h File Reference

Go to the source code of this file.

Macros

#define EN_API_FLOAT_TYPE   float
 

Enumerations

enum  EN_NodeProperty {
  EN_ELEVATION = 0, EN_BASEDEMAND = 1, EN_PATTERN = 2, EN_EMITTER = 3,
  EN_INITQUAL = 4, EN_SOURCEQUAL = 5, EN_SOURCEPAT = 6, EN_SOURCETYPE = 7,
  EN_TANKLEVEL = 8, EN_DEMAND = 9, EN_HEAD = 10, EN_PRESSURE = 11,
  EN_QUALITY = 12, EN_SOURCEMASS = 13, EN_INITVOLUME = 14, EN_MIXMODEL = 15,
  EN_MIXZONEVOL = 16, EN_TANKDIAM = 17, EN_MINVOLUME = 18, EN_VOLCURVE = 19,
  EN_MINLEVEL = 20, EN_MAXLEVEL = 21, EN_MIXFRACTION = 22, EN_TANK_KBULK = 23,
  EN_TANKVOLUME = 24, EN_MAXVOLUME = 25
}
 Node property codes. More...
 
enum  EN_LinkProperty {
  EN_DIAMETER = 0, EN_LENGTH = 1, EN_ROUGHNESS = 2, EN_MINORLOSS = 3,
  EN_INITSTATUS = 4, EN_INITSETTING = 5, EN_KBULK = 6, EN_KWALL = 7,
  EN_FLOW = 8, EN_VELOCITY = 9, EN_HEADLOSS = 10, EN_STATUS = 11,
  EN_SETTING = 12, EN_ENERGY = 13, EN_LINKQUAL = 14, EN_LINKPATTERN = 15
}
 Link property codes.
 
enum  EN_TimeProperty {
  EN_DURATION = 0, EN_HYDSTEP = 1, EN_QUALSTEP = 2, EN_PATTERNSTEP = 3,
  EN_PATTERNSTART = 4, EN_REPORTSTEP = 5, EN_REPORTSTART = 6, EN_RULESTEP = 7,
  EN_STATISTIC = 8, EN_PERIODS = 9, EN_STARTTIME = 10, EN_HTIME = 11,
  EN_QTIME = 12, EN_HALTFLAG = 13, EN_NEXTEVENT = 14
}
 Time parameter codes.
 
enum  EN_AnalysisStatistic { EN_ITERATIONS = 0, EN_RELATIVEERROR = 1 }
 
enum  EN_CountType {
  EN_NODECOUNT = 0, EN_TANKCOUNT = 1, EN_LINKCOUNT = 2, EN_PATCOUNT = 3,
  EN_CURVECOUNT = 4, EN_CONTROLCOUNT = 5
}
 
enum  EN_NodeType { EN_JUNCTION = 0, EN_RESERVOIR = 1, EN_TANK = 2 }
 
enum  EN_LinkType {
  EN_CVPIPE = 0, EN_PIPE = 1, EN_PUMP = 2, EN_PRV = 3,
  EN_PSV = 4, EN_PBV = 5, EN_FCV = 6, EN_TCV = 7,
  EN_GPV = 8
}
 
enum  EN_QualityType { EN_NONE = 0, EN_CHEM = 1, EN_AGE = 2, EN_TRACE = 3 }
 
enum  EN_SourceType { EN_CONCEN = 0, EN_MASS = 1, EN_SETPOINT = 2, EN_FLOWPACED = 3 }
 
enum  EN_FlowUnits {
  EN_CFS = 0, EN_GPM = 1, EN_MGD = 2, EN_IMGD = 3,
  EN_AFD = 4, EN_LPS = 5, EN_LPM = 6, EN_MLD = 7,
  EN_CMH = 8, EN_CMD = 9
}
 
enum  EN_Option {
  EN_TRIALS = 0, EN_ACCURACY = 1, EN_TOLERANCE = 2, EN_EMITEXPON = 3,
  EN_DEMANDMULT = 4
}
 Simulation Option codes.
 
enum  EN_ControlType { EN_LOWLEVEL = 0, EN_HILEVEL = 1, EN_TIMER = 2, EN_TIMEOFDAY = 3 }
 
enum  EN_StatisticType { EN_AVERAGE = 1, EN_MINIMUM = 2, EN_MAXIMUM = 3, EN_RANGE = 4 }
 
enum  EN_MixingModel { EN_MIX1 = 0, EN_MIX2 = 1, EN_FIFO = 2, EN_LIFO = 3 }
 
enum  EN_SaveOption { EN_NOSAVE = 0, EN_SAVE = 1, EN_INITFLOW = 10, EN_SAVE_AND_INIT = 11 }
 
enum  EN_CurveType { EN_CONST_HP = 0, EN_POWER_FUNC = 1, EN_CUSTOM = 2 }
 

Functions

int ENepanet (char *inpFile, char *rptFile, char *binOutFile, void(*callback)(char *))
 runs a complete EPANET simulation More...
 
int ENopen (char *inpFile, char *rptFile, char *binOutFile)
 Opens EPANET input file & reads in network data. More...
 
int ENsaveinpfile (char *filename)
 Saves current data to "INP" formatted text file. More...
 
int ENclose ()
 Frees all memory and files used by EPANET. More...
 
int ENsolveH ()
 Solves the network hydraulics for all time periods. More...
 
int ENsaveH ()
 Saves hydraulic results to binary file. More...
 
int ENopenH ()
 Sets up data structures for hydraulic analysis. More...
 
int ENinitH (int initFlag)
 Initializes hydraulic analysis. More...
 
int ENrunH (long *currentTime)
 Run a hydraulic solution period. More...
 
int ENnextH (long *tStep)
 Determine time (in seconds) until next hydraulic event. More...
 
int ENcloseH ()
 Frees data allocated by hydraulics solver. More...
 
int ENsavehydfile (char *filename)
 Copies binary hydraulics file to disk. More...
 
int ENusehydfile (char *filename)
 Opens previously saved binary hydraulics file. More...
 
int ENsolveQ ()
 Solves for network water quality in all time periods. More...
 
int ENopenQ ()
 Sets up data structures for WQ analysis. More...
 
int ENinitQ (int saveFlag)
 Initializes water quality analysis. More...
 
int ENrunQ (long *currentTime)
 Retrieves hydraulic & WQ results at time t. More...
 
int ENnextQ (long *tStep)
 Advances WQ simulation to next hydraulic event. More...
 
int ENstepQ (long *timeLeft)
 Advances WQ simulation by a single WQ time step. More...
 
int ENcloseQ ()
 Frees data allocated by water quality solver. More...
 
int ENwriteline (char *line)
 Writes line of text to the report file. More...
 
int ENreport ()
 Writes simulation report to the report file. More...
 
int ENresetreport ()
 Resets report options to default values. More...
 
int ENsetreport (char *reportFormat)
 Processes a reporting format command. More...
 
int ENgetcontrol (int controlIndex, int *controlType, int *linkIndex, EN_API_FLOAT_TYPE *setting, int *nodeIndex, EN_API_FLOAT_TYPE *level)
 Retrieves parameters that define a simple control. More...
 
int ENgetcount (int code, int *count)
 Retrieves the number of components of a given type in the network. More...
 
int ENgetoption (int code, EN_API_FLOAT_TYPE *value)
 Gets value for an analysis option. More...
 
int ENgettimeparam (int code, long *value)
 Retrieves value of specific time parameter. More...
 
int ENgetflowunits (int *code)
 Retrieves the flow units code. More...
 
int ENgetpatternindex (char *id, int *index)
 Retrieves the index of the time pattern with specified ID. More...
 
int ENgetpatternid (int index, char *id)
 Retrieves ID of a time pattern with specific index. More...
 
int ENgetpatternlen (int index, int *len)
 Retrieves the number of multipliers in a time pattern. More...
 
int ENgetpatternvalue (int index, int period, EN_API_FLOAT_TYPE *value)
 Retrive a multiplier from a pattern for a specific time period. More...
 
int ENgetaveragepatternvalue (int index, EN_API_FLOAT_TYPE *value)
 Retrieve the average multiplier value in a time pattern. More...
 
int ENgetqualtype (int *qualcode, int *tracenode)
 Retrieve the type of quality analytis to be run. More...
 
int ENgeterror (int errcode, char *errmsg, int maxLen)
 Get the text of an error code. More...
 
int ENgetstatistic (int code, EN_API_FLOAT_TYPE *value)
 Get hydraulic simulation statistic. More...
 
int ENgetnodeindex (char *id, int *index)
 Get index of node with specified ID. More...
 
int ENgetnodeid (int index, char *id)
 Get the string ID of the specified node. More...
 
int ENgetnodetype (int index, int *code)
 Get the type of node with specified index. More...
 
int ENgetnodevalue (int index, int code, EN_API_FLOAT_TYPE *value)
 Get a property value for specified node. More...
 
int ENgetcoord (int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
 Get coordinates (x,y) for a node. More...
 
int ENsetcoord (int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y)
 Set coordinates (x,y) for a node. More...
 
int ENgetnumdemands (int nodeIndex, int *numDemands)
 Get the number of demand categories for a node. More...
 
int ENgetbasedemand (int nodeIndex, int demandIndex, EN_API_FLOAT_TYPE *baseDemand)
 Get a node's base demand for a specified category. More...
 
int ENgetdemandpattern (int nodeIndex, int demandIndex, int *pattIndex)
 Get the index of the demand pattern assigned to a node for a category index. More...
 
int ENgetlinkindex (char *id, int *index)
 Get the index of a Link with specified ID. More...
 
int ENgetlinkid (int index, char *id)
 Get the string ID of a link with specified index. More...
 
int ENgetlinktype (int index, int *code)
 Get the link type code for a specified link. More...
 
int ENgetlinknodes (int index, int *node1, int *node2)
 Get the indexes of a link's start- and end-nodes. More...
 
int ENgetlinkvalue (int index, int code, EN_API_FLOAT_TYPE *value)
 Get a property value for specified link. More...
 
int ENgetcurve (int curveIndex, char *id, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues)
 Get a curve's properties. More...
 
int ENgetheadcurveindex (int pumpIndex, int *curveIndex)
 Retrieves the curve index for a specified pump index. More...
 
int ENgetpumptype (int linkIndex, int *outType)
 Get the type of pump. More...
 
int ENgetversion (int *version)
 Get the version number. This number is to be interpreted with implied decimals, i.e., "20100" == "2(.)01(.)00". More...
 
int ENsetcontrol (int cindex, int ctype, int lindex, EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level)
 Specify parameters to define a simple control. More...
 
int ENsetnodevalue (int index, int code, EN_API_FLOAT_TYPE v)
 Set a property value for a node. More...
 
int ENsetlinkvalue (int index, int code, EN_API_FLOAT_TYPE v)
 Set a proprty value for a link. More...
 
int ENaddpattern (char *id)
 Add a new time pattern. More...
 
int ENsetpattern (int index, EN_API_FLOAT_TYPE *f, int len)
 Set multipliers for a specific pattern. More...
 
int ENsetpatternvalue (int index, int period, EN_API_FLOAT_TYPE value)
 Set the multiplier for a specific pattern at a specific period. More...
 
int ENsettimeparam (int code, long value)
 Set the value for a time parameter. More...
 
int ENsetoption (int code, EN_API_FLOAT_TYPE v)
 Set a value for an anlysis option. More...
 
int ENsetstatusreport (int code)
 Sets the level of hydraulic status reporting. More...
 
int ENsetqualtype (int qualcode, char *chemname, char *chemunits, char *tracenode)
 Sets type of quality analysis called for. More...
 
int ENgetqualinfo (int *qualcode, char *chemname, char *chemunits, int *tracenode)
 Get quality analysis information (type, chemical name, units, trace node ID) More...
 
int ENsetbasedemand (int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE baseDemand)
 Sets the node's base demand for a category. More...
 
int ENgetcurveindex (char *id, int *index)
 Retrieves index of curve with specific ID. More...
 
int ENgetcurveid (int index, char *id)
 Retrieves ID of a curve with specific index. More...
 
int ENgetcurvelen (int index, int *len)
 Retrieves number of points in a curve. More...
 
int ENgetcurvevalue (int curveIndex, int pointIndex, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
 retrieves x,y point for a specific point number and curve More...
 
int ENsetcurvevalue (int curveIndex, int pointIndex, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y)
 Sets x,y point for a specific point and curve. More...
 
int ENsetcurve (int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y, int len)
 Sets x,y values for a specified curve. More...
 
int ENaddcurve (char *id)
 Adds a new curve appended to the end of the existing curves. More...
 

Detailed Description

Enumeration Type Documentation

Enumerator
EN_NODECOUNT 

Number of Nodes (Juntions + Tanks + Reservoirs)

EN_TANKCOUNT 

Number of Tanks

EN_LINKCOUNT 

Number of Links (Pipes + Pumps + Valves)

EN_PATCOUNT 

Number of Time Patterns

EN_CURVECOUNT 

Number of Curves

EN_CONTROLCOUNT 

Number of Control Statements

Node property codes.

Enumerator
EN_ELEVATION 

Node Elevation

EN_BASEDEMAND 

Node Base Demand, from last demand category

EN_PATTERN 

Node Demand Pattern

EN_EMITTER 

Node Emitter Coefficient

EN_INITQUAL 

Node initial quality

EN_SOURCEQUAL 

Node source quality

EN_SOURCEPAT 

Node source pattern index

EN_SOURCETYPE 

Node source type

EN_TANKLEVEL 

Tank Level

EN_DEMAND 

Node current simulated demand

EN_HEAD 

Node Head value

EN_PRESSURE 

Node pressure value

EN_QUALITY 

Node quality value

EN_SOURCEMASS 

Node source mass value

EN_INITVOLUME 

Tank or Reservoir initial volume

EN_MIXMODEL 

Tank mixing model

EN_MIXZONEVOL 

Tank mixing zone volume

EN_TANKDIAM 

Tank diameter

EN_MINVOLUME 

Tank minimum volume

EN_VOLCURVE 

Tank volume curve index

EN_MINLEVEL 

Tank minimum level

EN_MAXLEVEL 

Tank maximum level

EN_MIXFRACTION 

Tank mixing fraction

EN_TANK_KBULK 

Tank bulk decay coefficient

EN_TANKVOLUME 

Tank current volume

EN_MAXVOLUME 

Tank maximum volume

Function Documentation

int ENepanet ( char *  inpFile,
char *  rptFile,
char *  binOutFile,
void(*)(char *)  callback 
)

runs a complete EPANET simulation

Parameters
inpFilepointer to name of input file (must exist)
rptFilepointer to name of report file (to be created)
binOutFilepointer to name of binary output file (to be created)
callbacka callback function that takes a character string (char *) as its only parameter.
Returns
error code

The callback function should reside in and be used by the calling code to display the progress messages that EPANET generates as it carries out its computations. If this feature is not needed then the argument should be NULL.

int ENgetbasedemand ( int  nodeIndex,
int  demandIndex,
EN_API_FLOAT_TYPE *  baseDemand 
)

Get a node's base demand for a specified category.

Parameters
nodeIndexThe index of a node (first node is index 1)
demandIndexThe index of the demand category (starting at 1)
Returns
Error code
int ENgetlinkid ( int  index,
char *  id 
)

Get the string ID of a link with specified index.

Parameters
indexThe index of a link (first link is index 1)
[out]idThe ID of the link. Up to MAXID characters will be copied, so id must be pre-allocated by the calling code to hold at least that many characters.
Returns
Error code
See also
ENgetlinkindex
int ENgetlinkindex ( char *  id,
int *  index 
)

Get the index of a Link with specified ID.

Parameters
idThe string ID of a link.
[out]indexThe index of the named link (first link is index 1)
Returns
Error code
See also
ENgetlinkid
int ENgetlinknodes ( int  index,
int *  node1,
int *  node2 
)

Get the indexes of a link's start- and end-nodes.

Parameters
indexThe index of a link (first link is index 1)
[out]node1The index of the link's start node (first node is index 1).
[out]node2The index of the link's end node (first node is index 1).
Returns
Error code
See also
ENgetnodeid, ENgetlinkid
int ENgetlinktype ( int  index,
int *  code 
)

Get the link type code for a specified link.

Parameters
indexThe index of a link (first link is index 1)
[out]codeThe type code of the link.
Returns
Error code
See also
EN_LinkType
int ENgetlinkvalue ( int  index,
int  code,
EN_API_FLOAT_TYPE *  value 
)

Get a property value for specified link.

Parameters
indexThe index of a node (first node is index 1).
codeThe parameter desired.
[out]valueThe value of the link's specified property.
Returns
Error code
See also
ENgetnodevalue, EN_LinkProperty
int ENgetnumdemands ( int  nodeIndex,
int *  numDemands 
)

Get the number of demand categories for a node.

Parameters
nodeIndexThe index of a node (first node is index 1)
[out]numDemandsThe number of demand categories
Returns
Error code
int ENgetqualinfo ( int *  qualcode,
char *  chemname,
char *  chemunits,
int *  tracenode 
)

Get quality analysis information (type, chemical name, units, trace node ID)

Parameters
[out]qualcodeThe EN_QualityType code being used.
[out]chemnameThe name of the WQ constituent.
[out]chemunitsThe cencentration units of the WQ constituent.
[out]tracenodeThe trace node ID.
Returns
Error code.
See also
EN_QualityType
int ENgetversion ( int *  version)

Get the version number. This number is to be interpreted with implied decimals, i.e., "20100" == "2(.)01(.)00".

Parameters
[out]versionThe version of EPANET
Returns
Error code.
int ENsetbasedemand ( int  nodeIndex,
int  demandIdx,
EN_API_FLOAT_TYPE  baseDemand 
)

Sets the node's base demand for a category.

Parameters
nodeIndexThe index of a node.
demandIdxThe index of a demand category.
baseDemandThe base demand multiplier for the selected category.
Returns
Error code.
See also
ENgetbasedemand
int ENsetlinkvalue ( int  index,
int  code,
EN_API_FLOAT_TYPE  v 
)

Set a proprty value for a link.

Parameters
indexThe index of a link. First link is index 1.
codeThe code for the property to set.
vThe value to set for this link and property.
Returns
Error code.
See also
EN_LinkProperty
int ENsetnodevalue ( int  index,
int  code,
EN_API_FLOAT_TYPE  v 
)

Set a property value for a node.

Parameters
indexThe index of a node. First node is index 1.
codeThe code for the proprty to set.
vThe value to set for this node and property.
Returns
Error code.
See also
EN_NodeProperty
int ENsetoption ( int  code,
EN_API_FLOAT_TYPE  v 
)

Set a value for an anlysis option.

Parameters
codeThe code for the desired option.
vThe desired value for the option specified.
Returns
Error code.
See also
EN_Option
int ENsetqualtype ( int  qualcode,
char *  chemname,
char *  chemunits,
char *  tracenode 
)

Sets type of quality analysis called for.

Parameters
qualcodeWQ parameter code, EN_QualityType
chemnameName of WQ constituent
chemunitsConcentration units of WQ constituent
tracenodeID of node being traced (if applicable)
Returns
Error code.
See also
EN_QualityType

chemname and chemunits only apply when WQ analysis is for chemical. tracenode only applies when WQ analysis is source tracing.

int ENsetstatusreport ( int  code)

Sets the level of hydraulic status reporting.

Parameters
codeStatus reporting code.
Returns
Error code.
int ENsettimeparam ( int  code,
long  value 
)

Set the value for a time parameter.

Parameters
codeThe code for the parameter to set.
valueThe desired value of the parameter.
Returns
Error code.
See also
EN_TimeProperty