OpenWaterAnalytics / EPANET

The Water Distribution System Hydraulic and Water Quality Analysis Toolkit
MIT License
280 stars 205 forks source link

Issue with Volume Curve in Tanks in latest code. Works successfully in version 2.2 #767

Closed allenmlowe closed 6 months ago

allenmlowe commented 8 months ago

Error 225: invalid lower/upper levels for tank node 2

Net1-VolumeCurve.inp.txt

LRossman commented 8 months ago

Thanks @allenmlowe . There was a bug in the newly added validation check on tank min/max levels being within the limits of the tank's volume curve. A fix has just been added to the devbranch.

allenmlowe commented 8 months ago

Thank you @LRossman for the prompt response.

LRossman commented 6 months ago

The bug fix for this issue, checking that a tank's min/max levels are within its volume curve, was producing a false negative when a level limit was exactly equal to a curve's min or max level. As best as I can tell this was due to numerical round off in the test expression:

            if ((tank->Hmin - elev) * pr->Ucf[ELEV] < curve->X[0] ||
                (tank->Hmax - elev) * pr->Ucf[ELEV]> curve->X[n])
            {
                levelerr = 1;
            }

Subtracting a small amount (TINY= 1.e-6) from the RHS of the Hmintest and adding that amount to the RHS of the Hmaxtest resolved the issue. This update has been issued as PR #777.