Adds tank overflow feature

This commit is contained in:
Lew Rossman
2019-06-17 09:16:04 -04:00
parent fe92a99554
commit 9669742ab3
7 changed files with 151 additions and 7 deletions

View File

@@ -1802,6 +1802,7 @@ int DLLEXPORT EN_addnode(EN_Project p, char *id, int nodeType, int *index)
tank->Vcurve = 0;
tank->MixModel = 0;
tank->V1max = 10000;
tank->CanOverflow = FALSE;
}
net->Nnodes++;
p->parser.MaxNodes = net->Nnodes;
@@ -2197,6 +2198,11 @@ int DLLEXPORT EN_getnodevalue(EN_Project p, int index, int property, double *val
v = tankvolume(p, index - nJuncs, NodeHead[index]) * Ucf[VOLUME];
break;
case EN_CANOVERFLOW:
if (Node[index].Type != TANK) return 0;
v = Tank[index - nJuncs].CanOverflow;
break;
default:
return 251;
}
@@ -2495,6 +2501,11 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int property, double valu
}
break;
case EN_CANOVERFLOW:
if (Node[index].Type != TANK) return 0;
Tank[index - nJuncs].CanOverflow = (value != 0.0);
break;
default:
return 251;
}

View File

@@ -441,7 +441,7 @@ void tankstatus(Project *pr, int k, int n1, int n2)
h = hyd->NodeHead[n1] - hyd->NodeHead[n2];
// If tank is full, then prevent flow into it
if (hyd->NodeHead[n1] >= tank->Hmax - hyd->Htol)
if (hyd->NodeHead[n1] >= tank->Hmax - hyd->Htol && !tank->CanOverflow)
{
// Case 1: Link is a pump discharging into tank
if (link->Type == PUMP)

View File

@@ -195,8 +195,10 @@ int saveinpfile(Project *pr, const char *fname)
sqrt(4.0 * tank->A / PI) * pr->Ucf[ELEV],
tank->Vmin * SQR(pr->Ucf[ELEV]) * pr->Ucf[ELEV]);
if ((j = tank->Vcurve) > 0) sprintf(s1, "%s", net->Curve[j].ID);
else if (tank->CanOverflow) strcpy(s1, "*");
else strcpy(s1, " ");
fprintf(f, "\n%s %-31s", s, s1);
if (tank->CanOverflow) fprintf(f, " YES ");
if (node->Comment) fprintf(f, " ;%s", node->Comment);
}
}

View File

@@ -138,7 +138,8 @@ int tankdata(Project *pr)
int i, // Node index
n, // # data items
pattern = 0, // Time pattern index
curve = 0; // Curve index
curve = 0, // Curve index
overflow = FALSE;// Overflow indicator
double el = 0.0, // Elevation
initlevel = 0.0, // Initial level
minlevel = 0.0, // Minimum level
@@ -185,12 +186,20 @@ int tankdata(Project *pr)
if (n >= 7 && !getfloat(parser->Tok[6], &minvol)) return setError(parser, 6, 202);
// If volume curve supplied check it exists
if (n == 8)
if (n >= 8)
{
curve = findcurve(net, parser->Tok[7]);
if (curve == 0) return setError(parser, 7, 206);
net->Curve[curve].Type = VOLUME_CURVE;
if (strlen(parser->Tok[7]) > 0 && *(parser->Tok[7]) != '*')
{
curve = findcurve(net, parser->Tok[7]);
if (curve == 0) return setError(parser, 7, 206);
net->Curve[curve].Type = VOLUME_CURVE;
}
}
// Parse overflow indicator if present
if (n >= 9 && match(parser->Tok[8], w_YES))
overflow = TRUE;
if (initlevel < 0.0) return setError(parser, 2, 209);
if (minlevel < 0.0) return setError(parser, 3, 209);
if (maxlevel < 0.0) return setError(parser, 4, 209);
@@ -216,6 +225,7 @@ int tankdata(Project *pr)
tank->A = diam;
tank->Pat = pattern;
tank->Kb = MISSING;
tank->CanOverflow = overflow;
//*******************************************************************
// NOTE: The min, max, & initial volumes set here are based on a

View File

@@ -417,6 +417,7 @@ typedef struct // Tank Object
int Vcurve; // volume v. elev. curve index
MixType MixModel; // type of mixing model
double V1max; // mixing compartment size
int CanOverflow; // tank can overflow or not
} Stank;
typedef struct // Pump Object