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,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.3
4
+ Version: 2.2
5
5
  Module: input2.c
6
6
  Description: reads and interprets network data from an EPANET input file
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 02/19/2025
10
+ Last Updated: 10/29/2019
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -21,18 +21,24 @@ Last Updated: 02/19/2025
21
21
  #include "hash.h"
22
22
  #include "text.h"
23
23
 
24
+ #define MAXERRS 10 // Max. input errors reported
25
+
24
26
  extern char *SectTxt[]; // Input section keywords (see ENUMSTXT.H)
25
27
 
26
28
  // Exported functions
27
- int addnodeID(Network *, int, char *);
28
- int addlinkID(Network *, int, char *);
29
- int getunitsoption(Project *, char *);
30
- int getheadlossoption(Project *, char *);
29
+ int addnodeID(Network *n, int, char *);
30
+ int addlinkID(Network *n, int, char *);
31
+
32
+ // Imported functions
33
+ extern int powercurve(double, double, double, double, double, double *,
34
+ double *, double *);
31
35
 
32
36
  // Local functions
33
37
  static int newline(Project *, int, char *);
34
38
  static int addpattern(Network *, char *);
35
39
  static int addcurve(Network *, char *);
40
+ static int unlinked(Project *);
41
+ static int getpumpparams(Project *);
36
42
  static void inperrmsg(Project *, int, int, char *);
37
43
 
38
44
 
@@ -95,11 +101,7 @@ int netsize(Project *pr)
95
101
  if (sect == _END) break;
96
102
  continue;
97
103
  }
98
- else
99
- {
100
- sect = -1;
101
- continue;
102
- }
104
+ else continue;
103
105
  }
104
106
 
105
107
  // Add to count of current object
@@ -121,12 +123,6 @@ int netsize(Project *pr)
121
123
  errcode = addcurve(&pr->network, tok);
122
124
  parser->MaxCurves = pr->network.Ncurves;
123
125
  break;
124
- case _OPTIONS:
125
- if (match(tok, w_UNITS))
126
- getunitsoption(pr, strtok(line, SEPSTR));
127
- else if (match(tok, w_HEADLOSS))
128
- getheadlossoption(pr, strtok(line, SEPSTR));
129
- break;
130
126
  }
131
127
  if (errcode) break;
132
128
  }
@@ -134,6 +130,11 @@ int netsize(Project *pr)
134
130
  parser->MaxNodes = parser->MaxJuncs + parser->MaxTanks;
135
131
  parser->MaxLinks = parser->MaxPipes + parser->MaxPumps + parser->MaxValves;
136
132
  if (parser->MaxPats < 1) parser->MaxPats = 1;
133
+ if (!errcode)
134
+ {
135
+ if (parser->MaxJuncs < 1) errcode = 223; // Not enough nodes
136
+ else if (parser->MaxTanks == 0) errcode = 224; // No tanks
137
+ }
137
138
  return errcode;
138
139
  }
139
140
 
@@ -151,7 +152,6 @@ int readdata(Project *pr)
151
152
 
152
153
  char line[MAXLINE + 1], // Line from input data file
153
154
  wline[MAXLINE + 1]; // Working copy of input line
154
- char errmsg[MAXMSG + 1] = "";
155
155
  int sect, newsect, // Data sections
156
156
  errcode = 0, // Error code
157
157
  inperr, errsum; // Error code & total error count
@@ -213,7 +213,7 @@ int readdata(Project *pr)
213
213
  // Check if max. line length exceeded
214
214
  if (strlen(line) >= MAXLINE)
215
215
  {
216
- sprintf(pr->Msg, "%s section: %s", geterrmsg(214, errmsg), SectTxt[sect]);
216
+ sprintf(pr->Msg, "%s section: %s", geterrmsg(214, pr->Msg), SectTxt[sect]);
217
217
  writeline(pr, pr->Msg);
218
218
  writeline(pr, line);
219
219
  errsum++;
@@ -231,11 +231,9 @@ int readdata(Project *pr)
231
231
  }
232
232
  else
233
233
  {
234
- sect = -1;
235
- parser->ErrTok = 0;
234
+ inperrmsg(pr, 201, sect, line);
236
235
  errsum++;
237
- inperrmsg(pr, 299, sect, line);
238
- continue;
236
+ break;
239
237
  }
