epyt-flow 0.14.1__py3-none-any.whl → 0.14.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +8 -40
  2. epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +3 -3
  3. epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +18 -0
  4. epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +7 -24
  5. epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +374 -726
  6. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +32 -128
  7. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +131 -0
  8. epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +1 -7
  9. epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +14 -40
  10. epyt_flow/EPANET/EPANET/SRC_engines/hash.c +177 -177
  11. epyt_flow/EPANET/EPANET/SRC_engines/hash.h +28 -28
  12. epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +40 -192
  13. epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +46 -101
  14. epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +24 -85
  15. epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +63 -29
  16. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +37 -70
  17. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +234 -408
  18. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +37 -87
  19. epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +79 -153
  20. epyt_flow/EPANET/EPANET/SRC_engines/input1.c +94 -59
  21. epyt_flow/EPANET/EPANET/SRC_engines/input2.c +202 -73
  22. epyt_flow/EPANET/EPANET/SRC_engines/input3.c +351 -446
  23. epyt_flow/EPANET/EPANET/SRC_engines/main.c +93 -0
  24. epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +4 -8
  25. epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +23 -23
  26. epyt_flow/EPANET/EPANET/SRC_engines/output.c +4 -5
  27. epyt_flow/EPANET/EPANET/SRC_engines/project.c +75 -407
  28. epyt_flow/EPANET/EPANET/SRC_engines/quality.c +2 -12
  29. epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +13 -70
  30. epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +5 -7
  31. epyt_flow/EPANET/EPANET/SRC_engines/report.c +20 -88
  32. epyt_flow/EPANET/EPANET/SRC_engines/rules.c +6 -144
  33. epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +19 -19
  34. epyt_flow/EPANET/EPANET/SRC_engines/text.h +5 -16
  35. epyt_flow/EPANET/EPANET/SRC_engines/types.h +19 -73
  36. epyt_flow/EPANET/compile_linux.sh +1 -1
  37. epyt_flow/EPANET/compile_macos.sh +1 -1
  38. epyt_flow/VERSION +1 -1
  39. epyt_flow/simulation/scada/scada_data.py +1 -1
  40. epyt_flow/utils.py +66 -0
  41. epyt_flow/visualization/visualization_utils.py +4 -2
  42. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/METADATA +1 -1
  43. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/RECORD +46 -52
  44. epyt_flow/EPANET/EPANET/SRC_engines/flowbalance.c +0 -186
  45. epyt_flow/EPANET/EPANET/SRC_engines/leakage.c +0 -527
  46. epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.c +0 -59
  47. epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.h +0 -38
  48. epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.c +0 -92
  49. epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.h +0 -39
  50. epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.c +0 -212
  51. epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.h +0 -81
  52. epyt_flow/EPANET/EPANET/SRC_engines/validate.c +0 -408
  53. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/WHEEL +0 -0
  54. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/licenses/LICENSE +0 -0
  55. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/top_level.txt +0 -0
