OWA-EPANET Toolkit  2.2
Nodal Demand Functions

These functions are used for managing nodal demands. More...

Functions

int EN_getdemandmodel (EN_Project ph, int *out_type, double *out_pmin, double *out_preq, double *out_pexp)
 Retrieves the type of demand model in use and its parameters. More...
 
int EN_setdemandmodel (EN_Project ph, int type, double pmin, double preq, double pexp)
 Sets the type of demand model to use and its parameters. More...
 
int EN_adddemand (EN_Project ph, int nodeIndex, double baseDemand, char *demandPattern, char *demandName)
 appends a new demand to a junction node demands list. More...
 
int EN_deletedemand (EN_Project ph, int nodeIndex, int demandIndex)
 deletes a demand from a junction node. More...
 
int EN_getdemandindex (EN_Project ph, int nodeIndex, char *demandName, int *out_demandIndex)
 Retrieves the index of a node's named demand category. More...
 
int EN_getnumdemands (EN_Project ph, int nodeIndex, int *out_numDemands)
 Retrieves the number of demand categories for a junction node. More...
 
int EN_getbasedemand (EN_Project ph, int nodeIndex, int demandIndex, double *out_baseDemand)
 Gets the base demand for one of a node's demand categories. More...
 
int EN_setbasedemand (EN_Project ph, int nodeIndex, int demandIndex, double baseDemand)
 Sets the base demand for one of a node's demand categories. More...
 
int EN_getdemandpattern (EN_Project ph, int nodeIndex, int demandIndex, int *out_patIndex)
 Retrieves the index of a time pattern assigned to one of a node's demand categories. More...
 
int EN_setdemandpattern (EN_Project ph, int nodeIndex, int demandIndex, int patIndex)
 Sets the index of a time pattern used for one of a node's demand categories. More...
 
int EN_getdemandname (EN_Project ph, int nodeIndex, int demandIndex, char *out_demandName)
 Retrieves the name of a node's demand category. More...
 
int EN_setdemandname (EN_Project ph, int nodeIndex, int demandIdx, char *demandName)
 Assigns a name to a node's demand category. More...
 

Overview

These functions are used for managing nodal demands.

Function Documentation

◆ EN_adddemand()

int EN_adddemand ( EN_Project  ph,
int  nodeIndex,
double  baseDemand,
char *  demandPattern,
char *  demandName 
)

appends a new demand to a junction node demands list.

Parameters
phan EPANET project handle.
nodeIndexthe index of a node (starting from 1).
baseDemandthe demand's base value.
demandPatternthe name of a time pattern used by the demand
demandNamethe name of the demand's category
Returns
an error code.

A NULL or blank string can be used for demandPattern and for demandName to indicate that no time pattern or category name is associated with the demand.

◆ EN_deletedemand()

int EN_deletedemand ( EN_Project  ph,
int  nodeIndex,
int  demandIndex 
)

deletes a demand from a junction node.

Parameters
phan EPANET project handle.
nodeIndexthe index of a node (starting from 1).
demandIndexthe position of the demand in the node's demands list (starting from 1).
Returns
an error code.

◆ EN_getbasedemand()

int EN_getbasedemand ( EN_Project  ph,
int  nodeIndex,
int  demandIndex,
double *  out_baseDemand 
)

Gets the base demand for one of a node's demand categories.

Parameters
phan EPANET project handle.
nodeIndexa node's index (starting from 1).
demandIndexthe index of a demand category for the node (starting from 1).
[out]baseDemandthe category's base demand.
Returns
an error code.

◆ EN_getdemandindex()

int EN_getdemandindex ( EN_Project  ph,
int  nodeIndex,
char *  demandName,
int *  out_demandIndex 
)

Retrieves the index of a node's named demand category.

Parameters
phan EPANET project handle.
nodeIndexthe index of a node (starting from 1)
demandNamethe name of a demand category for the node
[out]demandIndexthe index of the demand being sought
Returns
an error code

◆ EN_getdemandmodel()

int EN_getdemandmodel ( EN_Project  ph,
int *  out_type,
double *  out_pmin,
double *  out_preq,
double *  out_pexp 
)