240
238
  }
241
239
 
@@ -251,13 +249,26 @@ int readdata(Project *pr)
251
249
  errsum++;
252
250
  }
253
251
  }
254
- else continue;
252
+ else
253
+ {
254
+ errcode = 200;
255
+ break;
256
+ }
255
257
  }
258
+
259
+ // Stop if reach end of file or max. error count
260
+ if (errsum == MAXERRS) break;
256
261
  }
257
262
 
258
263
  // Check for errors
259
264
  if (errsum > 0) errcode = 200;
260
265
 
266
+ // Check for unlinked nodes
267
+ if (!errcode) errcode = unlinked(pr);
268
+
269
+ // Determine pump curve parameters
270
+ if (!errcode) errcode = getpumpparams(pr);
271
+
261
272
  // Free input buffer
262
273
  free(parser->X);
263
274
  return errcode;
@@ -304,13 +315,11 @@ int newline(Project *pr, int sect, char *line)
304
315
  if (ruledata(pr) > 0)
305
316
  {
306
317
  ruleerrmsg(pr);
307
- deleterule(pr, pr->network.Nrules);
308
318
  return 200;
309
319
  }
310
320
  else return 0;
311
321
  case _SOURCES: return (sourcedata(pr));
312
322
  case _EMITTERS: return (emitterdata(pr));
313
- case _LEAKAGE: return (leakagedata(pr));
314
323
  case _QUALITY: return (qualdata(pr));
315
324
  case _STATUS: return (statusdata(pr));
316
325
  case _ROUGHNESS: return (0);
@@ -320,18 +329,139 @@ int newline(Project *pr, int sect, char *line)
320
329
  case _REPORT: return (reportdata(pr));
321
330
  case _TIMES: return (timedata(pr));
322
331
  case _OPTIONS: return (optiondata(pr));
323
- case _TAGS: return (tagdata(pr));
324
332
  case _COORDS: return (coordata(pr));
325
333
  case _VERTICES: return (vertexdata(pr));
326
334
 
327
335
  // Data in these sections are not used for any computations
328
336
  case _LABELS:
337
+ case _TAGS:
329
338
  case _BACKDROP:
330
339
  return (0);
331
340
  }
332
341
  return 201;
333
342
  }
334
343
 
