Skip to content

Commit

Permalink
Update validate.c
Browse files Browse the repository at this point in the history
Fixes bug in checking that tank min/max levels are within volume curve.
  • Loading branch information
LRossman committed Jan 25, 2024
1 parent 5fd17af commit 5c90eaf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 09/28/2023
Last Updated: 01/25/2024
******************************************************************************
*/

Expand Down Expand Up @@ -38,6 +38,7 @@ int validatetanks(Project *pr)
char errmsg[MAXMSG+1] = "";
Stank *tank;
Scurve *curve;
double elev;

for (j = 1; j <= net->Ntanks; j++)
{
Expand All @@ -52,13 +53,14 @@ int validatetanks(Project *pr)
) levelerr = 1;

// Check that tank heights are within volume curve
elev = net->Node[tank->Node].El;
i = tank->Vcurve;
if (i > 0)
{
curve = &net->Curve[i];
n = curve->Npts - 1;
if (tank->Hmin * pr->Ucf[ELEV] < curve->X[0] ||
tank->Hmax * pr->Ucf[ELEV]> curve->X[n])
if ((tank->Hmin - elev) * pr->Ucf[ELEV] < curve->X[0] ||
(tank->Hmax - elev) * pr->Ucf[ELEV]> curve->X[n])
{
levelerr = 1;
}
Expand Down

0 comments on commit 5c90eaf

Please sign in to comment.