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,7 +1,7 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.2
4
+ Version: 2.3
5
5
  Module: smatrix.c
6
6
  Description: solves a sparse set of linear equations
7
7
  Authors: see AUTHORS
@@ -48,8 +48,8 @@ static int paralink(Network *, Smatrix *, int, int, int k);
48
48
  static void xparalinks(Network *);
49
49
  static int reordernodes(Project *);
50
50
  static int factorize(Project *);
51
- static int growlist(Project *, int);
52
- static int newlink(Project *, Padjlist);
51
+ static int growlist(Project *, int, int *);
52
+ static int newlink(Project *, Padjlist, int *);
53
53
  static int linked(Network *, int, int);
54
54
  static int addlink(Network *, int, int, int);
55
55
  static int storesparse(Project *, int);
@@ -443,8 +443,8 @@ int factorize(Project *pr)
443
443
  Padjlist alink;
444
444
 
445
445
  // Find degree of each junction node
446
- sm->Degree = (int *)calloc(net->Nnodes + 1, sizeof(int));
447
- if (sm->Degree == NULL) return 101;
446
+ int *degree = (int *)calloc(net->Nnodes + 1, sizeof(int));
447
+ if (degree == NULL) return 101;
448
448
 
449
449
  // NOTE: For purposes of node re-ordering, Tanks (nodes with
450
450
  // indexes above Njuncs) have zero degree of adjacency.
@@ -453,7 +453,7 @@ int factorize(Project *pr)
453
453
  {
454
454
  for (alink = net->Adjlist[k]; alink != NULL; alink = alink->next)
455
455
  {
456
- if (alink->node > 0) sm->Degree[k]++;
456
+ if (alink->node > 0) degree[k]++;
457
457
  }
458
458
  }
459
459
 
@@ -463,19 +463,19 @@ int factorize(Project *pr)
463
463
  for (k = 1; k <= net->Njuncs; k++) // Examine each junction
464
464
  {
465
465
  knode = sm->Order[k]; // Re-ordered index
466
- if (!growlist(pr, knode)) // Augment adjacency list
466
+ if (!growlist(pr, knode, degree)) // Augment adjacency list
467
467
  {
468
468
  errcode = 101;
469
469
  break;
470
470
  }
471
- sm->Degree[knode] = 0; // In-activate node
471
+ degree[knode] = 0; // In-activate node
472
472
  }
473
- free(sm->Degree);
473
+ free(degree);
474
474
  return errcode;
475
475
  }
476
476
 
477
477
 
478
- int growlist(Project *pr, int knode)
478
+ int growlist(Project *pr, int knode, int *degree)
479
479
  /*
480
480
  **--------------------------------------------------------------
481
481
  ** Input: knode = node index
@@ -496,10 +496,10 @@ int growlist(Project *pr, int knode)
496
496
  for (alink = net->Adjlist[knode]; alink != NULL; alink = alink -> next)
497
497
  {
498
498
  node = alink->node; // End node of connecting link
499
- if (node > 0 && sm->Degree[node] > 0) // End node is active
499
+ if (node > 0 && degree[node] > 0) // End node is active
500
500
  {
501
- sm->Degree[node]--; // Reduce degree of adjacency
502
- if (!newlink(pr, alink)) // Add to adjacency list
501
+ degree[node]--; // Reduce degree of adjacency
502
+ if (!newlink(pr, alink, degree)) // Add to adjacency list
503
503
  {
504
504
  return 0;
505
505
  }
@@ -509,7 +509,7 @@ int growlist(Project *pr, int knode)
509
509
  }
510
510
 
511
511
 
512
- int newlink(Project *pr, Padjlist alink)
512
+ int newlink(Project *pr, Padjlist alink, int *degree)
513
513
  /*
514
514
  **--------------------------------------------------------------
515
515
  ** Input: alink = element of node's adjacency list
@@ -533,7 +533,7 @@ int newlink(Project *pr, Padjlist alink)
533
533
 
534
534
  // If jnode still active, and inode not connected to jnode,
535
535
  // then add a new connection between inode and jnode.
536
- if (jnode > 0 && sm->Degree[jnode] > 0) // jnode still active
536
+ if (jnode > 0 && degree[jnode] > 0) // jnode still active
537
537
  {
538
538
  if (!linked(net, inode, jnode)) // inode not linked to jnode
539
539
  {
@@ -545,8 +545,8 @@ int newlink(Project *pr, Padjlist alink)
545
545
  // reflect the new connection.
546
546
  if (!addlink(net, inode, jnode, sm->Ncoeffs)) return 0;
547
547
  if (!addlink(net, jnode, inode, sm->Ncoeffs)) return 0;
548
- sm->Degree[inode]++;
549
- sm->Degree[jnode]++;
548
+ degree[inode]++;
549
+ degree[jnode]++;
550
550
  }
551
551
  }
552
552
  }
@@ -651,7 +651,7 @@ int sortsparse(Smatrix *sm, int n)
651
651
  /*
652
652
  **--------------------------------------------------------------
653
653
  ** Input: n = number of rows in solution matrix
654
- ** Output: returns eror code
654
+ ** Output: returns error code
655
655
  ** Purpose: puts row indexes in ascending order in NZSUB
656
656
  **--------------------------------------------------------------
657
657
  */
