Improved flow checks for full and empty tanks

Improves  the way link flow into full and out of empty tanks is checked. Also corrects the head loss and gradient calculation for constant horsepower pumps at very low and very high flow rates (this was affecting one of the examples used to test the full/empty tank fix).
This commit is contained in:
Lew Rossman
2021-04-16 17:01:54 -04:00
parent aaa9b44aaf
commit 409a600455
2 changed files with 19 additions and 6 deletions

View File

@@ -437,12 +437,21 @@ void tankstatus(Project *pr, int k, int n1, int n2)
tank = &net->Tank[i];
if (tank->A == 0.0) return;
if (hyd->NodeHead[n1] >= tank->Hmax - hyd->Htol && !tank->CanOverflow)
// Can't add flow to a full tank
if (hyd->NodeHead[n1] >= tank->Hmax && !tank->CanOverflow)
{
if (q < 0.0) hyd->LinkStatus[k] = TEMPCLOSED;
if (link->Type == PUMP && link->N2 == n1)
hyd->LinkStatus[k] = TEMPCLOSED;
else if (q < 0.0)
hyd->LinkStatus[k] = TEMPCLOSED;
}
if (hyd->NodeHead[n1] <= tank->Hmin + hyd->Htol)
// Can't remove flow from an empty tank
if (hyd->NodeHead[n1] <= tank->Hmin)
{
if (q > 0.0) hyd->LinkStatus[k] = TEMPCLOSED;
if (link->Type == PUMP && link->N1 == n1)
hyd->LinkStatus[k] = TEMPCLOSED;
else if (q > 0.0)
hyd->LinkStatus[k] = TEMPCLOSED;
}
}