From a74171fa265ef24931aaf91d4b9a35ab419284c0 Mon Sep 17 00:00:00 2001 From: lbutler Date: Tue, 28 May 2024 22:18:29 -0400 Subject: [PATCH 1/2] 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 86b510b..7e3ef8f 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 2/2] 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 67680a8..b2f4ec9 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