Merge pull request #797 from lbutler/big-fix-emitter-coefficient

Fix emitter-related NaN errors from EN_setnodevalue API
This commit is contained in:
Lew Rossman
2024-05-29 08:23:56 -04:00
committed by GitHub
2 changed files with 2 additions and 0 deletions

View File

@@ -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. - `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. - 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. - 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.

View File

@@ -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) return 209;
if (value > 0.0) value = pow((Ucf[FLOW] / value), hyd->Qexp) / Ucf[PRESSURE]; if (value > 0.0) value = pow((Ucf[FLOW] / value), hyd->Qexp) / Ucf[PRESSURE];
Node[index].Ke = value; Node[index].Ke = value;
if (hyd->EmitterFlow[index] == 0.0) hyd->EmitterFlow[index] = 1.0;
break; break;
case EN_INITQUAL: case EN_INITQUAL: