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: hydcoeffs.c
6
6
  Description: computes coefficients for a hydraulic solution matrix
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 06/15/2024
10
+ Last Updated: 10/04/2019
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -36,7 +36,6 @@ const double CBIG = 1.e8;
36
36
 
37
37
  // Exported functions
38
38
  //void resistcoeff(Project *, int );
39
- //double pcvlosscoeff(Project *, int, double);
40
39
  //void headlosscoeffs(Project *);
41
40
  //void matrixcoeffs(Project *);
42
41
  //void emitterheadloss(Project *, int, double *, double *);
@@ -60,47 +59,11 @@ static void valvecoeff(Project *pr, int k);
60
59
  static void gpvcoeff(Project *pr, int k);
61
60
  static void pbvcoeff(Project *pr, int k);
62
61
  static void tcvcoeff(Project *pr, int k);
63
- static void pcvcoeff(Project *pr, int k);
64
62
  static void prvcoeff(Project *pr, int k, int n1, int n2);
65
63
  static void psvcoeff(Project *pr, int k, int n1, int n2);
66
64
  static void fcvcoeff(Project *pr, int k, int n1, int n2);
67
65
 
68
66
 
69
- void addlowerbarrier(double dq, double* hloss, double* hgrad)
70
- /*
71
- **--------------------------------------------------------------------
72
- ** Input: dq = difference between current flow and lower flow limit
73
- ** Output: hloss = updated head loss value
74
- ** hgrad = updated head loss gradient value
75
- ** Purpose: adds a head loss barrier to prevent flow from falling
76
- ** below a given lower limit.
77
- **--------------------------------------------------------------------
78
- */
79
- {
80
- double a = 1.e9 * dq;
81
- double b = sqrt(a*a + 1.e-6);
82
- *hloss += (a - b) / 2.;
83
- *hgrad += (1.e9 / 2.) * ( 1.0 - a / b);
84
- }
85
-
86
- void addupperbarrier(double dq, double* hloss, double* hgrad)
87
- /*
88
- **--------------------------------------------------------------------
89
- ** Input: dq = difference between current flow and upper flow limit
90
- ** Output: hloss = updated head loss value
91
- ** hgrad = updated head loss gradient value
92
- ** Purpose: adds a head loss barrier to prevent flow from exceeding
93
- ** a given upper limit.
94
- **--------------------------------------------------------------------
95
- */
96
- {
97
- double a = 1.e9 * dq;
98
- double b = sqrt(a*a + 1.e-6);
99
- *hloss += (a + b) / 2.;
100
- *hgrad += (1.e9 / 2.) * ( 1.0 + a / b);
101
- }
102
-
103
-
104
67
  void resistcoeff(Project *pr, int k)
105
68
  /*
106
69
  **--------------------------------------------------------------------
@@ -144,10 +107,6 @@ void resistcoeff(Project *pr, int k)
144
107
  case PUMP:
145
108
  link->R = CBIG;
146
109
  break;
147
-
148
- case PCV:
149
- link->R = pcvlosscoeff(pr, k, link->Kc);
150
- break;
151
110
 
152
111
  // ... For all other links (e.g. valves) use a small resistance
153
112
  default:
@@ -157,87 +116,6 @@ void resistcoeff(Project *pr, int k)
157
116
  }
158
117
 
159
118
 
160
- double pcvlosscoeff(Project* pr, int k, double s)
161
- /*
162
- **--------------------------------------------------------------
163
- ** Input: k = link index
164
- ** s = valve percent open setting
165
- ** Output: returns a valve loss coefficient
166
- ** Purpose: finds a Positional Control Valve's loss
167
- ** coefficient from its percent open setting.
168
- **--------------------------------------------------------------
169
- */
170
- {
171
- Network* net = &pr->network;
172
-
173
- int v = findvalve(net, k); // valve index
174
- int c = net->Valve[v].Curve; // Kv curve index
175
- double d; // valve diameter
176
- double kmo; // fully open loss coeff.
177
- double km; // partly open loss coeff.
178
- double kvr; // Kv / Kvo (Kvo = Kv at fully open)
179
- double *x, *y; // points on kvr v. percent open curve
180
- int k1, k2, npts;
181
- Scurve *curve;
182
-
183
- // Valve has no setting so return 0
184
- if (s == MISSING) return 0.0;
185
-
186
- // Valve is completely open so return its Km value
187
- d = net->Link[k].Diam;
188
- kmo = net->Link[k].Km;
189
- if (s >= 100.0) return kmo;
190
-
191
- // Valve is completely closed so return a large coeff.
192
- if (s <= 0.0) return CBIG;
193
-
194
- // Valve has no assigned curve so assume a linear one
195
- if (c == 0) kvr = s;
196
-
197
- else
198
- {
199
- // Valve curve data
200
- curve = &net->Curve[c];
201
- npts = curve->Npts;
202
- x = curve->X; // x = % open
203
- y = curve->Y; // y = Kv / Kvo as a %
204
-
205
- // s lies below first point of curve
206
- if (s < x[0])
207
- kvr = s / x[0] * y[0];
208
-
209
- // s lies above last point of curve
210
- else if (s > x[npts-1])
211
- {
212
- k2 = npts - 1;
213
- kvr = (s - x[k2]) / (1. - x[k2]) * (1. - y[k2]) + y[k2];
214
- }
215
-
216
- // Otherwise interpolate over curve segment that brackets s
217
- else
218
- {
219
- k2 = 0;
220
- while (k2 < npts && x[k2] < s) k2++;
221
- if (k2 == 0) k2++;
222
- else if (k2 == npts) k2--;
223
- k1 = k2 - 1;
224
- kvr = (y[k2] - y[k1]) / (x[k2] - x[k1]);
225
- kvr = y[k1] + kvr * (s - x[k1]);
226
- }
227
- }
228
-
229
- // Convert kvr from % to fraction
230
- kvr /= 100.;
231
- kvr = MIN(kvr, 1.0);
232
- kvr = MAX(kvr, CSMALL);
233
-
234
- // Convert from Kv ratio to minor loss coeff.
235
- km = kmo / (kvr * kvr);
236
- km = MIN(km, CBIG);
237
- return km;
238
- }
239
-
240
-
241
119
  void headlosscoeffs(Project *pr)
