epyt-flow 0.14.2__py3-none-any.whl → 0.15.0b1__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 (102) hide show
  1. epyt_flow/VERSION +1 -1
  2. epyt_flow/__init__.py +0 -37
  3. epyt_flow/data/benchmarks/battledim.py +2 -2
  4. epyt_flow/data/benchmarks/leakdb.py +12 -9
  5. epyt_flow/gym/scenario_control_env.py +32 -33
  6. epyt_flow/simulation/events/actuator_events.py +24 -18
  7. epyt_flow/simulation/events/leakages.py +59 -57
  8. epyt_flow/simulation/events/quality_events.py +21 -30
  9. epyt_flow/simulation/events/system_event.py +3 -3
  10. epyt_flow/simulation/scada/complex_control.py +14 -12
  11. epyt_flow/simulation/scada/custom_control.py +22 -21
  12. epyt_flow/simulation/scada/scada_data.py +107 -104
  13. epyt_flow/simulation/scada/simple_control.py +38 -31
  14. epyt_flow/simulation/scenario_simulator.py +367 -395
  15. epyt_flow/simulation/sensor_config.py +31 -32
  16. epyt_flow/topology.py +11 -10
  17. epyt_flow/uncertainty/model_uncertainty.py +146 -122
  18. epyt_flow/utils.py +0 -66
  19. epyt_flow/visualization/visualization_utils.py +2 -4
  20. {epyt_flow-0.14.2.dist-info → epyt_flow-0.15.0b1.dist-info}/METADATA +12 -18
  21. epyt_flow-0.15.0b1.dist-info/RECORD +65 -0
  22. epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +0 -28
  23. epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +0 -21
  24. epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +0 -18
  25. epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +0 -134
  26. epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +0 -5578
  27. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +0 -865
  28. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +0 -131
  29. epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +0 -73
  30. epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +0 -193
  31. epyt_flow/EPANET/EPANET/SRC_engines/genmmd.c +0 -1000
  32. epyt_flow/EPANET/EPANET/SRC_engines/hash.c +0 -177
  33. epyt_flow/EPANET/EPANET/SRC_engines/hash.h +0 -28
  34. epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +0 -1151
  35. epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +0 -1117
  36. epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +0 -720
  37. epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +0 -476
  38. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +0 -431
  39. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +0 -1786
  40. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +0 -468
  41. epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +0 -810
  42. epyt_flow/EPANET/EPANET/SRC_engines/input1.c +0 -707
  43. epyt_flow/EPANET/EPANET/SRC_engines/input2.c +0 -864
  44. epyt_flow/EPANET/EPANET/SRC_engines/input3.c +0 -2170
  45. epyt_flow/EPANET/EPANET/SRC_engines/main.c +0 -93
  46. epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +0 -142
  47. epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +0 -24
  48. epyt_flow/EPANET/EPANET/SRC_engines/output.c +0 -852
  49. epyt_flow/EPANET/EPANET/SRC_engines/project.c +0 -1359
  50. epyt_flow/EPANET/EPANET/SRC_engines/quality.c +0 -685
  51. epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +0 -743
  52. epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +0 -694
  53. epyt_flow/EPANET/EPANET/SRC_engines/report.c +0 -1489
  54. epyt_flow/EPANET/EPANET/SRC_engines/rules.c +0 -1362
  55. epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +0 -871
  56. epyt_flow/EPANET/EPANET/SRC_engines/text.h +0 -497
  57. epyt_flow/EPANET/EPANET/SRC_engines/types.h +0 -874
  58. epyt_flow/EPANET/EPANET-MSX/MSX_Updates.txt +0 -53
  59. epyt_flow/EPANET/EPANET-MSX/Src/dispersion.h +0 -27
  60. epyt_flow/EPANET/EPANET-MSX/Src/hash.c +0 -107
  61. epyt_flow/EPANET/EPANET-MSX/Src/hash.h +0 -28
  62. epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx.h +0 -102
  63. epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx_export.h +0 -42
  64. epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.c +0 -937
  65. epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.h +0 -39
  66. epyt_flow/EPANET/EPANET-MSX/Src/mempool.c +0 -204
  67. epyt_flow/EPANET/EPANET-MSX/Src/mempool.h +0 -24
  68. epyt_flow/EPANET/EPANET-MSX/Src/msxchem.c +0 -1285
  69. epyt_flow/EPANET/EPANET-MSX/Src/msxcompiler.c +0 -368
  70. epyt_flow/EPANET/EPANET-MSX/Src/msxdict.h +0 -42
  71. epyt_flow/EPANET/EPANET-MSX/Src/msxdispersion.c +0 -586
  72. epyt_flow/EPANET/EPANET-MSX/Src/msxerr.c +0 -116
  73. epyt_flow/EPANET/EPANET-MSX/Src/msxfile.c +0 -260
  74. epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.c +0 -175
  75. epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.h +0 -35
  76. epyt_flow/EPANET/EPANET-MSX/Src/msxinp.c +0 -1504
  77. epyt_flow/EPANET/EPANET-MSX/Src/msxout.c +0 -401
  78. epyt_flow/EPANET/EPANET-MSX/Src/msxproj.c +0 -791
  79. epyt_flow/EPANET/EPANET-MSX/Src/msxqual.c +0 -2010
  80. epyt_flow/EPANET/EPANET-MSX/Src/msxrpt.c +0 -400
  81. epyt_flow/EPANET/EPANET-MSX/Src/msxtank.c +0 -422
  82. epyt_flow/EPANET/EPANET-MSX/Src/msxtoolkit.c +0 -1164
  83. epyt_flow/EPANET/EPANET-MSX/Src/msxtypes.h +0 -551
  84. epyt_flow/EPANET/EPANET-MSX/Src/msxutils.c +0 -524
  85. epyt_flow/EPANET/EPANET-MSX/Src/msxutils.h +0 -56
  86. epyt_flow/EPANET/EPANET-MSX/Src/newton.c +0 -158
  87. epyt_flow/EPANET/EPANET-MSX/Src/newton.h +0 -34
  88. epyt_flow/EPANET/EPANET-MSX/Src/rk5.c +0 -287
  89. epyt_flow/EPANET/EPANET-MSX/Src/rk5.h +0 -39
  90. epyt_flow/EPANET/EPANET-MSX/Src/ros2.c +0 -293
  91. epyt_flow/EPANET/EPANET-MSX/Src/ros2.h +0 -35
  92. epyt_flow/EPANET/EPANET-MSX/Src/smatrix.c +0 -816
  93. epyt_flow/EPANET/EPANET-MSX/Src/smatrix.h +0 -29
  94. epyt_flow/EPANET/EPANET-MSX/readme.txt +0 -14
  95. epyt_flow/EPANET/compile_linux.sh +0 -4
  96. epyt_flow/EPANET/compile_macos.sh +0 -4
  97. epyt_flow/simulation/backend/__init__.py +0 -1
  98. epyt_flow/simulation/backend/my_epyt.py +0 -1101
  99. epyt_flow-0.14.2.dist-info/RECORD +0 -142
  100. {epyt_flow-0.14.2.dist-info → epyt_flow-0.15.0b1.dist-info}/WHEEL +0 -0
  101. {epyt_flow-0.14.2.dist-info → epyt_flow-0.15.0b1.dist-info}/licenses/LICENSE +0 -0
  102. {epyt_flow-0.14.2.dist-info → epyt_flow-0.15.0b1.dist-info}/top_level.txt +0 -0
