OWA-EPANET Toolkit 2.3
Loading...
Searching...
No Matches
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);
}
struct Project * EN_Project
The EPANET Project wrapper object.
Definition epanet2_2.h:49
@ EN_PRESSURE
Current computed pressure (read only)
Definition epanet2_enums.h:48
@ EN_BASEDEMAND
Primary demand baseline value.
Definition epanet2_enums.h:38
int DLLEXPORT EN_initH(EN_Project ph, int initFlag)
Initializes a network prior to running a hydraulic analysis.
int DLLEXPORT EN_closeH(EN_Project ph)
Closes the hydraulic solver freeing all of its allocated memory.
int DLLEXPORT EN_runH(EN_Project ph, long *out_currentTime)
Computes a hydraulic solution for the current point in time.
int DLLEXPORT EN_openH(EN_Project ph)
Opens a project's hydraulic solver.
int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int property, double *out_value)
Retrieves a property value for a node.
int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int property, double value)
Sets a property value for a node.
int DLLEXPORT EN_getnodeindex(EN_Project ph, const char *id, int *out_index)
Gets the index of a node given its ID name.
int DLLEXPORT EN_deleteproject(EN_Project ph)
Deletes a currently opened EPANET project.
int DLLEXPORT EN_createproject(EN_Project *ph)
Creates an EPANET project.
int DLLEXPORT EN_open(EN_Project ph, const char *inpFile, const char *rptFile, const char *outFile)
Reads an EPANET input file with no errors allowed.