epyt-flow 0.14.2__py3-none-any.whl → 0.15.0__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 (100) 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 +368 -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-0.14.2.dist-info → epyt_flow-0.15.0.dist-info}/METADATA +14 -19
  19. epyt_flow-0.15.0.dist-info/RECORD +65 -0
  20. epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +0 -28
  21. epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +0 -21
  22. epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +0 -18
  23. epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +0 -134
  24. epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +0 -5578
  25. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +0 -865
  26. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +0 -131
  27. epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +0 -73
  28. epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +0 -193
  29. epyt_flow/EPANET/EPANET/SRC_engines/genmmd.c +0 -1000
  30. epyt_flow/EPANET/EPANET/SRC_engines/hash.c +0 -177
  31. epyt_flow/EPANET/EPANET/SRC_engines/hash.h +0 -28
  32. epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +0 -1151
  33. epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +0 -1117
  34. epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +0 -720
  35. epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +0 -476
  36. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +0 -431
  37. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +0 -1786
  38. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +0 -468
  39. epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +0 -810
  40. epyt_flow/EPANET/EPANET/SRC_engines/input1.c +0 -707
  41. epyt_flow/EPANET/EPANET/SRC_engines/input2.c +0 -864
  42. epyt_flow/EPANET/EPANET/SRC_engines/input3.c +0 -2170
  43. epyt_flow/EPANET/EPANET/SRC_engines/main.c +0 -93
  44. epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +0 -142
  45. epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +0 -24
  46. epyt_flow/EPANET/EPANET/SRC_engines/output.c +0 -852
  47. epyt_flow/EPANET/EPANET/SRC_engines/project.c +0 -1359
  48. epyt_flow/EPANET/EPANET/SRC_engines/quality.c +0 -685
  49. epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +0 -743
  50. epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +0 -694
  51. epyt_flow/EPANET/EPANET/SRC_engines/report.c +0 -1489
  52. epyt_flow/EPANET/EPANET/SRC_engines/rules.c +0 -1362
  53. epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +0 -871
  54. epyt_flow/EPANET/EPANET/SRC_engines/text.h +0 -497
  55. epyt_flow/EPANET/EPANET/SRC_engines/types.h +0 -874
  56. epyt_flow/EPANET/EPANET-MSX/MSX_Updates.txt +0 -53
  57. epyt_flow/EPANET/EPANET-MSX/Src/dispersion.h +0 -27
  58. epyt_flow/EPANET/EPANET-MSX/Src/hash.c +0 -107
  59. epyt_flow/EPANET/EPANET-MSX/Src/hash.h +0 -28
  60. epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx.h +0 -102
  61. epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx_export.h +0 -42
  62. epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.c +0 -937
  63. epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.h +0 -39
  64. epyt_flow/EPANET/EPANET-MSX/Src/mempool.c +0 -204
  65. epyt_flow/EPANET/EPANET-MSX/Src/mempool.h +0 -24
  66. epyt_flow/EPANET/EPANET-MSX/Src/msxchem.c +0 -1285
  67. epyt_flow/EPANET/EPANET-MSX/Src/msxcompiler.c +0 -368
  68. epyt_flow/EPANET/EPANET-MSX/Src/msxdict.h +0 -42
  69. epyt_flow/EPANET/EPANET-MSX/Src/msxdispersion.c +0 -586
  70. epyt_flow/EPANET/EPANET-MSX/Src/msxerr.c +0 -116
  71. epyt_flow/EPANET/EPANET-MSX/Src/msxfile.c +0 -260
  72. epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.c +0 -175
  73. epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.h +0 -35
  74. epyt_flow/EPANET/EPANET-MSX/Src/msxinp.c +0 -1504
  75. epyt_flow/EPANET/EPANET-MSX/Src/msxout.c +0 -401
  76. epyt_flow/EPANET/EPANET-MSX/Src/msxproj.c +0 -791
  77. epyt_flow/EPANET/EPANET-MSX/Src/msxqual.c +0 -2010
  78. epyt_flow/EPANET/EPANET-MSX/Src/msxrpt.c +0 -400
  79. epyt_flow/EPANET/EPANET-MSX/Src/msxtank.c +0 -422
  80. epyt_flow/EPANET/EPANET-MSX/Src/msxtoolkit.c +0 -1164
  81. epyt_flow/EPANET/EPANET-MSX/Src/msxtypes.h +0 -551
  82. epyt_flow/EPANET/EPANET-MSX/Src/msxutils.c +0 -524
  83. epyt_flow/EPANET/EPANET-MSX/Src/msxutils.h +0 -56
  84. epyt_flow/EPANET/EPANET-MSX/Src/newton.c +0 -158
  85. epyt_flow/EPANET/EPANET-MSX/Src/newton.h +0 -34
  86. epyt_flow/EPANET/EPANET-MSX/Src/rk5.c +0 -287
  87. epyt_flow/EPANET/EPANET-MSX/Src/rk5.h +0 -39
  88. epyt_flow/EPANET/EPANET-MSX/Src/ros2.c +0 -293
  89. epyt_flow/EPANET/EPANET-MSX/Src/ros2.h +0 -35
  90. epyt_flow/EPANET/EPANET-MSX/Src/smatrix.c +0 -816
  91. epyt_flow/EPANET/EPANET-MSX/Src/smatrix.h +0 -29
  92. epyt_flow/EPANET/EPANET-MSX/readme.txt +0 -14
  93. epyt_flow/EPANET/compile_linux.sh +0 -4
  94. epyt_flow/EPANET/compile_macos.sh +0 -4
  95. epyt_flow/simulation/backend/__init__.py +0 -1
  96. epyt_flow/simulation/backend/my_epyt.py +0 -1101
  97. epyt_flow-0.14.2.dist-info/RECORD +0 -142
  98. {epyt_flow-0.14.2.dist-info → epyt_flow-0.15.0.dist-info}/WHEEL +0 -0
  99. {epyt_flow-0.14.2.dist-info → epyt_flow-0.15.0.dist-info}/licenses/LICENSE +0 -0
  100. {epyt_flow-0.14.2.dist-info → epyt_flow-0.15.0.dist-info}/top_level.txt +0 -0
