Skip to content

Efficiency Issues

Elad Salomons edited this page Sep 23, 2015 · 4 revisions

When making multiple hydraulic analyses on the same network (as would be done in an optimization procedure), do not use repeated calls to ENsolveH. Instead, use an iterated ENrunH - ENnextH loop as shown below:

int stop;
long t, tstep; 
stop = 0; 
do { 
  do { 
    evalresults(t, &stop); 
  } while (tstep > 0 && !stop); 
} while (!stop); 

In the code above, setparams() would be a user-defined function which modifies the network in same manner from one iteration to the next. Another user-defined function, evalresults(), would evaluate the results at time t and set the value of a stop flag that signals the end of the iterations. Note that the argument passed to ENinitH() is 0, indicating that there is no need to save hydraulic results to file since they are being used directly as they are generated. This will also speed up the computations.

When there is a need to make repeated water quality runs using the same hydraulics, then call ENsolveH once to generate and save the hydraulic solution and use code similar to that above for the water quality runs (using the ENopenQ, ENinitQ, ENrunQ, ENnextQ, and ENcloseQ functions instead).

Clone this wiki locally
You can’t perform that action at this time.