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: input1.c
6
6
  Description: retrieves 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: 04/19/2025
10
+ Last Updated: 07/08/2019
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -40,9 +40,6 @@ Last Updated: 04/19/2025
40
40
  // Defined in ENUMSTXT.H
41
41
  extern char *Fldname[];
42
42
  extern char *RptFlowUnitsTxt[];
43
- extern char *PressUnitsTxt[];
44
- extern void reindextanks(Project *pr);
45
-
46
43
 
47
44
  int getdata(Project *pr)
48
45
  /*
@@ -61,18 +58,13 @@ int getdata(Project *pr)
61
58
 
62
59
  // Read in network data
63
60
  rewind(pr->parser.InFile);
64
- errcode = readdata(pr);
65
-
61
+ ERRCODE(readdata(pr));
62
+
66
63
  // Adjust data and convert it to internal units
67
- // (error code 200 means there are non-fatal errors in input file)
68
- if (errcode == 0 || errcode == 200)
69
- {
70
- reindextanks(pr);
71
- adjustdata(pr);
72
- inittanks(pr);
73
- initunits(pr);
74
- convertunits(pr);
75
- }
64
+ if (!errcode) adjustdata(pr);
65
+ if (!errcode) initunits(pr);
66
+ ERRCODE(inittanks(pr));
67
+ if (!errcode) convertunits(pr);
76
68
  return errcode;
77
69
  }
78
70
 
@@ -104,7 +96,8 @@ void setdefaults(Project *pr)
104
96
  pr->Warnflag = FALSE; // Warning flag is off
105
97
  parser->Unitsflag = US; // US unit system
106
98
  parser->Flowflag = GPM; // Flow units are gpm
107
- parser->Pressflag = DEFAULTUNIT; // Pressure units set based on unit system
99
+ parser->Pressflag = PSI; // Pressure units are psi
100
+ parser->DefPat = 0; // Default demand pattern index
108
101
  out->Hydflag = SCRATCH; // No external hydraulics file
109
102
  rpt->Tstatflag = SERIES; // Generate time series output
110
103
 
@@ -128,8 +121,6 @@ void setdefaults(Project *pr)
128
121
  hyd->Epump = EPUMP; // Default pump efficiency
129
122
  hyd->Emax = 0.0; // Zero peak energy usage
130
123
  hyd->Qexp = 2.0; // Flow exponent for emitters
131
- hyd->EmitBackFlag = 1; // Allow emitter backflow
132
- hyd->DefPat = 0; // Default demand pattern index
133
124
  hyd->Dmult = 1.0; // Demand multiplier
134
125
  hyd->RQtol = RQTOL; // Default hydraulics parameters
135
126
  hyd->CheckFreq = CHECKFREQ;
@@ -221,7 +212,9 @@ void adjustdata(Project *pr)
221
212
 
222
213
  int i;
223
214
  double ucf; // Unit conversion factor
215
+ Pdemand demand; // Pointer to demand record
224
216
  Slink *link;
217
+ Snode *node;
225
218
  Stank *tank;
226
219
 
227
220
  // Use 1 hr pattern & report time step if none specified
@@ -236,6 +229,9 @@ void adjustdata(Project *pr)
236
229
  // Report start time cannot be greater than simulation duration
237
230
  if (time->Rstart > time->Dur) time->Rstart = 0;
238
231
 
232
+ // No water quality analysis for single period run
233
+ if (time->Dur == 0) qual->Qualflag = NONE;
234
+
239
235
  // If no quality timestep, then make it 1/10 of hydraulic timestep
240
236
  if (time->Qstep == 0) time->Qstep = time->Hstep / 10;
241
237
 
@@ -262,7 +258,6 @@ void adjustdata(Project *pr)
262
258
  case MLD: // megaliters/day
263
259
  case CMH: // cubic meters/hr
264
260
  case CMD: // cubic meters/day
265
- case CMS: // cubic meters/second
266
261
  parser->Unitsflag = SI;
267
262
  break;
268
263
  default:
@@ -270,11 +265,8 @@ void adjustdata(Project *pr)
270
265
  }
271
266
 
272
267
  // Revise pressure units depending on flow units
273
- if (parser->Pressflag == DEFAULTUNIT)
274
- {
275
- if (parser->Unitsflag == SI) parser->Pressflag = METERS;
276
- else parser->Pressflag = PSI;
277
- }
268
+ if (parser->Unitsflag != SI) parser->Pressflag = PSI;
269
+ else if (parser->Pressflag == PSI) parser->Pressflag = METERS;
278
270
 
279
271
  // Store value of viscosity & diffusivity
280
272
  ucf = 1.0;
@@ -330,20 +322,26 @@ void adjustdata(Project *pr)
330
322
  if (tank->Kb == MISSING) tank->Kb = qual->Kbulk;
331
323
  }
332
324
 
333
- // Set default pattern index
334
- i = findpattern(net, parser->DefPatID);
335
- if (i > 0)
336
- hyd->DefPat = i;
325
+ // Use default pattern if none assigned to a demand
326
+ parser->DefPat = findpattern(net, parser->DefPatID);
327
+ if (parser->DefPat > 0) for (i = 1; i <= net->Nnodes; i++)
328
+ {
329
+ node = &net->Node[i];
330
+ for (demand = node->D; demand != NULL; demand = demand->next)
331
+ {
332
+ if (demand->Pat == 0) demand->Pat = parser->DefPat;
333
+ }
334
+ }
337
335
 
338
336
  // Remove QUALITY as a reporting variable if no WQ analysis
339
337
  if (qual->Qualflag == NONE) rpt->Field[QUALITY].Enabled = FALSE;
340
338
  }
341
339
 
342
- void inittanks(Project *pr)
340
+ int inittanks(Project *pr)
343
341
  /*
344
342
  **---------------------------------------------------------------
345
343
  ** Input: none
346
- ** Output: none
344
+ ** Output: returns error code
347
345
  ** Purpose: initializes volumes in non-cylindrical tanks
348
346
  **---------------------------------------------------------------
349
347
  */