Retrieves the type of demand model in use and its parameters.

Parameters
phan EPANET project handle.
[out]typeType of demand model (see EN_DemandModel).
[out]pminPressure below which there is no demand.
[out]preqPressure required to deliver full demand.
[out]pexpPressure exponent in demand function.
Returns
an error code.

Parameters pmin, preq, and pexp are only used when the demand model is EN_PDA.

◆ EN_getdemandname()

int EN_getdemandname ( EN_Project  ph,
int  nodeIndex,
int  demandIndex,
char *  out_demandName 
)

Retrieves the name of a node's demand category.

Parameters
phan EPANET project handle.
nodeIndexa node's index (starting from 1).
demandIndexthe index of one of the node's demand categories (starting from 1).
[out]out_demandNameThe name of the selected category.
Returns
an error code.

demandName must be sized to contain at least EN_MAXID characters.

◆ EN_getdemandpattern()

int EN_getdemandpattern ( EN_Project  ph,
int  nodeIndex,
int  demandIndex,
int *  out_patIndex 
)

Retrieves the index of a time pattern assigned to one of a node's demand categories.

Parameters
phan EPANET project handle.
nodeIndexthe node's index (starting from 1).
demandIndexthe index of a demand category for the node (starting from 1).
[out]patIndexthe index of the category's time pattern.
Returns
an error code.

A returned pattern index of 0 indicates that no time pattern has been assigned to the demand category.

◆ EN_getnumdemands()

int EN_getnumdemands ( EN_Project  ph,
int  nodeIndex,
int *  out_numDemands 
)

Retrieves the number of demand categories for a junction node.

Parameters
phan EPANET project handle.
nodeIndexthe index of a node (starting from 1).
[out]numDemandsthe number of demand categories assigned to the node.
Returns
an error code.

◆ EN_setbasedemand()

int EN_setbasedemand ( EN_Project  ph,
int  nodeIndex,
int  demandIndex,
double  baseDemand 
)

Sets the base demand for one of a node's demand categories.

Parameters
phan EPANET project handle.
nodeIndexa node's index (starting from 1).
demandIndexthe index of a demand category for the node (starting from 1).
baseDemandthe new base demand for the category.
Returns
an error code.

◆ EN_setdemandmodel()

int EN_setdemandmodel ( EN_Project  ph,
int  type,
double  pmin,
double  preq,
double  pexp 
)

Sets the type of demand model to use and its parameters.

Parameters
phan EPANET project handle.
typeType of demand model (see EN_DemandModel).
pminPressure below which there is no demand.
preqPressure required to deliver full demand.
pexpPressure exponent in demand function.
Returns
an error code.

Set type to EN_DDA for a traditional demand driven analysis (in which case the remaining three parameter values are ignored) or to EN_PDA for a pressure driven analysis. In the latter case a node's demand is computed as:

Dfull * [ (P - pmin) / (preq - pmin) ] ^ pexp

where Dfull is the full demand and P is the current pressure.

Setting preq equal to pmin will result in a solution with the smallest amount of demand reductions needed to insure that no node delivers positive demand at a pressure below pmin.

◆ EN_setdemandname()

int EN_setdemandname ( EN_Project  ph,
int  nodeIndex,
int  demandIdx,
char *  demandName 
)

Assigns a name to a node's demand category.

Parameters
phan EPANET project handle.
nodeIndexa node's index (starting from 1).
demandIdxthe index of one of the node's demand categories (starting from 1).
demandNamethe new name assigned to the category.
Returns
Error code.

The category name must contain no more than EN_MAXID characters.

◆ EN_setdemandpattern()

int EN_setdemandpattern ( EN_Project  ph,
int  nodeIndex,
int  demandIndex,
int  patIndex 
)

Sets the index of a time pattern used for one of a node's demand categories.

Parameters
phan EPANET project handle.
nodeIndexa node's index (starting from 1).
demandIndexthe index of one of the node's demand categories (starting from 1).
patIndexthe index of the time pattern assigned to the category.
Returns
an error code.

Specifying a pattern index of 0 indicates that no time pattern is assigned to the demand category.