Skip to content

Commit b2f8265

Browse files
committed
Set types of curves after parsing
1 parent 6c8136c commit b2f8265

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

epanet-src/project.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,52 @@ int openproject(Project *pr, const char *inpFile, const char *rptFile,
9797
pr->Openflag = TRUE;
9898
}
9999
errmsg(pr, errcode);
100+
101+
// Fix curve types
102+
Network *net = &pr->network;
103+
104+
// Pump curves
105+
for (int i = 1; i <= net->Npumps; i++)
106+
{
107+
Spump *pump = &net->Pump[i];
108+
109+
int j;
110+
if ((j = pump->Hcurve) > 0) {
111+
net->Curve[j].Type = PUMP_CURVE;
112+
}
113+
if ((j = pump->Ecurve) > 0) {
114+
net->Curve[j].Type = EFFIC_CURVE;
115+
}
116+
}
117+
118+
// Tank volume curves
119+
for (int i=1; i <= net->Ntanks; i++) {
120+
Stank* tank = &net->Tank[i];
121+
122+
int j;
123+
if ((j = tank->Vcurve) > 0) {
124+
net->Curve[j].Type = VOLUME_CURVE;
125+
}
126+
}
127+
128+
// Valve curves
129+
for (int i=1; i <= net->Nvalves; i++) {
130+
Svalve* valve = &net->Valve[i];
131+
Slink* link = &net->Link[valve->Link];
132+
133+
int j;
134+
if (link->Type == PCV) {
135+
if((j = valve->Curve) > 0) {
136+
net->Curve[j].Type = VALVE_CURVE;
137+
}
138+
}
139+
else if (link->Type == GPV){
140+
if((j = valve->Curve) > 0) {
141+
net->Curve[j].Type = HLOSS_CURVE;
142+
}
143+
}
144+
}
145+
100146
return errcode;
101147
}
102148

0 commit comments

Comments
 (0)