@@ -1,874 +0,0 @@
1
- /*
2
- ******************************************************************************
3
- Project: OWA EPANET
4
- Version: 2.2
5
- Module: types.h
6
- Description: symbolic constants and data types used throughout EPANET
7
- Authors: see AUTHORS
8
- Copyright: see AUTHORS
9
- License: see LICENSE
10
- Last Updated: 10/29/2019
11
- ******************************************************************************
12
- */
13
-
14
- #ifndef TYPES_H
15
- #define TYPES_H
16
-
17
- #include <stdio.h>
18
-
19
- #include "hash.h"
20
-
21
- /*
22
- -------------------------------------------
23
- Definition of 4-byte integers & reals
24
- -------------------------------------------
25
- */
26
- typedef float REAL4;
27
- typedef int INT4;
28
-
29
- /*
30
- ----------------------------------------------
31
- Various constants
32
- ----------------------------------------------
33
- */
34
- #define CODEVERSION 20200
35
- #define MAGICNUMBER 516114521
36
- #define ENGINE_VERSION 201 // Used for binary hydraulics file
37
- #define EOFMARK 0x1A // Use 0x04 for UNIX systems
38
- #define MAXTITLE 3 // Max. # title lines
39
- #define TITLELEN 79 // Max. # characters in a title line
40
- #define MAXID 31 // Max. # characters in ID name
41
- #define MAXMSG 255 // Max. # characters in message text
42
- #define MAXLINE 1024 // Max. # characters read from input line
43
- #define MAXFNAME 259 // Max. # characters in file name
44
- #define MAXTOKS 40 // Max. items per line of input
45
- #define TRUE 1
46
- #define FALSE 0
47
- #define FULL 2
48
- #define BIG 1.E10
49
- #define TINY 1.E-6
50
- #define MISSING -1.E10 // Missing value indicator
51
- #define DIFFUS 1.3E-8 // Diffusivity of chlorine
52
- // @ 20 deg C (sq ft/sec)
53
- #define VISCOS 1.1E-5 // Kinematic viscosity of water
54
- // @ 20 deg C (sq ft/sec)
55
- #define MINPDIFF 0.1 // PDA min. pressure difference (psi or m)
56
- #define SEPSTR " \t\n\r" // Token separator characters
57
- #ifdef M_PI
58
- #define PI M_PI
59
- #else
60
- #define PI 3.141592654
61
- #endif
62
-
63
- /*
64
- ----------------------------------------------
65
- Flow units conversion factors
66
- ----------------------------------------------
67
- */
68
- #define GPMperCFS 448.831
69
- #define AFDperCFS 1.9837
70
- #define MGDperCFS 0.64632
71
- #define IMGDperCFS 0.5382
72
- #define LPSperCFS 28.317
73
- #define LPMperCFS 1699.0
74
- #define CMHperCFS 101.94
75
- #define CMDperCFS 2446.6
76
- #define MLDperCFS 2.4466
77
- #define M3perFT3 0.028317
78
- #define LperFT3 28.317
79
- #define MperFT 0.3048
80
- #define PSIperFT 0.4333
81
- #define KPAperPSI 6.895
82
- #define KWperHP 0.7457
83
- #define SECperDAY 86400
84
-
85
- /*
86
- ---------------------------------------------------------------------
87
- Macros to test for successful allocation of memory and to free it
88
- ---------------------------------------------------------------------
89
- */
90
- #define MEMCHECK(x) (((x) == NULL) ? 101 : 0 )
91
- #define FREE(x) do { free(x); (x) = NULL; } while(0)
92
-
93
- /*
94
- ---------------------------------------------------------------------
95
- Conversion macros to be used in place of functions
96
- ---------------------------------------------------------------------
97
- */
98
- #define INT(x) ((int)(x)) // integer portion of x
99
- #define FRAC(x) ((x)-(int)(x)) // fractional part of x
100
- #define ABS(x) (((x)<0) ? -(x) : (x)) // absolute value of x
101
- #define MIN(x,y) (((x)<=(y)) ? (x) : (y)) // minimum of x and y
102
- #define MAX(x,y) (((x)>=(y)) ? (x) : (y)) // maximum of x and y
103
- #define ROUND(x) (((x)>=0) ? (int)((x)+.5) : (int)((x)-.5))
104
- // round-off of x
105
- #define MOD(x,y) ((x)%(y)) // x modulus y
106
- #define SQR(x) ((x)*(x)) // x-squared
107
- #define SGN(x) (((x)<0) ? (-1) : (1)) // sign of x
108
- #define UCHAR(x) (((x) >= 'a' && (x) <= 'z') ? ((x)&~32) : (x))
109
- // uppercase char of x
110
- /*
111
- ------------------------------------------------------
112
- Macro to evaluate function x with error checking
113
- (Fatal errors are numbered higher than 100)
114
- ------------------------------------------------------
115
- */
116
- #define ERRCODE(x) (errcode = ((errcode>100) ? (errcode) : (x)))
117
-
118
- /*
119
- ----------------------------------------------
120
- Enumerated Data Types
121
- ----------------------------------------------
122
- */
123
-
124
- typedef enum {
125
- NODE,
126
- LINK,
127
- TIMEPAT,
128
- CURVE,
129
- CONTROL,
130
- RULE
131
- } ObjectType;
132
-
133
- typedef enum {
134
- JUNCTION,
135
- RESERVOIR,
136
- TANK
137
- } NodeType;
138
-
139
- typedef enum {
140
- CVPIPE, // pipe with check valve
141
- PIPE, // pipe
142
- PUMP, // pump
143
- PRV, // pressure reducing valve
144
- PSV, // pressure sustaining valve
145
- PBV, // pressure breaker valve
146
- FCV, // flow control valve
147
- TCV, // throttle control valve
148
- GPV // general purpose valve
149
- } LinkType;
150
-
151
- typedef enum {
152
- USE, // use hydraulics file from previous run
153
- SAVE, // save hydraulics file after current run
154
- SCRATCH // use temporary hydraulics file
155
- } HydFiletype;
156
-
157
- typedef enum {
158
- NONE, // no quality analysis
159
- CHEM, // analyze a chemical
160
- AGE, // analyze water age
161
- TRACE // trace % of flow from a source
162
- } QualType;
163
-
164
- typedef enum {
165
- VOLUME_CURVE, // volume curve
166
- PUMP_CURVE, // pump curve
167
- EFFIC_CURVE, // efficiency curve
168
- HLOSS_CURVE, // head loss curve
169
- GENERIC_CURVE // generic curve
170
- } CurveType;
171
-
172
- typedef enum {
173
- CONST_HP, // constant horsepower
174
- POWER_FUNC, // power function
175
- CUSTOM, // user-defined custom curve
176
- NOCURVE
177
- } PumpType;
178
-
179
- typedef enum {
180
- CONCEN, // inflow concentration
181
- MASS, // mass inflow booster
182
- SETPOINT, // setpoint booster
183
- FLOWPACED // flow paced booster
184
- } SourceType;
185
-
186
- typedef enum {
187
- LOWLEVEL, // act when grade below set level
188
- HILEVEL, // act when grade above set level
189
- TIMER, // act when set time reached
190
- TIMEOFDAY // act when time of day occurs
191
- } ControlType;
192
-
193
- typedef enum {
194
- XHEAD, // pump cannot deliver head (closed)
195
- TEMPCLOSED, // temporarily closed
196
- CLOSED, // closed
197
- OPEN, // open
198
- ACTIVE, // valve active (partially open)
199
- XFLOW, // pump exceeds maximum flow
200
- XFCV, // FCV cannot supply flow
201
- XPRESSURE, // valve cannot supply pressure
202
- FILLING, // tank filling
203
- EMPTYING, // tank emptying
204
- OVERFLOWING // tank overflowing
205
- } StatusType;
206
-
207
- typedef enum {
208
- HW, // Hazen-Williams
209
- DW, // Darcy-Weisbach
210
- CM // Chezy-Manning
211
- } HeadLossType;
212
-
213
- typedef enum {
214
- US, // US
215
- SI // SI (metric)
216
- } UnitsType;
217
-
218
- typedef enum {
219
- CFS, // cubic feet per second
220
- GPM, // gallons per minute
221
- MGD, // million gallons per day
222
- IMGD, // imperial million gal. per day
223
- AFD, // acre-feet per day
224
- LPS, // liters per second
225
- LPM, // liters per minute
226
- MLD, // megaliters per day
227
- CMH, // cubic meters per hour
228
- CMD // cubic meters per day
229
- } FlowUnitsType;
230
-
231
- typedef enum {
232
- PSI, // pounds per square inch
233
- KPA, // kiloPascals
234
- METERS // meters
235
- } PressureUnitsType;
236
-
237
- typedef enum {
238
- LOW, // lower limit
239
- HI, // upper limit
240
- PREC // precision
241
- } RangeType;
242
-
243
- typedef enum {
244
- MIX1, // complete mix model
245
- MIX2, // 2-compartment model
246
- FIFO, // first in, first out model
247
- LIFO // last in, first out model
248
- } MixType;
249
-
250
- typedef enum {
251
- SERIES, // point time series
252
- AVG, // time-averages
253
- MIN, // minimum values
254
- MAX, // maximum values
255
- RANGE // max - min values
256
- } StatisticType;
257
-
258
- typedef enum {
259
- ELEV = 0, // nodal elevation
260
- DEMAND, // nodal demand flow
261
- HEAD, // nodal hydraulic head
262
- PRESSURE, // nodal pressure
263
- QUALITY, // nodal water quality
264
-
265
- LENGTH, // link length
266
- DIAM, // link diameter
267
- FLOW, // link flow rate
268
- VELOCITY, // link flow velocity
269
- HEADLOSS, // link head loss
270
- LINKQUAL, // avg. water quality in link
271
- STATUS, // link status
272
- SETTING, // pump/valve setting
273
- REACTRATE, // avg. reaction rate in link
274
- FRICTION, // link friction factor
275
-
276
- POWER, // pump power output
277
- TIME, // simulation time
278
- VOLUME, // tank volume
279
- CLOCKTIME, // simulation time of day
280
- FILLTIME, // time to fill a tank
281
- DRAINTIME, // time to drain a tank
282
- MAXVAR // total number of variable fields
283
- } FieldType;
284
-
285
- typedef enum {
286
- _TITLE, _JUNCTIONS, _RESERVOIRS, _TANKS, _PIPES, _PUMPS,
287
- _VALVES, _CONTROLS, _RULES, _DEMANDS, _SOURCES, _EMITTERS,
288
- _PATTERNS, _CURVES, _QUALITY, _STATUS, _ROUGHNESS, _ENERGY,
289
- _REACTIONS, _MIXING, _REPORT, _TIMES, _OPTIONS,
290
- _COORDS, _VERTICES, _LABELS, _BACKDROP, _TAGS, _END
291
- } SectionType;
292
-
293
- typedef enum {
294
- STATHDR, // hydraulic status header
295
- ENERHDR, // energy usage header
296
- NODEHDR, // node results header
297
- LINKHDR // link results header
298
- } HdrType;
299
-
300
- typedef enum {
301
- NEGATIVE = -1, // flow in reverse of pre-assigned direction
302
- ZERO_FLOW = 0, // zero flow
303
- POSITIVE = 1 // flow in pre-assigned direction
304
- } FlowDirection;
305
-
306
- typedef enum {
307
- DDA, // demand driven analysis
308
- PDA // pressure driven analysis
309
- } DemandModelType;
310
-
311
- /*
312
- ------------------------------------------------------
313
- Fundamental Data Structures
314
- ------------------------------------------------------
315
- */
316
-
317
- struct IDstring // Holds component ID label
318
- {
319
- char ID[MAXID+1];
320
- };
321
-
322
- typedef struct // Time Pattern Object
323
- {
324
- char ID[MAXID+1]; // pattern ID
325
- char *Comment; // pattern comment
326
- int Length; // pattern length
327
- double *F; // pattern factors
328
- } Spattern;
329
-
330
- typedef struct // Curve Object
331
- {
332
- char ID[MAXID+1]; // curve ID
333
- char *Comment; // curve comment
334
- CurveType Type; // curve type
335
- int Npts; // number of points
336
- int Capacity; // size of X & Y arrays
337
- double *X; // x-values
338
- double *Y; // y-values
339
- } Scurve;
340
-
341
- struct Sdemand // Demand List Item
342
- {
343
- double Base; // baseline demand
344
- int Pat; // pattern index
345
- char *Name; // demand category name
346
- struct Sdemand *next; // next demand list item
347
- };
348
- typedef struct Sdemand *Pdemand; // Pointer to demand list
349
-
350
- typedef struct // Energy Usage Object
351
- {
352
- double TimeOnLine; // hours pump is online
353
- double Efficiency; // total time wtd. efficiency
354
- double KwHrsPerFlow; // total kw-hrs per unit of flow
355
- double KwHrs; // total kw-hrs consumed
356
- double MaxKwatts; // max. kw consumed
357
- double TotalCost; // total pumping cost
358
- } Senergy;
359
-
360
- struct Ssource // Water Quality Source Object
361
- {
362
- double C0; // base concentration/mass
363
- int Pat; // pattern index
364
- double Smass; // actual mass flow rate
365
- SourceType Type; // type of source
366
- };
367
- typedef struct Ssource *Psource; // Pointer to source object
368
-
369
- struct Svertices // Coordinates of a link's vertices
370
- {
371
- double *X; // array of x-coordinates
372
- double *Y; // array of y-coordinates
373
- int Npts; // number of vertex points
374
- int Capacity; // capacity of coordinate arrays
375
- };
376
- typedef struct Svertices *Pvertices; // Pointer to a link's vertices
377
-
378
- typedef struct // Node Object
379
- {
380
- char ID[MAXID+1]; // node ID
381
- double X; // x-coordinate
382
- double Y; // y-coordinate
383
- double El; // elevation
384
- Pdemand D; // demand pointer
385
- Psource S; // source pointer
386
- double C0; // initial quality
387
- double Ke; // emitter coeff.
388
- int Rpt; // reporting flag
389
- int ResultIndex; // saved result index
390
- NodeType Type; // node type
391
- char *Comment; // node comment
392
- } Snode;
393
-
394
- typedef struct // Link Object
395
- {
396
- char ID[MAXID+1]; // link ID
397
- int N1; // start node index
398
- int N2; // end node index
399
- double Diam; // diameter
400
- double Len; // length
401
- double Kc; // roughness
402
- double Km; // minor loss coeff.
403
- double Kb; // bulk react. coeff.
404
- double Kw; // wall react. coef.
405
- double R; // flow resistance
406
- double Rc; // reaction coeff.
407
- LinkType Type; // link type
408
- StatusType Status; // initial status
409
- Pvertices Vertices; // internal vertex coordinates
410
- int Rpt; // reporting flag
411
- int ResultIndex; // saved result index
412
- char *Comment; // link comment
413
- } Slink;
414
-
415
- typedef struct // Tank Object
416
- {
417
- int Node; // node index of tank
418
- double A; // tank area
419
- double Hmin; // minimum water elev
420
- double Hmax; // maximum water elev
421
- double H0; // initial water elev
422
- double Vmin; // minimum volume
423
- double Vmax; // maximum volume
424
- double V0; // initial volume
425
- double Kb; // bulk reaction coeff.
426
- double V; // tank volume
427
- double C; // concentration
428
- int Pat; // fixed grade time pattern
429
- int Vcurve; // volume v. elev. curve index
430
- MixType MixModel; // type of mixing model
431
- double V1max; // mixing compartment size
432
- int CanOverflow; // tank can overflow or not
433
- } Stank;
434
-
435
- typedef struct // Pump Object
436
- {
437
- int Link; // link index of pump
438
- int Ptype; // pump curve type
439
- double Q0; // initial flow
440
- double Qmax; // maximum flow
441
- double Hmax; // maximum head
442
- double H0; // shutoff head
443
- double R; // flow coeffic.
444
- double N; // flow exponent
445
- int Hcurve; // head v. flow curve index
446
- int Ecurve; // effic. v. flow curve index
447
- int Upat; // utilization pattern index
448
- int Epat; // energy cost pattern index
449
- double Ecost; // unit energy cost
450
- Senergy Energy; // energy usage statistics
451
- } Spump;
452
-
453
- typedef struct // Valve Object
454
- {
455
- int Link; // link index of valve
456
- } Svalve;
457
-
458
- typedef struct // Control Statement
459
- {
460
- int Link; // link index
461
- int Node; // control node index
462
- long Time; // control time
463
- double Grade; // control grade
464
- double Setting; // new link setting
465
- StatusType Status; // new link status
466
- ControlType Type; // control type
467
- } Scontrol;
468
-
469
- typedef struct // Field Object of Report Table
470
- {
471
- char Name[MAXID+1]; // name of reported variable
472
- char Units[MAXID+1]; // units of reported variable
473
- int Enabled; // enabled if in table
474
- int Precision; // number of decimal places
475
- double RptLim[2]; // lower/upper report limits
476
- } SField;
477
-
478
- struct Sadjlist // Node Adjacency List Item
479
- {
480
- int node; // index of connecting node
481
- int link; // index of connecting link
482
- struct Sadjlist *next; // next item in list
483
- };
484
- typedef struct Sadjlist *Padjlist; // Pointer to adjacency list
485
-
486
- struct Sseg // Pipe Segment List Item
487
- {
488
- double v; // segment volume
489
- double c; // segment water quality
490
- struct Sseg *prev; // previous segment in list
491
- };
492
- typedef struct Sseg *Pseg; // Pointer to pipe segment list
493
-
494
- typedef struct s_Premise // Rule Premise Clause
495
- {
496
- int logop; // logical operator (IF, AND, OR)
497
- int object; // NODE or LINK
498
- int index; // object's index
499
- int variable; // pressure, flow, etc.
500
- int relop; // relational operator (=, >, <, etc.)
501
- int status; // variable's status (OPEN, CLOSED)
502
- double value; // variable's value
503
- struct s_Premise *next; // next premise clause
504
- } Spremise;
505
-
506
- typedef struct s_Action // Rule Action Clause
507
- {
508
- int link; // link index
509
- int status; // link's status
510
- double setting; // link's setting
511
- struct s_Action *next;
512
- } Saction;
513
-
514
- typedef struct // Control Rule Structure
515
- {
516
- char label[MAXID+1]; // rule label
517
- double priority; // priority level
518
- Spremise *Premises; // list of premises
519
- Saction *ThenActions; // list of THEN actions
520
- Saction *ElseActions; // list of ELSE actions
521
- } Srule;
522
-
523
- typedef struct s_ActionItem // Action List Item
524
- {
525
- int ruleIndex; // index of rule action belongs to
526
- Saction *action; // an action clause
527
- struct s_ActionItem *next; // next action on the list
528
- } SactionList;
529
-
530
- typedef struct // Mass Balance Components
531
- {
532
- double initial; // initial mass in system
533
- double inflow; // mass inflow to system
534
- double outflow; // mass outflow from system
535
- double reacted; // mass reacted in system
536
- double final; // final mass in system
537
- double ratio; // ratio of mass added to mass lost
538
- } SmassBalance;
539
-
540
- /*
541
- ------------------------------------------------------
542
- Wrapper Data Structures
543
- ------------------------------------------------------
544
- */
545
-
546
- // Input File Parser Wrapper
547
- typedef struct {
548
- FILE *InFile; // Input file handle
549
-
550
- char
551
- DefPatID[MAXID + 1], // Default demand pattern ID
552
- InpFname[MAXFNAME + 1], // Input file name
553
- *Tok[MAXTOKS], // Array of token strings
554
- Comment[MAXMSG + 1], // Comment text
555
- LineComment[MAXMSG + 1]; // Full line comment
556
-
557
- int
558
- MaxNodes, // Node count from input file */
559
- MaxLinks, // Link count " " "
560
- MaxJuncs, // Junction count " " "
561
- MaxPipes, // Pipe count " " "
562
- MaxTanks, // Tank count " " "
563
- MaxPumps, // Pump count " " "
564
- MaxValves, // Valve count " " "
565
- MaxControls, // Control count " " "
566
- MaxRules, // Rule count " " "
567
- MaxPats, // Pattern count " " "
568
- MaxCurves, // Curve count " " "
569
- Ntokens, // Number of tokens in line of input
570
- Ntitle, // Number of title lines
571
- ErrTok, // Index of error-producing token
572
- Unitsflag, // Unit system flag
573
- Flowflag, // Flow units flag
574
- Pressflag, // Pressure units flag
575
- DefPat; // Default demand pattern
576
-
577
- Spattern *PrevPat; // Previous pattern processed
578
- Scurve *PrevCurve; // Previous curve processed
579
- double *X; // Temporary array for curve data
580
-
581
- } Parser;
582
-
583
- // Time Step Wrapper
584
- typedef struct {
585
-
586
- long
587
- Tstart, // Starting time of day
588
- Hstep, // Nominal hyd. time step
589
- Pstep, // Time pattern time step
590
- Pstart, // Starting pattern time
591
- Rstep, // Reporting time step
592
- Rstart, // Time when reporting starts
593
- Rtime, // Next reporting time
594
- Htime, // Current hyd. time
595
- Hydstep, // Actual hydraulic time step
596
- Qstep, // Quality time step
597
- Qtime, // Current quality time
598
- Rulestep, // Rule evaluation time step
599
- Dur; // Duration of simulation
600
-
601
- } Times;
602
-
603
- // Reporting Wrapper
604
- typedef struct {
605
-
606
- FILE *RptFile; // Report file handle
607
-
608
- int
609
- Nperiods, // Number of reporting periods
610
- PageSize, // Lines/page in output report/
611
- Rptflag, // Report flag
612
- Tstatflag, // Report time series statistic flag
613
- Summaryflag, // Report summary flag
614
- Messageflag, // Error/warning message flag
615
- Statflag, // Status report flag
616
- Energyflag, // Energy report flag
617
- Nodeflag, // Node report flag
618
- Linkflag, // Link report flag
619
- Fprinterr; // File write error flag
620
-
621
- long
622
- LineNum, // Current line number
623
- PageNum; // Current page number
624
-
625
- char
626
- Atime[13], // Clock time (hrs:min:sec)
627
- Rpt1Fname[MAXFNAME+1], // Primary report file name
628
- Rpt2Fname[MAXFNAME+1], // Secondary report file name
629
- DateStamp[26]; // Current date & time
630
-
631
- SField Field[MAXVAR]; // Output reporting fields
632
-
633
- } Report;
634
-
635
- // Output File Wrapper
636
- typedef struct {
637
-
638
- char
639
- HydFname[MAXFNAME+1], // Hydraulics file name
640
- OutFname[MAXFNAME+1]; // Binary output file name
641
-
642
- int
643
- Outflag, // Output file flag
644
- Hydflag, // Hydraulics flag
645
- SaveHflag, // Hydraulic results saved flag
646
- SaveQflag, // Quality results saved flag
647
- Saveflag; // General purpose save flag
648
-
649
- long
650
- HydOffset, // Hydraulics file byte offset
651
- OutOffset1, // 1st output file byte offset
652
- OutOffset2; // 2nd output file byte offset
653
-
654
- FILE
655
- *OutFile, // Output file handle
656
- *HydFile, // Hydraulics file handle
657
- *TmpOutFile; // Temporary file handle
658
-
659
- } Outfile;
660
-
661
- // Rule-Based Controls Wrapper
662
- typedef struct {
663
-
664
- SactionList *ActionList; // Linked list of action items
665
- int RuleState; // State of rule interpreter
666
- int Errcode; // Rule parser error code
667
- long Time1; // Start of rule evaluation time interval
668
- Spremise *LastPremise; // Previous premise clause
669
- Saction *LastThenAction; // Previous THEN action
670
- Saction *LastElseAction; // Previous ELSE action
671
-
672
- } Rules;
673
-
674
- // Sparse Matrix Wrapper
675
- typedef struct {
676
-
677
- double
678
- *Aii, // Diagonal matrix coeffs.
679
- *Aij, // Non-zero, off-diagonal matrix coeffs.
680
- *F, // Right hand side vector
681
- *temp; // Array used by linear eqn. solver
682
-
683
- int
684
- Ncoeffs, // Number of non-zero matrix coeffs
685
- *Order, // Node-to-row of re-ordered matrix
686
- *Row, // Row-to-node of re-ordered matrix
687
- *Ndx, // Index of link's coeff. in Aij
688
- *XLNZ, // Start position of each column in NZSUB
689
- *NZSUB, // Row index of each coeff. in each column
690
- *LNZ, // Position of each coeff. in Aij array
691
- *Degree, // Number of links adjacent to each node
692
- *link, // Array used by linear eqn. solver
693
- *first; // Array used by linear eqn. solver
694
-
695
- } Smatrix;
696
-
697
- // Hydraulics Solver Wrapper
698
- typedef struct {
699
-
700
- double
701
- *NodeHead, // Node hydraulic heads
702
- *NodeDemand, // Node demand + emitter flows
703
- *DemandFlow, // Work array of demand flows
704
- *EmitterFlow, // Emitter outflows
705
- *LinkFlow, // Link flows
706
- *LinkSetting, // Link settings
707
- Htol, // Hydraulic head tolerance
708
- Qtol, // Flow rate tolerance
709
- RQtol, // Flow resistance tolerance
710
- Hexp, // Exponent in headloss formula
711
- Qexp, // Exponent in emitter formula
712
- Pexp, // Exponent in demand formula
713
- Pmin, // Pressure needed for any demand
714
- Preq, // Pressure needed for full demand
715
- Dmult, // Demand multiplier
716
- Hacc, // Relative flow change limit
717
- FlowChangeLimit, // Absolute flow change limit
718
- HeadErrorLimit, // Hydraulic head error limit
719
- DampLimit, // Solution damping threshold
720
- Viscos, // Kin. viscosity (sq ft/sec)
721
- SpGrav, // Specific gravity
722
- Epump, // Global pump efficiency
723
- Dsystem, // Total system demand
724
- Ecost, // Base energy cost per kwh
725
- Dcost, // Energy demand charge/kw/day
726
- Emax, // Peak energy usage
727
- RelativeError, // Total flow change / total flow
728
- MaxHeadError, // Max. error for link head loss
729
- MaxFlowChange, // Max. change in link flow
730
- DemandReduction, // % demand reduction at pressure deficient nodes
731
- RelaxFactor, // Relaxation factor for flow updating
732
- *P, // Inverse of head loss derivatives
733
- *Y, // Flow correction factors
734
- *Xflow; // Inflow - outflow at each node
735
-
736
- int
737
- Epat, // Energy cost time pattern
738
- DemandModel, // Fixed or pressure dependent
739
- Formflag, // Head loss formula flag
740
- Iterations, // Number of hydraulic trials taken
741
- MaxIter, // Max. hydraulic trials allowed
742
- ExtraIter, // Extra hydraulic trials
743
- CheckFreq, // Hydraulic trials between status checks
744
- MaxCheck, // Hydraulic trials limit on status checks
745
- OpenHflag, // Hydraulic system opened flag
746
- Haltflag, // Flag to halt simulation
747
- DeficientNodes; // Number of pressure deficient nodes
748
-
749
- StatusType
750
- *LinkStatus, // Link status
751
- *OldStatus; // Previous link/tank status
752
-
753
- Smatrix smatrix; // Sparse matrix storage
754
-
755
- } Hydraul;
756
-
757
- // Forward declaration of the Mempool structure defined in mempool.h
758
- struct Mempool;
759
-
760
- // Water Quality Solver Wrapper
761
- typedef struct {
762
-
763
- int
764
- Qualflag, // Water quality analysis flag
765
- OpenQflag, // Quality system opened flag
766
- Reactflag, // Reaction indicator
767
- OutOfMemory, // Out of memory indicator
768
- TraceNode, // Source node for flow tracing
769
- *SortedNodes; // Topologically sorted node indexes
770
-
771
- char
772
- ChemName[MAXID + 1], // Name of chemical
773
- ChemUnits[MAXID + 1]; // Units of chemical
774
-
775
- double
776
- Ctol, // Water quality tolerance
777
- Diffus, // Diffusivity (sq ft/sec)
778
- Wbulk, // Avg. bulk reaction rate
779
- Wwall, // Avg. wall reaction rate
780
- Wtank, // Avg. tank reaction rate
781
- Wsource, // Avg. mass inflow
782
- Rfactor, // Roughness-reaction factor
783
- Sc, // Schmidt Number
784
- Bucf, // Bulk reaction units conversion factor
785
- Tucf, // Tank reaction units conversion factor
786
- BulkOrder, // Bulk flow reaction order
787
- WallOrder, // Pipe wall reaction order
788
- TankOrder, // Tank reaction order
789
- Kbulk, // Global bulk reaction coeff.
790
- Kwall, // Global wall reaction coeff.
791
- Climit, // Limiting potential quality
792
- SourceQual, // External source quality
793
- *NodeQual, // Reported node quality state
794
- *PipeRateCoeff; // Pipe reaction rate coeffs.
795
-
796
- struct Mempool
797
- *SegPool; // Memory pool for water quality segments
798
-
799
- Pseg
800
- FreeSeg, // Pointer to unused segment
801
- *FirstSeg, // First (downstream) segment in each pipe
802
- *LastSeg; // Last (upstream) segment in each pipe
803
-
804
- FlowDirection
805
- *FlowDir; // Flow direction for each pipe
806
-
807
- SmassBalance
808
- MassBalance; // Mass balance components
809
-
810
- } Quality;
811
-
812
- // Pipe Network Wrapper
813
- typedef struct {
814
-
815
- int
816
- Nnodes, // Number of network nodes
817
- Ntanks, // Number of tanks
818
- Njuncs, // Number of junction nodes
819
- Nlinks, // Number of network links
820
- Npipes, // Number of pipes
821
- Npumps, // Number of pumps
822
- Nvalves, // Number of valves
823
- Ncontrols, // Number of simple controls
824
- Nrules, // Number of control rules
825
- Npats, // Number of time patterns
826
- Ncurves; // Number of data curves
827
-
828
- Snode *Node; // Node array
829
- Slink *Link; // Link array
830
- Stank *Tank; // Tank array
831
- Spump *Pump; // Pump array
832
- Svalve *Valve; // Valve array
833
- Spattern *Pattern; // Time pattern array
834
- Scurve *Curve; // Data curve array
835
- Scontrol *Control; // Simple controls array
836
- Srule *Rule; // Rule-based controls array
837
- HashTable
838
- *NodeHashTable, // Hash table for Node ID names
839
- *LinkHashTable; // Hash table for Link ID names
840
- Padjlist *Adjlist; // Node adjacency lists
841
-
842
- } Network;
843
-
844
- // Overall Project Wrapper
845
- typedef struct Project {
846
-
847
- Network network; // Pipe network wrapper
848
- Parser parser; // Input file parser wrapper
849
- Times times; // Time step wrapper
850
- Report report; // Reporting wrapper
851
- Outfile outfile; // Output file wrapper
852
- Rules rules; // Rule-based controls wrapper
853
- Hydraul hydraul; // Hydraulics solver wrapper
854
- Quality quality; // Water quality solver wrapper
855
-
856
- double Ucf[MAXVAR]; // Unit conversion factors
857
-
858
- int
859
- Openflag, // Project open flag
860
- Warnflag; // Warning flag
861
-
862
- char
863
- Msg[MAXMSG+1], // General-purpose string: errors, messages
864
- Title[MAXTITLE][TITLELEN+1], // Project title
865
- MapFname[MAXFNAME+1], // Map file name
866
- TmpHydFname[MAXFNAME+1], // Temporary hydraulics file name
867
- TmpOutFname[MAXFNAME+1], // Temporary output file name
868
- TmpStatFname[MAXFNAME+1]; // Temporary statistic file name
869
-
870
- void (* viewprog) (char *); // Pointer to progress viewing function
871
-
872
- } Project, *EN_Project;
873
-
874
- #endif