@@ -352,7 +350,7 @@ void inittanks(Project *pr)
352
350
 
353
351
  int i, j, n = 0;
354
352
  double a;
355
- int errcode = 0;
353
+ int errcode = 0, levelerr;
356
354
  char errmsg[MAXMSG+1] = "";
357
355
  Stank *tank;
358
356
  Scurve *curve;
@@ -362,23 +360,47 @@ void inittanks(Project *pr)
362
360
  tank = &net->Tank[j];
363
361
  if (tank->A == 0.0) continue; // Skip reservoirs
364
362
 
365
- // See if tank has a volume curve
363
+ // Check for valid lower/upper tank levels
364
+ levelerr = 0;
365
+ if (tank->H0 > tank->Hmax ||
366
+ tank->Hmin > tank->Hmax ||
367
+ tank->H0 < tank->Hmin
368
+ ) levelerr = 1;
369
+
370
+ // Check that tank heights are within volume curve
366
371
  i = tank->Vcurve;
367
372
  if (i > 0)
368
373
  {
369
374
  curve = &net->Curve[i];
370
375
  n = curve->Npts - 1;
376
+ if (tank->Hmin < curve->X[0] || tank->Hmax > curve->X[n])
377
+ {
378
+ levelerr = 1;
379
+ }
371
380
 
372
- // Find min., max., and initial volumes from curve
373
- tank->Vmin = interp(curve->Npts, curve->X, curve->Y, tank->Hmin);
374
- tank->Vmax = interp(curve->Npts, curve->X, curve->Y, tank->Hmax);
375
- tank->V0 = interp(curve->Npts, curve->X, curve->Y, tank->H0);
381
+ else
382
+ {
383
+ // Find min., max., and initial volumes from curve
384
+ tank->Vmin = interp(curve->Npts, curve->X, curve->Y, tank->Hmin);
385
+ tank->Vmax = interp(curve->Npts, curve->X, curve->Y, tank->Hmax);
386
+ tank->V0 = interp(curve->Npts, curve->X, curve->Y, tank->H0);
387
+
388
+ // Find a "nominal" diameter for tank
389
+ a = (curve->Y[n] - curve->Y[0]) / (curve->X[n] - curve->X[0]);
390
+ tank->A = sqrt(4.0 * a / PI);
391
+ }
392
+ }
376
393
 