@@ -1,408 +0,0 @@
1
- /*
2
- ******************************************************************************
3
- Project: OWA EPANET
4
- Version: 2.3
5
- Module: validate.c
6
- Description: validates project data
7
- Authors: see AUTHORS
8
- Copyright: see AUTHORS
9
- License: see LICENSE
10
- Last Updated: 03/18/2024
11
- ******************************************************************************
12
- */
13
-
14
- #include <stdlib.h>
15
- #include <stdio.h>
16
- #include <string.h>
17
- #include <math.h>
18
-
19
- #include "types.h"
20
- #include "funcs.h"
21
- #include "text.h"
22
-
23
- // Exported functions
24
- int validateproject(Project *);
25
- void reindextanks(Project *);
26
-
27
- int validatetanks(Project *pr)
28
- /*
29
- **-------------------------------------------------------------------
30
- ** Input: none
31
- ** Output: returns 1 if successful, 0 if not
32
- ** Purpose: checks for valid tank levels.
33
- **-------------------------------------------------------------------
34
- */
35
- {
36
- Network *net = &pr->network;
37
- int i, j, n, result = 1, levelerr;
38
- char errmsg[MAXMSG+1] = "";
39
- Stank *tank;
40
- Scurve *curve;
41
- double elev;
42
-
43
- for (j = 1; j <= net->Ntanks; j++)
44
- {
45
- tank = &net->Tank[j];
46
- if (tank->A == 0.0) continue; // Skip reservoirs
47
-
48
- // Check for valid lower/upper tank levels
49
- levelerr = 0;
50
- if (tank->H0 > tank->Hmax ||
51
- tank->Hmin > tank->Hmax ||
52
- tank->H0 < tank->Hmin
53
- ) levelerr = 1;
54
-
55
- // Check that tank heights are within volume curve
56
- elev = net->Node[tank->Node].El;
57
- i = tank->Vcurve;
58
- if (i > 0)
59
- {
60
- curve = &net->Curve[i];
61
- n = curve->Npts - 1;
62
- if ((tank->Hmin - elev) * pr->Ucf[ELEV] < curve->X[0] - TINY ||
63
- (tank->Hmax - elev) * pr->Ucf[ELEV] > curve->X[n] + TINY)
64
- {
65
- levelerr = 1;
66
- }
67
- }
68
-
69
- // Report error in levels if found
70
- if (levelerr)
71
- {
72
- sprintf(pr->Msg, "Error 225: %s node %s", geterrmsg(225, errmsg),
73
- net->Node[tank->Node].ID);
74
- writeline(pr, pr->Msg);
75
- result = 0;
76
- }
77
- }
78
- return result;
79
- }
80
-
81
- int validatepatterns(Project *pr)
82
- /*
83
- **-------------------------------------------------------------------
84
- ** Input: none
85
- ** Output: returns 1 if successful, 0 if not
86
- ** Purpose: checks if time patterns have data.
87
- **-------------------------------------------------------------------
88
- */
89
- {
90
- Network *net = &pr->network;
91
- int j, result = 1;
92
- char errmsg[MAXMSG+1] = "";
93
-
94
- if (pr->network.Pattern != NULL)
95
- {
96
- for (j = 0; j <= pr->network.Npats; j++)
97
- {
98
- if (pr->network.Pattern[j].Length == 0)
99
- {
100
- sprintf(pr->Msg, "Error 232: %s %s", geterrmsg(232, errmsg),
101
- pr->network.Pattern[j].ID);
102
- writeline(pr, pr->Msg);
103
- result = 0;
104
- }
105
- }
106
- }
107
- return result;
108
- }
109
-
110
- int validatecurves(Project *pr)
111
- /*
112
- **-------------------------------------------------------------------
113
- ** Input: none
114
- ** Output: returns 1 if successful, 0 if not
115
- ** Purpose: checks if data curves have data.
116
- **-------------------------------------------------------------------
117
- */
118
- {
119
- int i, j, npts, result = 1;
120
- char errmsg[MAXMSG+1] = "";
121
- Scurve *curve;
122
-
123
- if (pr->network.Curve != NULL)
124
- {
125
- for (j = 1; j <= pr->network.Ncurves; j++)
126
- {
127
- // Check that curve has data
128
- curve = &pr->network.Curve[j];
129
- npts = curve->Npts;
130
- if (npts == 0)
131
- {
132
- sprintf(pr->Msg, "Error 231: %s %s", geterrmsg(231, errmsg),
133
- curve->ID);
134
- writeline(pr, pr->Msg);
135
- result = 0;
136
- }
137
-
138
- // Check that x values are increasing
139
- for (i = 1; i < npts; i++)
140
- {
141
- if (curve->X[i-1] >= curve->X[i])
142
- {
143
- sprintf(pr->Msg, "Error 230: %s %s", geterrmsg(230, errmsg),
144
- curve->ID);
145
- writeline(pr, pr->Msg);
146
- result = 0;
147
- break;
148
- }
149
- }
150
- }
151
- }
152
- return result;
153
- }
154
-
155
- int powerfuncpump(double h0, double h1, double h2, double q1, double q2,
156
- double *a, double *b, double *c)
157
- /*
158
- **---------------------------------------------------------
159
- ** Input: h0 = shutoff head
160
- ** h1 = design head
161
- ** h2 = head at max. flow
162
- ** q1 = design flow
163
- ** q2 = max. flow
164
- ** Output: *a, *b, *c = pump curve coeffs. (H = a-bQ^c),
165
- ** Returns 1 if successful, 0 otherwise.
166
- ** Purpose: computes coeffs. for a power function pump curve
167
- **----------------------------------------------------------
168
- */
169
- {
170
- double h4, h5;
171
-
172
- if (h0 < TINY || h0 - h1 < TINY || h1 - h2 < TINY ||
173
- q1 < TINY || q2 - q1 < TINY
174
- ) return 0;
175
- *a = h0;
176
- h4 = h0 - h1;
177
- h5 = h0 - h2;
178
- *c = log(h5 / h4) / log(q2 / q1);
179
- if (*c <= 0.0 || *c > 20.0) return 0;
180
- *b = -h4 / pow(q1, *c);
181
- if (*b >= 0.0) return 0;
182
- return 1;
183
- }
184
-
185
- int customcurvepump(Project *pr, Spump *pump, Scurve *curve)
186
- /*
187
- **-------------------------------------------------------------------
188
- ** Input: pump = a pump object
189
- ** curve = a data curve object
190
- ** Output: returns an error code
191
- ** Purpose: computes properties for a pump with a custom pump curve.
192
- **-------------------------------------------------------------------
193
- */
194
- {
195
- int m, npts = curve->Npts;
196
- pump->Ptype = CUSTOM;
197
- for (m = 1; m < npts; m++)
198
- {
199
- // Curve must have continuously decreasing head (the Y value)
200
- if (curve->Y[m] >= curve->Y[m - 1])
201
- {
202
- pump->Ptype = NOCURVE;
203
- return 227;
204
- }
205
- }
206
- pump->Qmax = curve->X[npts - 1];
207
- pump->Q0 = (curve->X[0] + pump->Qmax) / 2.0 / pr->Ucf[FLOW];
208
- pump->Qmax /= pr->Ucf[FLOW];
209
- pump->Hmax = curve->Y[0] / pr->Ucf[HEAD];
210
- return 0;
211
- }
212
-
213
- int pumpcurvepump(Project *pr, Spump *pump, Scurve *curve)
214
- /*
215
- **-------------------------------------------------------------------
216
- ** Input: pump = a pump object
217
- ** curve = a data curve object
218
- ** Output: returns an error code
219
- ** Purpose: computes properties for a pump assigned a pump curve.
220
- **-------------------------------------------------------------------
221
- */
222
- {
223
- double a, b, c, h0 = 0.0, h1 = 0.0, h2 = 0.0, q1 = 0.0, q2 = 0.0;
224
- int npts = curve->Npts;
225
-
226
- curve->Type = PUMP_CURVE;
227
-
228
- // Generic power function curve
229
- if (npts == 1)
230
- {
231
- pump->Ptype = POWER_FUNC;
232
- q1 = curve->X[0];
233
- h1 = curve->Y[0];
234
- h0 = 1.33334 * h1;
235
- q2 = 2.0 * q1;
236
- h2 = 0.0;
237
- }
238
-
239
- // 3 point curve with shutoff head
240
- else if (npts == 3 && curve->X[0] == 0.0)
241
- {
242
- pump->Ptype = POWER_FUNC;
243
- h0 = curve->Y[0];
244
- q1 = curve->X[1];
245
- h1 = curve->Y[1];
246
- q2 = curve->X[2];
247
- h2 = curve->Y[2];
248
- }
249
- else return customcurvepump(pr, pump, curve);
250
-
251
- // Compute shape factors & limits of power function curves
252
- if (!powerfuncpump(h0, h1, h2, q1, q2, &a, &b, &c))
253
- {
254
- pump->Ptype = NOCURVE;
255
- return 227;
256
- }
257
- else
258
- {
259
- pump->H0 = -a / pr->Ucf[HEAD];
260
- pump->R = -b * (pow(pr->Ucf[FLOW], c) / pr->Ucf[HEAD]);
261
- pump->N = c;
262
- pump->Q0 = q1 / pr->Ucf[FLOW];
263
- pump->Qmax = pow((-a / b), (1.0 / c)) / pr->Ucf[FLOW];
264
- pump->Hmax = h0 / pr->Ucf[HEAD];
265
- }
266
- return 0;
267
- }
268
-
269
- int constpowerpump(Project *pr, Spump *pump)
270
- /*
271
- **-------------------------------------------------------------------
272
- ** Input: pump = a pump object
273
- ** Output: returns an error code
274
- ** Purpose: computes properties for a constant power pump.
275
- **-------------------------------------------------------------------
276
- */
277
- {
278
- pump->Ptype = CONST_HP;
279
- pump->H0 = 0.0;
280
- pump->R = -8.814 * pr->network.Link[pump->Link].Km / pr->Ucf[POWER];
281
- pump->N = -1.0;
282
- pump->Hmax = BIG; // No head limit
283
- pump->Qmax = BIG; // No flow limit
284
- pump->Q0 = 1.0; // Init. flow = 1 cfs
285
- return 0;
286
- }
287
-
288
- int validatepumps(Project *pr)
289
- /*
290
- **-------------------------------------------------------------------
291
- ** Input: none
292
- ** Output: returns 1 if successful, 0 if not
293
- ** Purpose: checks if pumps are assigned valid pump curve data.
294
- **-------------------------------------------------------------------
295
- */
296
- {
297
- Network *net = &pr->network;
298
- int i, errcode, result = 1;
299
- char errmsg[MAXMSG+1] = "";
300
- Spump *pump;
301
-
302
- for (i = 1; i <= net->Npumps; i++)
303
- {
304
- // Pump has a designated pump curve
305
- pump = &net->Pump[i];
306
- if (pump->Hcurve > 0)
307
- errcode = pumpcurvepump(pr, pump, &net->Curve[pump->Hcurve]);
308
-
309
- // Pump has a constant power setting
310
- else if (net->Link[pump->Link].Km > 0.0)
311
- errcode = constpowerpump(pr, pump);
312
-
313
- // Pump has no pump curve info assigned
314
- else
315
- {
316
- pump->Ptype = NOCURVE;
317
- errcode = 226;
318
- }
319
-
320
- if (errcode)
321
- {
322
- sprintf(pr->Msg, "Error %d: %s %s",
323
- errcode, geterrmsg(errcode, errmsg), net->Link[pump->Link].ID);
324
- writeline(pr, pr->Msg);
325
- result = 0;
326
- }
327
- }
328
- return result;
329
- }
330
-
331
- int validateproject(Project *pr)
332
- /*
333
- *--------------------------------------------------------------
334
- * Input: none
335
- * Output: returns error code
336
- * Purpose: checks for valid network data.
337
- *--------------------------------------------------------------
338
- */
339
- {
340
- int errcode = 0;
341
- if (pr->network.Nnodes < 2) return 223;
342
- if (pr->network.Ntanks == 0) return 224;
343
- if (!validatetanks(pr)) errcode = 110;
344
- if (!validatepumps(pr)) errcode = 110;
345
- if (!validatepatterns(pr)) errcode = 110;
346
- if (!validatecurves(pr)) errcode = 110;
347
- return errcode;
348
- }
349
-
350
- void reindextanks(Project *pr)
351
- /*
352
- *--------------------------------------------------------------
353
- * Input: none
354
- * Output: none
355
- * Purpose: adjusts tank node indexes when the number of
356
- * junctions created from an input file is less than
357
- * the total number of junction lines in the file.
358
- *--------------------------------------------------------------
359
- */
360
- {
361
- Network *net = &pr->network;
362
- Parser *parser = &pr->parser;
363
- Quality *qual = &pr->quality;
364
- Scontrol *control;
365
- int i, j, ndiff, n1, n2, size;
366
-
367
- // ndiff = # unused entries in Node array before first tank node
368
- ndiff = parser->MaxJuncs - net->Njuncs;
369
- if (ndiff > 0)
370
- {
371
- for (i = 1; i <= net->Ntanks; ++i)
372
- {
373
- // n1 is current tank index in Node array, n2 is adjusted index
374
- n1 = net->Tank[i].Node;
375
- n2 = n1 - ndiff;
376
-
377
- // Update the tank node's hash table entry
378
- hashtable_update(net->NodeHashTable, net->Node[n1].ID, n2);
379
-
380
- // Update the tank's node index
381
- net->Tank[i].Node = n2;
382
-
383
- // Re-position tank node in Node array
384
- net->Node[n2] = net->Node[n1];
385
-
386
- // Replace all references to old tank node index with new one
387
- for (j = 1; j <= net->Nlinks; ++j)
388
- {
389
- if (net->Link[j].N1 == n1) net->Link[j].N1 = n2;
390
- if (net->Link[j].N2 == n1) net->Link[j].N2 = n2;
391
- }
392
- for (j = 1; j <= net->Ncontrols; ++j)
393
- {
394
- control = &net->Control[j];
395
- if (control->Node == n1) control->Node = n2;
396
- }
397
- adjusttankrules(pr, -ndiff);
398
- if (qual->TraceNode == n1) qual->TraceNode = n2;
399
- }
400
-
401
- // Reallocate the Node array (shouldn't fail as new size < old size)
402
- parser->MaxJuncs = net->Njuncs;
403
- parser->MaxNodes = net->Njuncs + net->Ntanks;
404
- size = (net->Nnodes + 2) * sizeof(Snode);
405
- net->Node = (Snode *)realloc(net->Node, size);
406
- }
407
- }
408
-