Solved the tank level issue. LemonTigerJ now gives right hyd/WQ results.

This commit is contained in:
JinduanChen
2013-01-24 00:48:19 -05:00
parent c622ad66b4
commit 9f8dcadb58
25 changed files with 295 additions and 203 deletions
+55 -24
View File
@@ -16,60 +16,91 @@ int main(int argc, char* argv[]) {
long stime = 0; //simulation time point, = t = Htime
long step = 1; //time to next time point, = tstep = hydstep
long tleft = 0; //time left in the simulation
int id; // some node id
int id, id2, id3; // some node id
float value; // some node/link value
int TIME_A = 3600*10;
int TIME_B = 3600*20; //two time points for testing
int TIME_A = 3600*3;
int TIME_B = 3600*6; //two time points for testing
int TIME_C = 3600*10;
/* Asychronous solver (old epanet) */
printf("*****Original EPANET results******\n");
if (err=ENopen(argv[1], argv[2], "")) return err;
ENgetnodeindex("184", &id);
ENgetnodeindex("184", &id); // a node far away from water source
ENgetlinkindex("101", &id2); // a link close to the lake
ENgetnodeindex("199", &id3); // a node close to the lake (tracer point)
for (ENopenH(), ENinitH(1), step=1;
// must save intermediate results to disk (initH(1)), otherwise WQ solver won't execute
step>0; ) {
step>0; ENnextH(&step)) {
ENrunH(&stime); ENnextH(&step);
printf("stime = %d sec, step = %d sec.\n", stime, step);
ENrunH(&stime);
if (stime == TIME_A || stime == TIME_B || stime == TIME_C) { // grab some results
printf("Hydraulic simulation time = %d sec, step = %d sec.\n", stime, step);
if (stime == TIME_A || stime == TIME_B) { // grab some results
ENgetnodevalue(id, EN_HEAD, &value);
printf("Node 184's head = %f.\n", value);
printf("Node 184's head = \t%f.\n", value);
ENgetlinkvalue(id2, EN_FLOW, &value);
printf("Link 101's flowrate = \t%f. \n", value);
ENgetnodevalue(id3, EN_HEAD, &value);
printf("Node 199's head = \t%f.\n", value);
}
}
ENcloseH();
printf("Reset time pointer and run WQ.\n");
for (ENopenQ(), ENinitQ(0), step=1; step>0; ) {
/* this operation resets the internal time pointer (back to 0)*/
ENrunQ(&stime); ENnextQ(&step);
printf("stime = %d sec, step = %d sec.\n", stime, step);
printf("\nReset time pointer and run WQ.\n");
for (step=1, ENopenQ(), ENinitQ(0); // this operation resets the internal time pointer (back to 0)
step>0; ENnextQ(&step)) {
ENrunQ(&stime);
// grab some results
if (stime == TIME_A || stime == TIME_B) {
if (stime == TIME_A || stime == TIME_B || stime == TIME_C) {
printf("WQ simulation time = %d sec, step = %d sec.\n", stime, step);
ENgetnodevalue(id, EN_QUALITY, &value);
printf("Node 184's quality = %f.\n", value);
printf("Node 184's quality = \t%f.\n", value);
ENgetnodevalue(id3, EN_QUALITY, &value);
printf("Node 199's quality = \t%f.\n", value);
}
}
ENcloseQ();
ENclose();
/* Sychronous solver (LemonTiger) */
printf("\n\n*****LemonTiger results******\n\n");
if (err=ENopen(argv[1], argv[2], "")) return err;
for (ENopeninitHQ(), tleft=Dur; tleft>0; ) {
ENrunstepHQ(&stime, &tleft);
printf("stime = %d sec, time left = %d sec.\n", stime, tleft);
if (stime == TIME_A || stime == TIME_B) {
if (stime == TIME_A || stime == TIME_B || stime == TIME_C) {
//if (! (stime%1800)){
printf("Simulation = %d sec, time left = %d sec.\n", stime, tleft);
ENgetnodevalue(id, EN_HEAD, &value);
printf("Node 184's head = %f.\n", value);
printf("Node 184's head = \t%f.\n", value);
ENgetnodevalue(id, EN_QUALITY, &value);
printf("Node 184's quality = %f.\n", value);
printf("Node 184's quality = \t%f.\n", value);
ENgetnodevalue(id3, EN_HEAD, &value);
printf("Node 199's head = \t%f.\n", value);
ENgetnodevalue(id3, EN_QUALITY, &value);
printf("Node 199's quality = \t%f.\n", value);
ENgetlinkvalue(id2, EN_FLOW, &value);
printf("Link 101's flowrate = \t%f. \n", value);
printf("\n");
}
}
ENcloseHQ();