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