epyt-flow 0.14.0__py3-none-any.whl → 0.14.1__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 (60) hide show
  1. epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +40 -8
  2. epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +3 -3
  3. epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +24 -7
  4. epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +726 -374
  5. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +128 -32
  6. epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +7 -1
  7. epyt_flow/EPANET/EPANET/SRC_engines/flowbalance.c +186 -0
  8. epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +40 -14
  9. epyt_flow/EPANET/EPANET/SRC_engines/hash.c +177 -177
  10. epyt_flow/EPANET/EPANET/SRC_engines/hash.h +28 -28
  11. epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +192 -40
  12. epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +101 -46
  13. epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +85 -24
  14. epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +29 -63
  15. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +70 -37
  16. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +408 -234
  17. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +87 -37
  18. epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +153 -79
  19. epyt_flow/EPANET/EPANET/SRC_engines/input1.c +59 -94
  20. epyt_flow/EPANET/EPANET/SRC_engines/input2.c +73 -202
  21. epyt_flow/EPANET/EPANET/SRC_engines/input3.c +446 -351
  22. epyt_flow/EPANET/EPANET/SRC_engines/leakage.c +527 -0
  23. epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +8 -4
  24. epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +23 -23
  25. epyt_flow/EPANET/EPANET/SRC_engines/output.c +5 -4
  26. epyt_flow/EPANET/EPANET/SRC_engines/project.c +407 -75
  27. epyt_flow/EPANET/EPANET/SRC_engines/quality.c +12 -2
  28. epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +70 -13
  29. epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +7 -5
  30. epyt_flow/EPANET/EPANET/SRC_engines/report.c +88 -20
  31. epyt_flow/EPANET/EPANET/SRC_engines/rules.c +144 -6
  32. epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +19 -19
  33. epyt_flow/EPANET/EPANET/SRC_engines/text.h +16 -5
  34. epyt_flow/EPANET/EPANET/SRC_engines/types.h +73 -19
  35. epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.c +59 -0
  36. epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.h +38 -0
  37. epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.c +92 -0
  38. epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.h +39 -0
  39. epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.c +212 -0
  40. epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.h +81 -0
  41. epyt_flow/EPANET/EPANET/SRC_engines/validate.c +408 -0
  42. epyt_flow/EPANET/compile_linux.sh +1 -1
  43. epyt_flow/EPANET/compile_macos.sh +1 -1
  44. epyt_flow/VERSION +1 -1
  45. epyt_flow/gym/scenario_control_env.py +26 -3
  46. epyt_flow/simulation/events/quality_events.py +6 -6
  47. epyt_flow/simulation/events/sensor_faults.py +24 -24
  48. epyt_flow/simulation/events/system_event.py +3 -3
  49. epyt_flow/simulation/scada/scada_data.py +1 -1
  50. epyt_flow/simulation/scenario_simulator.py +14 -11
  51. epyt_flow/topology.py +8 -1
  52. epyt_flow/uncertainty/model_uncertainty.py +292 -150
  53. {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/METADATA +2 -2
  54. {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/RECORD +57 -51
  55. epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +0 -18
  56. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +0 -131
  57. epyt_flow/EPANET/EPANET/SRC_engines/main.c +0 -93
  58. {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/WHEEL +0 -0
  59. {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/licenses/LICENSE +0 -0
  60. {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.2
4
+ Version: 2.3
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: 10/29/2019
10
+ Last Updated: 02/19/2025
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -21,24 +21,18 @@ Last Updated: 10/29/2019
21
21
  #include "hash.h"
22
22
  #include "text.h"
23
23
 
24
- #define MAXERRS 10 // Max. input errors reported
25
-
26
24
  extern char *SectTxt[]; // Input section keywords (see ENUMSTXT.H)
27
25
 
28
26
  // Exported functions
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 *);
27
+ int addnodeID(Network *, int, char *);
28
+ int addlinkID(Network *, int, char *);
29
+ int getunitsoption(Project *, char *);
30
+ int getheadlossoption(Project *, char *);
35
31
 
36
32
  // Local functions
37
33
  static int newline(Project *, int, char *);
38
34
  static int addpattern(Network *, char *);
39
35
  static int addcurve(Network *, char *);
40
- static int unlinked(Project *);
41
- static int getpumpparams(Project *);
42
36
  static void inperrmsg(Project *, int, int, char *);
43
37
 
44
38
 
@@ -101,7 +95,11 @@ int netsize(Project *pr)
101
95
  if (sect == _END) break;
102
96
  continue;
103
97
  }
104
- else continue;
98
+ else
99
+ {
100
+ sect = -1;
101
+ continue;
102
+ }
105
103
  }
106
104
 
107
105
  // Add to count of current object
@@ -123,6 +121,12 @@ int netsize(Project *pr)
123
121
  errcode = addcurve(&pr->network, tok);
124
122
  parser->MaxCurves = pr->network.Ncurves;
125
123
  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;
126
130
  }
127
131
  if (errcode) break;
128
132
  }
@@ -130,11 +134,6 @@ int netsize(Project *pr)
130
134
  parser->MaxNodes = parser->MaxJuncs + parser->MaxTanks;