@@ -834,7 +834,7 @@ int linsolve(Smatrix *sm, int n)
834
834
  }
835
835
  } // next j
836
836
 
837
- // Foward substitution
837
+ // Forward substitution
838
838
  for (j = 1; j <= n; j++)
839
839
  {
840
840
  bj = B[j]/Aii[j];
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.2
4
+ Version: 2.3
5
5
  Module: text.h
6
6
  Description: string constants used throughout EPANET
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 07/15/2019
10
+ Last Updated: 03/10/2025
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -40,6 +40,7 @@
40
40
  #define w_FCV "FCV"
41
41
  #define w_TCV "TCV"
42
42
  #define w_GPV "GPV"
43
+ #define w_PCV "PCV"
43
44
 
44
45
  #define w_OPEN "OPEN"
45
46
  #define w_CLOSED "CLOSED"
@@ -51,9 +52,6 @@
51
52
  #define w_IS "IS"
52
53
  #define w_NOT "NOT"
53
54
 
54
- #define w_ADD "ADD"
55
- #define w_MULTIPLY "MULT"
56
-
57
55
  #define w_LIMITING "LIMIT"
58
56
  #define w_ORDER "ORDER"
59
57
  #define w_GLOBAL "GLOB"
@@ -86,11 +84,14 @@
86
84
  #define w_MLD "MLD"
87
85
  #define w_CMH "CMH"
88
86
  #define w_CMD "CMD"
87
+ #define w_CMS "CMS"
89
88
  #define w_SI "SI"
90
89
 
91
90
  #define w_PSI "PSI"
92
91
  #define w_KPA "KPA"
93
92
  #define w_METERS "METERS"
93
+ #define w_BAR "BAR"
94
+ #define w_FEET "FEET"
94
95
 
95
96
  #define w_ELEV "ELEV"
96
97
  #define w_DEMAND "DEMAND"
@@ -130,6 +131,8 @@
130
131
  #define w_SEGMENTS "SEGM"
131
132
  #define w_TOLERANCE "TOLER"
132
133
  #define w_EMITTER "EMIT"
134
+ #define w_BACKFLOW "BACK"
135
+ #define w_ALLOWED "ALLOW"
133
136
 
134
137
  #define w_PRICE "PRICE"
135
138
  #define w_DMNDCHARGE "DEMAN"
@@ -150,6 +153,9 @@
150
153
  #define w_REQUIRED "REQ"
151
154
  #define w_EXPONENT "EXP"
152
155
 
156
+ #define w_AREA "AREA"
157
+ #define w_EXPAN "EXPAN"
158
+
153
159
  #define w_SECONDS "SEC"
154
160
  #define w_MINUTES "MIN"
155
161
  #define w_HOURS "HOU"
@@ -192,6 +198,7 @@
192
198
  #define w_THEN "THEN"
193
199
  #define w_ELSE "ELSE"
194
200
  #define w_PRIORITY "PRIO"
201
+ #define w_DISABLED "DISABLED"
195
202
 
196
203
  // ------ Input File Section Names ------------------------
197
204
 
@@ -207,6 +214,7 @@
207
214
  #define s_DEMANDS "[DEMANDS]"
208
215
  #define s_SOURCES "[SOURCES]"
209
216
  #define s_EMITTERS "[EMITTERS]"
217
+ #define s_LEAKAGE "[LEAKAGE]"
210
218
  #define s_PATTERNS "[PATTERNS]"
211
219
  #define s_CURVES "[CURVES]"
212
220
  #define s_QUALITY "[QUALITY]"
@@ -234,6 +242,7 @@
234
242
  #define u_IMGD "Imgd"
235
243
  #define u_LPS "L/s"
236
244
  #define u_LPM "Lpm"
245
+ #define u_CMS "m3/s"
237
246
  #define u_CMH "m3/h"
238
247
  #define u_CMD "m3/d"
239
248
  #define u_MLD "ML/d"
@@ -263,6 +272,8 @@
263
272
  #define c_PUMP "PUMP"
264
273
  #define c_EFFIC "EFFIC"
265
274
  #define c_VOLUME "VOLUME"
275
+ #define c_VALVE "VALVE"
276
+ #define c_GENERIC "GENERIC"
266
277
 
267
278
  //------- Text Phrases ------------------------------------
268
279
 
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.2
4
+ Version: 2.3
5
5
  Module: types.h
6
6
  Description: symbolic constants and data types used throughout EPANET
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 10/29/2019
10
+ Last Updated: 04/19/2025
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -31,7 +31,7 @@ typedef int INT4;
31
31
  Various constants
32
32
  ----------------------------------------------
33
33
  */
34
- #define CODEVERSION 20200
34
+ #define CODEVERSION 20300
35
35
  #define MAGICNUMBER 516114521
36
36
  #define ENGINE_VERSION 201 // Used for binary hydraulics file
37
37
  #define EOFMARK 0x1A // Use 0x04 for UNIX systems
@@ -48,6 +48,9 @@ typedef int INT4;
48
48
  #define BIG 1.E10
49
49
  #define TINY 1.E-6
50
50
  #define MISSING -1.E10 // Missing value indicator
51
+ #define SET_CLOSED -1.E10 // Link set closed indicator
52
+ #define SET_OPEN 1.E10 // Link set open indicator
53
+
51
54
  #define DIFFUS 1.3E-8 // Diffusivity of chlorine
52
55
  // @ 20 deg C (sq ft/sec)
53
56
  #define VISCOS 1.1E-5 // Kinematic viscosity of water
@@ -71,6 +74,7 @@ typedef int INT4;
71
74
  #define IMGDperCFS 0.5382
72
75
  #define LPSperCFS 28.317
73
76
  #define LPMperCFS 1699.0
77
+ #define CMSperCFS 0.028317
74
78
  #define CMHperCFS 101.94
75
79
  #define CMDperCFS 2446.6
76
80
  #define MLDperCFS 2.4466
@@ -79,6 +83,7 @@ typedef int INT4;
79
83
  #define MperFT 0.3048
80
84
  #define PSIperFT 0.4333
81
85
  #define KPAperPSI 6.895
86
+ #define BARperPSI 0.068948
82
87
  #define KWperHP 0.7457
83
88
  #define SECperDAY 86400
84
89
 
@@ -145,7 +150,8 @@ typedef enum {
145
150
  PBV, // pressure breaker valve
146
151
  FCV, // flow control valve
147
152
  TCV, // throttle control valve
148
- GPV // general purpose valve
153
+ GPV, // general purpose valve
154
+ PCV // positional control valve
149
155
  } LinkType;
150
156
 
151
157
  typedef enum {
@@ -166,7 +172,8 @@ typedef enum {
166
172
  PUMP_CURVE, // pump curve
167
173
  EFFIC_CURVE, // efficiency curve
168
174
  HLOSS_CURVE, // head loss curve
169
- GENERIC_CURVE // generic curve
175
+ GENERIC_CURVE, // generic curve
176
+ VALVE_CURVE // positional valve loss curve
170
177
  } CurveType;
171
178
 
172
179
  typedef enum {
@@ -225,13 +232,17 @@ typedef enum {
225
232
  LPM, // liters per minute
226
233
  MLD, // megaliters per day
227
234
  CMH, // cubic meters per hour
228
- CMD // cubic meters per day
235
+ CMD, // cubic meters per day
236
+ CMS // cubic meters per second
229
237
  } FlowUnitsType;
230
238
 
231
239
  typedef enum {
232
240
  PSI, // pounds per square inch
233
241
  KPA, // kiloPascals
234
- METERS // meters
242
+ METERS, // meters
243
+ BAR, // bar
244
+ FEET, // feet
245
+ DEFAULTUNIT // default based on unit system (SI or US)
235
246
  } PressureUnitsType;
236
247
 
237
248
  typedef enum {
@@ -287,7 +298,7 @@ typedef enum {
287
298
  _VALVES, _CONTROLS, _RULES, _DEMANDS, _SOURCES, _EMITTERS,
288
299
  _PATTERNS, _CURVES, _QUALITY, _STATUS, _ROUGHNESS, _ENERGY,
289
300
  _REACTIONS, _MIXING, _REPORT, _TIMES, _OPTIONS,
290
- _COORDS, _VERTICES, _LABELS, _BACKDROP, _TAGS, _END
301
+ _COORDS, _VERTICES, _LABELS, _BACKDROP, _TAGS, _LEAKAGE, _END
291
302
  } SectionType;
292
303
 
293
304
  typedef enum {
@@ -355,6 +366,8 @@ typedef struct // Energy Usage Object
355
366
  double KwHrs; // total kw-hrs consumed
356
367
  double MaxKwatts; // max. kw consumed
357
368
  double TotalCost; // total pumping cost
369
+ double CurrentPower; // current pump power (kw)
370
+ double CurrentEffic; // current pump efficiency
358
371
  } Senergy;
359
372
 
360
373
  struct Ssource // Water Quality Source Object
@@ -389,6 +402,7 @@ typedef struct // Node Object
389
402
  int ResultIndex; // saved result index
390
403
  NodeType Type; // node type
391
404
  char *Comment; // node comment
405
+ char *Tag; // optional category tag
392
406
  } Snode;
393
407
 
394
408
  typedef struct // Link Object
@@ -398,18 +412,22 @@ typedef struct // Link Object
398
412
  int N2; // end node index
399
413
  double Diam; // diameter
400
414
  double Len; // length
401
- double Kc; // roughness
415
+ double Kc; // pipe roughness, pump speed, valve setting
402
416
  double Km; // minor loss coeff.
403
417
  double Kb; // bulk react. coeff.
404
418
  double Kw; // wall react. coef.
405
419
  double R; // flow resistance
406
420
  double Rc; // reaction coeff.
421
+ double LeakArea; // leak area (sq mm per 100 pipe length units
422
+ double LeakExpan; // leak expansion (sq mm per unit of head)
407
423
  LinkType Type; // link type
408
- StatusType Status; // initial status
424
+ StatusType InitStatus; // initial status
425
+ double InitSetting; // initial setting
409
426
  Pvertices Vertices; // internal vertex coordinates
410
427
  int Rpt; // reporting flag
411
428
  int ResultIndex; // saved result index
412
429
  char *Comment; // link comment
430
+ char *Tag; // optional category tag
413
431
  } Slink;
414
432
 
415
433
  typedef struct // Tank Object
@@ -428,7 +446,7 @@ typedef struct // Tank Object
428
446
  int Pat; // fixed grade time pattern
429
447
  int Vcurve; // volume v. elev. curve index
430
448
  MixType MixModel; // type of mixing model
431
- double V1max; // mixing compartment size
449
+ double V1frac; // mixing compartment fraction
432
450
  int CanOverflow; // tank can overflow or not
433
451
  } Stank;
434
452
 
@@ -453,6 +471,7 @@ typedef struct // Pump Object
453
471
  typedef struct // Valve Object
454
472
  {
455
473
  int Link; // link index of valve
474
+ int Curve; // positional loss coeff. curve
456
475
  } Svalve;
457
476
 
458
477
  typedef struct // Control Statement
@@ -464,6 +483,7 @@ typedef struct // Control Statement
464
483
  double Setting; // new link setting
465
484
  StatusType Status; // new link status
466
485
  ControlType Type; // control type
486
+ int isEnabled; // control enabled?
467
487
  } Scontrol;