344
+ int getpumpparams(Project *pr)
345
+ /*
346
+ **-------------------------------------------------------------
347
+ ** Input: none
348
+ ** Output: returns error code
349
+ ** Purpose: computes pump curve coefficients for all pumps
350
+ **--------------------------------------------------------------
351
+ */
352
+ {
353
+ Network *net = &pr->network;
354
+ int i, k, errcode = 0;
355
+ char errmsg[MAXMSG+1];
356
+
357
+ for (i = 1; i <= net->Npumps; i++)
358
+ {
359
+ errcode = updatepumpparams(pr, i);
360
+ if (errcode)
361
+ {
362
+ k = net->Pump[i].Link;
363
+ sprintf(pr->Msg, "Error %d: %s %s",
364
+ errcode, geterrmsg(errcode, errmsg), net->Link[k].ID);
365
+ writeline(pr, pr->Msg);
366
+ return 200;
367
+ }
368
+ }
369
+ return 0;
370
+ }
371
+
372
+ int updatepumpparams(Project *pr, int pumpindex)
373
+ /*
374
+ **-------------------------------------------------------------
375
+ ** Input: pumpindex = index of a pump
376
+ ** Output: returns error code
377
+ ** Purpose: computes & checks a pump's head curve coefficients
378
+ **--------------------------------------------------------------
379
+ */
380
+ {
381
+ Network *net = &pr->network;
382
+ Spump *pump;
383
+ Scurve *curve;
384
+
385
+ int m;
386
+ int curveindex;
387
+ int npts = 0;
388
+ int errcode = 0;
389
+ double a, b, c, h0 = 0.0, h1 = 0.0, h2 = 0.0, q1 = 0.0, q2 = 0.0;
390
+
391
+ pump = &net->Pump[pumpindex];
392
+ if (pump->Ptype == CONST_HP) // Constant Hp pump
393
+ {
394
+ pump->H0 = 0.0;
395
+ pump->R = -8.814 * net->Link[pump->Link].Km;
396
+ pump->N = -1.0;
397
+ pump->Hmax = BIG; // No head limit
398
+ pump->Qmax = BIG; // No flow limit
399
+ pump->Q0 = 1.0; // Init. flow = 1 cfs
400
+ return errcode;
401
+ }
402
+
403
+ else if (pump->Ptype == NOCURVE) // Pump curve specified
404
+ {
405
+ curveindex = pump->Hcurve;
406
+ if (curveindex == 0) return 226;
407
+ curve = &net->Curve[curveindex];
408
+ curve->Type = PUMP_CURVE;
409
+ npts = curve->Npts;
410
+
411
+ // Generic power function curve
412
+ if (npts == 1)
413
+ {
414
+ pump->Ptype = POWER_FUNC;
415
+ q1 = curve->X[0];
416
+ h1 = curve->Y[0];
417
+ h0 = 1.33334 * h1;
418
+ q2 = 2.0 * q1;
419
+ h2 = 0.0;
420
+ }
421
+
422
+ // 3 point curve with shutoff head
423
+ else if (npts == 3 && curve->X[0] == 0.0)
424
+ {
425
+ pump->Ptype = POWER_FUNC;
426
+ h0 = curve->Y[0];
427
+ q1 = curve->X[1];
428
+ h1 = curve->Y[1];
429
+ q2 = curve->X[2];
430
+ h2 = curve->Y[2];
431
+ }
432
+
433
+ // Custom pump curve
434
+ else
435
+ {
436
+ pump->Ptype = CUSTOM;
437
+ for (m = 1; m < npts; m++)
438
+ {
439
+ if (curve->Y[m] >= curve->Y[m - 1]) return 227;
440
+ }
441
+ pump->Qmax = curve->X[npts - 1];
442
+ pump->Q0 = (curve->X[0] + pump->Qmax) / 2.0;
443
+ pump->Hmax = curve->Y[0];
444
+ }
445
+
446
+ // Compute shape factors & limits of power function curves
447
+ if (pump->Ptype == POWER_FUNC)
448
+ {
449
+ if (!powercurve(h0, h1, h2, q1, q2, &a, &b, &c)) return 227;
450
+ else
451
+ {
452
+ pump->H0 = -a;
453
+ pump->R = -b;
454
+ pump->N = c;
455
+ pump->Q0 = q1;
456
+ pump->Qmax = pow((-a / b), (1.0 / c));
457
+ pump->Hmax = h0;
458
+ }
459
+ }
460
+ }
461
+ return 0;
462
+ }
463
+
464
+
335
465
  int addnodeID(Network *net, int n, char *id)
336
466
  /*
337
467
  **-------------------------------------------------------------
@@ -442,49 +572,52 @@ int addcurve(Network *network, char *id)
442
572
  return 0;
443
573
  }
444
574
 
445
- int getunitsoption(Project *pr, char *units)
575
+ int unlinked(Project *pr)
446
576
  /*
447
- **-------------------------------------------------------------
448
- ** Input: units = name of flow units to be used
449
- ** Output: returns 1 if successful, 0 if not
450
- ** Purpose: sets the flows units to be used by a project.
451
577
  **--------------------------------------------------------------
452
- */
453
- {
454
- Parser *parser = &pr->parser;
455
- if (match(units, w_CFS)) parser->Flowflag = CFS;
456
- else if (match(units, w_GPM)) parser->Flowflag = GPM;
457
- else if (match(units, w_AFD)) parser->Flowflag = AFD;
458
- else if (match(units, w_MGD)) parser->Flowflag = MGD;
459
- else if (match(units, w_IMGD)) parser->Flowflag = IMGD;
460
- else if (match(units, w_LPS)) parser->Flowflag = LPS;
461
- else if (match(units, w_LPM)) parser->Flowflag = LPM;
462
- else if (match(units, w_CMH)) parser->Flowflag = CMH;
463
- else if (match(units, w_CMD)) parser->Flowflag = CMD;
464
- else if (match(units, w_MLD)) parser->Flowflag = MLD;
465
- else if (match(units, w_CMS)) parser->Flowflag = CMS;
466
- else if (match(units, w_SI)) parser->Flowflag = LPS;
467
- else return 0;
468
- if (parser->Flowflag >= LPS) parser->Unitsflag = SI;
469
- else parser->Unitsflag = US;
470
- return 1;
471
- }
472
-
473
- int getheadlossoption(Project *pr, char *formula)
474
- /*
475
- **-------------------------------------------------------------
476
- ** Input: formula = name of head loss formula to be used
477
- ** Output: returns 1 if successful, 0 if not
478
- ** Purpose: sets the head loss formula to be used by a project.
578
+ ** Input: none
579
+ ** Output: returns error code if any unlinked junctions found
580
+ ** Purpose: checks for unlinked junctions in network
581
+ **
582
+ ** NOTE: unlinked tanks have no effect on computations.
479
583
  **--------------------------------------------------------------
480
584
  */
