From 3c788567a43eb6f84c6fedab7586da5402b27d9c Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Mon, 1 May 2017 13:25:59 +0300 Subject: [PATCH] Fix ENsetqualtype to set node initial values When changing from CHEM to AGE or TRACE, nodes initial quality values must be returned to their original ones. Reported by R.T., CSIRO AU - thanks! --- src/epanet.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/epanet.c b/src/epanet.c index 2c25429..31c4a54 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -2305,6 +2305,7 @@ int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits, char { /*** Updated 3/1/01 ***/ double ccf = 1.0; + int i; if (!Openflag) return(102); if (qualcode < EN_NONE || qualcode > EN_TRACE) return(251); @@ -2339,6 +2340,14 @@ int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits, char /*** Updated 3/1/01 ***/ strcpy(Field[QUALITY].Units,u_HOURS); } + + if ((Qualflag == AGE || Qualflag == TRACE) & (Ucf[QUALITY] != 1)) + { + for (i=1; i<=Nnodes; i++) + { + Node[i].C0 *= Ucf[QUALITY]; + } + } /*** Updated 3/1/01 ***/ Ucf[QUALITY] = ccf;