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

@@ -691,6 +691,8 @@ void pumpcoeff(Project *pr, int k)
hgrad; // Head loss gradient
Spump *pump;
double qstar;
// Use high resistance pipe if pump closed or cannot deliver head
setting = hyd->LinkSetting[k];
if (hyd->LinkStatus[k] <= CLOSED || setting == 0.0)
@@ -748,12 +750,14 @@ void pumpcoeff(Project *pr, int k)
if (hgrad > CBIG)
{
hgrad = CBIG;
hloss = -hgrad * hyd->LinkFlow[k];
qstar = sqrt(-r / hgrad);
hloss = (r / qstar) - hgrad * (qstar - q);
}
else if (hgrad < hyd->RQtol)
{
hgrad = hyd->RQtol;
hloss = -hgrad * hyd->LinkFlow[k];
qstar = sqrt(-r / hgrad);
hloss = (r / qstar) - hgrad * (qstar - q);
}
// ... otherwise compute head loss from pump curve
else

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;
}
}