epanet_plus

epanet_plus.epanet_wrapper

This module contains a Python wrapper (incl. error handling) for EPANET and EPANET-MSX functions.

class epanet_plus.epanet_wrapper.EpanetAPI(use_project: bool = False, raise_exception_on_error: bool = True, warn_on_error: bool = False, ignore_error_codes: list[int] = [])[source]

Bases: object

Interface for EPANET and EPANET-MSX functions, incl. a proper error handling.

Parameters:
  • use_project (bool, optional) –

    If True, projects will be used when calling EPANET functions (default in EPANET >= 2.2). Note that this is incompatible with EPANET-MSX. Please set to False when using EPANET-MSX.

    The default is False.

  • raise_on_error (bool, optional) –

    True if an exception should be raised in the case of an error/warning, False otherwise.

    The default is True.

  • warn_on_error (bool, optional) –

    True if a warning should be generated in the case of an error/warning, False otherwise.

    The default is False.

  • ignore_error_codes (list[int], optional) –

    List of error codes that should be ignored – i.e., no exception or warning will be generated.

    The default is an empty list.

MSXENclose() None[source]

MSXENclose: pass-thru to close the EPANET toolkit system

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXENopen(inp_file: str, rpt_file: str, out_file: str) None[source]

MSXENopen: pass-thru to open the EPANET toolkit system

Parameters:
  • inp_file (str) – name of the EPANET input file

  • rpt_file (str) – name of the EPANET report file

  • out_file (str) – name of the EPANET output/binary file

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXaddpattern(id: str) None[source]
Parameters:

id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXclose() None[source]

MSXclose: Closes the EPANET-MSX toolkit system.

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXgetID(item_type: int, index: int) str[source]
Parameters:
  • item_type (int)

  • index (int)

Returns:

The ID/name of the specified MSX object. The underlying C function returns a tuple (errcode, id), which _process_result unwraps and returns as a plain string.

Return type:

str

MSXgetIDlen(item_type: int, index: int) int[source]
Parameters:
  • item_type (int)

  • index (int)

Returns:

Maximum number of characters available in the object’s ID. The underlying C function returns a tuple (errcode, length), which _process_result unwraps and returns as a plain integer.

Return type:

int

MSXgetconstant(index: int) float[source]
Parameters:

index (int)

Returns:

The value of the reaction constant. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

MSXgetcount(item_type: int) int[source]
Parameters:

item_type (int)

Returns:

Number of objects of the given type. The underlying C function returns a tuple (errcode, count), which _process_result unwraps and returns as a plain integer.

Return type:

int

MSXgeterror(err_code: int) str[source]
Parameters:

err_code (int)

Returns:

The error message corresponding to the given error code If MSXgeterror itself fails, a RuntimeError is raised.

Return type:

str

MSXgetindex(item_type: int, id: str) int[source]
Parameters:
  • item_type (int)

  • id (str)

Returns:

The index of the MSX item. The underlying C function returns a tuple (errcode, index), which _process_result unwraps and returns as a plain integer.

Return type:

int

MSXgetinitqual(item_type: int, index: int, species: int) float[source]
Parameters:
  • item_type (int)

  • index (int)

  • species (int)

Returns:

Initial concentration of the species at the given object. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

MSXgetparameter(item_type: int, index: int, param: int) float[source]
Parameters:
  • item_type (int)

  • index (int)

  • param (int)

Returns:

The value of the requested MSX parameter. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

MSXgetpatternlen(pat: int) int[source]
Parameters:

pat (int)

Returns:

Number of periods in the MSX pattern. The underlying C function returns a tuple (errcode, length), which _process_result unwraps and returns as a plain integer.

Return type:

int

MSXgetpatternvalue(pat: int, period: int) float[source]
Parameters:
  • pat (int)

  • period (int)

Returns:

