OWA-EPANET Toolkit  2.2
Hydrant Rating Curve Example

This example illustrates how the Toolkit could be used to develop a hydrant rating curve used in fire flow studies. This curve shows the amount of flow available at a node in the system as a function of pressure. The curve is generated by running a number of steady state hydraulic analyses with the node of interest subjected to a different demand in each analysis. For this example we assume that the ID label of the node of interest is MyNode and that N different demand levels stored in the array D need to be examined. The corresponding pressures will be stored in P. To keep the code more readable, no error checking is made on the results returned from the Toolkit function calls.

#include "epanet2_2.h"
void HydrantRating(char *MyNode, int N, double D[], double P[])
{
int i, nodeindex;
long t;
double pressure;
// Create a project
// Retrieve network data from an input file
EN_open(ph, "example2.inp", "example2.rpt", "");
// Open the hydraulic solver
EN_openH(ph);
// Get the index of the node of interest
EN_getnodeindex(ph, MyNode, &nodeindex);
// Iterate over all demands
for (i=1; i<N; i++)
{
// Set nodal demand, initialize hydraulics, make a
// single period run, and retrieve pressure
EN_setnodevalue(ph, nodeindex, EN_BASEDEMAND, D[i]);
EN_initH(ph, 0);
EN_runH(ph, &t);
EN_getnodevalue(ph, nodeindex, EN_PRESSURE, &pressure);
P[i] = pressure;
}
// Close hydraulics solver & delete the project
EN_closeH(ph);
}
EN_getnodevalue
int EN_getnodevalue(EN_Project ph, int index, int property, double *value)
Retrieves a property value for a node.
EN_closeH
int EN_closeH(EN_Project ph)
Closes the hydraulic solver freeing all of its allocated memory.
EN_open
int EN_open(EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile)
Opens an EPANET input file & reads in network data.
EN_setnodevalue
int EN_setnodevalue(EN_Project ph, int index, int property, double value)
Sets a property value for a node.
EN_Project
struct Project * EN_Project
The EPANET Project wrapper object.
Definition: epanet2_2.h:49
EN_getnodeindex
int EN_getnodeindex(EN_Project ph, char *id, int *index)
Gets the index of a node given its ID name.
EN_BASEDEMAND
Primary demand baseline value.
Definition: epanet2_enums.h:40
EN_createproject
int EN_createproject(EN_Project *ph)
Creates an EPANET project.
EN_PRESSURE
Current computed pressure (read only)
Definition: epanet2_enums.h:50
EN_openH
int EN_openH(EN_Project ph)
Opens a project's hydraulic solver.
EN_runH
int EN_runH(EN_Project ph, long *currentTime)
Computes a hydraulic solution for the current point in time.
EN_deleteproject
int EN_deleteproject(EN_Project ph)
Deletes a currently opened EPANET project.
EN_initH
int EN_initH(EN_Project ph, int initFlag)
Initializes a network prior to running a hydraulic analysis.
epanet2_2.h