242
120
  /*
243
121
  **--------------------------------------------------------------
@@ -270,9 +148,6 @@ void headlosscoeffs(Project *pr)
270
148
  case TCV:
271
149
  tcvcoeff(pr, k);
272
150
  break;
273
- case PCV:
274
- pcvcoeff(pr, k);
275
- break;
276
151
  case GPV:
277
152
  gpvcoeff(pr, k);
278
153
  break;
@@ -310,7 +185,6 @@ void matrixcoeffs(Project *pr)
310
185
  linkcoeffs(pr);
311
186
  emittercoeffs(pr);
312
187
  demandcoeffs(pr);
313
- if (hyd->HasLeakage) leakagecoeffs(pr);
314
188
 
315
189
  // Update nodal flow balances with demands and add onto r.h.s. coeffs.
316
190
  nodecoeffs(pr);
@@ -507,7 +381,7 @@ void emitterheadloss(Project *pr, int i, double *hloss, double *hgrad)
507
381
  ** Input: i = node index
508
382
  ** Output: hloss = head loss across node's emitter
509
383
  ** hgrad = head loss gradient
510
- ** Purpose: computes an emitter's head loss and gradient.
384
+ ** Purpose: computes an emitters's head loss and gradient.
511
385
  **-------------------------------------------------------------
512
386
  */
513
387
  {
@@ -526,18 +400,12 @@ void emitterheadloss(Project *pr, int i, double *hloss, double *hgrad)
526
400
  // Use linear head loss function for small gradient
527
401
  if (*hgrad < hyd->RQtol)
528
402
  {
529
- *hgrad = hyd->RQtol / hyd->Qexp;
403
+ *hgrad = hyd->RQtol;
530
404
  *hloss = (*hgrad) * q;
531
405
  }
532
406
 
533
407
  // Otherwise use normal emitter head loss function
534
408
  else *hloss = (*hgrad) * q / hyd->Qexp;
535
-
536
- // Prevent negative flow if backflow not allowed
537
- if (hyd->EmitBackFlag == 0)
538
- {
539
- addlowerbarrier(q, hloss, hgrad);
540
- }
541
409
  }
542
410
 
543
411
 
@@ -575,7 +443,7 @@ void demandcoeffs(Project *pr)
575
443
  for (i = 1; i <= net->Njuncs; i++)