The multiplier value for the given pattern period. The underlying C function returns a tuple (errcode, value), which _process_result` unwraps and returns as a plain float.

Return type:

float

MSXgetqual(item_type: int, index: int, species: int) float[source]
Parameters:
  • item_type (int)

  • index (int)

  • species (int)

Returns:

Current concentration of the species at the given object. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

MSXgetsource(node: int, species: int) list[source]
Parameters:
  • node (int)

  • species (int)

Returns:

A list containing information about the source term. The underlying C function returns a tuple (errcode, type, level, pat), which _process_result unwraps and returns as a list.

Return type:

list

MSXgetspecies(index: int) list[source]
Parameters:

index (int)

Returns:

A list containing the attributes of a chemical species. The underlying C function returns a tuple (errcode, type, units, aTol, rTol), which _process_result unwraps and returns as a list.

Return type:

list

MSXinit(save_flag: int) None[source]

MSXinit: Initializes an MSX water quality analsis.

Parameters:

save_flag (int) – Flag indicating whether MSX should save intermediate results.

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXopen(fname: str) None[source]

MSXopen: opens the EPANET-MSX toolkit system.

Parameters:

fname (str) – name of an MSX input file

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXreport() None[source]

MSXreport: Generates the MSX report file defined earlier via MSXENopen().

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsavemsxfile(fname: str) None[source]
Parameters:

fname (str) – File name to save the current MSX model.

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsaveoutfile(fname: str) None[source]

MSXsaveoutfile: Saves all results of the WQ simulation.

Parameters:

fname (str) – Output file to write MSX results to.

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsetconstant(index: int, value: float) None[source]
Parameters:
  • index (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsetinitqual(item_type: int, index: int, species: int, value: float) None[source]
Parameters:
  • item_type (int)

  • index (int)

  • species (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsetparameter(item_type: int, index: int, param: int, value: float) None[source]
Parameters:
  • item_type (int)

  • index (int)

  • param (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsetpattern(pat: int, mult: list[float], len: int) None[source]
Parameters:
  • pat (int)

  • mult (list[float])

  • len (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsetpatternvalue(pat: int, period: int, value: float) None[source]
Parameters:
  • pat (int)

  • period (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsetsource(node: int, species: int, item_type: int, level: float, pat: int) None[source]
Parameters:
  • node (int)

  • species (int)

  • item_type (int)

  • level (float)

  • pat (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsolveH() None[source]

MSXsolveH: Runs the hydraulic solver for MSX.

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXsolveQ() None[source]

MSXsolveQ: Runs the water-quality solver for MSX.

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

MSXstep() list[source]

MSXstep: Advances the MSX water‑quality simulation by one time step.

Returns:

A list containing the current time (seconds) and the time remaining until the next quality step (seconds). The underlying C function returns a tuple (errcode, t, tleft), which _process_result unwraps and returns as a list.

Return type:

list

MSXusehydfile(fname: str) None[source]

MSXusehydfile: registers a hydraulics solution file with the MSX system.

Parameters:

fname (str) – A hydraulic file

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

addcontrol(type: int, link_index: int, setting: float, node_index: int, level: float) int[source]

EN_addcontrol

Parameters:
  • type (int)

  • link_index (int)

  • setting (float)

  • int (node_index .)

  • level (float)

Returns:

The index of the newly added control. The underlying C function returns a tuple (errcode, index), which _process_result unwraps and returns as a plain integer.

Return type:

int

addcurve(id: str) None[source]

EN_addcurve

Parameters:

id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

adddemand(node_index: int, base_demand: float, demand_pattern: str, demand_name: str) None[source]

EN_adddemand

node_index : int base_demand : float demand_pattern : str demand_name : str

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

EN_addlink

Parameters:
  • id (str)

  • link_type (int)

  • from_node (str)

  • to_node (str)

Returns:

The index of the newly added link. The underlying C function returns a tuple (errcode, index), which _process_result unwraps and returns as a plain integer.

Return type:

int

addnode(node_id: str, node_type: int) int[source]

EN_addnode

Parameters:
  • node_id (str)

  • node_type (int)

Returns:

The index of the newly added node. The underlying C function returns a tupel (errcode, index), which _process_result unwraps and returns as a plain integer.

Return type:

int

addpattern(id: str) None[source]

EN_addpattern

Parameters:

id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

addrule(rule: str) None[source]

EN_addrule

Parameters:

rule (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

clearreport() None[source]

EN_clearreport

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

close() None[source]

EN_close

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

closeH() None[source]

EN_closeH

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

closeQ() None[source]

EN_closeQ

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

copyreport() None[source]

EN_copyreport

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

createproject() int[source]

EN_createproject

Returns:

The project handle created by EN_createproject. The underlying C function returns a tuple (errcode, handle), which _process_result unwraps and returns only the handle.

Return type:

int

deletecontrol(index: int) None[source]

EN_deletecontrol

Parameters:

index (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

deletecurve(index: int) None[source]

EN_deletecurve

Parameters:

index (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

deletedemand(node_index: int, demand_index: int) None[source]

EN_deletedemand

Parameters:
  • node_index (int)

  • demand_index (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

EN_deletelink

Parameters:
  • index (int)

  • action_code (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

deletenode(index: int, action_code: int) None[source]

EN_deletenode

Parameters:
  • index (int)

  • action_code (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

deletepattern(index: int) None[source]

EN_deletepattern

Parameters:

index (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

deleteproject() None[source]

EN_deleteproject

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Raises RuntimeError on failure.

Return type:

None

deleterule(index: int) None[source]

EN_deleterule

Parameters:

index (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

get_last_error_code() int[source]

Returns the code of the last EPANET-(MSX) error/warnning (if any).

Refer to the EPANET documentation for a list of all possible warning codes and their meanings.

Returns:

Code of the last error/warning. 0, if there was no error/warning.

Return type:

int

get_last_error_desc() str[source]

Returns the description of the last EPANET-(MSX) error/warning (if any).

Returns:

Description of the last error/warning. None, if there was no error/warning.

Return type:

str

getaveragepatternvalue(index: int) float[source]

EN_getaveragepatternvalue

Parameters:

index (int)

Returns:

The average multiplier value of the specified pattern. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

getbasedemand(node_index: int, demand_index: int) float[source]

EN_getbasedemand

Parameters:
  • node_index (int)

  • demand_index (int)

Returns:

The base demand value for the specified demand at the given node. The underlying C function returns a tuple (errcode, baseDemand), which _process_result unwraps and returns as a plain float.

Return type:

float

getcomment(obj: int, index: int) str[source]

EN_getcomment

Parameters:
  • obj (int)

  • index (int)

Returns:

The comment string associated with the given object and index. The underlying C function returns a tuple (errcode, comment), which _process_results unwraps and returns as a plain string.

Return type:

str

getcontrol(index: int) list[source]

EN_getcontrol

Parameters:

index (int)

Returns:

A list containing the properties of the specified control. The underlying C function returns a tuple (errcode, type, linkIndex, setting, nodeIndex, level), which _process_result unwraps and returns as a list of these values.

Return type:

list

getcontrolenabled(control_idx: int) int[source]

EN_getcontrolenabled: Gets the enabled status of a simple control.

Parameters:

control_idx (int)

Returns:

1 if the control is enabled, 0 if disabled. The underlying C function returns a tuple (errcode, enabled), which _process_result unwraps and returns as a plain integer.

Return type:

int

getcoord(index: int) list[source]

EN_getcoord

Parameters:

index (int)

Returns:

A list containing the x- and y-coordinates of the node: [x, y]. The underlying C function returns a tuple (errcode, x, y), which _process_result unwraps and returns as a list of two floats.

Return type:

list

getcount(obj: int) int[source]

EN_getcount

Parameters:

obj (int)

Returns:

The number of the objects of the given type. The underlying C function returns a tuple (errcode, count), which _process_result unwraps and returns as a plain integer

Return type:

int

getcurve(index: int) list[source]

EN_getcurve

Parameters:

index (int)

Returns:

  • A list [x_values, y_values] containing the curve’s point

  • coordinates. The underlying C function returns

  • (errcode, xValuesList, yValuesList), which _process_result

  • unwraps and returns as a list of two lists of floats.

getcurveid(index: int) str[source]

EN_getcurveid

Parameters:

index (int)

Returns:

The ID of the curve at the given index. The underlying C function returns a tuple (errcode, id), which _process_result unwraps and returns as a plain string.

Return type:

str

getcurveindex(id: str) int[source]

EN_getcurveindex

Parameters:

id (str)

Returns:

The index of the curve with the given ID. The underlying C function returns a tuple (errcode, idnex), which _process_result unwraps and returns as a plain integer.

Return type:

int

getcurvelen(index: int) int[source]

EN_getcurvelen

Parameters:

index (int)

Returns:

The number of points in the specified curve. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain integer.

Return type:

int

getcurvetype(index: int) int[source]

EN_getcurvetype

Parameters:

index (int)

Returns:

The type of the curve at the given index. The underlying C function returns a tuple (errcode, type), which _process_result unwraps and returns as a plain integer.

Return type:

int

getcurvevalue(curve_index: int, point_index: int) list[source]

EN_getcurvevalue

Parameters:
  • curve_index (int)

  • point_index (int)

Returns:

A list [x, y] containing the coordinates of the specified curve point. The underlying C function returns (errcode, x, y), which _process_result unwraps and returns as a list of two floats.

Return type:

list

getdemandindex(node_index: int, demand_name: str) int[source]

EN_getdemandindex

Parameters:
  • node_index (int)

  • demand_name (str)

Returns:

The index of the demand with the given name at the specified node. The underlying C function returns a tuple (errcode, demandIndex), which _process_result unwraps and returns as a plain integer.

Return type:

int

getdemandmodel() list[source]

EN_getdemandmodel

Returns:

A list containing the demand model parameters: [type, pmin, preq, pexp]. The underlying C function returns a tuple (errcode, type, pmin, preq, pexp), which _process_result unwraps and returns as a list of these values.

Return type:

list

getdemandname(node_index: int, demand_index: int) str[source]

EN_getdemandname

Parameters:
  • node_index (int)

  • demand_index (int)

Returns:

The name of the specified demand. The underlying C function returns a tuple (errcode, demandName), which _process_result unwraps and returns as a plain string.

Return type:

str

getdemandpattern(node_index: int, demand_index: int) int[source]

EN_getdemandpattern

Parameters:
  • node_index (int)

  • demand_index (int)

Returns:

The index of the demand pattern assigned to the specified demand. The underlying C function returns a tuple (errcode, patIndex), which _process_result unwraps and returns as a plain integer.

Return type:

int

getelseaction(rule_index: int, action_index: int) list[source]

EN_getelseaction

Parameters:
  • rule_index (int)

  • action_index (int)

Returns:

A list containing the properties of an ELSE-action. The underlying C function returns a tuple (errcode, linkIndex, status, setting), which _process_result unwraps and returns as a list.

Return type:

list

geterror(error_code: int) str[source]

EN_geterror

Parameters:

error_code (int)

Returns:

The descriptive error message associated with the given error code. The underlying C function returns a tuple (errcode, errmsg). If retrieving the message fails, a RuntimeError is raised.

Return type:

str

getflowunits() int[source]

EN_getflowunits

Returns:

The flow units used in the project. The underlying C function returns a tuple (errcode, units), which _process_results unwraps and returns as a plain integer.

Return type:

int

getheadcurveindex(link_index: int) int[source]

EN_getheadcurveindex

Parameters:

link_index (int)

Returns:

The index of the head curve assigned to the pump. The underlying C function returns a tuple (errcode, curveIndex), which _process_result unwraps and returns as a plain integer.

Return type:

int

getlinkid(index: int) str[source]

EN_getlinkid

Parameters:

index (int)

Returns:

The ID of the link at the given index. The underlying C function returns a tuple (errcode, id), which _process_result unwraps and returns as a plain string.

Return type:

str

getlinkindex(link_id: str) int[source]

EN_getlinkindex

Parameters:

link_id (str)

Returns:

The index of the link with the given ID. The underlying C function returns a tuple (errcode, index), which _process_result unwraps and returns as a plain integer.

Return type:

int

getlinknodes(index: int) list[source]

EN_getlinknodes

Parameters:

index (int)

Returns:

A list containing the indices of the upstream and downstream nodes of the link: [node1, node2]. The underlying C function returns a tuple (errcode, node1, node2), which _process_result unwraps and returns as a list of two integers.

Return type:

list

getlinktype(index: int) int[source]

EN_getlinktype

Parameters:

index (int)

Returns:

The type of the link at the given index. The underlying C function returns a tuple (errcode, linkType), which _process_result unwraps and returns as a plain integer.

Return type:

int

getlinkvalue(index: int, property: int) float[source]

EN_getlinkvalue

Parameters:
  • index (int)

  • property (int)

Returns:

The value of the specified link property. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

getlinkvalues(property: int) list[float][source]

EN_getlinkvalues

Parameters:

property (int)

Returns:

A list of link property values. The underlying C function returns a tuple (errcode, valuesList), which _process_result unwraps and returns as a plain list of floats.

Return type:

list[float]

getlinkvalues_numpy(property: int) numpy.ndarray[source]

EN_getlinkvalues (NumPy compatible)

Parameters:

property (int)

Returns:

A NumPy array of link property values. The underlying C function returns a tuple (errcode, array), which _process_result unwraps and returns as a NumPy array.

Return type:

numpy.ndarray

getnodeid(index: int) str[source]

EN_getnodeid

Parameters:

index (int)

Returns:

The ID of the node at the given index. The underlying C function returns a tuple (errcode, id), which _process_result unwraps and returns as a plain string.

Return type:

str

getnodeindex(node_id: str) int[source]

EN_getnodeindex

Parameters:

node_id (str)

Returns:

The index of the node with the given ID. The underlying C function returns a tuple (errcode, index), which _process_result unwraps and returns as a plain integer.

Return type:

int

getnodetype(index: int) int[source]

EN_getnodetype

Parameters:

index (int)

Returns:

The type of the node at the given index. The underlying C function returns a tuple (errcode, nodeType), which _process_result unwraps and returns as a plain integer.

Return type:

int

getnodevalue(index: int, node_property: int) float[source]

EN_getnodevalue

Parameters:
  • index (int)

  • node_property (int)

Returns:

The value of the specified node property. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

getnodevalues(property: int) list[float][source]

EN_getnodevalues

Parameters:

property (int)

Returns:

A list of node property values. The underlying C function returns a tuple (errcode, valuesList), which _process_result unwraps and returns as a plain list of floats.

Return type:

list[float]

getnodevalues_numpy(property: int) numpy.ndarray[source]

EN_getnodevalues (NumPy compatible)

Parameters:

property (int)

Returns:

A NumPy array of node property values. The underlying C function returns a tuple (errcode, array), which _process_result unwraps and returns as a NumPy array.

Return type:

numpy.ndarray

getnumdemands(node_index: int) int[source]

EN_getnumdemands

Parameters:

node_index (int)

Returns:

The number of demands defined for the specified node. The underlying C function returns a tuple (errcode, numDemands), which _process_result unwraps and returns as a plain integer.

Return type:

int

getoption(option: int) float[source]

EN_getoption

Parameters:

option (int)

Returns:

The value of the specfied analysis option. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

getpatternid(index: int) str[source]

EN_getpatternid

Parameters:

index (int)

Returns:

The ID of the pattern at the given index. The underlying C function returns a tuple (errcode, id), which _process_result unwraps and returns as a plain string.

Return type:

str

getpatternindex(pattern_id: str) int[source]

EN_getpatternindex

Parameters:

pattern_id (str)

Returns:

The index of the pattern with the given ID. The underlying C function returns a tuple (errcode, index), which _process_result unwraps and returns as a plain integer.

Return type:

int

getpatternlen(index: int) int[source]

EN_getpatternlen

Parameters:

index (int)

Returns:

The number of periods in the specified pattern. The underlying C function returns a tuple (errcode, length), which _process_result unwraps and returns as a plain integer.

Return type:

int

getpatternvalue(index: int, period: int) float[source]

EN_getpatternvalue

Parameters:
  • index (int)

  • period (int)

Returns:

The multiplier value for the specified pattern period. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

getpremise(rule_index: int, premise_index: int) list[source]

EN_getpremise

Parameters:
  • rule_index (int)

  • premise_index (int)

Returns:

A list describing the premise. The underlying C function returns a tuple (errcode, logop, object, objIndex, variable, relop, status, value), which _process_result unwraps and returns as a list.

Return type:

list

getpumptype(link_index: int) int[source]

EN_getpumptype

Parameters:

link_index (int)

Returns:

The pump type of the specified link. The underlying C function returns a tuple (errcode, pumpType), which _process_result unwraps and returns as a plain integer.

Return type:

int

getqualinfo() list[source]

EN_getqualinfo

Returns:

A list containing: [qualType, chemName, chemUnits, traceNode]. The underlying C function returns a tuple (errcode, qualType, chemName, chemUnits, traceNode), which _process_result unwraps and returns as a list of these values.

Return type:

list

getqualtype() list[source]

EN_getqualtype

Returns:

A list containing: [qualType, traceNode]. The underlying C function returns a tuple (errdcode, qualType, traceNode), which _process_results unwraps and returns a list of these values.

Return type:

list

getresultindex(result_type: int, index: int) int[source]

EN_getresultindex

Parameters:
  • result_type (int)

  • index (int)

Returns:

The index of the requested result variable. The underlying C function returns a tuple (errcode, value), which process_result unwraps and returns as a plain integer.

Return type:

int

getrule(index: int) list[source]

EN_getrule

Parameters:

index (int)

Returns:

A list describing the rule structure. The underlying C function returns a tuple (errcode, nPremises, nThenActions, nElseActions, priority), which _process_result unwraps and returns as a list of these values.

Return type:

list

getruleenabled(rule_idx: int) int[source]

EN_getruleenabled: Gets the enabled status of a rule-based control.

Parameters:

rule_idx (int)

Returns:

1 if the rule is enabled, 0 if disabled. The underlying C function returns a tuple (errcode, enabled), which _process_result unwraps and returns as a plain integer.

Return type:

int

getruleid(index: int) str[source]

EN_getruleID

Parameters:

index (int)

Returns:

The ID of the rule at the given index. The underlying C function returns a tuple (errcode, id), which _process_result unwraps and returns as a plain string.

Return type:

str

getstatistic(stat_type: int) float[source]

EN_getstatistic

Parameters:

stat_type (int)

Returns:

The requested project statistic. The underlying C function returns a tuple (errcode, value), which _process_result unwraps and returns as a plain float.

Return type:

float

gettag(obj_type: int, obj_idx: int) str[source]

EN_gettag

Parameters:
  • obj_type (int)

  • obj_idx (int)

Returns:

The tag assigned to the object. The underlying C function returns a tuple (errcode, tag), which _process_result unwraps and returns as a plain string.

Return type:

str

getthenaction(rule_index: int, action_index: int) list[source]

EN_getthenaction

Parameters:
  • rule_index (int)

  • action_index (int)

Returns:

A list containing the properties of a THEN-action. The underlying C function returns a tuple (errcode, linkIndex, status, setting), which _process_result unwraps and returns as a list.

Return type:

list

gettimeparam(param: int) int[source]

EN_gettimeparam

Parameters:

param (int)

Returns:

The requested time parameter (in seconds). The underlying C function returns a tuple (errcode, value), which _process_result unwraps and retruns as a plain integer.

Return type:

int

gettitle() list[str][source]

EN_gettitle

Returns:

A list containing the three title lines of the EPANET project. The underlying C function returns a tuple (errcode, line1, line2, line3), which _process_result unwraps and returns as a list of three strings.

Return type:

list[str]

getversion() int[source]

EN_getversion

Returns:

The EPANET version number. The underlying C function returns a tuple (errcode, version), which _process_result unwraps and returns as a plain integer.

Return type:

int

getvertex(index: int, vertex: int) list[source]

EN_getvertex

Parameters:
  • index (int)

  • vertex (int)

Returns:

A list [x, y] containing the coordinates of the specified vertex. The underlying C function returns a tuple (errcode, x, y), which _process_result unwraps and returns as a list of two floats.

Return type:

list

getvertexcount(index: int) int[source]

EN_getvertexcount

Parameters:

index (int)

Returns:

The number of vertices associated with the link. The underlying C function returns a tuple (errcode, count), which _process_result unwraps and returns as a plain integer.

Return type:

int

init(rptFile: str, outFile: str, unitsType: int, headLossType: int) None[source]

EN_init

Parameters:
  • rptFile (str)

  • outFile (str)

  • unitsType (int)

  • headLossType (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

initH(initFlag: int) None[source]

EN_initH

Parameters:

initFlag (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

initQ(save_flag: int) None[source]

EN_initQ

Parameters:

save_flag (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

loadpatternfile(filename: str, id: str) None[source]

EN_loadpatternfile

Parameters:
  • filename (str)

  • id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

nextH() int[source]

EN_nextH

Returns:

The next hydraulic time step (in seconds). The underlying C function returns a tuple (errcode, tStep), which _process_result unwraps and returns as a plain integer.

Return type:

int

nextQ() int[source]

EN_nextQ

Returns:

The next water quality simulation time (in seconds). The underlying C funtion returns a tuple (errcode, currentTime), which _process_result unwraps and returns as a plain integer.

Return type:

int

open(inpFile: str, rptFile: str, outFile: str) None[source]

EN_open

Parameters:
  • inpFile (str)

  • rptFile (str)

  • outFile (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

openH() None[source]

EN_openH

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

openQ() None[source]

EN_openQ

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

openX(inpFile: str, rptFile: str, outFile: str) None[source]

EN_openX

Parameters:
  • inpFile (str)

  • rptFile (str)

  • outFile (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

openfrombuffer(inpBuffer: str, inpFile: str, rptFile: str, outFile: str) int[source]

EN_openfrombuffer – extension of EPANET and part of EPANET-PLUS

Parameters:
  • inpBuffer (str)

  • inpFile (str)

  • rptFile (str)

  • outFile (str)

Returns:

Error code returned by ENopenfrombuffer / EN_openfrombuffer. The underlying C function returns a tuple containing a single integer (the error code), which _process_result unwraps and returns as a plain int.

Return type:

int

property ph: int

Returns a pointer (memory address) to the project structure.

Returns:

Pointer to project structure – please do not change or access the memory location!

Return type:

int

report() None[source]

EN_report

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

resetreport() None[source]

EN_resetreport

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

runH() int[source]

EN_runH

Returns:

The current simulation time (in seconds). The underlying C function returns a tuple (errcode, currentTime), which _process_result unwraps and returns as a plain integer.

Return type:

int

runQ() int[source]

EN_runQ

Returns:

The current water quality simulation time (in seconds). The underlying C funtion returns a tuple (errcode, currentTime), which _process_result unwraps and returns as a plain integer.

Return type:

int

saveH() None[source]

EN_saveH

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

savehydfile(filename) None[source]

EN_savehydfile

Parameters:

filename (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

saveinpfile(filename: str) None[source]

EN_saveinpfile

Parameters:

filename (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

set_error_handling(raise_exception_on_error: bool, warn_on_error: bool, ignore_error_codes: list[int] = []) None[source]

Specifies the behavior in the case of an error/warning – i.e. should an exception or warning be raised or not?

Parameters:
  • raise_exception_on_error (bool) – True if an exception should be raised, False otherwise.

  • warn_on_error (bool) – True if a warning should be generated, False otherwise.

  • ignore_error_codes (list[int]) – List of error codes that should be ignored – i.e., no exception or warning will be generated.

setbasedemand(node_index: int, demand_index: int, base_demand: float) None[source]

EN_setbasedemand

Parameters:
  • node_index (int)

  • demand_index (int)

  • base_demand (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setcomment(obj: int, index: int, comment: str) None[source]

EN_setcomment

Parameters:
  • obj (int)

  • index (int)

  • comment (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setcontrol(index: int, type: int, link_index: int, setting: float, node_index: int, level: float) None[source]

EN_setcontrol

Parameters:
  • index (int)

  • type (int)

  • link_index (int)

  • setting (float)

  • node_index (int)

  • level (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setcontrolenabled(control_idx: int, enabled: int) None[source]

EN_setcontrolenabled

Parameters:
  • control_idx (int)

  • enabled (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setcoord(index: int, x: float, y: float) None[source]

EN_setcoord

Parameters:
  • index (int)

  • x (float)

  • y (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setcurve(index: int, x_values: list[float], y_values: list[float], n_points: int) None[source]

EN_setcurve

Parameters:
  • index (int)

  • x_values (list[float])

  • y_values (list[float])

  • n_points (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setcurveid(index: int, id: str) None[source]

EN_setcurveid

Parameters:
  • index (int)

  • id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setcurvetype(curve_idx: int, curve_type: int) None[source]

EN_setcurvetype

Parameters:
  • curve_idx (int)

  • curve_type (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setcurvevalue(curve_index: int, point_index: int, x: float, y: float) None[source]

EN_setcurvevalue

Parameters:
  • curve_index (int)

  • point_index (int)

  • x (float)

  • y (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setdemandmodel(demand_type: int, pmin: float, preq: float, pexp: float) None[source]

EN_setdemandmodel

Parameters:
  • demand_type (int)

  • pmin (float)

  • preq (float)

  • pexp (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setdemandname(node_index: int, demand_index: int, demand_name: str) None[source]

EN_setdemandname

Parameters:
  • node_index (int)

  • demand_index (int)

  • demand_name (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setdemandpattern(node_index: int, demand_index: int, pat_index: int) None[source]

EN_setdemandpattern

Parameters:
  • node_index (int)

  • demand_index (int)

  • pat_index (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setelseaction(rule_index: int, action_index: int, link_index: int, status: int, setting: float) None[source]

EN_setelseaction

Parameters:
  • rule_index (int)

  • action_index (int)

  • link_index (int)

  • status (int)

  • setting (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setflowunits(units: int) None[source]

EN_setflowunits

Parameters:

units (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setheadcurveindex(link_index: int, curve_index: int) None[source]

EN_setheadcurveindex

Parameters:
  • link_index (int)

  • curve_index (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setjuncdata(index: int, elev: float, dmnd: float, dmnd_pat: str) None[source]

EN_setjuncdata

Parameters:
  • index (int)

  • elev (float)

  • dmnd (float)

  • dmdn_pat (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setlinkid(index: int, new_id: str) None[source]

EN_setlinkid

Parameters:
  • index (int)

  • new_id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setlinknodes(index: int, node1: int, node2: int) None[source]

EN_setlinknodes

Parameters:
  • index (int)

  • node1 (int)

  • node2 (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setlinktype(index: int, link_type: int, action_code: int) int[source]

EN_setlinktype

Parameters:
  • index (int)

  • link_type (int)

  • action_code (int)

Returns:

The (possibly updated) link index. The underlying C function returns a tuple (errcode, input_index), which _process_result unwraps and returns as a plain integer.

Return type:

int

setlinkvalue(index: int, property: int, value: float) None[source]

EN_setlinkvalue

Parameters:
  • index (int)

  • property (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setlinkvalues(property: int, values: list[float]) int[source]

EN_setlinkvalues

Parameters:
  • property (int)

  • values (list[float])

Returns:

The index of the first link for which the update failed. The underlying C function returns a tuple (errcode, badIndex), which _process_result unwraps and returns as a plain integer. A return value of 0 indicates that all updates succeeded.

Return type:

int

setnodeid(index: int, new_id: str) None[source]

EN_setnodeid

Parameters:
  • index (int)

  • new_id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setnodevalue(index: int, node_property: int, value: float) None[source]

EN_setnodevalue

Parameters:
  • index (int)

  • node_property (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setnodevalues(node_property: int, values: list[float]) None[source]

EN_setnodevalues

Parameters:
  • node_property (int)

  • values (list[float])

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setoption(option: int, value: float) None[source]

EN_setoption

Parameters:
  • option (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setpattern(index: int, values: list[float], len: int) None[source]

EN_setpattern

Parameters:
  • index (int)

  • values (list[float])

  • len (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setpatternid(index: int, id: str) None[source]

EN_setpatternid

Parameters:
  • index (int)

  • id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setpatternvalue(index: int, period: int, value: float) None[source]

EN_setpatternvalue

Parameters:
  • index (int)

  • period (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setpipedata(index: int, length: float, diam: float, rough: float, mloss: float) None[source]

EN_setpipedata

Parameters:
  • index (int)

  • length (float)

  • diam (float)

  • rough (float)

  • mloss (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setpremise(rule_index: int, premise_index: int, logop: int, object: int, obj_index: int, variable: int, relop: int, status: int, value: float) None[source]

EN_setpremise

Parameters:
  • rule_index (int)

  • premise_index (int)

  • logop (int)

  • object (int)

  • obj_index (int)

  • variable (int)

  • relop (int)

  • status (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setpremiseindex(rule_index: int, premise_index: int, obj_index: int) None[source]

EN_setpremiseindex

Parameters:
  • rule_index (int)

  • premise_index (int)

  • obj_index (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setpremisestatus(rule_index: int, premise_index: int, status: int) None[source]

EN_setpremisestatus

Parameters:
  • rule_index (int)

  • premise_index (int)

  • status (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setpremisevalue(rule_index: int, premise_index: int, value: float) None[source]

EN_setpremisevalue

Parameters:
  • rule_index (int)

  • premise_index (int)

  • value (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setqualtype(qual_type: int, chem_name: str, chem_units: str, trace_node_id: str) None[source]

EN_setqualtype

Parameters:
  • qual_type (int)

  • chem_name (str)

  • chem_units (str)

  • trace_node_id (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setreport(format_desc: str) None[source]

EN_setreport

Parameters:

format_desc (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setruleenabled(rule_idx: int, enabled: int) None[source]

EN_setruleenabled

Parameters:
  • rule_idx (int)

  • enabled (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setrulepriority(index: int, priority: float) None[source]

EN_setrulepriority

Parameters:
  • index (int)

  • priority (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setstatusreport(level: int) None[source]

EN_setstatusreport

Parameters:

level (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

settag(obj_type: int, obj_idx: int, tag: str) None[source]

EN_settag

Parameters:
  • obj_type (int)

  • obj_idx (int)

  • tag (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

settankdata(index: int, elev: float, initlvl: float, minlvl: float, maxlvl: float, diam: float, minvol: float, volcurve: str) None[source]

EN_settankdata

Parameters:
  • index (int)

  • elev (float)

  • initlvl (float)

  • minlvl (float)

  • maxlvl (float)

  • diam (float)

  • minvol (float)

  • volcurve (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setthenaction(rule_index: int, action_index: int, link_index: int, status: int, setting: float) None[source]

EN_setthenaction

Parameters:
  • rule_index (int)

  • action_index (int)

  • link_index (int)

  • status (int)

  • setting (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

settimeparam(param: int, value: int) None[source]

EN_settimeparam

Parameters:
  • param (int)

  • value (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

settitle(line1: str, line2: str, line3: str) None[source]

EN_settitle

Parameters:
  • line1 (str)

  • line2 (str)

  • line3 (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setvertex(link_idx: int, vertex_idx: int, x: float, y: float) None[source]

EN_setvertex

Parameters:
  • link_idx (int)

  • vertex_idx (int)

  • x (float)

  • y (float)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

setvertices(index: int, x: list[float], y: list[float], count: int) None[source]

EN_setvertices

Parameters:
  • index (int)

  • x (list[float])

  • y (list[float])

  • count (int)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

solveH() None[source]

EN_solveH

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

solveQ() None[source]

EN_solveQ

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

stepQ() int[source]

EN_stepQ

Returns:

The remaining water quality simulation time (in seconds). The underlying C funtion returns a tuple (errcode, currentTime), which _process_result unwraps and returns as a plain integer.

Return type:

int

timetonextevent() list[source]

EN_timetonextevent

Returns:

A list containing information about when the next hydraulic time step occurs. The underlying C function returns a tuple (errcode, eventType, duration, elemIndex), which _process_result unwraps and returns as a list.

Return type:

list

property use_project: bool

Returns whether EPANET projects are used or not.

Returns:

True, if EPANET projects are used, False otherwise.

Return type:

bool

usehydfile(filename: str) None[source]

EN_usehydfile

Parameters:

filename (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

was_last_func_successful() bool[source]

Checks if the last EPANET call was successful or not.

Parameters:

bool – True if the last EPANET call returned an error/warning, False otherwise.

writeline(line: str) None[source]

EN_writeline

Parameters:

line (str)

Returns:

The underlying C function returns a tuple containing only the error code (errcode,), which _process_result unwraps and returns as None. Errors trigger warnings or exceptions depending on configuration.

Return type:

None

epanet_plus.epanet_toolkit

This module contains a Python toolkit with higher-level functions for working with EPANET and EPANET-MSX.

class epanet_plus.epanet_toolkit.EPyT(inp_file_in: str | None = None, msx_file_in: str | None = None, use_project: bool = False, inp_buffer: str | None = None, **kwds)[source]

Bases: EpanetAPI

Python toolkit for EPANET and EPANET-MSX.

Parameters:
  • inp_file_in (str, optional) –

    Path to .inp file. Note that the file will be created automatically if it does not exist.

    If None, an empty network will be created in the temp folder.

    The default is None.

  • msx_file_in (str, optional) –

    Path to .msx file. If this is not None, use_project must be set to False.

    The default is None.

  • use_project (bool, optional) –

    If True, projects will be used when calling EPANET functions (default in EPANET >= 2.2). Note that this is incompatible with EPANET-MSX. Please set to False when using EPANET-MSX or when specifying an .msx file in msx_file_in.

    The default is False.

  • inp_buffer (str, optional,) –

    Buffer containing the network – i.e., content of an .inp file.

    The default is None.

add_control(control_type: int, link_index: int, setting: float, node_index: int, level: float) None[source]

Adds a control.

Parameters:
  • control_type (int) –

    Type of control. Must be one of the following:

    • EN_LOWLEVEL

    • EN_HILEVEL

    • EN_TIMER

    • EN_TIMEOFDAY

  • link_index (int) – Index of the link (i.e., valve or pump) that is being controlled.

  • setting (float) – Link control setting (e.g., pump speed).

  • node_index (int) – Index of the node that is controlling the link.

  • level (float) – Control activation level – pressure for junction nodes, water level for tank nodes or time value for time-based control.

add_curve(curve_id: str, values: list[tuple[float, float]]) None[source]

Adds a new curve – e.g., a head curve for a pump or a volume curve for a (non-cylindric) tank.

Parameters:
  • curve_id (str) – ID of the curve.

  • values (list[tuple[float, float]]) – Curve values/points.

add_msx_pattern(pattern_id: str, pattern_mult: list[float]) None[source]

Adds a new MSX pattern.

Parameters:
  • pattern_id (str) – ID of the new pattern.

  • pattern_mult (list[float]) – Pattern values (i.e., multipliers).

add_pattern(pattern_id: str, pattern_values: list[float]) None[source]

Adds a new pattern.

Parameters:
  • pattern_id (str) – ID of the pattern.

  • pattern_values (list[float]) – Pattern values.

can_tank_overflow(tank_idx: int) bool[source]

Checks if a given tank can overflow or not.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

True if the tank can overflow, False otherwise.

Return type:

bool

close() None[source]

Closes EPANET and EPANET-MSX, and deletes all temprorary files.

get_all_bulk_species_id() list[str][source]

Returns the IDs of all bulk species.

Returns:

List of IDs.

Return type:

list[int]

get_all_bulk_species_idx() list[int][source]

Returns the indices of all bulk species.

Returns:

List of indices.

Return type:

list[int]

get_all_junctions_id() list[str][source]

Returns all junction IDs – i.e., IDs of nodes that are neither a reservoir nor a tank.

Returns:

List of all junction IDs.

Return type:

list[str]

get_all_junctions_idx() list[int][source]

Returns all junction indices – i.e., indices of nodes that are neither a reservoir nor a tank.

Returns:

List of all junction indices.

Return type:

list[int]

Returns a list of all connecting node IDs for each link in the network.

Returns:

List of tuple of connecting node IDs of all links.

Return type:

list[tuple[str]]

Returns all link IDs.

Returns:

List of all link IDs.

Return type:

list[str]

Returns all link indcies.

Returns:

List of all link indices.

Return type:

list[int]

get_all_msx_pattern_id() list[str][source]

Returns a list of the IDs of all MSX patterns.

Returns:

List of patterns (IDs).

Return type:

list[str]

get_all_msx_species_id() list[str][source]

Returns a list of all species IDs.

Returns:

List of all species IDs.

Return type:

list[str]

get_all_msx_species_info() list[dict][source]

Returns information about all species.

Returns:

List of species information – ordered by species index.# Each entry in the list contains a dictionary with the following entries:

  • ’type’: MSX_BULK for a bulk flow species or MSX_WALL for a surface species;

  • ’units’: mass units;

  • ’atol’: absolute concentration tolerance (concentration units);

  • ’rtol’: relative concentration tolerance (unitless);

Return type:

list[dict]

get_all_nodes_id() list[str][source]

Returns all node IDs.

Returns:

List of node IDs.

Return type:

list[str]

get_all_nodes_idx() list[int][source]

Returns all node indices.

Returns:

List of node indices:

Return type:

list[int]

get_all_patterns_id() list[str][source]

Returns a list of all pattern IDs.

Returns:

List of IDs.

Return type:

list[str]

get_all_pipes_id() list[str][source]

Returns the IDs of all pipes in the network.

Returns:

List of pipe IDs.

Return type:

list[str]

get_all_pipes_idx() list[int][source]

Return the indices of all pipes in the network.

Returns:

List of pipe indices.

Return type:

list[int]

get_all_pumps_id() list[str][source]

Returns all pump IDs.

Returns:

List of all pump IDs.

Return type:

list[str]

get_all_pumps_idx() list[int][source]

Returns all pump_indices.

Returns:

List of all pump indices.

Return type:

list[int]

get_all_reservoirs_id() list[str][source]

Returns all reservoir IDs.

Returns:

List of all reservoir IDs.

Return type:

list[str]

get_all_reservoirs_idx() list[int][source]

Returns all reservoir indices.

Returns:

List of all reservoir indices.

Return type:

list[int]

get_all_rules_id() list[str][source]

Returns the IDs of all rules.

Returns:

List of rule IDs – ordered by their index.

Return type:

list[str]

get_all_tanks_id() list[str][source]

Returns all tank IDs.

Returns:

List of all tank IDs.

Return type:

list[str]

get_all_tanks_idx() list[int][source]

Returns all tank indices.

Returns:

List of all tank indices.

Return type:

list[int]

get_all_valves_id() list[str][source]

Returns a list of all valve IDs.

Returns:

List of all valve IDs.

Return type:

list[str]

get_all_valves_idx() list[int][source]

Returns all valve indices.

Returns:

List of all valve indices.

Return type:

list[int]

get_all_wall_species_id() list[str][source]

Returns the IDs of all wall species.

Returns:

List of IDs.

Return type:

list[int]

get_all_wall_species_idx() list[int][source]

Returns the indices of all wall species.

Returns:

List of indices.

Return type:

list[int]

get_curve(curve_id: str) list[tuple[float, float]][source]

Returns the values/points of a given curve.

Parameters:

curve_id (str) – ID of the curve.

Returns:

List of all values/points of the curve.

Return type:

list[tuple[float, float]]

get_demand_model() dict[source]

Returns the specifications of the demand model.

Returns:

Dictionary contains the specifications of the demand model:

  • ’type’: type of demand model (either EN_DDA or EN_PDA);

  • ’pmin’: minimum pressure for any demand;

  • ’preq’: required pressure for full demand;

  • ’pexp’: exponent in pressure dependent demand formula;

Return type:

dict

get_hydraulic_time_step() int[source]

Returns the hydraulic time step in seconds.

Returns:

Hydraulic time step.

Return type:

int

get_limiting_concentration() float[source]

Returns the limiting concentration in reactions.

Returns:

Limiting concentration.

Return type:

float

Returns the bulk decay rate at a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Bulk decay rate.

Return type:

float

Returns the bulk reaction coefficient of a link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Bulk reaction coefficient.

Return type:

float

Returns the diameter of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Diameter of the link.

Return type:

float

Returns the current flow rate at a given link.

Parameters:

link_idx – Index of the link.

Returns:

Current flow rate.

Return type:

float

Returns the ID of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

ID of the link.

Return type:

str

Returns the index of a given link.

Parameters:

link_id (str) – ID of the link.

Returns:

Index of the link.

Return type:

int

Returns the initial setting of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Initial setting.

Return type:

float

Returns the initial status (open or closed) of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Initial status of the link. Will be one of the following:

  • EN_CLOSED

  • EN_OPEN

Return type:

int

Returns the length of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Length of the link.

Return type:

float

Returns the minor loss coefficient of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Minor loss coefficient of the link.

Return type:

float

Returns the current quality value (e.g., concentration, age, …) at a given link.

Parameters:

link_idx – Index of the link.

Returns:

Current link quality value.

Return type:

float

Returns the roughness coefficient of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Roughness coefficient of the link.

Return type:

float

Returns the type of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Type of the link. Will be one of the following:

  • EN_CVPIPE

  • EN_PIPE

  • EN_PUMP

  • EN_PRV

  • EN_PSV

  • EN_PBV

  • EN_FCV

  • EN_TCV

  • EN_GPV

Return type:

int

Returns the wall decay rate at a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Wall decay rate.

Return type:

float

Returns the wall reaction coefficient of a given link.

Parameters:

link_idx (int) – Index of the link.

Returns:

Wall reaction coefficient.

Return type:

float

get_msx_options() dict[source]

Returns the MSX options as specified in the .msx file.

Returns:

Dictionary of MSX options as specified in the .msx file – note that not all options might be specified. Possible options (dictinary keys) are: REA_UNITS, RATE_UNITS, SOLVER, COUPLING, TIMESTEP, ATOL, RTOL, COMPILER, SEGMENTS, PECLET

Return type:

dict

get_msx_pattern(pattern_idx: int) list[float][source]

Returns a particular MSX pattern – i.e., returns the multipliers.

Parameters:

pattern_idx (int) – Index of the pattern.

Returns:

Pattern multipliers.

Return type:

list[float]

get_msx_species_concentration(obj_type: int, obj_index: int, species_idx: int) float[source]

Returns the current concentration of a given species at a given location in the network.

Parameters:
  • obj_type (int) –

    Type of the location (i.e., node or link). Must be one of the following:

    • MSX_NODE

    • MSX_LINK

  • obj_index (int) – Index of the link or node.

  • species_idx (int) – Index of the species.

Returns:

Species concentration.

Return type:

float

get_msx_species_idx(species_id) int[source]

Returns the index of a given species.

Parameters:

species_id (str) – ID of the species.

Returns:

Index of the species.

Return type:

int

get_msx_species_info(species_idx: int) dict[source]

Returns information about a given species.

Parameters:

species_idx (int) – Index of the species.

Returns:

Information as a dictionary. Will contains the following entries:

  • ’type’: MSX_BULK for a bulk flow species or MSX_WALL for a surface species;

  • ’units’: mass units;

  • ’atol’: absolute concentration tolerance (concentration units);

  • ’rtol’: relative concentration tolerance (unitless);

Return type:

dict

get_msx_species_init_concentration(obj_type: int, obj_index: int, species_idx: int) float[source]

Returns the initial concentration of a given species at a given location in the network.

Parameters:
  • obj_type (int) –

    Type of the location (i.e., node or link). Must be one of the following:

    • MSX_NODE

    • MSX_LINK

  • obj_index (int) – Index of the link or node.

  • species_idx (int) – Index of the species.

Returns:

Initial concentration.

Return type:

float

get_msx_time_step() int[source]

Returns the MSX time step.

Returns:

Time step.

Return type:

int

get_node_base_demand(node_idx: int) float[source]

Returns the primary base demand of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Primary base demand.

Return type:

int

get_node_base_demands(node_idx: int) list[float][source]

Returns all base demands of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

List of base demands.

Return type:

list[int]

get_node_comment(node_idx: int) str[source]

Returns the comment of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Comment.

Return type:

str

get_node_demand(node_idx: int) float[source]

Returns the current demand at a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Current demand.

Return type:

float

get_node_demand_patterns_idx(node_idx: int) list[int][source]

Returns the index of all demand patterns of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

List of indices of the demand patterns.

Return type:

list[int]

get_node_elevation(node_idx: int) float[source]

Returns the evelvation of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Elevation.

Return type:

float

get_node_emitter_coeff(node_idx: int) float[source]

Returns the roughness coefficient of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Emitter coefficient of the node.

Return type:

float

get_node_head(node_idx: int) float[source]

Returns the current hydraulic head at a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Current hydraulic head.

Return type:

float

get_node_id(node_idx) str[source]

Returns the ID of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

ID of the node.

Return type:

str

get_node_idx(node_id: str) int[source]

Returns the index of a given node.

Parameters:

node_id (str) – ID of the node.

Returns:

Index of the node.

Return type:

int

get_node_init_qual(node_idx: int) float[source]

Returns the initial quality value/state of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Initial quality state/value.

Return type:

float

get_node_init_quality(node_idx: int) float[source]

Returns the initial quality (e.g., concentration) of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Initial quality.

Return type:

float

get_node_pattern_idx(node_idx: int) float[source]

Returns the index of the primary demand pattern of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Index of the primary demand pattern.

Return type:

int

get_node_pressure(node_idx: int) float[source]

Returns the current pressure at a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Current pressure.

Return type:

float

get_node_quality(node_idx: int) float[source]

Returns the current quality value at a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Current node quality value.

Return type:

float

get_node_source_pattern_idx(node_idx: int) int[source]

Returns the index of the quality source pattern at a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Index of the pattern.

Return type:

int

get_node_source_qual(node_idx: int) float[source]

Returns the current quality state/value at a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Current quality state/value.

Return type:

float

get_node_source_type(node_idx: int) int[source]

Returns the type of the water quality source at a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Type of the water quality source. Will be one of the following:

  • EN_CONCEN

  • EN_MASS

  • EN_SETPOINT

  • EN_FLOWPACED

Return type:

int

get_node_type(node_idx: int) int[source]

Returns the type of a given node.

Parameters:

node_idx (int) – Index of the node.

Returns:

Type of the node. Will be one of the following:

  • EN_JUNCTION

  • EN_TANK

  • EN_RESERVOIR

Return type:

int

get_num_controls() int[source]

Returns the number of controls.

Returns:

Number of controls.

Return type:

int

get_num_junctions() int[source]

Returns the number of junctions – i.e., number of nodes that are neither a tank nor a reservoir.

Returns:

Number of junctions.

Return type:

int

Returns the number of links in the network.

Returns:

Number of links.

Return type:

int

get_num_msx_species() int[source]

Returns the total number of bulk and wall species.

Returns:

Number of species.

Return type:

int

get_num_nodes() int[source]

Returns the number of nodes in the network.

Returns:

Number of nodes.

Return type:

int

get_num_pipes() int[source]

Returns the number of pipes in the network.

Returns:

Returns the maximum number of pipes.

Return type:

int

get_num_pumps() int[source]

Returns the number of pumps in the network.

Returns:

Number of pumps.

Return type:

int

get_num_reservoirs() int[source]

Returns the number of reservoirs in the network.

Returns:

Number of reservoirs.

Return type:

int

get_num_rules() int[source]

Returns the numer of rules.

Returns:

Number of rules.

Return type:

int

get_num_tanks() int[source]

Returns the number of tanks in the network.

Returns:

Number of tanks.

Return type:

int

get_num_valves() int[source]

Returns the number of valves.

Returns:

Number of valves.

Return type:

int

get_pattern(pattern_idx: int) list[float][source]

Returns the values of a given pattern.

Parameters:

pattern_idx (int) – Index of the pattern.

Returns:

Pattern values.

Return type:

list[float]

get_pattern_start_time() int[source]

Returns the pattern offset in seconds, which will start to be applied at simulation start.

Returns:

Pattern offset time.

Return type:

int

get_pattern_time_step() int[source]

Returns the pattern time step in seconds.

Returns:

Pattern time step.

Return type:

int

get_pipe_bulk_reaction_order() int[source]

Returns the the pipe bulk reaction order.

Returns:

Reaction order.

Return type:

int

get_pipe_wall_reaction_order() int[source]

Returns the pipe wall reaction order.

Returns:

Reaction oder.

Return type:

int

get_pump_avg_energy_price(pump_idx: int) float[source]

Returns the average energy price of a given pump.

Parameters:

pump_idx (int) – Index of the pump

Returns:

Average energy price.

Return type:

float

get_pump_efficiency(pump_idx: int) float[source]

Returns the current effciency of a given pump.

Parameters:

pump_idx (int) – Index of the pump

Returns:

Current pump effciency.

Return type:

float

get_pump_energy_price_pattern(pump_idx) int[source]

Returns the index of the energy price pattern of a given pump.

Parameters:

pump_idx (int) – Index of the pump.

Returns:

Pattern index.

Return type:

int

get_pump_energy_usage(pump_idx: int) float[source]

Returns the current energy usage of a given pump.

Parameters:

pump_idx (int) – Index of the pump

Returns:

Current energy usage.

Return type:

float

get_pump_pattern(pump_idx: int) int[source]

Returns the pattern of a given pump.

Parameters:

pump_idx (int) – Index of the pump

Returns:

Index of the pump pattern.

Return type:

int

get_pump_status(pump_idx: int) int[source]

Returns the current pump status.

Parameters:

pump_idx (int) – Index of the pump.

Returns:

Current pump status. Will be one of the following:

  • EN_PUMP_XHEAD

  • EN_PUMP_CLOSED

  • EN_PUMP_OPEN

  • EN_PUMP_XFLOW

Return type:

int

get_pump_type(pump_idx: int) int[source]

Returns the type (type of pump curve) of a given pump.

Parameters:

pump_idx (int) – Index of the pump.

Returns:

Pump curve type. Will be one of the following:

  • EN_CONST_HP

  • EN_POWER_FUNC

  • EN_CUSTOM

  • EN_NOCURVE

Return type:

int

get_quality_info() dict[source]

Returns the water quality analysis parameters.

Returns:

Water quality analysis information as a dictionary with the following entries:

  • ’qualType’: type of quality analysis (EN_NONE, EN_CHEM, EN_AGE, or EN_TRACE);

  • ’chemName’: name of chemical constituent;

  • ’chemUnits’: concentration units of constituent;

  • ’traceNode’: ID of node being traced (if applicable,

    only if ‘qualType’ = EN_TRACE);

Return type:

dict

get_quality_time_step() int[source]

Returns the quality time step in seconds.

Returns:

Quality time step.

Return type:

int

get_quality_tolerance() float[source]

Returns the water quality tolerance.

Returns:

Water quality tolerance.

Return type:

float

get_quality_type() dict[source]

Returns the type of quality analysis.

Returns:

Dictioanry containing the type of quality analysis and the ID of the node being traced (if applicable):

  • ’qualType’: type of quality analysis (EN_NONE, EN_CHEM, EN_AGE, or EN_TRACE);

  • ’traceNode’: ID of node being traced (if applicable, only if ‘qualType’ = EN_TRACE);

Return type:

dict

get_reporting_start_time() int[source]

Returns the reporting start time in seconds since the simulation start.

Returns:

Reporting start time.

Return type:

int

get_reporting_time_step() int[source]

Returns the reporting time step in seconds.

Returns:

Reporting time step.

Return type:

int

get_simulation_duration() int[source]

Returns the simulation duration in seconds.

Returns:

Simulation duration.

Return type:

int

get_specific_diffusivity() float[source]

Returns the specific diffusivity.

Returns:

Specific diffusivity.

Return type:

float

get_specific_gravity() float[source]

Returns the specific gravity.

Returns:

Specific gravity.

Return type:

float

get_specific_viscosity() float[source]

Returns the specific viscosity.

Returns:

Specific viscosity.

Return type:

float

get_tank_bulk_decacy(tank_idx: int) float[source]

Returns the bulk decay rate in a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Bulk decay rate.

Return type:

float

get_tank_bulk_reaction_coeff(tank_idx: int) float[source]

Returns the bulk reaction coefficient of a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Bulk reaction coefficient.

Return type:

float

get_tank_bulk_reaction_order() int[source]

Returns the bulk reaction order in tanks.

Returns:

Bulk reaction order.

Return type:

int

get_tank_diameter(tank_idx: int) float[source]

Return the diameter of given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Diameter of the tank.

Return type:

float

get_tank_init_vol(tank_idx) float[source]

Return the inital water volume in a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Initial water volume.

Return type:

float

get_tank_level(tank_idx: int) float[source]

Returns the current water level in a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Current water level.

Return type:

float

get_tank_max_level(tank_idx: int) float[source]

Returns the maximum water level of a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Maximum water level.

Return type:

float

get_tank_max_vol(tank_idx: int) float[source]

Return the maxmium volume of given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Maximum volume.

Return type:

float

get_tank_min_level(tank_idx: int) float[source]

Returns the minimum water level of a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Minimum water level.

Return type:

float

get_tank_min_vol(tank_idx: int) float[source]

Return the minimum volume of given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Minimum volume.

Return type:

float

get_tank_mix_fraction(tank_idx: int) float[source]

Returns the mixing fraction of a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Mixing fraction.

Return type:

float

get_tank_mix_model(tank_idx: int) int[source]

Returns the mixing model of a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Type of mixing model. Will be one of the following:

  • EN_MIX1

  • EN_MIX2

  • EN_FIFO

  • EN_LIFO

Return type:

int

get_tank_mix_zone_vol(tank_idx: int) float[source]

Returns the mixing zone volume of a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Tank mixing zone valume.

Return type:

float

get_tank_vol_curve_idx(tank_idx: int) int[source]

Returns the index of the volume curve of a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Index of the volume curve.

Return type:

int

get_tank_volume(tank_idx: int) float[source]

Returns the current water volume inside a given tank.

Parameters:

tank_idx (int) – Index of the tank.

Returns:

Current water volume.

Return type:

float

get_valve_status(valve_idx: int) int[source]

Returns the current status of a given valve.

Parameters:

valve_idx (int) – Index of the valve.

Returns:

Current status. Will be one of the following:

  • EN_CLOSED

  • EN_OPEN

Return type:

int

load_msx_file(msx_file_in: str) None[source]

Loads an EPANET-MSX file.

Parameters:

msx_file_in (str) – Path to .msx file.

property msx_file: str

Returns the file path to the .msx file.

Returns:

File path to .msx file.

Return type:

str

remove_all_controls() None[source]

Removes all controls.

remove_all_rules() None[source]

Removes all rules.

remove_curve(curve_id: str) None[source]

Deletes a given curve.

Parameters:

curve_id (str) – ID of the curve.

set_demand_model(model_type: int, pmin: float, preq: float, pexp: float) None[source]

Specifies the demand model.

Parameters:
  • model_type (int) –

    Type of demand model. Must be one of the following:

    • EN_DDA

    • EN_PDA

  • pmin (float) – Minimum pressure for any demand.

  • preq (float) – Required pressure for full demand.

  • pexp (float) – Exponent in pressure dependent demand formula.

set_hydraulic_time_step(time_step: int) None[source]

Specifies the hydraulic time step.

Parameters:

time_step (int) – Hydraulic time step in seconds.

set_msx_source(node_id: str, species_id: str, source_type: int, source_concentration: float, msx_pattern_id: str) None[source]

Adds a species source (i.e., injection of a given species) at a given node.

Parameters:
  • node_id (str) – ID of the node where the species in injected into the network.

  • species_id (str) – ID of the species to be injected.

  • source_type (int) –

    Type of injection/source. Must be one of the following:

    • MSX_NOSOURCE = -1 for no source,

    • MSX_CONCEN = 0 for a concentration source,

    • MSX_MASS = 1 for a mass booster source,

    • MSX_SETPOINT = 2 for a setpoint source,

    • MSX_FLOWPACED = 3 for a flow paced source;

  • source_concentration (float) – Injetion concentration – can change over time according the the pattern of multiplies.

  • msx_pattern_id (str) – ID of the injection pattern – i.e., multipliers.

set_msx_time_step(time_step: int) None[source]

Specifies the MSX time step.

Parameters:

time_step (int) – New MSX time step.

set_node_data(node_idx: int, elev: float, base_demand: float, demand_pattern_id: str) None[source]

Specifies some properties, such as elevation and demand, of a given node.

Parameters:
  • node_idx (int) – Index of the node.

  • elev (float) – Elevation of the node.

  • base_demand (float) – Base demand of the node.

  • demand_pattern_id (str) – ID of the primary demand pattern of the node.

set_node_init_quality(node_idx: int, init_qual: float) None[source]

Specifies the initial quality (e.g., concentration) of a given node.

Parameters:
  • node_idx (int) – Index of the node.

  • init_qual (float) – Initial quality.

set_node_source(node_idx: int, source_type: int, source_strengh: float, pattern_idx: int) None[source]

Specifies the quality source of a given node.

Parameters:
  • node_idx (int) – Index of the node.

  • source_type (int) –

    Type of the source. Must be one of the following:

    • EN_CONCEN

    • EN_MASS

    • EN_SETPOINT

    • EN_FLOWPACED

  • source_strength (float) – Source strength.

  • pattern_idx (int) – Index of the source pattern.

set_node_source_quality(node_idx, source_strength: float) None[source]

Specifies the strength of a node quality source.

Parameters:
  • node_idx (int) – Index of the node.

  • source_strength (float) – Source strength.

set_pattern(pattern_idx: int, pattern_values: list[float]) None[source]

Set the values of a given pattern.

Parameters:
  • pattern_idx (int) – Index of the pattern.

  • pattern_values (list[float]) – New pattern values.

set_pattern_start_time(start_time: int) None[source]

Specifies the pattern offset in seconds, which will start to be applied at simulation start.

Parameters:

start_time (int) – Pattern offset time step in seconds since simulation start.

set_pattern_time_step(time_step: int) None[source]

Specifies the pattern time step.

Parameters:

time_step (int) – Pattern time step in seconds.

set_pump_avg_energy_price(pump_idx: int, price: float) float[source]

Specifies the average energy price of a given pump.

Parameters:
  • pump_idx (int) – Index of the pump

  • price (float) – Average energy price.

set_pump_energy_price_pattern(pump_idx: int, pattern_idx: int) None[source]

Sets the energy price pattern of a given pump.

Parameters:
  • pump_idx (int) – Index of the pump.

  • pattern_idx (int) – Index of the pattern.

set_pump_pattern(pump_idx: int, pattern_idx: int) None[source]

Specifies the pattern of a given pump.

Parameters:
  • pump_idx (int) – Index of the pump

  • pattern_idx (int) – Index of the pattern.

set_pump_status(pump_idx: int, status: int) None[source]

Sets the the current status of a given pump.

Parameters:
  • pump_idx (int) – Index of the pump

  • status (int) –

    Pump status. Must be one of the following:

    • EN_CLOSED

    • EN_OPEN

set_quality_time_step(time_step: int) None[source]

Specifies the water quality time step.

Parameters:

time_step (int) – Water quality time step in seconds.

set_quality_type(qual_code: int, chem_name: str, chem_units: str, tracenode_id: str) None[source]

Specifies the water quality analysis parameters.

Parameters:
  • qual_code (int) –

    Type of quality analysis. Must be one of the following:

    • EN_NONE

    • EN_CHEM

    • EN_AGE

    • EN_TRACE

  • chem_name (str) – Name of chemical constituent

  • chem_units (str) – Concentration units of constituent

  • tracenode_id (str) – ID of node being traced (if applicable, only if ‘qualType’ = EN_TRACE).

set_reporting_start_time(start_time: int) None[source]

Specifies the start time of reporting.

Parameters:

start_time (int) – Reporting start time step in seconds since simulation start.

set_reporting_time_step(time_step: int) None[source]

Specifies the reporting time step.

Parameters:

time_step (int) – Reporting time step in seconds.

set_simulation_duration(duration: int) None[source]

Sets the simulation duration.

Parameters:

duration (int) – Simulation duration in seconds.

set_valve_status(valve_idx, status: int)[source]

Sets the current status of a given valve.

Parameters:
  • valve_idx (int) – Index of the valve.

  • status (int) –

    New status of the valve. Must be one of the following:

    • EN_CLOSED

    • EN_OPEN

split_pipe(pipe_id: str, new_pipe_id: str, new_node_id: str) None[source]

Splits a pipe (pipeID), creating two new pipes (pipeID and newPipeID) and adds a junction/node (newNodeID) in between. If the pipe is linear the pipe is splitted in half, otherwisw the middle point of the vertice array elemnts is taken as the split point. The two new pipes have the same properties as the one which is splitted. The new node’s properties are the same with the nodes on the left and right and New Node Elevation and Initial quality is the average of the two.

Note that this code is taken from EPyT – slightly modified to fit into this toolkit.

Parameters:
  • pipe_id (str) – ID of the pipe to be split.

  • new_pipe_id (str) – ID of the new pipe.

  • new_node_id (str) – ID of the new node, placed in the middle of the splitted pipe.

class epanet_plus.epanet_toolkit.EpanetConstants[source]

Bases: object

EPANET and EPANET-MSX constants.