From 7e661148638506fde24192ac0112079167b8b189 Mon Sep 17 00:00:00 2001 From: Lew Rossman Date: Sat, 11 May 2024 12:37:52 -0400 Subject: [PATCH 1/5] Changes EMITTER BACKFLOW keyword This change avoids a conflict between the EMITTER EXPONENT and EMITTER BACKFLOW keywords when running a v2.3 input file in the v2.2 EPANET GUI. --- src/inpfile.c | 6 +++--- src/input3.c | 10 +++++----- src/text.h | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/inpfile.c b/src/inpfile.c index e23284d3..b2d82d08 100644 --- a/src/inpfile.c +++ b/src/inpfile.c @@ -1,13 +1,13 @@ /* ****************************************************************************** Project: OWA EPANET -Version: 2.2 +Version: 2.3 Module: inpfile.c Description: saves network data to an EPANET formatted text file Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE -Last Updated: 04/30/2023 +Last Updated: 05/11/2024 ****************************************************************************** */ @@ -682,7 +682,7 @@ int saveinpfile(Project *pr, const char *fname) fprintf(f, "\n PATTERN %s", net->Pattern[hyd->DefPat].ID); fprintf(f, "\n DEMAND MULTIPLIER %-.4f", hyd->Dmult); fprintf(f, "\n EMITTER EXPONENT %-.4f", 1.0 / hyd->Qexp); - fprintf(f, "\n EMITTER BACKFLOW %s", BackflowTxt[hyd->EmitBackFlag]); + fprintf(f, "\n BACKFLOW ALLOWED %s", BackflowTxt[hyd->EmitBackFlag]); fprintf(f, "\n VISCOSITY %-.6f", hyd->Viscos / VISCOS); fprintf(f, "\n DIFFUSIVITY %-.6f", qual->Diffus / DIFFUS); fprintf(f, "\n SPECIFIC GRAVITY %-.6f", hyd->SpGrav); diff --git a/src/input3.c b/src/input3.c index 8c10c10e..1d4f03a7 100644 --- a/src/input3.c +++ b/src/input3.c @@ -7,7 +7,7 @@ Description: parses network data from a line of an EPANET input file Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE -Last Updated: 09/28/2023 +Last Updated: 05/11/2024 ****************************************************************************** */ @@ -1832,7 +1832,7 @@ int optionchoice(Project *pr, int n) ** UNBALANCED STOP/CONTINUE {Niter} ** PATTERN id ** DEMAND MODEL DDA/PDA -** EMITTER BACKFLOW YES/NO +** BACKFLOW ALLOWED YES/NO **-------------------------------------------------------------- */ { @@ -1956,11 +1956,11 @@ int optionchoice(Project *pr, int n) hyd->DemandModel = choice; } - // EMITTER BACKFLOW - else if (match(parser->Tok[0], w_EMITTER)) + // Emitter BACKFLOW ALLOWED + else if (match(parser->Tok[0], w_BACKFLOW)) { if (n < 2) return 0; - if (!match(parser->Tok[1], w_BACKFLOW)) return -1; + if (!match(parser->Tok[1], w_ALLOWED)) return -1; choice = findmatch(parser->Tok[2], BackflowTxt); if (choice < 0) return setError(parser, 2, 213); hyd->EmitBackFlag = choice; diff --git a/src/text.h b/src/text.h index 3f3b50ab..1a78573b 100755 --- a/src/text.h +++ b/src/text.h @@ -1,13 +1,13 @@ /* ****************************************************************************** Project: OWA EPANET - Version: 2.2 + Version: 2.3 Module: text.h Description: string constants used throughout EPANET Authors: see AUTHORS Copyright: see AUTHORS License: see LICENSE - Last Updated: 02/05/2023 + Last Updated: 05/11/2024 ****************************************************************************** */ @@ -130,6 +130,7 @@ #define w_TOLERANCE "TOLER" #define w_EMITTER "EMIT" #define w_BACKFLOW "BACK" +#define w_ALLOWED "ALLOW" #define w_PRICE "PRICE" #define w_DMNDCHARGE "DEMAN" From 9307913c5bb584c7916c49e595915c1aa4c895db Mon Sep 17 00:00:00 2001 From: Dennis <65568528+zannads@users.noreply.github.com> Date: Thu, 23 May 2024 10:24:29 +0300 Subject: [PATCH 2/5] Proposed Fix for Issue #789 See the comment on the Issue. --- src/hydraul.c | 1 + src/quality.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/hydraul.c b/src/hydraul.c index 7d1718b0..36c746e0 100755 --- a/src/hydraul.c +++ b/src/hydraul.c @@ -286,6 +286,7 @@ void closehyd(Project *pr) { freesparse(pr); freematrix(pr); + freeadjlists(pr); } diff --git a/src/quality.c b/src/quality.c index 41869fe5..2b8ccb6f 100644 --- a/src/quality.c +++ b/src/quality.c @@ -410,6 +410,7 @@ int closequal(Project *pr) FREE(qual->FlowDir); FREE(qual->SortedNodes); } + freeadjlists(pr); return errcode; } From d50c6733213d8952daddfd823531527df5e1bbe4 Mon Sep 17 00:00:00 2001 From: Dennis <65568528+zannads@users.noreply.github.com> Date: Thu, 23 May 2024 10:33:30 +0300 Subject: [PATCH 3/5] Fix Issue #790 - incorrect number of pipes The pipe counter was not decreased if the element was a pipe. --- src/epanet.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/epanet.c b/src/epanet.c index 86b510ba..4c8399f7 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -3408,6 +3408,12 @@ int DLLEXPORT EN_deletelink(EN_Project p, int index, int actionCode) if (net->Valve[i].Link > index) net->Valve[i].Link -= 1; } + // Reduce the number of pipes count by one if it is a pipe. + if (linkType == PIPE) + { + net->Npipes--; + } + // Delete any pump associated with the deleted link if (linkType == PUMP) { From a74171fa265ef24931aaf91d4b9a35ab419284c0 Mon Sep 17 00:00:00 2001 From: lbutler Date: Tue, 28 May 2024 22:18:29 -0400 Subject: [PATCH 4/5] Fix emitter-related NaN errors by initializing zero EmitterFlow to 1.0. Co-Authored-By: Lew Rossman --- src/epanet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/epanet.c b/src/epanet.c index 86b510ba..7e3ef8f5 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -2429,6 +2429,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int property, double valu if (value < 0.0) return 209; if (value > 0.0) value = pow((Ucf[FLOW] / value), hyd->Qexp) / Ucf[PRESSURE]; Node[index].Ke = value; + if (hyd->EmitterFlow[index] == 0.0) hyd->EmitterFlow[index] = 1.0; break; case EN_INITQUAL: From 48934c7089701153c5337c3c7299bc967626473a Mon Sep 17 00:00:00 2001 From: lbutler Date: Tue, 28 May 2024 22:23:46 -0400 Subject: [PATCH 5/5] Updated ReleaseNotes for EN_EMITTER bug --- ReleaseNotes2_3.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ReleaseNotes2_3.md b/ReleaseNotes2_3.md index 67680a8a..b2f4ec98 100644 --- a/ReleaseNotes2_3.md +++ b/ReleaseNotes2_3.md @@ -53,3 +53,4 @@ This document describes the changes and updates that have been made in version 2 - `EN_PRESS_UNITS` can now be used with `EN_getoption` and `EN_setoption` to get or set the pressure unit used in EPANET. - Continuous barrier functions were added to constrain emitter flows to allowable values. - The `EN_openx` function has been added to enable the opening of input files with formatting errors through the API. This allows users to continue using toolkit functions even when such errors are present. +- Fixed a bug in EN_setnodevalue with EN_EMITTER option that could cause NaN results. \ No newline at end of file