epanet-plus 0.0.1__cp313-cp313-macosx_11_0_arm64.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.

Potentially problematic release.


This version of epanet-plus might be problematic. Click here for more details.

Files changed (105) hide show
  1. docs/conf.py +67 -0
  2. epanet-msx-src/dispersion.h +27 -0
  3. epanet-msx-src/hash.c +107 -0
  4. epanet-msx-src/hash.h +28 -0
  5. epanet-msx-src/include/epanetmsx.h +104 -0
  6. epanet-msx-src/include/epanetmsx_export.h +42 -0
  7. epanet-msx-src/mathexpr.c +937 -0
  8. epanet-msx-src/mathexpr.h +39 -0
  9. epanet-msx-src/mempool.c +204 -0
  10. epanet-msx-src/mempool.h +24 -0
  11. epanet-msx-src/msxchem.c +1285 -0
  12. epanet-msx-src/msxcompiler.c +368 -0
  13. epanet-msx-src/msxdict.h +42 -0
  14. epanet-msx-src/msxdispersion.c +586 -0
  15. epanet-msx-src/msxerr.c +116 -0
  16. epanet-msx-src/msxfile.c +260 -0
  17. epanet-msx-src/msxfuncs.c +175 -0
  18. epanet-msx-src/msxfuncs.h +35 -0
  19. epanet-msx-src/msxinp.c +1504 -0
  20. epanet-msx-src/msxout.c +398 -0
  21. epanet-msx-src/msxproj.c +791 -0
  22. epanet-msx-src/msxqual.c +2011 -0
  23. epanet-msx-src/msxrpt.c +400 -0
  24. epanet-msx-src/msxtank.c +422 -0
  25. epanet-msx-src/msxtoolkit.c +1164 -0
  26. epanet-msx-src/msxtypes.h +551 -0
  27. epanet-msx-src/msxutils.c +524 -0
  28. epanet-msx-src/msxutils.h +56 -0
  29. epanet-msx-src/newton.c +158 -0
  30. epanet-msx-src/newton.h +34 -0
  31. epanet-msx-src/rk5.c +287 -0
  32. epanet-msx-src/rk5.h +39 -0
  33. epanet-msx-src/ros2.c +293 -0
  34. epanet-msx-src/ros2.h +35 -0
  35. epanet-msx-src/smatrix.c +816 -0
  36. epanet-msx-src/smatrix.h +29 -0
  37. epanet-src/AUTHORS +60 -0
  38. epanet-src/LICENSE +21 -0
  39. epanet-src/enumstxt.h +151 -0
  40. epanet-src/epanet.c +5937 -0
  41. epanet-src/epanet2.c +961 -0
  42. epanet-src/epanet2.def +131 -0
  43. epanet-src/errors.dat +79 -0
  44. epanet-src/flowbalance.c +186 -0
  45. epanet-src/funcs.h +219 -0
  46. epanet-src/genmmd.c +1000 -0
  47. epanet-src/hash.c +177 -0
  48. epanet-src/hash.h +28 -0
  49. epanet-src/hydcoeffs.c +1303 -0
  50. epanet-src/hydraul.c +1164 -0
  51. epanet-src/hydsolver.c +781 -0
  52. epanet-src/hydstatus.c +442 -0
  53. epanet-src/include/epanet2.h +466 -0
  54. epanet-src/include/epanet2_2.h +1962 -0
  55. epanet-src/include/epanet2_enums.h +518 -0
  56. epanet-src/inpfile.c +884 -0
  57. epanet-src/input1.c +672 -0
  58. epanet-src/input2.c +970 -0
  59. epanet-src/input3.c +2265 -0
  60. epanet-src/leakage.c +527 -0
  61. epanet-src/mempool.c +146 -0
  62. epanet-src/mempool.h +24 -0
  63. epanet-src/output.c +853 -0
  64. epanet-src/project.c +1691 -0
  65. epanet-src/quality.c +695 -0
  66. epanet-src/qualreact.c +800 -0
  67. epanet-src/qualroute.c +696 -0
  68. epanet-src/report.c +1559 -0
  69. epanet-src/rules.c +1500 -0
  70. epanet-src/smatrix.c +871 -0
  71. epanet-src/text.h +508 -0
  72. epanet-src/types.h +928 -0
  73. epanet-src/util/cstr_helper.c +59 -0
  74. epanet-src/util/cstr_helper.h +38 -0
  75. epanet-src/util/errormanager.c +92 -0
  76. epanet-src/util/errormanager.h +39 -0
  77. epanet-src/util/filemanager.c +212 -0
  78. epanet-src/util/filemanager.h +81 -0
  79. epanet-src/validate.c +408 -0
  80. epanet.cpython-313-darwin.so +0 -0
  81. epanet_plus/VERSION +1 -0
  82. epanet_plus/__init__.py +8 -0
  83. epanet_plus/epanet_plus.c +118 -0
  84. epanet_plus/epanet_toolkit.py +2730 -0
  85. epanet_plus/epanet_wrapper.py +2414 -0
  86. epanet_plus/include/epanet_plus.h +9 -0
  87. epanet_plus-0.0.1.dist-info/METADATA +152 -0
  88. epanet_plus-0.0.1.dist-info/RECORD +105 -0
  89. epanet_plus-0.0.1.dist-info/WHEEL +6 -0
  90. epanet_plus-0.0.1.dist-info/licenses/LICENSE +21 -0
  91. epanet_plus-0.0.1.dist-info/top_level.txt +11 -0
  92. examples/basic_usage.py +35 -0
  93. python-extension/ext.c +344 -0
  94. python-extension/pyepanet.c +2133 -0
  95. python-extension/pyepanet.h +143 -0
  96. python-extension/pyepanet2.c +1823 -0
  97. python-extension/pyepanet2.h +141 -0
  98. python-extension/pyepanet_plus.c +37 -0
  99. python-extension/pyepanet_plus.h +4 -0
  100. python-extension/pyepanetmsx.c +388 -0
  101. python-extension/pyepanetmsx.h +35 -0
  102. tests/test_epanet.py +16 -0
  103. tests/test_epanetmsx.py +36 -0
  104. tests/test_epyt.py +114 -0
  105. tests/test_load_inp_from_buffer.py +18 -0