576
444
  {
577
445
  // Skip junctions with non-positive demands
578
- if (hyd->FullDemand[i] <= 0.0) continue;
446
+ if (hyd->NodeDemand[i] <= 0.0) continue;
579
447
 
580
448
  // Find head loss for demand outflow at node's elevation
581
449
  demandheadloss(pr, i, dp, n, &hloss, &hgrad);
@@ -607,17 +475,35 @@ void demandheadloss(Project *pr, int i, double dp, double n,
607
475
  Hydraul *hyd = &pr->hydraul;
608
476
 
609
477
  double d = hyd->DemandFlow[i];
610
- double dfull = hyd->FullDemand[i];
478
+ double dfull = hyd->NodeDemand[i];
611
479
  double r = d / dfull;
612
480
 
613
- // Evaluate inverted demand function
614
- r = fabs(d) / dfull;
615
- *hgrad = n * dp * pow(r, n - 1.0) / dfull;
616
- *hloss = (*hgrad) * d / n;
481
+ // Use lower barrier function for negative demand
482
+ if (r <= 0)
483
+ {
484
+ *hgrad = CBIG;
485
+ *hloss = CBIG * d;
486
+ }
487
+
488
+ // Use power head loss function for demand less than full
489
+ else if (r < 1.0)
490
+ {
491
+ *hgrad = n * dp * pow(r, n - 1.0) / dfull;
492
+ // ... use linear function for very small gradient
493
+ if (*hgrad < hyd->RQtol)
494
+ {
495
+ *hgrad = hyd->RQtol;
496
+ *hloss = (*hgrad) * d;
497
+ }
498
+ else *hloss = (*hgrad) * d / n;
499
+ }
617
500
 
618
- // Add barrier functions
619
- addlowerbarrier(d, hloss, hgrad);
620
- addupperbarrier(d-dfull, hloss, hgrad);
501
+ // Use upper barrier function for demand above full value
502
+ else
503
+ {
504
+ *hgrad = CBIG;
505
+ *hloss = dp + CBIG * (d - dfull);
506
+ }
621
507
  }
622
508
 
623
509
 
@@ -667,7 +553,7 @@ void pipecoeff(Project *pr, int k)
667
553
  // ... use linear function for very small gradient
668
554
  if (hgrad < hyd->RQtol)
669
555
  {
670
- hgrad = hyd->RQtol / hyd->Hexp;
556
+ hgrad = hyd->RQtol;
671
557
  hloss = hgrad * q;
672
558
  }
673
559
  // ... otherwise use original formula
@@ -858,23 +744,17 @@ void pumpcoeff(Project *pr, int k)
858
744
  {
859
745
  // ... compute pump curve's gradient
860
746
  hgrad = -r / q / q;
861
-
862
- // ... treat as closed link if gradient too large
747
+ // ... use linear curve if gradient too large or too small
863
748
  if (hgrad > CBIG)
864
749
  {
865
- hyd->P[k] = 1.0 / CBIG;
866
- hyd->Y[k] = hyd->LinkFlow[k];
867
- return;
750
+ hgrad = CBIG;
751
+ hloss = -hgrad * hyd->LinkFlow[k];
868
752
  }
869
-
870
- // ... treat as open valve if gradient too small
871
- else if (hgrad < CSMALL)
753
+ else if (hgrad < hyd->RQtol)
872
754
  {
873
- hyd->P[k] = 1.0 / CSMALL;
874
- hyd->Y[k] = hyd->LinkFlow[k];
875
- return;
876
- }
877
-
755
+ hgrad = hyd->RQtol;
756
+ hloss = -hgrad * hyd->LinkFlow[k];
757
+ }
878
758
  // ... otherwise compute head loss from pump curve
879
759
  else
880
760
  {
@@ -1059,36 +939,6 @@ void tcvcoeff(Project *pr, int k)
1059
939
  }
1060
940
 
1061
941
 
1062
- void pcvcoeff(Project *pr, int k)
1063
- /*
1064
- **--------------------------------------------------------------
1065
- ** Input: k = link index
1066
- ** Output: none
1067
- ** Purpose: computes P & Y coeffs. for positional control valve
1068
- **--------------------------------------------------------------
1069
- */
1070
- {
1071
- double km;
1072
- Hydraul *hyd = &pr->hydraul;
1073
- Slink *link = &pr->network.Link[k];
1074
-
1075
- // Save original loss coeff. for open valve
1076
- km = link->Km;
1077
-
1078
- // If valve not fixed OPEN or CLOSED, compute its loss coeff.
1079
- if (hyd->LinkSetting[k] != MISSING)
1080
- {
1081
- link->Km = link->R;
1082
- }
1083
-
1084
- // Then apply usual valve formula
1085
- valvecoeff(pr, k);
1086
-
1087
- // Restore original loss coeff.
1088
- link->Km = km;
1089
- }
1090
-
1091
-
1092
942
  void prvcoeff(Project *pr, int k, int n1, int n2)
1093
943
  /*
1094
944
  **--------------------------------------------------------------
@@ -1179,8 +1029,6 @@ void psvcoeff(Project *pr, int k, int n1, int n2)
1179
1029
  {
1180
1030
  sm->F[j] += hyd->Xflow[n1];
1181
1031
  }
1182
- sm->Aij[sm->Ndx[k]] -= 1.0 / CBIG; // Preserve connectivity
1183
- sm->Aii[j] += 1.0 / CBIG;
1184
1032
  return;
1185
1033
  }
1186
1034
 
@@ -1283,7 +1131,7 @@ void valvecoeff(Project *pr, int k)
1283
1131
  // Guard against too small a head loss gradient
1284
1132
  if (hgrad < hyd->RQtol)
1285
1133
  {
1286
- hgrad = hyd->RQtol / 2.0;
1134
+ hgrad = hyd->RQtol;
1287
1135
  hloss = flow * hgrad;
1288
1136
  }
1289
1137
  else hloss = flow * hgrad / 2.0;