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,260 @@
1
+ /*******************************************************************************
2
+ ** MODULE: MSXFILE.C
3
+ ** PROJECT: EPANET-MSX
4
+ ** DESCRIPTION: writes MSX project data to a MSX input file.
5
+ ** AUTHORS: see AUTHORS
6
+ ** Copyright: see AUTHORS
7
+ ** License: see LICENSE
8
+ ** VERSION: 2.0.00
9
+ ** LAST UPDATE: 04/14/2021
10
+ *******************************************************************************/
11
+
12
+ #include <stdio.h>
13
+ #include <string.h>
14
+
15
+ #include "msxtypes.h"
16
+ #include "msxutils.h"
17
+ #include "msxdict.h"
18
+ #include "epanet2.h"
19
+
20
+ // External variables
21
+ //--------------------
22
+ extern MSXproject MSX; // MSX project data
23
+
24
+ // Exported functions
25
+ //--------------------
26
+ int MSXfile_save(FILE *f);
27
+
28
+ // Local functions
29
+ //-----------------
30
+ static void saveSpecies(FILE *f);
31
+ static void saveCoeffs(FILE *f);
32
+ static int saveInpSections(FILE *f);
33
+ static void saveParams(FILE *f);
34
+ static void saveQuality(FILE *f);
35
+ static void saveSources(FILE *f);
36
+ static void savePatterns(FILE *f);
37
+
38
+ //=============================================================================
39
+
40
+ int MSXfile_save(FILE *f)
41
+ /*
42
+ ** Purpose:
43
+ ** saves current MSX project data to file.
44
+ **
45
+ ** Input:
46
+ ** f = pointer to MSX file where data are saved.
47
+ */
48
+ {
49
+ int errcode;
50
+ fprintf(f, "[TITLE]");
51
+ fprintf(f, "\n%s\n", MSX.Title);
52
+ saveSpecies(f);
53
+ saveCoeffs(f);
54
+ errcode = saveInpSections(f);
55
+ saveParams(f);
56
+ saveQuality(f);
57
+ saveSources(f);
58
+ savePatterns(f);
59
+ return errcode;
60
+ }
61
+
62
+ //=============================================================================
63
+
64
+ void saveSpecies(FILE *f)
65
+ {
66
+ int i, n;
67
+ fprintf(f, "\n[SPECIES]");
68
+ n = MSX.Nobjects[SPECIES];
69
+ for (i=1; i<=n; i++)
70
+ {
71
+ if ( MSX.Species[i].type == BULK ) fprintf(f, "\nBULK ");
72
+ else fprintf(f, "\nWALL ");
73
+ fprintf(f, "%-32s %-15s %e %e",
74
+ MSX.Species[i].id, MSX.Species[i].units,
75
+ MSX.Species[i].aTol, MSX.Species[i].rTol);
76
+ }
77
+ }
78
+
79
+ //=============================================================================
80
+
81
+ void saveCoeffs(FILE *f)
82
+ {
83
+ int i, n;
84
+ fprintf(f, "\n\n[COEFFICIENTS]");
85
+ n = MSX.Nobjects[CONSTANT];
86
+ for (i=1; i<=n; i++)
87
+ {
88
+ fprintf(f, "\nCONSTANT %-32s %e",
89
+ MSX.Const[i].id, MSX.Const[i].value);
90
+ }
91
+ n = MSX.Nobjects[PARAMETER];
92
+ for (i=1; i<=n; i++)
93
+ {
94
+ fprintf(f, "\nPARAMETER %-32s %e",
95
+ MSX.Param[i].id, MSX.Param[i].value);
96
+ }
97
+ }
98
+
99
+ //=============================================================================
100
+
101
+ int saveInpSections(FILE *f)
102
+ {
103
+ char line[MAXLINE+1];
104
+ char writeLine;
105
+ int newsect;
106
+
107
+ if ((MSX.MsxFile.file = fopen(MSX.MsxFile.name,"rt")) == NULL) return ERR_OPEN_MSX_FILE;
108
+ rewind(MSX.MsxFile.file);
109
+
110
+ fprintf(f,"\n\n");
111
+ writeLine = FALSE;
112
+ while ( fgets(line, MAXLINE, MSX.MsxFile.file) != NULL )
113
+ {
114
+ if (*line == '[' )
115
+ {
116
+ writeLine = TRUE;
117
+ newsect = MSXutils_findmatch(line, MsxSectWords);
118
+ if ( newsect >= 0 ) switch(newsect)
119
+ {
120
+ case s_OPTION:
121
+ case s_TERM:
122
+ case s_PIPE:
123
+ case s_TANK:
124
+ case s_REPORT:
125
+ break;
126
+ default:
127
+ writeLine = FALSE;
128
+ }
129
+ }
130
+ if ( writeLine) fprintf(f, "%s", line);
131
+ }
132
+ if ( MSX.MsxFile.file ) fclose(MSX.MsxFile.file);
133
+ MSX.MsxFile.file = NULL;
134
+ return 0;
135
+ }
136
+
137
+ //=============================================================================
138
+
139
+ void saveParams(FILE *f)
140
+ {
141
+ int i, j, k;
142
+ double x;
143
+ char id[MAXLINE+1];
144
+
145
+ if ( MSX.Nobjects[PARAMETER] > 0 )
146
+ {
147
+ fprintf(f, "\n\n[PARAMETERS]");
148
+ for (j=1; j<=MSX.Nobjects[PARAMETER]; j++)
149
+ {
150
+ x = MSX.Param[j].value;
151
+ for (i=1; i<=MSX.Nobjects[LINK]; i++)
152
+ {
153
+ if ( MSX.Link[i].param[j] != x )
154
+ {
155
+ ENgetlinkid(i, id);
156
+ fprintf(f, "\nPIPE %-32s %-32s %e",
157
+ id, MSX.Param[j].id, MSX.Link[i].param[j]);
158
+ }
159
+ }
160
+ for (i=1; i<=MSX.Nobjects[TANK]; i++)
161
+ {
162
+ if ( MSX.Tank[i].param[j] != x )
163
+ {
164
+ k = MSX.Tank[i].node;
165
+ ENgetnodeid(k, id);
166
+ fprintf(f, "\nTANK %-32s %-32s %e",
167
+ id, MSX.Param[j].id, MSX.Tank[i].param[j]);
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ //=============================================================================
175
+
176
+ void saveQuality(FILE *f)
177
+ {
178
+ int i, j;
179
+ char id[MAXLINE+1];
180
+
181
+ fprintf(f, "\n\n[QUALITY]");
182
+ for (j=1; j<=MSX.Nobjects[SPECIES]; j++)
183
+ {
184
+ if (MSX.C0[j] > 0.0)
185
+ fprintf(f, "\nGLOBAL %-32s %e",
186
+ MSX.Species[j].id, MSX.C0[j]);
187
+
188
+ for (i=1; i<=MSX.Nobjects[NODE]; i++)
189
+ {
190
+ if ( MSX.Node[i].c0[j] > 0.0 && MSX.Node[i].c0[j] != MSX.C0[j])
191
+ {
192
+ ENgetnodeid(i, id);
193
+ fprintf(f, "\nNODE %-32s %-32s %e",
194
+ id, MSX.Species[j].id, MSX.Node[i].c0[j]);
195
+ }
196
+ }
197
+ for (i=1; i<=MSX.Nobjects[LINK]; i++)
198
+ {
199
+ if ( MSX.Link[i].c0[j] > 0.0 && MSX.Link[i].c0[j] != MSX.C0[j])
200
+ {
201
+ ENgetlinkid(i, id);
202
+ fprintf(f, "\nLINK %-32s %-32s %e",
203
+ id, MSX.Species[j].id, MSX.Link[i].c0[j]);
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ //=============================================================================
210
+
211
+ void saveSources(FILE *f)
212
+ {
213
+ int i;
214
+ Psource source;
215
+ char id[MAXLINE+1];
216
+
217
+ fprintf(f, "\n\n[SOURCES]");
218
+ for (i=1; i<=MSX.Nobjects[NODE]; i++)
219
+ {
220
+ source = MSX.Node[i].sources;
221
+ while ( source )
222
+ {
223
+ if ( source->c0 > 0.0 && source->type > -1) //Feng Shang 09/23/2008
224
+ {
225
+ ENgetnodeid(i, id);
226
+ fprintf(f, "\n%-10s %-32s %-32s %e",
227
+ SourceTypeWords[source->type], id,
228
+ MSX.Species[source->species].id, source->c0);
229
+ if ( source->pat > 0 )
230
+ fprintf(f, " %-32s", MSX.Pattern[source->pat].id);
231
+ }
232
+ source = source->next;
233
+ }
234
+ }
235
+ }
236
+
237
+ //=============================================================================
238
+
239
+ void savePatterns(FILE *f)
240
+ {
241
+ int i, count;
242
+ SnumList *listItem;
243
+
244
+ if ( MSX.Nobjects[PATTERN] > 0 ) fprintf(f, "\n\n[PATTERNS]");
245
+ for (i=1; i<=MSX.Nobjects[PATTERN]; i++)
246
+ {
247
+ count = 0;
248
+ listItem = MSX.Pattern[i].first;
249
+ while (listItem)
250
+ {
251
+ if ( count % 6 == 0 )
252
+ {
253
+ fprintf(f, "\n%-32s", MSX.Pattern[i].id);
254
+ }
255
+ fprintf(f, " %e", listItem->value);
256
+ count++;
257
+ listItem = listItem->next;
258
+ }
259
+ }
260
+ }
@@ -0,0 +1,175 @@
1
+ /*******************************************************************************
2
+ ** MODULE: MSXFUNCS.C
3
+ ** PROJECT: EPANET-MSX
4
+ ** DESCRIPTION: compiles chemistry functions to a shared dynamic library.
5
+ ** COPYRIGHT: Copyright (C) 2007 Feng Shang, Lewis Rossman, and James Uber.
6
+ ** All Rights Reserved. See license information in LICENSE.TXT.
7
+ ** AUTHORS: see AUTHORS
8
+ ** VERSION: 2.0.00
9
+ ** LAST UPDATE: 04/14/2014
10
+ *******************************************************************************/
11
+
12
+ #include <stdio.h>
13
+
14
+ // --- define WINDOWS
15
+
16
+ #undef WINDOWS
17
+ #ifdef _WIN32
18
+ #define WINDOWS
19
+ #endif
20
+ #ifdef __WIN32__
21
+ #define WINDOWS
22
+ #endif
23
+ #ifdef WIN32
24
+ #define WINDOWS
25
+ #endif
26
+
27
+ #ifdef WINDOWS
28
+ #include <windows.h>
29
+ HMODULE hDLL;
30
+ #else
31
+ #include <dlfcn.h>
32
+ void *hDLL;
33
+ #endif
34
+
35
+ #include "msxfuncs.h"
36
+
37
+
38
+ MSXGETRATES MSXgetPipeRates = NULL;
39
+ MSXGETRATES MSXgetTankRates = NULL;
40
+ MSXGETEQUIL MSXgetPipeEquil = NULL;
41
+ MSXGETEQUIL MSXgetTankEquil = NULL;
42
+ MSXGETFORMULAS MSXgetPipeFormulas = NULL;
43
+ MSXGETFORMULAS MSXgetTankFormulas = NULL;
44
+
45
+
46
+
47
+ //=============================================================================
48
+
49
+ int MSXfuncs_load(char * libName)
50
+ /*
51
+ ** Purpose:
52
+ ** loads compiled chemistry functions from a named library
53
+ **
54
+ ** Input:
55
+ ** libName = path to shared library
56
+ **
57
+ ** Returns:
58
+ ** an error code (0 if no error).
59
+ */
60
+ {
61
+
62
+ #ifdef WINDOWS
63
+ hDLL = LoadLibraryA(libName);
64
+ if (hDLL == NULL) return 1;
65
+
66
+ MSXgetPipeRates = (MSXGETRATES) GetProcAddress(hDLL, "MSXgetPipeRates");
67
+ MSXgetTankRates = (MSXGETRATES) GetProcAddress(hDLL, "MSXgetTankRates");
68
+ MSXgetPipeEquil = (MSXGETEQUIL) GetProcAddress(hDLL, "MSXgetPipeEquil");
69
+ MSXgetTankEquil = (MSXGETEQUIL) GetProcAddress(hDLL, "MSXgetTankEquil");
70
+ MSXgetPipeFormulas = (MSXGETFORMULAS) GetProcAddress(hDLL, "MSXgetPipeFormulas");
71
+ MSXgetTankFormulas = (MSXGETFORMULAS) GetProcAddress(hDLL, "MSXgetTankFormulas");
72
+
73
+ #else
74
+ hDLL = dlopen(libName, RTLD_LAZY);
75
+ if (hDLL == NULL) return 1;
76
+
77
+ MSXgetPipeRates = (MSXGETRATES) dlsym(hDLL, "MSXgetPipeRates");
78
+ MSXgetTankRates = (MSXGETRATES) dlsym(hDLL, "MSXgetTankRates");
79
+ MSXgetPipeEquil = (MSXGETEQUIL) dlsym(hDLL, "MSXgetPipeEquil");
80
+ MSXgetTankEquil = (MSXGETEQUIL) dlsym(hDLL, "MSXgetTankEquil");
81
+ MSXgetPipeFormulas = (MSXGETFORMULAS) dlsym(hDLL, "MSXgetPipeFormulas");
82
+ MSXgetTankFormulas = (MSXGETFORMULAS) dlsym(hDLL, "MSXgetTankFormulas");
83
+ #endif
84
+
85
+ if (MSXgetPipeRates == NULL || MSXgetTankRates == NULL ||
86
+ MSXgetPipeEquil == NULL || MSXgetTankEquil == NULL ||
87
+ MSXgetPipeFormulas == NULL || MSXgetTankFormulas == NULL)
88
+ {
89
+ MSXfuncs_free();
90
+ hDLL = NULL;
91
+ return 2;
92
+ }
93
+ return 0;
94
+ }
95
+
96
+ //=============================================================================
97
+
98
+ void MSXfuncs_free()
99
+ /*
100
+ ** Purpose:
101
+ ** frees the handle to the shared function library
102
+ **
103
+ ** Input:
104
+ ** none
105
+ **
106
+ ** Returns:
107
+ ** none
108
+ */
109
+ {
110
+ #ifdef WINDOWS
111
+ if (hDLL) FreeLibrary(hDLL);
112
+ #else
113
+ if (hDLL) dlclose(hDLL);
114
+ #endif
115
+ }
116
+
117
+ //=============================================================================
118
+
119
+ int MSXfuncs_run(char* cmdLine)
120
+ /*
121
+ ** Purpose:
122
+ ** executes a program and waits for it to end
123
+ **
124
+ ** Input:
125
+ ** cmdLine = command line string that executes the program
126
+ **
127
+ ** Returns:
128
+ ** the program's exit code (or -1 if the program was not run)
129
+ */
130
+ {
131
+ #ifdef WINDOWS
132
+
133
+ unsigned long exitCode;
134
+ STARTUPINFOA si;
135
+ PROCESS_INFORMATION pi;
136
+
137
+ // --- initialize data structures
138
+
139
+ memset(&si, 0, sizeof(si));
140
+ memset(&pi, 0, sizeof(pi));
141
+ si.cb = sizeof(si);
142
+
143
+ // --- hide the window that the program runs in
144
+
145
+ si.dwFlags = STARTF_USESHOWWINDOW;
146
+ si.wShowWindow = SW_HIDE;
147
+
148
+ // --- execute the command line in a new console window
149
+ exitCode = CreateProcess(NULL, cmdLine, NULL, NULL, 0,
150
+ CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
151
+ if (exitCode == 0)
152
+ {
153
+ exitCode = GetLastError();
154
+ return exitCode;
155
+ }
156
+
157
+ // --- wait for program to end
158
+
159
+ exitCode = WaitForSingleObject(pi.hProcess, INFINITE);
160
+
161
+ // --- retrieve the error code produced by the program
162
+
163
+ BOOL rt = GetExitCodeProcess(pi.hProcess, &exitCode);
164
+
165
+ // --- release handles
166
+
167
+ CloseHandle(pi.hProcess);
168
+ CloseHandle(pi.hThread);
169
+ return exitCode;
170
+
171
+ #else
172
+ return -1;
173
+ #endif
174
+ }
175
+
@@ -0,0 +1,35 @@
1
+ /************************************************************************
2
+ ** MODULE: MSXFUNCS.H
3
+ ** PROJECT: EPANET-MSX
4
+ ** DESCRIPTION: Definitions of functions loaded from compiled chemistry file.
5
+ ** COPYRIGHT: Copyright (C) 2007 Feng Shang, Lewis Rossman, and James Uber.
6
+ ** All Rights Reserved. See license information in LICENSE.TXT.
7
+ ** AUTHORS: See Authors
8
+ ** VERSION: 2.0.00
9
+ ** LAST UPDATE: 04/14/2021
10
+ ***********************************************************************/
11
+
12
+ #ifndef MSXFUNCS_H
13
+ #define MSXFUNCS_H
14
+
15
+ // Define pointers for each group of chemistry functions
16
+ typedef void (*MSXGETRATES)(double *, double *, double * , double *, double *);
17
+ typedef void (*MSXGETEQUIL)(double *, double *, double * , double *, double *);
18
+ typedef void (*MSXGETFORMULAS)(double *, double *, double *, double *);
19
+
20
+ // Declare each chemistry function
21
+ extern MSXGETRATES MSXgetPipeRates;
22
+ extern MSXGETRATES MSXgetTankRates;
23
+ extern MSXGETEQUIL MSXgetPipeEquil;
24
+ extern MSXGETEQUIL MSXgetTankEquil;
25
+ extern MSXGETFORMULAS MSXgetPipeFormulas;
26
+ extern MSXGETFORMULAS MSXgetTankFormulas;
27
+
28
+ // Functions that load and free the chemistry functions
29
+ int MSXfuncs_load(char *);
30
+ void MSXfuncs_free(void);
31
+
32
+ // Function that executes a command line program
33
+ int MSXfuncs_run(char * );
34
+
35
+ #endif