@@ -1,401 +0,0 @@
1
- /******************************************************************************
2
- ** MODULE: MSXOUT.C
3
- ** PROJECT: EPANET-MSX
4
- ** DESCRIPTION: I/O routines for the binary output file used by the
5
- ** EPANET Multi-Species Extension toolkit.
6
- ** AUTHORS: see AUTHORS
7
- ** Copyright: see AUTHORS
8
- ** License: see LICENSE
9
- ** VERSION: 2.0.00
10
- ** LAST UPDATE: 08/30/2022
11
- ******************************************************************************/
12
-
13
- #include <stdio.h>
14
- #include <string.h>
15
- #include <math.h>
16
-
17
- #if defined(macintosh) || defined(Macintosh) || defined(__APPLE__) && defined(__MACH__)
18
- #include <stdlib.h>
19
- #endif
20
-
21
- #include "msxtypes.h"
22
-
23
- // External variables
24
- //--------------------
25
- extern MSXproject MSX; // MSX project data
26
-
27
- // Local variables
28
- //-----------------
29
- static long ResultsOffset; // Offset byte where results begin
30
- static long NodeBytesPerPeriod; // Bytes per time period used by all nodes
31
- static long LinkBytesPerPeriod; // Bytes per time period used by all links
32
-
33
- // Imported functions
34
- //--------------------
35
- double MSXqual_getNodeQual(int j, int m);
36
- double MSXqual_getLinkQual(int k, int m);
37
-
38
- // Exported functions
39
- //--------------------
40
- int MSXout_open(void);
41
- int MSXout_saveInitialResults(void);
42
- int MSXout_saveResults(void);
43
- int MSXout_saveFinalResults(void);
44
- float MSXout_getNodeQual(int k, int j, int m);
45
- float MSXout_getLinkQual(int k, int j, int m);
46
-
47
- // Local functions
48
- //-----------------
49
- static int saveStatResults(void);
50
- static void getStatResults(int objType, int m, double* stats1,
51
- double* stats2, REAL4* x);
52
-
53
-
54
- //=============================================================================
55
-
56
- int MSXout_open()
57
- /*
58
- ** Purpose:
59
- ** opens an MSX binary output file.
60
- **
61
- ** Input:
62
- ** none.
63
- **
64
- ** Returns:
65
- ** an error code (or 0 if no error).
66
- */
67
- {
68
- // --- close output file if already opened
69
-
70
- if (MSX.OutFile.file != NULL) fclose(MSX.OutFile.file);
71
-
72
- // --- try to open the file
73
-
74
- if ( (MSX.OutFile.file = fopen(MSX.OutFile.name, "w+b")) == NULL)
75
- {
76
- return ERR_OPEN_OUT_FILE;
77
- }
78
-
79
- // --- open a scratch output file for statistics
80
-
81
- if ( MSX.Statflag == SERIES ) MSX.TmpOutFile.file = MSX.OutFile.file;
82
- else if ( (MSX.TmpOutFile.file = fopen(MSX.TmpOutFile.name, "w+b")) == NULL)
83
- {
84
- return ERR_OPEN_OUT_FILE;
85
- }
86
-
87
- // --- write initial results to file
88
-
89
- MSX.Nperiods = 0;
90
- MSXout_saveInitialResults();
91
- return 0;
92
- }
93
-
94
- //=============================================================================
95
-
96
- int MSXout_saveInitialResults()
97
- /*
98
- ** Purpose:
99
- ** saves general information to beginning of MSX binary output file.
100
- **
101
- ** Input:
102
- ** none.
103
- **
104
- ** Returns:
105
- ** an error code (or 0 if no error).
106
- */
107
- {
108
- int m;
109
- INT4 n;
110
- INT4 magic = MAGICNUMBER;
111
- INT4 version = VERSION;
112
- FILE* f = MSX.OutFile.file;
113
-
114
- rewind(f);
115
- fwrite(&magic, sizeof(INT4), 1, f); //Magic number
116
- fwrite(&version, sizeof(INT4), 1, f); //Version number
117
- n = (INT4)MSX.Nobjects[NODE];
118
- fwrite(&n, sizeof(INT4), 1, f); //Number of nodes
119
- n = (INT4)MSX.Nobjects[LINK];
120
- fwrite(&n, sizeof(INT4), 1, f); //Number of links
121
- n = (INT4)MSX.Nobjects[SPECIES];
122
- fwrite(&n, sizeof(INT4), 1, f); //Number of species
123
- n = (INT4)MSX.Rstep;
124
- fwrite(&n, sizeof(INT4), 1, f); //Reporting step size
125
- for (m=1; m<=MSX.Nobjects[SPECIES]; m++)
126
- {
127
- n = (INT4)strlen(MSX.Species[m].id);
128
- fwrite(&n, sizeof(INT4), 1, f); //Length of species ID
129
- fwrite(MSX.Species[m].id, sizeof(char), n, f); //Species ID string
130
- fwrite(&MSX.Species[m].units, sizeof(char), MAXUNITS, f); //Species mass units
131
- }
132
- ResultsOffset = ftell(f);
133
- NodeBytesPerPeriod = MSX.Nobjects[NODE]*MSX.Nobjects[SPECIES]*sizeof(REAL4);
134
- LinkBytesPerPeriod = MSX.Nobjects[LINK]*MSX.Nobjects[SPECIES]*sizeof(REAL4);
135
- return 0;
136
- }
137
-
138
-
139
- //=============================================================================
140
-
141
- int MSXout_saveResults()
142
- /*
143
- ** Purpose:
144
- ** saves computed species concentrations for each node and link at the
145
- ** current time period to the temporary MSX binary output file (which
146
- ** will be the same as the permanent MSX binary file if time series
147
- ** values were specified as the reported statistic, which is the
148
- ** default case).
149
- **
150
- ** Input:
151
- ** none.
152
- **
153
- ** Returns:
154
- ** an error code (or 0 if no error).
155
- */
156
- {
157
- int m, j;
158
- REAL4 x;
159
- for (m=1; m<=MSX.Nobjects[SPECIES]; m++)
160
- {
161
- for (j=1; j<=MSX.Nobjects[NODE]; j++)
162
- {
163
- x = (REAL4)MSXqual_getNodeQual(j, m);
164
- fwrite(&x, sizeof(REAL4), 1, MSX.TmpOutFile.file);
165
- }
166
- }
167
- for (m=1; m<=MSX.Nobjects[SPECIES]; m++)
168
- {
169
- for (j=1; j<=MSX.Nobjects[LINK]; j++)
170
- {
171
- x = (REAL4)MSXqual_getLinkQual(j, m);
172
- fwrite(&x, sizeof(REAL4), 1, MSX.TmpOutFile.file);
173
- }
174
- }
175
- return 0;
176
- }
177
-
178
- //=============================================================================
179
-
180
- int MSXout_saveFinalResults()
181
- /*
182
- ** Purpose:
183
- ** saves any statistical results plus the following information to the end
184
- ** of the MSX binary output file:
185
- ** - byte offset into file where WQ results for each time period begins,
186
- ** - total number of time periods written to the file,
187
- ** - any error code generated by the analysis (0 if there were no errors),
188
- ** - the Magic Number to indicate that the file is complete.
189
- **
190
- ** Input:
191
- ** none.
192
- **
193
- ** Returns:
194
- ** an error code (or 0 if no error).
195
- */
196
- {
197
- INT4 n;
198
- INT4 magic = MAGICNUMBER;
199
- int err = 0;
200
-
201
- // --- save statistical results to the file
202
-
203
- if ( MSX.Statflag != SERIES ) err = saveStatResults();
204
- if ( err > 0 ) return err;
205
-
206
- // --- write closing records to the file
207
-
208
- n = (INT4)ResultsOffset;
209
- fwrite(&n, sizeof(INT4), 1, MSX.OutFile.file);
210
- n = (INT4)MSX.Nperiods;
211
- fwrite(&n, sizeof(INT4), 1, MSX.OutFile.file);
212
- n = (INT4)MSX.ErrCode;
213
- fwrite(&n, sizeof(INT4), 1, MSX.OutFile.file);
214
- fwrite(&magic, sizeof(INT4), 1, MSX.OutFile.file);
215
- return 0;
216
- }
217
-
218
- //=============================================================================
219
-
220
- float MSXout_getNodeQual(int k, int j, int m)
221
- /*
222
- ** Purpose:
223
- ** retrieves a result for a specific node from the MSX binary output file.
224
- **
225
- ** Input:
226
- ** k = time period index
227
- ** j = node index
228
- ** m = species index.
229
- **
230
- ** Returns:
231
- ** the requested species concentration.
232
- */
233
- {
234
- REAL4 c;
235
- long bp = ResultsOffset + k * (NodeBytesPerPeriod + LinkBytesPerPeriod);
236
- bp += ((m-1)*MSX.Nobjects[NODE] + (j-1)) * sizeof(REAL4);
237
- fseek(MSX.OutFile.file, bp, SEEK_SET);
238
- fread(&c, sizeof(REAL4), 1, MSX.OutFile.file);
239
- return (float)c;
240
- }
241
-
242
- //=============================================================================
243
-
244
- float MSXout_getLinkQual(int k, int j, int m)
245
- /*
246
- ** Purpose:
247
- ** retrieves a result for a specific link from the MSX binary output file.
248
- **
249
- ** Input:
250
- ** k = time period index
251
- ** j = link index
252
- ** m = species index.
253
- **
254
- ** Returns:
255
- ** the requested species concentration.
256
- */
257
- {
258
- REAL4 c;
259
- long bp = ResultsOffset + ((k+1)*NodeBytesPerPeriod) + (k*LinkBytesPerPeriod);
260
- bp += ((m-1)*MSX.Nobjects[LINK] + (j-1)) * sizeof(REAL4);
261
- fseek(MSX.OutFile.file, bp, SEEK_SET);
262
- fread(&c, sizeof(REAL4), 1, MSX.OutFile.file);
263
- return (float)c;
264
- }
265
-
266
- //=============================================================================
267
-
268
- int saveStatResults()
269
- /*
270
- ** Purpose:
271
- ** saves time statistic results (average, min., max., or range) for each
272
- ** node and link to the permanent binary output file.
273
- **
274
- ** Input:
275
- ** none.
276
- **
277
- ** Returns:
278
- ** an error code (or 0 if no error).
279
- */
280
- {
281
- int m, err = 0;
282
- REAL4* x = NULL;
283
- double* stats1 = NULL;
284
- double* stats2 = NULL;
285
-
286
- // --- create arrays used to store statistics results
287
-
288
- if ( MSX.Nperiods <= 0 ) return err;
289
- m = MAX(MSX.Nobjects[NODE], MSX.Nobjects[LINK]);
290
- x = (REAL4 *) calloc(m+1, sizeof(REAL4));
291
- stats1 = (double *) calloc(m+1, sizeof(double));
292
- stats2 = (double *) calloc(m+1, sizeof(double));
293
-
294
- // --- get desired statistic for each node & link and save to binary file
295
-
296
- if ( x && stats1 && stats2 )
297
- {
298
- for (m = 1; m <= MSX.Nobjects[SPECIES]; m++ )
299
- {
300
- getStatResults(NODE, m, stats1, stats2, x);
301
- fwrite(x+1, sizeof(REAL4), MSX.Nobjects[NODE], MSX.OutFile.file);
302
- }
303
- for (m = 1; m <= MSX.Nobjects[SPECIES]; m++)
304
- {
305
- getStatResults(LINK, m, stats1, stats2, x);
306
- fwrite(x+1, sizeof(REAL4), MSX.Nobjects[LINK], MSX.OutFile.file);
307
- }
308
- MSX.Nperiods = 1;
309
- }
310
- else err = ERR_MEMORY;
311
-
312
- // --- free allocated arrays
313
-
314
- FREE(x);
315
- FREE(stats1);
316
- FREE(stats2);
317
- return err;
318
- }
319
-
320
- //=============================================================================
321
-
322
- void getStatResults(int objType, int m, double * stats1, double * stats2,
323
- REAL4 * x)
324
- /*
325
- ** Purpose:
326
- ** reads all results for a given type of object from the temporary
327
- ** binary output file and computes the required statistic (average,
328
- ** min., max., or range) for each object.
329
- **
330
- ** Input:
331
- ** objType = type of object (nodes or links)
332
- ** m = species index
333
- ** stats1, stats2 = work arrays used to hold intermediate values
334
- ** x = array used to store results read from file.
335
- **
336
- ** Output:
337
- ** x = array that contains computed statistic for each object.
338
- */
339
- {
340
- int j, k;
341
- int n = MSX.Nobjects[objType];
342
- long bp;
343
-
344
- // --- initialize work arrays
345
-
346
- for (j = 1; j <= n; j++)
347
- {
348
- stats1[j] = 0.0;
349
- stats2[j] = 0.0;
350
- }
351
-
352
- // --- for all time periods
353
-
354
- for (k = 0; k < MSX.Nperiods; k++)
355
- {
356
-
357
- // --- position file at start of time period
358
-
359
- bp = k*(NodeBytesPerPeriod + LinkBytesPerPeriod);
360
- if ( objType == NODE )
361
- {
362
- bp += (m-1) * MSX.Nobjects[NODE] * sizeof(REAL4);
363
- }
364
- if ( objType == LINK)
365
- {
366
- bp += NodeBytesPerPeriod +
367
- (m-1) * MSX.Nobjects[LINK] * sizeof(REAL4);
368
- }
369
- fseek(MSX.TmpOutFile.file, bp, SEEK_SET);
370
-
371
- // --- read concentrations and update stats for all objects
372
-
373
- fread(x+1, sizeof(REAL4), n, MSX.TmpOutFile.file);
374
- if ( MSX.Statflag == AVGERAGE )
375
- {
376
- for (j = 1; j <= n; j++) stats1[j] += x[j];
377
- }
378
- else for (j = 1; j <= n; j++)
379
- {
380
- stats1[j] = MIN(stats1[j], x[j]);
381
- stats2[j] = MAX(stats2[j], x[j]);
382
- }
383
- }
384
-
385
- // --- place final stat value for each object in x
386
-
387
- if ( MSX.Statflag == AVGERAGE )
388
- {
389
- for ( j = 1; j <= n; j++) stats1[j] /= (double)MSX.Nperiods;
390
- }
391
- if ( MSX.Statflag == RANGE )
392
- {
393
- for ( j = 1; j <= n; j++)
394
- stats1[j] = fabs(stats2[j] - stats1[j]);
395
- }
396
- if ( MSX.Statflag == MAXIMUM)
397
- {
398
- for ( j = 1; j <= MSX.Nobjects[NODE]; j++) stats1[j] = stats2[j];
399
- }
400
- for (j = 1; j <= n; j++) x[j] = (REAL4)stats1[j];
401
- }