131
135
  parser->MaxLinks = parser->MaxPipes + parser->MaxPumps + parser->MaxValves;
132
136
  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
- }
138
137
  return errcode;
139
138
  }
140
139
 
@@ -152,6 +151,7 @@ int readdata(Project *pr)
152
151
 
153
152
  char line[MAXLINE + 1], // Line from input data file
154
153
  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, pr->Msg), SectTxt[sect]);
216
+ sprintf(pr->Msg, "%s section: %s", geterrmsg(214, errmsg), SectTxt[sect]);
217
217
  writeline(pr, pr->Msg);
218
218
  writeline(pr, line);
219
219
  errsum++;
@@ -231,9 +231,11 @@ int readdata(Project *pr)
231
231
  }
232
232
  else
233
233
  {
234
- inperrmsg(pr, 201, sect, line);
234
+ sect = -1;
235
+ parser->ErrTok = 0;
235
236
  errsum++;
236
- break;
237
+ inperrmsg(pr, 299, sect, line);
238
+ continue;
237
239
  }
238
240
  }
239
241
 
@@ -249,26 +251,13 @@ int readdata(Project *pr)
249
251
  errsum++;
250
252
  }
251
253
  }
252
- else
253
- {
254
- errcode = 200;
255
- break;
256
- }
254
+ else continue;
257
255
  }
258
-
259
- // Stop if reach end of file or max. error count
260
- if (errsum == MAXERRS) break;
261
256
  }
262
257
 
263
258
  // Check for errors
264
259
  if (errsum > 0) errcode = 200;
265
260
 
266
- // Check for unlinked nodes
267
- if (!errcode) errcode = unlinked(pr);
268
-
269
- // Determine pump curve parameters
270
- if (!errcode) errcode = getpumpparams(pr);
271
-
272
261
  // Free input buffer
273
262
  free(parser->X);
274
263
  return errcode;
@@ -315,11 +304,13 @@ int newline(Project *pr, int sect, char *line)
315
304
  if (ruledata(pr) > 0)
316
305
  {
317
306
  ruleerrmsg(pr);
307
+ deleterule(pr, pr->network.Nrules);
318
308
  return 200;
319
309
  }
320
310
  else return 0;
321
311
  case _SOURCES: return (sourcedata(pr));
322
312
  case _EMITTERS: return (emitterdata(pr));
313
+ case _LEAKAGE: return (leakagedata(pr));
323
314
  case _QUALITY: return (qualdata(pr));
324
315
  case _STATUS: return (statusdata(pr));
325
316
  case _ROUGHNESS: return (0);
@@ -329,139 +320,18 @@ int newline(Project *pr, int sect, char *line)
329
320
  case _REPORT: return (reportdata(pr));
330
321
  case _TIMES: return (timedata(pr));
331
322
  case _OPTIONS: return (optiondata(pr));
323
+ case _TAGS: return (tagdata(pr));
332
324
  case _COORDS: return (coordata(pr));
333
325
  case _VERTICES: return (vertexdata(pr));
334
326
 
335
327
  // Data in these sections are not used for any computations
336
328
  case _LABELS:
337
- case _TAGS:
338
329
  case _BACKDROP:
339
330
  return (0);
340
331
  }
341
332
  return 201;
342
333
  }
343
334
 
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
-
465
335
  int addnodeID(Network *net, int n, char *id)
466
336
  /*
467
337
  **-------------------------------------------------------------
@@ -572,52 +442,49 @@ int addcurve(Network *network, char *id)
572
442
  return 0;
573
443
  }
574
444
 
575
- int unlinked(Project *pr)
445
+ int getunitsoption(Project *pr, char *units)
576
446
  /*
577
- **--------------------------------------------------------------
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.
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.
583
451
  **--------------------------------------------------------------
584
452
  */
585
453
  {
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
- }
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
+ }
605
472
 
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;
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.
479
+ **--------------------------------------------------------------
480
+ */
481
+ {
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;
621
488
  }
622
489
 
623
490
  int findmatch(char *line, char *keyword[])
@@ -686,7 +553,7 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
686
553
  */
687
554
  {
688
555
  int n;
689
- size_t len, m;
556
+ int len, m;
690
557
  char *c, *c2;
691
558
 
692
559
  // clear comment
@@ -704,10 +571,10 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
704
571
  if (c2)
705
572
  {
706
573
  // there is a comment here, after the semi-colon.
707
- len = strlen(c2);
574
+ len = (int)strlen(c2);
708
575
  if (len > 0)
709
576
  {
710
- len = strcspn(c2, "\n\r");
577
+ len = (int)strcspn(c2, "\n\r");
711
578
  len = MIN(len, MAXMSG);
712
579
  strncpy(comment, c2, len);
713
580
  comment[MIN(len,MAXMSG)] = '\0';
@@ -855,7 +722,11 @@ void inperrmsg(Project *pr, int err, int sect, char *line)
855
722
  else strcpy(tok, "");
856
723
 
857
724
  // write error message to report file
858
- sprintf(pr->Msg, "Error %d: %s %s in %s section:",
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:",
859
730
  err, geterrmsg(err, errStr), tok, SectTxt[sect]);
860
731
  writeline(pr, pr->Msg);
861
732