Revert "Replaced status checking for pumps & FCVs"

This reverts commit 3ee30ce019.
This commit is contained in:
Lew Rossman
2020-02-09 17:25:33 -05:00
parent a3537b767a
commit a9ab376aa7
5 changed files with 73 additions and 61 deletions

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 02/07/2020
Last Updated: 10/04/2019
******************************************************************************
*/
@@ -59,9 +59,9 @@ static void valvecoeff(Project *pr, int k);
static void gpvcoeff(Project *pr, int k);
static void pbvcoeff(Project *pr, int k);
static void tcvcoeff(Project *pr, int k);
static void fcvcoeff(Project *pr, int k);
static void prvcoeff(Project *pr, int k, int n1, int n2);
static void psvcoeff(Project *pr, int k, int n1, int n2);
static void fcvcoeff(Project *pr, int k, int n1, int n2);
void resistcoeff(Project *pr, int k)
@@ -152,8 +152,6 @@ void headlosscoeffs(Project *pr)
gpvcoeff(pr, k);
break;
case FCV:
fcvcoeff(pr, k);
break;
case PRV:
case PSV:
if (hyd->LinkSetting[k] == MISSING) valvecoeff(pr, k);
@@ -287,8 +285,8 @@ void valvecoeffs(Project *pr)
** Input: none
** Output: none
** Purpose: computes coeffs. of the linearized hydraulic eqns.
** contributed by PRVs & PSVs whose status is not
** fixed to OPEN/CLOSED
** contributed by PRVs, PSVs & FCVs whose status is
** not fixed to OPEN/CLOSED
**--------------------------------------------------------------
*/
{
@@ -315,8 +313,19 @@ void valvecoeffs(Project *pr)
n2 = link->N2;
// Call valve-specific function
if (link->Type == PRV) prvcoeff(pr, k, n1, n2);
if (link->Type == PSV) psvcoeff(pr, k, n1, n2);
switch (link->Type)
{
case PRV:
prvcoeff(pr, k, n1, n2);
break;
case PSV:
psvcoeff(pr, k, n1, n2);
break;
case FCV:
fcvcoeff(pr, k, n1, n2);
break;
default: continue;
}
}
}
@@ -692,31 +701,20 @@ void pumpcoeff(Project *pr, int k)
}
// Obtain reference to pump object
q = ABS(hyd->LinkFlow[k]);
p = findpump(&pr->network, k);
pump = &pr->network.Pump[p];
// Prevent negative flow
q = hyd->LinkFlow[k];
if (q < 0.0)
{
hloss = -(SQR(setting) * pump->Hmax) + CBIG * q;
hgrad = CBIG;
hyd->P[k] = 1.0 / hgrad;
hyd->Y[k] = hloss / hgrad;
return;
}
// If no pump curve treat pump as an open valve
if (pump->Ptype == NOCURVE)
{
hyd->P[k] = 1.0 / CSMALL;
hyd->Y[k] = q;
hyd->Y[k] = hyd->LinkFlow[k];
return;
}
// Get pump curve coefficients for custom pump curve
// (Other pump types have pre-determined coeffs.)
q = ABS(q);
if (pump->Ptype == CUSTOM)
{
// Find intercept (h0) & slope (r) of pump curve
@@ -1046,10 +1044,12 @@ void psvcoeff(Project *pr, int k, int n1, int n2)
}
void fcvcoeff(Project *pr, int k)
void fcvcoeff(Project *pr, int k, int n1, int n2)
/*
**--------------------------------------------------------------
** Input: k = link index
** n1 = upstream node of valve
** n2 = downstream node of valve
** Output: none
** Purpose: computes solution matrix coeffs. for flow control
** valve
@@ -1059,28 +1059,40 @@ void fcvcoeff(Project *pr, int k)
Hydraul *hyd = &pr->hydraul;
Smatrix *sm = &hyd->smatrix;
double qset; // Valve flow setting
double flow; // Current valve flow
double hloss, hgrad; // Head loss & gradient
int i, j; // Rows in solution matrix
double q; // Valve flow setting
// Treat as a regular valve if status fixed or flow below setting
qset = hyd->LinkSetting[k];
flow = hyd->LinkFlow[k];
if (qset == MISSING || hyd->LinkStatus[k] <= CLOSED || flow < qset)
q = hyd->LinkSetting[k];
i = sm->Row[n1];
j = sm->Row[n2];
// If valve active, break network at valve and treat
// flow setting as external demand at upstream node
// and external supply at downstream node.
if (hyd->LinkStatus[k] == ACTIVE)
{
valvecoeff(pr, k);
hyd->Xflow[n1] -= q;
hyd->Xflow[n2] += q;
hyd->Y[k] = hyd->LinkFlow[k] - q;
sm->F[i] -= q;
sm->F[j] += q;
hyd->P[k] = 1.0 / CBIG;
sm->Aij[sm->Ndx[k]] -= hyd->P[k];
sm->Aii[i] += hyd->P[k];
sm->Aii[j] += hyd->P[k];
}
// Otherwise prevent flow from exceeding the setting
// Otherwise treat valve as an open pipe
else
{
hyd->LinkFlow[k] = qset;
valvecoeff(pr, k);
hloss = hyd->Y[k] / hyd->P[k] + CBIG * (flow - qset);
hgrad = CBIG;
hyd->P[k] = 1.0 / hgrad;
hyd->Y[k] = hloss / hgrad;
hyd->LinkFlow[k] = flow;
sm->Aij[sm->Ndx[k]] -= hyd->P[k];
sm->Aii[i] += hyd->P[k];
sm->Aii[j] += hyd->P[k];
sm->F[i] += (hyd->Y[k] - hyd->LinkFlow[k]);
sm->F[j] -= (hyd->Y[k] - hyd->LinkFlow[k]);
}
}