468
488
 
469
489
  typedef struct // Field Object of Report Table
@@ -515,6 +535,7 @@ typedef struct // Control Rule Structure
515
535
  {
516
536
  char label[MAXID+1]; // rule label
517
537
  double priority; // priority level
538
+ int isEnabled; // is the rule enabled?
518
539
  Spremise *Premises; // list of premises
519
540
  Saction *ThenActions; // list of THEN actions
520
541
  Saction *ElseActions; // list of ELSE actions
@@ -535,8 +556,29 @@ typedef struct // Mass Balance Components
535
556
  double reacted; // mass reacted in system
536
557
  double final; // final mass in system
537
558
  double ratio; // ratio of mass added to mass lost
559
+ int segCount; // total number of pipe segments used
538
560
  } SmassBalance;
539
561
 
562
+ typedef struct
563
+ {
564
+ double totalInflow;
565
+ double totalOutflow;
566
+ double consumerDemand;
567
+ double emitterDemand;
568
+ double leakageDemand;
569
+ double deficitDemand;
570
+ double storageDemand;
571
+ double ratio;
572
+ } SflowBalance;
573
+
574
+ typedef struct // Node Leakage Object
575
+ {
576
+ double qfa; // fixed area leakage flow
577
+ double qva; // variable area leakage flow
578
+ double cfa; // fixed area leakage coeff.
579
+ double cva; // variable area leakage coeff.
580
+ } Sleakage;
581
+
540
582
  /*
541
583
  ------------------------------------------------------
542
584
  Wrapper Data Structures
@@ -571,8 +613,7 @@ typedef struct {
571
613
  ErrTok, // Index of error-producing token
572
614
  Unitsflag, // Unit system flag
573
615
  Flowflag, // Flow units flag
574
- Pressflag, // Pressure units flag
575
- DefPat; // Default demand pattern
616
+ Pressflag; // Pressure units flag
576
617
 
577
618
  Spattern *PrevPat; // Previous pattern processed
578
619
  Scurve *PrevCurve; // Previous curve processed
@@ -628,7 +669,10 @@ typedef struct {
628
669
  Rpt2Fname[MAXFNAME+1], // Secondary report file name
629
670
  DateStamp[26]; // Current date & time
630
671
 
631
- SField Field[MAXVAR]; // Output reporting fields
672
+ SField Field[MAXVAR]; // Output reporting fields
673
+
674
+ void (*reportCallback)(void*,void*,const char*); // user-supplied reporting callback
675
+ void *reportCallbackUserData; // user-supplied reporting context
632
676
 
633
677
  } Report;
634
678
 
@@ -688,7 +732,6 @@ typedef struct {
688
732
  *XLNZ, // Start position of each column in NZSUB
689
733
  *NZSUB, // Row index of each coeff. in each column
690
734
  *LNZ, // Position of each coeff. in Aij array
691
- *Degree, // Number of links adjacent to each node
692
735
  *link, // Array used by linear eqn. solver
693
736
  *first; // Array used by linear eqn. solver
694
737
 
@@ -699,9 +742,11 @@ typedef struct {
699
742
 
700
743
  double
701
744
  *NodeHead, // Node hydraulic heads
702
- *NodeDemand, // Node demand + emitter flows
703
- *DemandFlow, // Work array of demand flows
704
- *EmitterFlow, // Emitter outflows
745
+ *NodeDemand, // Node total demand (consumer + emitter + leakage)
746
+ *FullDemand, // Required consumer demand
747
+ *DemandFlow, // Demand flow from nodes
748
+ *EmitterFlow, // Emitter flow from nodes
749
+ *LeakageFlow, // Leakage flow from nodes
705
750
  *LinkFlow, // Link flows
706
751
  *LinkSetting, // Link settings
707
752
  Htol, // Hydraulic head tolerance
@@ -728,15 +773,18 @@ typedef struct {
728
773
  MaxHeadError, // Max. error for link head loss
729
774
  MaxFlowChange, // Max. change in link flow
730
775
  DemandReduction, // % demand reduction at pressure deficient nodes
776
+ LeakageLoss, // % system leakage loss
731
777
  RelaxFactor, // Relaxation factor for flow updating
732
778
  *P, // Inverse of head loss derivatives
733
779
  *Y, // Flow correction factors
734
780
  *Xflow; // Inflow - outflow at each node
735
781
 
736
782
  int
783
+ DefPat, // Default demand pattern
737
784
  Epat, // Energy cost time pattern
738
785
  DemandModel, // Fixed or pressure dependent
739
786
  Formflag, // Head loss formula flag
787
+ EmitBackFlag, // Emitter backflow flag
740
788
  Iterations, // Number of hydraulic trials taken
741
789
  MaxIter, // Max. hydraulic trials allowed
742
790
  ExtraIter, // Extra hydraulic trials
@@ -744,12 +792,18 @@ typedef struct {
744
792
  MaxCheck, // Hydraulic trials limit on status checks
745
793
  OpenHflag, // Hydraulic system opened flag
746
794
  Haltflag, // Flag to halt simulation
747
- DeficientNodes; // Number of pressure deficient nodes
795
+ DeficientNodes, // Number of pressure deficient nodes
796
+ HasLeakage; // TRUE if project has non-zero leakage parameters
797
+
798
+ Sleakage *Leakage; // Array of node leakage parameters
748
799
 
749
800
  StatusType
750
801
  *LinkStatus, // Link status
751
802
  *OldStatus; // Previous link/tank status
752
803
 
804
+ SflowBalance
805
+ FlowBalance; // Flow balance components
806
+
753
807
  Smatrix smatrix; // Sparse matrix storage
754
808
 
755
809
  } Hydraul;
@@ -0,0 +1,59 @@
1
+ /*
2
+ ******************************************************************************
3
+ Project: OWA EPANET
4
+ Version: 2.3
5
+ Module: util/cstr_helper.c
6
+ Description: Provides C string helper functions
7
+ Authors: see AUTHORS
8
+ Copyright: see AUTHORS
9
+ License: see LICENSE
10
+ Last Updated: 04/02/2019
11
+ ******************************************************************************
12
+ */
13
+
14
+ #include <stdlib.h>
15
+ #include <string.h>
16
+
17
+ #include "cstr_helper.h"
18
+
19
+
20
+ int cstr_duplicate(char **dest, const char *source)
21
+ // Duplicates source string
22
+ {
23
+ size_t size = 1 + strlen(source);
24
+ *dest = (char *) calloc(size, sizeof(char));
25
+
26
+ if (*dest == NULL)
27
+ return -1;
28
+ else {
29
+ #ifdef _MSC_VER
30
+ strncpy_s(*dest, size, source, size);
31
+ #else
32
+ strncpy(*dest, source, size);
33
+ #endif
34
+ }
35
+ return 0;
36
+ }
37
+
38
+
39
+ bool cstr_isvalid(const char *element_id)
40
+ // Determines if invalid characters are present in an element id string
41
+ {
42
+ const char *invalid_chars = " \";";
43
+
44
+ // if invalid char is present a pointer to it is returned else NULL
45
+ if (strpbrk(element_id, invalid_chars))
46
+ return false;
47
+ else
48
+ return true;
49
+ }
50
+
51
+
52
+ bool cstr_isnullterm(const char *source)
53
+ // Determines if the string passed is null terminated or not
54
+ {
55
+ if (strchr(source, '\0'))
56
+ return true;
57
+ else
58
+ return false;
59
+ }
@@ -0,0 +1,38 @@
1
+ /*
2
+ ******************************************************************************
3
+ Project: OWA EPANET
4
+ Version: 2.3
5
+ Module: util/cstr_helper.h
6
+ Description: Provides C string helper functions
7
+ Authors: see AUTHORS
8
+ Copyright: see AUTHORS
9
+ License: see LICENSE
10
+ Last Updated: 04/02/2019
11
+ ******************************************************************************
12
+ */
13
+
14
+ #ifndef CSTR_HELPER_H_
15
+ #define CSTR_HELPER_H_
16
+
17
+
18
+ #include <stdbool.h>
19
+
20
+
21
+ #if defined(__cplusplus)
22
+ extern "C" {
23
+ #endif
24
+
25
+
26
+ int cstr_duplicate(char **dest, const char *source);
27
+
28
+ bool cstr_isvalid(const char *element_id);
29
+
30
+ bool cstr_isnullterm(const char *source);
31
+
32
+
33
+ #if defined(__cplusplus)
34
+ }
35
+ #endif
36
+
37
+
38
+ #endif /* CSTR_HELPER_H_ */
@@ -0,0 +1,92 @@
1
+ /*
2
+ ******************************************************************************
3
+ Project: OWA EPANET
4
+ Version: 2.3
5
+ Module: util/errormanager.c
6
+ Description: Provides a simple interface for managing errors
7
+ Authors: see AUTHORS
8
+ Copyright: see AUTHORS
9
+ License: see LICENSE
10
+ Last Updated: 08/02/2023
11
+ ******************************************************************************
12
+ */
13
+
14
+ //#ifdef _WIN32
15
+ //#define _CRTDBG_MAP_ALLOC
16
+ //#include <stdlib.h>
17
+ //#include <crtdbg.h>
18
+ //#else
19
+ #include <stdlib.h>
20
+ //#endif
21
+ #include <string.h>
22
+
23
+ #include "errormanager.h"
24
+
25
+
26
+ typedef struct error_s {
27
+ int error_status;
28
+ void (*p_msg_lookup)(int, char*, int);
29
+ } error_handle_t;
30
+
31
+
32
+ error_handle_t *create_error_manager(void (*p_error_message)(int, char*, int))
33
+ //
34
+ // Purpose: Constructs a new error handle.
35
+ //
36
+ {
37
+ error_handle_t *error_handle;
38
+ error_handle = (error_handle_t*)calloc(1, sizeof(error_handle_t));
39
+ if (error_handle == NULL) return NULL;
40
+
41
+ error_handle->p_msg_lookup = p_error_message;
42
+
43
+ return error_handle;
44
+ }
45
+
46
+ void delete_error_manager(error_handle_t *error_handle)
47
+ //
48
+ // Purpose: Destroys the error handle.
49
+ //
50
+ {
51
+ free(error_handle);
52
+ }
53
+
54
+ int set_error(error_handle_t *error_handle, int error_code)
55
+ //
56
+ // Purpose: Sets an error code in the handle.
57
+ //
58
+ {
59
+ // If the error code is 0 no action is taken and 0 is returned.
60
+ // This is a feature not a bug.
61
+ if (error_code)
62
+ error_handle->error_status = error_code;
63
+
64
+ return error_code;
65
+ }
66
+
67
+ int check_error(error_handle_t *error_handle, char **error_message)
68
+ //
69
+ // Purpose: Returns the error message or NULL.
70
+ //
71
+ // Note: Caller must free memory allocated by check_error
72
+ //
73
+ { int error_code = error_handle->error_status;
74
+ char *temp = NULL;
75
+
76
+ if (error_code != 0) {
77
+ temp = (char*) calloc(ERR_MAXMSG + 1, sizeof(char));
78
+
79
+ if (temp)
80
+ error_handle->p_msg_lookup(error_code, temp, ERR_MAXMSG);
81
+ }
82
+ *error_message = temp;
83
+ return error_code;
84
+ }
85
+
86
+ void clear_error(error_handle_t *error_handle)
87
+ //
88
+ // Purpose: Clears the error from the handle.
89
+ //
90
+ {
91
+ error_handle->error_status = 0;
92
+ }