@@ -0,0 +1,400 @@
1
+ /******************************************************************************
2
+ ** MODULE: MSXRPT.C
3
+ ** PROJECT: EPANET-MSX
4
+ ** DESCRIPTION: report writing routines for the EPANET Multi-Species
5
+ ** Extension toolkit.
6
+ ** AUTHORS: see AUTHORS
7
+ ** Copyright: see AUTHORS
8
+ ** License: see LICENSE
9
+ ** VERSION: 2.0.00
10
+ ** LAST UPDATE: 04/14/2021
11
+ ******************************************************************************/
12
+
13
+ #include <stdio.h>
14
+ #include <string.h>
15
+ #include <time.h>
16
+ #include <math.h>
17
+
18
+ #include "msxtypes.h"
19
+ #include "epanet2.h"
20
+
21
+ // Constants
22
+ //----------
23
+ #define SERIES_TABLE 0
24
+ #define STATS_TABLE 1
25
+
26
+ // External variables
27
+ //--------------------
28
+ extern MSXproject MSX; // MSX project data
29
+
30
+ // Local variables
31
+ //-----------------
32
+ static char *Logo[] =
33
+ {"******************************************************************",
34
+ "* E P A N E T - M S X *",
35
+ "* Multi-Species Water Quality *",
36
+ "* Analysis for Pipe Networks *",
37
+ "* Version 2.0.0 *", //2.0.00
38
+ "******************************************************************"};
39
+
40
+ static char PageHdr[] = " Page %d ";
41
+ static char *StatsHdrs[] =
42
+ {"", "Average Values ", "Minimum Values ",
43
+ "Maximum Values ", "Range of Values "};
44
+ static char Line[MAXLINE+1];
45
+ static long LineNum;
46
+ static long PageNum;
47
+ static int *RptdSpecies;
48
+ static struct TableHdrStruct
49
+ {
50
+ char Line1[MAXLINE+1];
51
+ char Line2[MAXLINE+1];
52
+ char Line3[MAXLINE+1];
53
+ char Line4[MAXLINE+1];
54
+ char Line5[MAXLINE+1];
55
+ } TableHdr;
56
+ static char IDname[MAXLINE+1];
57
+
58
+ // Imported functions
59
+ //--------------------
60
+ void MSXinp_getSpeciesUnits(int m, char *units);
61
+ float MSXout_getNodeQual(int k, int j, int m);
62
+ float MSXout_getLinkQual(int k, int j, int m);
63
+
64
+ // Exported functions
65
+ //--------------------
66
+ int MSXrpt_write(void);
67
+ void MSXrpt_writeLine(char *line);
68
+
69
+ // Local functions
70
+ //-----------------
71
+ static void createSeriesTables(void);
72
+ static void createStatsTables(void);
73
+ static void createTableHdr(int objType, int tableType);
74
+ static void writeTableHdr(void);
75
+ static void writeNodeTable(int j, int tableType);
76
+ static void writeLinkTable(int j, int tableType);
77
+ static void getHrsMins(int k, int *hrs, int *mins);
78
+ static void newPage(void);
79
+ static void writeLine(char *line);
80
+
81
+ static void writemassbalance();
82
+
83
+ //=============================================================================
84
+
85
+ int MSXrpt_write()
86
+ {
87
+ INT4 magic = 0;
88
+ int j;
89
+ int recordsize = sizeof(INT4);
90
+
91
+ // --- check that results are available
92
+
93
+ if ( MSX.Nperiods < 1 ) return 0;
94
+ if ( MSX.OutFile.file == NULL ) return ERR_OPEN_OUT_FILE;
95
+ fseek(MSX.OutFile.file, -recordsize, SEEK_END);
96
+ fread(&magic, sizeof(INT4), 1, MSX.OutFile.file);
97
+ if ( magic != MAGICNUMBER ) return ERR_IO_OUT_FILE;
98
+
99
+ // --- write program logo & project title
100
+
101
+ PageNum = 1;
102
+ LineNum = 1;
103
+ newPage();
104
+ for (j=0; j<=5; j++) writeLine(Logo[j]);
105
+ writeLine("");
106
+ writeLine(MSX.Title);
107
+
108
+ // --- generate the appropriate type of table
109
+
110
+ if ( MSX.Statflag == SERIES ) createSeriesTables();
111
+ else createStatsTables();
112
+
113
+ writemassbalance();
114
+
115
+ writeLine("");
116
+ return 0;
117
+ }
118
+
119
+ //=============================================================================
120
+
121
+ void MSXrpt_writeLine(char *line)
122
+ {
123
+ writeLine(line);
124
+ }
125
+
126
+ //=============================================================================
127
+
128
+ void createSeriesTables()
129
+ {
130
+ int j;
131
+
132
+ // --- report on all requested nodes
133
+
134
+ for (j=1; j<=MSX.Nobjects[NODE]; j++)
135
+ {
136
+ if ( !MSX.Node[j].rpt ) continue;
137
+ ENgetnodeid(j, IDname);
138
+ createTableHdr(NODE, SERIES_TABLE);
139
+ writeNodeTable(j, SERIES_TABLE);
140
+ }
141
+
142
+ // --- report on all requested links
143
+
144
+ for (j=1; j<=MSX.Nobjects[LINK]; j++)
145
+ {
146
+ if ( !MSX.Link[j].rpt ) continue;
147
+ ENgetlinkid(j, IDname);
148
+ createTableHdr(LINK, SERIES_TABLE);
149
+ writeLinkTable(j, SERIES_TABLE);
150
+ }
151
+ }
152
+
153
+ //=============================================================================
154
+
155
+ void createStatsTables()
156
+ {
157
+ int j;
158
+ int count;
159
+
160
+ // --- check if any nodes to be reported
161
+
162
+ count = 0;
163
+ for (j = 1; j <= MSX.Nobjects[NODE]; j++) count += MSX.Node[j].rpt;
164
+
165
+ // --- report on all requested nodes
166
+
167
+ if ( count > 0 )
168
+ {
169
+ createTableHdr(NODE, STATS_TABLE);
170
+ for (j = 1; j <= MSX.Nobjects[NODE]; j++)
171
+ {
172
+ if ( MSX.Node[j].rpt ) writeNodeTable(j, STATS_TABLE);
173
+ }
174
+ }
175
+
176
+ // --- check if any links to be reported
177
+
178
+ count = 0;
179
+ for (j = 1; j <= MSX.Nobjects[LINK]; j++) count += MSX.Link[j].rpt;
180
+
181
+ // --- report on all requested links
182
+
183
+ if ( count > 0 )
184
+ {
185
+ createTableHdr(LINK, STATS_TABLE);
186
+ for (j = 1; j <= MSX.Nobjects[LINK]; j++)
187
+ {
188
+ if ( MSX.Link[j].rpt ) writeLinkTable(j, STATS_TABLE);
189
+ }
190
+ }
191
+ }
192
+
193
+ //=============================================================================
194
+
195
+ void createTableHdr(int objType, int tableType)
196
+ {
197
+ int m;
198
+ char s1[MAXLINE+1];
199
+ char s2[MAXLINE+1];
200
+
201
+ if ( tableType == SERIES_TABLE )
202
+ {
203
+ if ( objType == NODE )
204
+ sprintf(TableHdr.Line1, "<<< Node %s >>>", IDname);
205
+ else
206
+ sprintf(TableHdr.Line1, "<<< Link %s >>>", IDname);
207
+ strcpy(TableHdr.Line2, "Time ");
208
+ strcpy(TableHdr.Line3, "hr:min ");
209
+ strcpy(TableHdr.Line4, "-------");
210
+ }
211
+ if ( tableType == STATS_TABLE )
212
+ {
213
+ strcpy(TableHdr.Line1, "");
214
+ sprintf(TableHdr.Line2, "%-16s", StatsHdrs[tableType]);
215
+ if ( objType == NODE ) strcpy(TableHdr.Line3, "for Node ");
216
+ else strcpy(TableHdr.Line3, "for Link ");
217
+ strcpy(TableHdr.Line4, "----------------");
218
+ }
219
+ for (m=1; m<=MSX.Nobjects[SPECIES]; m++)
220
+ {
221
+ if ( !MSX.Species[m].rpt ) continue;
222
+ if ( objType == NODE && MSX.Species[m].type == WALL ) continue;
223
+ sprintf(s1, " %10s", MSX.Species[m].id);
224
+ strcat(TableHdr.Line2, s1);
225
+ strcat(TableHdr.Line4, " ----------");
226
+ MSXinp_getSpeciesUnits(m, s1);
227
+ sprintf(s2, " %10s", s1);
228
+ strcat(TableHdr.Line3, s2);
229
+ }
230
+ if ( MSX.PageSize > 0 && MSX.PageSize - LineNum < 8 ) newPage();
231
+ else writeTableHdr();
232
+ }
233
+
234
+ //=============================================================================
235
+
236
+ void writeTableHdr()
237
+ {
238
+ if ( MSX.PageSize > 0 && MSX.PageSize - LineNum < 6 ) newPage();
239
+ writeLine("");
240
+ writeLine(TableHdr.Line1);
241
+ writeLine("");
242
+ writeLine(TableHdr.Line2);
243
+ writeLine(TableHdr.Line3);
244
+ writeLine(TableHdr.Line4);
245
+ }
246
+
247
+ //=============================================================================
248
+
249
+ void writeNodeTable(int j, int tableType)
250
+ {
251
+ int k, m, hrs, mins;
252
+ char s[MAXLINE+1];
253
+ float c;
254
+
255
+ for (k=0; k<MSX.Nperiods; k++)
256
+ {
257
+ if ( tableType == SERIES_TABLE )
258
+ {
259
+ getHrsMins(k, &hrs, &mins);
260
+ sprintf(Line, "%4d:%02d", hrs, mins);
261
+ }
262
+ if ( tableType == STATS_TABLE )
263
+ {
264
+ ENgetnodeid(j, IDname);
265
+ sprintf(Line, "%-16s", IDname);
266
+ }
267
+ for (m=1; m<=MSX.Nobjects[SPECIES]; m++)
268
+ {
269
+ if ( !MSX.Species[m].rpt ) continue;
270
+ if ( MSX.Species[m].type == WALL ) continue;
271
+ c = MSXout_getNodeQual(k, j, m);
272
+ sprintf(s, " %10.*f", MSX.Species[m].precision, c);
273
+ strcat(Line, s);
274
+ }
275
+ writeLine(Line);
276
+ }
277
+ }
278
+
279
+ //=============================================================================
280
+
281
+ void writeLinkTable(int j, int tableType)
282
+ {
283
+ int k, m, hrs, mins;
284
+ char s[MAXLINE+1];
285
+ float c;
286
+
287
+ for (k=0; k<MSX.Nperiods; k++)
288
+ {
289
+ if ( tableType == SERIES_TABLE )
290
+ {
291
+ getHrsMins(k, &hrs, &mins);
292
+ sprintf(Line, "%4d:%02d", hrs, mins);
293
+ }
294
+ if ( tableType == STATS_TABLE )
295
+ {
296
+ ENgetlinkid(j, IDname);
297
+ sprintf(Line, "%-16s", IDname);
298
+ }
299
+ for (m=1; m<=MSX.Nobjects[SPECIES]; m++)
300
+ {
301
+ if ( !MSX.Species[m].rpt ) continue;
302
+ c = MSXout_getLinkQual(k, j, m);
303
+ sprintf(s, " %10.*f", MSX.Species[m].precision, c);
304
+ strcat(Line, s);
305
+ }
306
+ writeLine(Line);
307
+ }
308
+ }
309
+
310
+ //=============================================================================
311
+
312
+ void getHrsMins(int k, int *hrs, int *mins)
313
+ {
314
+ long m, h;
315
+
316
+ m = (MSX.Rstart + k*MSX.Rstep) / 60;
317
+ h = m / 60;
318
+ m = m - 60*h;
319
+ *hrs = h;
320
+ *mins = m;
321
+ }
322
+
323
+ //=============================================================================
324
+
325
+ void newPage()
326
+ {
327
+ char s[MAXLINE+1];
328
+ LineNum = 1;
329
+ sprintf(s,
330
+ "\nPage %-3d EPANET-MSX 2.0.0", //2.0.0
331
+ PageNum);
332
+ writeLine(s);
333
+ writeLine("");
334
+ if ( PageNum > 1 ) writeTableHdr();
335
+ PageNum++;
336
+ }
337
+
338
+ //=============================================================================
339
+
340
+ void writeLine(char *line)
341
+ {
342
+ if ( LineNum == MSX.PageSize ) newPage();
343
+ if ( MSX.RptFile.file ) fprintf(MSX.RptFile.file, " %s\n", line); //(modified, FS-01/07/2008)
344
+ else ENwriteline(line);
345
+ LineNum++;
346
+ }
347
+
348
+
349
+ void writemassbalance()
350
+ /*
351
+ **-------------------------------------------------------------
352
+ ** Input: none
353
+ ** Output: none
354
+ ** Purpose: writes water quality mass balance ratio
355
+ ** (Outflow + Final Storage) / Inflow + Initial Storage)
356
+ ** to report file.
357
+ **-------------------------------------------------------------
358
+ */
359
+ {
360
+
361
+ char s1[MAXMSG + 1];
362
+ int kunits = 0;
363
+
364
+ for (int m = 1; m <= MSX.Nobjects[SPECIES]; m++)
365
+ {
366
+ if (MSX.Species[m].pipeExprType != RATE)
367
+ continue;
368
+
369
+ snprintf(s1, MAXMSG, "\n");
370
+ writeLine(s1);
371
+ snprintf(s1, MAXMSG, "Water Quality Mass Balance: %s (%s)", MSX.Species[m].id, MSX.Species[m].units);
372
+ writeLine(s1);
373
+ snprintf(s1, MAXMSG, "================================");
374
+ writeLine(s1);
375
+ snprintf(s1, MAXMSG, "Initial Mass: %12.5e", MSX.MassBalance.initial[m]);
376
+ writeLine(s1);
377
+ snprintf(s1, MAXMSG, "Mass Inflow: %12.5e", MSX.MassBalance.inflow[m]+ MSX.MassBalance.indisperse[m]);
378
+ writeLine(s1);
379
+ // snprintf(s1, MAXMSG, "Mass Dispersed Inflow: %12.5e", MSX.MassBalance.indisperse[m]);
380
+ // writeLine(s1);
381
+ snprintf(s1, MAXMSG, "Mass Outflow: %12.5e", MSX.MassBalance.outflow[m]);
382
+ writeLine(s1);
383
+ snprintf(s1, MAXMSG, "Mass Reacted: %12.5e", MSX.MassBalance.reacted[m]);
384
+ writeLine(s1);
385
+ snprintf(s1, MAXMSG, "Final Mass: %12.5e", MSX.MassBalance.final[m]);
386
+ writeLine(s1);
387
+ snprintf(s1, MAXMSG, "Mass Ratio: %-.5f", MSX.MassBalance.ratio[m]);
388
+ writeLine(s1);
389
+ snprintf(s1, MAXMSG, "================================\n");
390
+ writeLine(s1);
391
+ }
392
+ }
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+