377
- // Find a "nominal" diameter for tank
378
- a = (curve->Y[n] - curve->Y[0]) / (curve->X[n] - curve->X[0]);
379
- tank->A = sqrt(4.0 * a / PI);
394
+ // Report error in levels if found
395
+ if (levelerr)
396
+ {
397
+ sprintf(pr->Msg, "Error 225: %s node %s", geterrmsg(225, errmsg),
398
+ net->Node[tank->Node].ID);
399
+ writeline(pr, pr->Msg);
400
+ errcode = 200;
380
401
  }
381
402
  }
403
+ return errcode;
382
404
  }
383
405
 
384
406
  void initunits(Project *pr)
@@ -408,6 +430,8 @@ void initunits(Project *pr)
408
430
  strcpy(rpt->Field[DEMAND].Units, RptFlowUnitsTxt[parser->Flowflag]);
409
431
  strcpy(rpt->Field[ELEV].Units, u_METERS);
410
432
  strcpy(rpt->Field[HEAD].Units, u_METERS);
433
+ if (parser->Pressflag == METERS) strcpy(rpt->Field[PRESSURE].Units, u_METERS);
434
+ else strcpy(rpt->Field[PRESSURE].Units, u_KPA);
411
435
  strcpy(rpt->Field[LENGTH].Units, u_METERS);
412
436
  strcpy(rpt->Field[DIAM].Units, u_MMETERS);
413
437
  strcpy(rpt->Field[FLOW].Units, RptFlowUnitsTxt[parser->Flowflag]);
@@ -422,9 +446,10 @@ void initunits(Project *pr)
422
446
  if (parser->Flowflag == MLD) qcf = MLDperCFS;
423
447
  if (parser->Flowflag == CMH) qcf = CMHperCFS;
424
448
  if (parser->Flowflag == CMD) qcf = CMDperCFS;
425
- if (parser->Flowflag == CMS) qcf = CMSperCFS;
426
449
 
427
450
  hcf = MperFT;
451
+ if (parser->Pressflag == METERS) pcf = MperFT * hyd->SpGrav;
452
+ else pcf = KPAperPSI * PSIperFT * hyd->SpGrav;
428
453
  wcf = KWperHP;
429
454
  }
430
455
  else // US units
@@ -432,6 +457,7 @@ void initunits(Project *pr)
432
457
  strcpy(rpt->Field[DEMAND].Units, RptFlowUnitsTxt[parser->Flowflag]);
433
458
  strcpy(rpt->Field[ELEV].Units, u_FEET);
434
459
  strcpy(rpt->Field[HEAD].Units, u_FEET);
460
+ strcpy(rpt->Field[PRESSURE].Units, u_PSI);
435
461
  strcpy(rpt->Field[LENGTH].Units, u_FEET);
436
462
  strcpy(rpt->Field[DIAM].Units, u_INCHES);
437
463
  strcpy(rpt->Field[FLOW].Units, RptFlowUnitsTxt[parser->Flowflag]);
@@ -447,16 +473,10 @@ void initunits(Project *pr)
447
473
  if (parser->Flowflag == IMGD) qcf = IMGDperCFS;
448
474
  if (parser->Flowflag == AFD) qcf = AFDperCFS;
449
475
  hcf = 1.0;
476
+ pcf = PSIperFT * hyd->SpGrav;
450
477
  wcf = 1.0;
451
478
  }
452
479
 
