Saturday, January 21, 2023

EPANET 2,2 Code runhyd in EPANET.C

 This code is a function called "runhyd" that solves the network hydraulics for a single time period in a project.

It takes in two parameters, a pointer to a "Project" struct (pr) and a pointer to a long int (t) which will hold the current time in seconds. The function returns an error code.

It first finds new demands and control actions by calling the "demands" and "controls" functions. Then it solves the network hydraulic equations by calling the "hydsolve" function and passing it the pointer to the "Project" struct, the iteration count, and the solution accuracy. If there is no error code, it then checks for system unbalance and activates the "Haltflag" if the error is too high. Finally, it reports any warning conditions by calling the "writehydwarn" function.

The function uses the following variables:

VariablePurpose
hydpointer to the "Hydraul" struct in the "Project" struct
timepointer to the "Times" struct in the "Project" struct
rptpointer to the "Report" struct in the "Project" struct
iteriteration count
errcodeerror code
relerrsolution accuracy

int runhyd(Project *pr, long *t) /* **-------------------------------------------------------------- ** Input: none ** Output: t = pointer to current time (in seconds) ** Returns: error code ** Purpose: solves network hydraulics in a single time period **-------------------------------------------------------------- */ { Hydraul *hyd = &pr->hydraul; Times *time = &pr->times; Report *rpt = &pr->report; int iter; // Iteration count int errcode; // Error code double relerr; // Solution accuracy // Find new demands & control actions *t = time->Htime; demands(pr); controls(pr); // Solve network hydraulic equations errcode = hydsolve(pr,&iter,&relerr); if (!errcode) { // Report new status & save results if (rpt->Statflag) writehydstat(pr,iter,relerr); // If system unbalanced and no extra trials // allowed, then activate the Haltflag if (relerr > hyd->Hacc && hyd->ExtraIter == -1) { hyd->Haltflag = 1; } // Report any warning conditions if (!errcode) errcode = writehydwarn(pr,iter,relerr); } return errcode;

No comments:

ChatGPT Version of the SWMM5 Wikipedia Page Introduction

  The EPA Storm Water Management Model (SWMM) is a computer software that simulates the rainfall-runoff-routing process in urban areas. It o...