481
585
  {
482
- Hydraul *hyd = &pr->hydraul;
483
- if (match(formula, w_HW)) hyd->Formflag = HW;
484
- else if (match(formula, w_DW)) hyd->Formflag = DW;
485
- else if (match(formula, w_CM)) hyd->Formflag = CM;
486
- else return 0;
487
- return 1;
586
+ Network *net = &pr->network;
587
+ int *marked;
588
+ int i, err, errcode;
589
+
590
+ errcode = 0;
591
+ err = 0;
592
+
593
+ // Create an array to record number of links incident on each node
594
+ marked = (int *)calloc(net->Nnodes + 1, sizeof(int));
595
+ ERRCODE(MEMCHECK(marked));
596
+ if (errcode) return errcode;
597
+ memset(marked, 0, (net->Nnodes + 1) * sizeof(int));
598
+
599
+ // Mark end nodes of each link
600
+ for (i = 1; i <= net->Nlinks; i++)
601
+ {
602
+ marked[net->Link[i].N1]++;
603
+ marked[net->Link[i].N2]++;
604
+ }
605
+
606
+ // Check each junction
607
+ for (i = 1; i <= net->Njuncs; i++)
608
+ {
609
+ // If not marked then error
610
+ if (marked[i] == 0)
611
+ {
612
+ err++;
613
+ sprintf(pr->Msg, "Error 233: %s %s", geterrmsg(233, pr->Msg), net->Node[i].ID);
614
+ writeline(pr, pr->Msg);
615
+ }
616
+ if (err >= MAXERRS) break;
617
+ }
618
+ if (err > 0) errcode = 200;
619
+ free(marked);
620
+ return errcode;
488
621
  }
489
622
 
490
623
  int findmatch(char *line, char *keyword[])
@@ -553,7 +686,7 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
553
686
  */
554
687
  {
555
688
  int n;
556
- int len, m;
689
+ size_t len, m;
557
690
  char *c, *c2;
558
691
 
559
692
  // clear comment
@@ -571,10 +704,10 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
571
704
  if (c2)
572
705
  {
573
706
  // there is a comment here, after the semi-colon.
574
- len = (int)strlen(c2);
707
+ len = strlen(c2);
575
708
  if (len > 0)
576
709
  {
577
- len = (int)strcspn(c2, "\n\r");
710
+ len = strcspn(c2, "\n\r");
578
711
  len = MIN(len, MAXMSG);
579
712
  strncpy(comment, c2, len);
580
713
  comment[MIN(len,MAXMSG)] = '\0';
@@ -722,11 +855,7 @@ void inperrmsg(Project *pr, int err, int sect, char *line)
722
855
  else strcpy(tok, "");
723
856
 
724
857
  // write error message to report file
725
- if (err == 299)
726
- sprintf(pr->Msg, "Error %d: %s %s: section contents ignored.",
727
- err, geterrmsg(err, errStr), tok);
728
- else
729
- sprintf(pr->Msg, "Error %d: %s %s in %s section:",
858
+ sprintf(pr->Msg, "Error %d: %s %s in %s section:",
730
859
  err, geterrmsg(err, errStr), tok, SectTxt[sect]);
731
860
  writeline(pr, pr->Msg);
732
861