453
- strcpy(rpt->Field[PRESSURE].Units, PressUnitsTxt[parser->Pressflag]);
454
- pcf = PSIperFT * hyd->SpGrav; // Default to PSI
455
- if (parser->Pressflag == METERS) pcf = MperFT;
456
- if (parser->Pressflag == KPA) pcf = KPAperPSI * PSIperFT * hyd->SpGrav;
457
- if (parser->Pressflag == BAR) pcf = BARperPSI * PSIperFT * hyd->SpGrav;
458
- if (parser->Pressflag == FEET) pcf = 1.0;
459
-
460
480
  strcpy(rpt->Field[QUALITY].Units, "");
461
481
  ccf = 1.0;
462
482
  if (qual->Qualflag == CHEM)
@@ -513,11 +533,12 @@ void convertunits(Project *pr)
513
533
  Parser *parser = &pr->parser;
514
534
 
515
535
  int i, j, k;
516
- double ucf, ecf; // Unit conversion factor
536
+ double ucf; // Unit conversion factor
517
537
  Pdemand demand; // Pointer to demand record
518
538
  Snode *node;
519
539
  Stank *tank;
520
540
  Slink *link;
541
+ Spump *pump;
521
542
  Scontrol *control;
522
543
 
523
544
  // Convert nodal elevations & initial WQ
@@ -544,9 +565,7 @@ void convertunits(Project *pr)
544
565
  hyd->Preq /= pr->Ucf[PRESSURE];
545
566
 
546
567
  // Convert emitter discharge coeffs. to head loss coeff.
547
- ecf = (parser->Unitsflag == US) ? (PSIperFT * hyd->SpGrav) : (MperFT);
548
-
549
- ucf = pow(pr->Ucf[FLOW], hyd->Qexp) / ecf;
568
+ ucf = pow(pr->Ucf[FLOW], hyd->Qexp) / pr->Ucf[PRESSURE];
550
569
  for (i = 1; i <= net->Njuncs; i++)
551
570
  {
552
571
  node = &net->Node[i];
@@ -569,6 +588,7 @@ void convertunits(Project *pr)
569
588
  tank->Kb /= SECperDAY;
570
589
  tank->V = tank->V0;
571
590
  tank->C = node->C0;
591
+ tank->V1max *= tank->Vmax;
572
592
  }
573
593
 
574
594
  // Convert hydraulic convergence criteria
@@ -600,17 +620,33 @@ void convertunits(Project *pr)
600
620
  // Convert units on reaction coeffs.
601
621
  link->Kb /= SECperDAY;
602
622
  link->Kw /= SECperDAY;
603
-
604
- // Convert leakage parameters
605
- link->LeakArea /= pr->Ucf[LENGTH];
606
- link->LeakExpan /= pr->Ucf[LENGTH];
607
623
  }
608
624
 
609
625
  else if (link->Type == PUMP)
610
626
  {
611
- link->Km /= pr->Ucf[POWER];
627
+ // Convert units for pump curve parameters
628
+ i = findpump(net, k);
629
+ pump = &net->Pump[i];
630
+ if (pump->Ptype == CONST_HP)
631
+ {
632
+ // For constant hp pump, convert kw to hp
633
+ if (parser->Unitsflag == SI) pump->R /= pr->Ucf[POWER];
634
+ }
635
+ else
636
+ {
637
+ // For power curve pumps, convert shutoff head and flow coeff.
638
+ if (pump->Ptype == POWER_FUNC)
639
+ {
640
+ pump->H0 /= pr->Ucf[HEAD];
641
+ pump->R *= (pow(pr->Ucf[FLOW], pump->N) / pr->Ucf[HEAD]);
642
+ }
643
+
644
+ // Convert flow range & max. head units
645
+ pump->Q0 /= pr->Ucf[FLOW];
646
+ pump->Qmax /= pr->Ucf[FLOW];
647
+ pump->Hmax /= pr->Ucf[HEAD];
648
+ }
612
649
  }
613
-
614
650
  else
615
651
  {
616
652
  // For flow control valves, convert flow setting
@@ -631,7 +667,6 @@ void convertunits(Project *pr)
631
667
  break;
632
668
  }
633
669
  }
634
- link->InitSetting = link->Kc;
635
670
  }
636
671
 
637
672
  // Convert units on control settings