epanet-plus 0.0.1__cp313-cp313-win_amd64.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.cp313-win_amd64.pyd +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 +5 -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,141 @@
1
+ #include <Python.h>
2
+
3
+
4
+ PyObject* method_ENopen(PyObject* self, PyObject* args);
5
+ PyObject* method_ENclose(PyObject* self, PyObject* Py_UNUSED(args));
6
+ PyObject* method_ENaddcontrol(PyObject* self, PyObject* args);
7
+ PyObject* method_ENaddcurve(PyObject* self, PyObject* args);
8
+ PyObject* method_ENadddemand(PyObject* self, PyObject* args);
9
+ PyObject* method_ENaddlink(PyObject* self, PyObject* args);
10
+ PyObject* method_ENaddnode(PyObject* self, PyObject* args);
11
+ PyObject* method_ENaddpattern(PyObject* self, PyObject* args);
12
+ PyObject* method_ENaddrule(PyObject* self, PyObject* args);
13
+ PyObject* method_ENclearreport(PyObject* self, PyObject* Py_UNUSED(args));
14
+ PyObject* method_ENcloseH(PyObject* self, PyObject* Py_UNUSED(args));
15
+ PyObject* method_ENcloseQ(PyObject* self, PyObject* Py_UNUSED(args));
16
+ PyObject* method_ENcopyreport(PyObject* self, PyObject* args);
17
+ PyObject* method_ENdeletecontrol(PyObject* self, PyObject* args);
18
+ PyObject* method_ENdeletecurve(PyObject* self, PyObject* args);
19
+ PyObject* method_ENdeletedemand(PyObject* self, PyObject* args);
20
+ PyObject* method_ENdeletelink(PyObject* self, PyObject* args);
21
+ PyObject* method_ENdeletenode(PyObject* self, PyObject* args);
22
+ PyObject* method_ENdeletepattern(PyObject* self, PyObject* args);
23
+ PyObject* method_ENdeleterule(PyObject* self, PyObject* args);
24
+ PyObject* method_ENgetaveragepatternvalue(PyObject* self, PyObject* args);
25
+ PyObject* method_ENgetbasedemand(PyObject* self, PyObject* args);
26
+ PyObject* method_ENgetcomment(PyObject* self, PyObject* args);
27
+ PyObject* method_ENgetcontrol(PyObject* self, PyObject* args);
28
+ PyObject* method_ENgetcoord(PyObject* self, PyObject* args);
29
+ PyObject* method_ENgetcount(PyObject* self, PyObject* args);
30
+ PyObject* method_ENgetcurve(PyObject* self, PyObject* args);
31
+ PyObject* method_ENgetcurveid(PyObject* self, PyObject* args);
32
+ PyObject* method_ENgetcurveindex(PyObject* self, PyObject* args);
33
+ PyObject* method_ENgetcurvelen(PyObject* self, PyObject* args);
34
+ PyObject* method_ENgetcurvetype(PyObject* self, PyObject* args);
35
+ PyObject* method_ENgetcurvevalue(PyObject* self, PyObject* args);
36
+ PyObject* method_ENgetdemandindex(PyObject* self, PyObject* args);
37
+ PyObject* method_ENgetdemandmodel(PyObject* self, PyObject* Py_UNUSED(args));
38
+ PyObject* method_ENgetdemandname(PyObject* self, PyObject* args);
39
+ PyObject* method_ENgetdemandpattern(PyObject* self, PyObject* args);
40
+ PyObject* method_ENgetelseaction(PyObject* self, PyObject* args);
41
+ PyObject* method_ENgeterror(PyObject* self, PyObject* args);
42
+ PyObject* method_ENgetflowunits(PyObject* self, PyObject* Py_UNUSED(args));
43
+ PyObject* method_ENgetheadcurveindex(PyObject* self, PyObject* args);
44
+ PyObject* method_ENgetlinkid(PyObject* self, PyObject* args);
45
+ PyObject* method_ENgetlinkindex(PyObject* self, PyObject* args);
46
+ PyObject* method_ENgetlinknodes(PyObject* self, PyObject* args);
47
+ PyObject* method_ENgetlinktype(PyObject* self, PyObject* args);
48
+ PyObject* method_ENgetlinkvalue(PyObject* self, PyObject* args);
49
+ PyObject* method_ENgetnodeid(PyObject* self, PyObject* args);
50
+ PyObject* method_ENgetnodeindex(PyObject* self, PyObject* args);
51
+ PyObject* method_ENgetnodetype(PyObject* self, PyObject* args);
52
+ PyObject* method_ENgetnodevalue(PyObject* self, PyObject* args);
53
+ PyObject* method_ENgetnumdemands(PyObject* self, PyObject* args);
54
+ PyObject* method_ENgetoption(PyObject* self, PyObject* args);
55
+ PyObject* method_ENgetpatternid(PyObject* self, PyObject* args);
56
+ PyObject* method_ENgetpatternindex(PyObject* self, PyObject* args);
57
+ PyObject* method_ENgetpatternlen(PyObject* self, PyObject* args);
58
+ PyObject* method_ENgetpatternvalue(PyObject* self, PyObject* args);
59
+ PyObject* method_ENgetpremise(PyObject* self, PyObject* args);
60
+ PyObject* method_ENgetpumptype(PyObject* self, PyObject* args);
61
+ PyObject* method_ENgetqualinfo(PyObject* self, PyObject* Py_UNUSED(args));
62
+ PyObject* method_ENgetqualtype(PyObject* self, PyObject* Py_UNUSED(args));
63
+ PyObject* method_ENgetresultindex(PyObject* self, PyObject* args);
64
+ PyObject* method_ENgetrule(PyObject* self, PyObject* args);
65
+ PyObject* method_ENgetruleID(PyObject* self, PyObject* args);
66
+ PyObject* method_ENgetstatistic(PyObject* self, PyObject* args);
67
+ PyObject* method_ENgetthenaction(PyObject* self, PyObject* args);
68
+ PyObject* method_ENgettimeparam(PyObject* self, PyObject* args);
69
+ PyObject* method_ENgettitle(PyObject* self, PyObject* Py_UNUSED(args));
70
+ PyObject* method_ENgetversion(PyObject* self, PyObject* Py_UNUSED(args));
71
+ PyObject* method_ENgetvertex(PyObject* self, PyObject* args);
72
+ PyObject* method_ENgetvertexcount(PyObject* self, PyObject* args);
73
+ PyObject* method_ENinit(PyObject* self, PyObject* args);
74
+ PyObject* method_ENinitH(PyObject* self, PyObject* args);
75
+ PyObject* method_ENinitQ(PyObject* self, PyObject* args);
76
+ PyObject* method_ENnextH(PyObject* self, PyObject* Py_UNUSED(args));
77
+ PyObject* method_ENnextQ(PyObject* self, PyObject* Py_UNUSED(args));
78
+ PyObject* method_ENopenH(PyObject* self, PyObject* Py_UNUSED(args));
79
+ PyObject* method_ENopenQ(PyObject* self, PyObject* Py_UNUSED(args));
80
+ PyObject* method_ENreport(PyObject* self, PyObject* Py_UNUSED(args));
81
+ PyObject* method_ENresetreport(PyObject* self, PyObject* Py_UNUSED(args));
82
+ PyObject* method_ENrunH(PyObject* self, PyObject* Py_UNUSED(args));
83
+ PyObject* method_ENrunQ(PyObject* self, PyObject* Py_UNUSED(args));
84
+ PyObject* method_ENsavehydfile(PyObject* self, PyObject* args);
85
+ PyObject* method_ENsaveH(PyObject* self, PyObject* Py_UNUSED(args));
86
+ PyObject* method_ENsaveinpfile(PyObject* self, PyObject* args);
87
+ PyObject* method_ENsetbasedemand(PyObject* self, PyObject* args);
88
+ PyObject* method_ENsetcomment(PyObject* self, PyObject* args);
89
+ PyObject* method_ENsetcontrol(PyObject* self, PyObject* args);
90
+ PyObject* method_ENsetcurveid(PyObject* self, PyObject* args);
91
+ PyObject* method_ENsetcurve(PyObject* self, PyObject* args);
92
+ PyObject* method_ENsetcoord(PyObject* self, PyObject* args);
93
+ PyObject* method_ENsetcurvevalue(PyObject* self, PyObject* args);
94
+ PyObject* method_ENsetdemandmodel(PyObject* self, PyObject* args);
95
+ PyObject* method_ENsetdemandname(PyObject* self, PyObject* args);
96
+ PyObject* method_ENsetdemandpattern(PyObject* self, PyObject* args);
97
+ PyObject* method_ENsetelseaction(PyObject* self, PyObject* args);
98
+ PyObject* method_ENsetflowunits(PyObject* self, PyObject* args);
99
+ PyObject* method_ENsetheadcurveindex(PyObject* self, PyObject* args);
100
+ PyObject* method_ENsetjuncdata(PyObject* self, PyObject* args);
101
+ PyObject* method_ENsetlinkid(PyObject* self, PyObject* args);
102
+ PyObject* method_ENsetlinknodes(PyObject* self, PyObject* args);
103
+ PyObject* method_ENsetlinktype(PyObject* self, PyObject* args);
104
+ PyObject* method_ENsetlinkvalue(PyObject* self, PyObject* args);
105
+ PyObject* method_ENsetnodeid(PyObject* self, PyObject* args);
106
+ PyObject* method_ENsetnodevalue(PyObject* self, PyObject* args);
107
+ PyObject* method_ENsetoption(PyObject* self, PyObject* args);
108
+ PyObject* method_ENsetpattern(PyObject* self, PyObject* args);
109
+ PyObject* method_ENsetpatternid(PyObject* self, PyObject* args);
110
+ PyObject* method_ENsetpatternvalue(PyObject* self, PyObject* args);
111
+ PyObject* method_ENsetpipedata(PyObject* self, PyObject* args);
112
+ PyObject* method_ENsetpremise(PyObject* self, PyObject* args);
113
+ PyObject* method_ENsetpremiseindex(PyObject* self, PyObject* args);
114
+ PyObject* method_ENsetpremisevalue(PyObject* self, PyObject* args);
115
+ PyObject* method_ENsetpremisestatus(PyObject* self, PyObject* args);
116
+ PyObject* method_ENsetqualtype(PyObject* self, PyObject* args);
117
+ PyObject* method_ENsetreport(PyObject* self, PyObject* args);
118
+ PyObject* method_ENsetrulepriority(PyObject* self, PyObject* args);
119
+ PyObject* method_ENsetstatusreport(PyObject* self, PyObject* args);
120
+ PyObject* method_ENsettankdata(PyObject* self, PyObject* args);
121
+ PyObject* method_ENsetthenaction(PyObject* self, PyObject* args);
122
+ PyObject* method_ENsettimeparam(PyObject* self, PyObject* args);
123
+ PyObject* method_ENsettitle(PyObject* self, PyObject* args);
124
+ PyObject* method_ENsetvertices(PyObject* self, PyObject* args);
125
+ PyObject* method_ENsolveH(PyObject* self, PyObject* Py_UNUSED(args));
126
+ PyObject* method_ENsolveQ(PyObject* self, PyObject* Py_UNUSED(args));
127
+ PyObject* method_ENstepQ(PyObject* self, PyObject* Py_UNUSED(args));
128
+ PyObject* method_ENusehydfile(PyObject* self, PyObject* args);
129
+ PyObject* method_ENwriteline(PyObject* self, PyObject* args);
130
+ PyObject* method_ENgettag(PyObject* self, PyObject* args);
131
+ PyObject* method_ENsettag(PyObject* self, PyObject* args);
132
+ PyObject* method_ENtimetonextevent(PyObject* self, PyObject* Py_UNUSED(args));
133
+ PyObject* method_ENgetnodevalues(PyObject* self, PyObject* args);
134
+ PyObject* method_ENgetlinkvalues(PyObject* self, PyObject* args);
135
+ PyObject* method_ENsetvertex(PyObject* self, PyObject* args);
136
+ PyObject* method_ENloadpatternfile(PyObject* self, PyObject* args);
137
+ PyObject* method_ENsetcurvetype(PyObject* self, PyObject* args);
138
+ PyObject* method_ENgetcontrolenabled(PyObject* self, PyObject* args);
139
+ PyObject* method_ENsetcontrolenabled(PyObject* self, PyObject* args);
140
+ PyObject* method_ENgetruleenabled(PyObject* self, PyObject* args);
141
+ PyObject* method_ENsetruleenabled(PyObject* self, PyObject* args);
@@ -0,0 +1,37 @@
1
+ #include <Python.h>
2
+ #include "epanet_plus.h"
3
+
4
+
5
+ PyObject* method_ENopenfrombuffer(PyObject* self, PyObject* args)
6
+ {
7
+ char* inpBuffer = NULL;
8
+ char* inpFile = NULL;
9
+ char* rptFile = NULL;
10
+ char* outFile = NULL;
11
+
12
+ if(!PyArg_ParseTuple(args, "ssss", &inpBuffer, &inpFile, &rptFile, &outFile)) {
13
+ return NULL;
14
+ }
15
+
16
+ int err = ENopenfrombuffer(inpBuffer, inpFile, rptFile, outFile);
17
+
18
+ return PyTuple_Pack(1, PyLong_FromLong(err));
19
+ }
20
+
21
+ PyObject* method_EN_openfrombuffer(PyObject* self, PyObject* args)
22
+ {
23
+ uintptr_t ptr;
24
+ char* inpBuffer = NULL;
25
+ char* inpFile = NULL;
26
+ char* rptFile = NULL;
27
+ char* outFile = NULL;
28
+
29
+ if(!PyArg_ParseTuple(args, "Kssss", &ptr, &inpBuffer, &inpFile, &rptFile, &outFile)) {
30
+ return NULL;
31
+ }
32
+ EN_Project ph = (EN_Project) ptr;
33
+
34
+ int err = EN_openfrombuffer(ph, inpBuffer, inpFile, rptFile, outFile);
35
+
36
+ return PyTuple_Pack(1, PyLong_FromLong(err));
37
+ }
@@ -0,0 +1,4 @@
1
+ #include <Python.h>
2
+
3
+ PyObject* method_ENopenfrombuffer(PyObject* self, PyObject* args);
4
+ PyObject* method_EN_openfrombuffer(PyObject* self, PyObject* args);
@@ -0,0 +1,388 @@
1
+ #include <Python.h>
2
+ #include "epanetmsx.h"
3
+ #include "msxtypes.h"
4
+
5
+ #define MAXID 31 // Max. # characters in ID name
6
+
7
+
8
+ PyObject* method_MSXENopen(PyObject* self, PyObject* args)
9
+ {
10
+ char *inpFile, *rptFile, *outFile = NULL;
11
+
12
+ if(!PyArg_ParseTuple(args, "sss", &inpFile, &rptFile, &outFile)) {
13
+ return NULL;
14
+ }
15
+
16
+ int err = MSXENopen(inpFile, rptFile, outFile);
17
+
18
+ return PyTuple_Pack(1, PyLong_FromLong(err));
19
+ }
20
+
21
+ PyObject* method_MSXopen(PyObject* self, PyObject* args)
22
+ {
23
+ char* fname = NULL;
24
+ if(!PyArg_ParseTuple(args, "s", &fname)) {
25
+ return NULL;
26
+ }
27
+
28
+ int err = MSXopen(fname);
29
+
30
+ return PyTuple_Pack(1, PyLong_FromLong(err));
31
+ }
32
+
33
+ PyObject* method_MSXsolveH(PyObject* self, PyObject* Py_UNUSED(args))
34
+ {
35
+ int err = MSXsolveH();
36
+
37
+ return PyTuple_Pack(1, PyLong_FromLong(err));
38
+ }
39
+
40
+ PyObject* method_MSXusehydfile(PyObject* self, PyObject* args)
41
+ {
42
+ char* fname = NULL;
43
+ if(!PyArg_ParseTuple(args, "s", &fname)) {
44
+ return NULL;
45
+ }
46
+
47
+ int err = MSXusehydfile(fname);
48
+
49
+ return PyTuple_Pack(1, PyLong_FromLong(err));
50
+ }
51
+
52
+ PyObject* method_MSXsolveQ(PyObject* self, PyObject* Py_UNUSED(args))
53
+ {
54
+ int err = MSXsolveQ();
55
+
56
+ return PyTuple_Pack(1, PyLong_FromLong(err));
57
+ }
58
+
59
+ PyObject* method_MSXinit(PyObject* self, PyObject* args)
60
+ {
61
+ int saveFlag;
62
+ if(!PyArg_ParseTuple(args, "i", &saveFlag)) {
63
+ return NULL;
64
+ }
65
+
66
+ int err = MSXinit(saveFlag);
67
+
68
+ return PyTuple_Pack(1, PyLong_FromLong(err));
69
+ }
70
+
71
+ PyObject* method_MSXstep(PyObject* self, PyObject* args)
72
+ {
73
+ double t, tleft;
74
+ int err = MSXstep(&t, &tleft);
75
+
76
+ return Py_BuildValue("(idd)", err, t, tleft);
77
+ }
78
+
79
+ PyObject* method_MSXsaveoutfile(PyObject* self, PyObject* args)
80
+ {
81
+ char* fname = NULL;
82
+ if(!PyArg_ParseTuple(args, "s", &fname)) {
83
+ return NULL;
84
+ }
85
+
86
+ int err = MSXsaveoutfile(fname);
87
+
88
+ return PyTuple_Pack(1, PyLong_FromLong(err));
89
+ }
90
+
91
+ PyObject* method_MSXsavemsxfile(PyObject* self, PyObject* args)
92
+ {
93
+ char* fname = NULL;
94
+ if(!PyArg_ParseTuple(args, "s", &fname)) {
95
+ return NULL;
96
+ }
97
+
98
+ int err = MSXsavemsxfile(fname);
99
+
100
+ return PyTuple_Pack(1, PyLong_FromLong(err));
101
+ }
102
+
103
+ PyObject* method_MSXreport(PyObject* self, PyObject* Py_UNUSED(args))
104
+ {
105
+ int err = MSXreport();
106
+
107
+ return PyTuple_Pack(1, PyLong_FromLong(err));
108
+ }
109
+
110
+ PyObject* method_MSXclose(PyObject* self, PyObject* Py_UNUSED(args))
111
+ {
112
+ int err = MSXclose();
113
+
114
+ return PyTuple_Pack(1, PyLong_FromLong(err));
115
+ }
116
+
117
+ PyObject* method_MSXENclose(PyObject* self, PyObject* Py_UNUSED(args))
118
+ {
119
+ int err = MSXENclose();
120
+
121
+ return PyTuple_Pack(1, PyLong_FromLong(err));
122
+ }
123
+
124
+ PyObject* method_MSXgetindex(PyObject* self, PyObject* args)
125
+ {
126
+ int type, index;
127
+ char* id = NULL;
128
+
129
+ if(!PyArg_ParseTuple(args, "is", &type, &id)) {
130
+ return NULL;
131
+ }
132
+
133
+ int err = MSXgetindex(type, id, &index);
134
+
135
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyLong_FromLong(index));
136
+ }
137
+
138
+ PyObject* method_MSXgetIDlen(PyObject* self, PyObject* args)
139
+ {
140
+ int type, index, len;
141
+ if(!PyArg_ParseTuple(args, "ii", &type, &index)) {
142
+ return NULL;
143
+ }
144
+
145
+ int err = MSXgetIDlen(type, index, &len);
146
+
147
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyLong_FromLong(len));
148
+ }
149
+
150
+ PyObject* method_MSXgetID(PyObject* self, PyObject* args)
151
+ {
152
+ int type, index;
153
+ if(!PyArg_ParseTuple(args, "ii", &type, &index)) {
154
+ return NULL;
155
+ }
156
+
157
+ char id[MAXID + 1]; // TODO: MSXgetIDlen
158
+ int err = MSXgetID(type, index, &id[0], MAXID);
159
+
160
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyUnicode_FromString(&id[0]));
161
+ }
162
+
163
+ PyObject* method_MSXgetcount(PyObject* self, PyObject* args)
164
+ {
165
+ int type, count;
166
+ if(!PyArg_ParseTuple(args, "i", &type)) {
167
+ return NULL;
168
+ }
169
+
170
+ int err = MSXgetcount(type, &count);
171
+
172
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyLong_FromLong(count));
173
+ }
174
+
175
+ PyObject* method_MSXgetspecies(PyObject* self, PyObject* args)
176
+ {
177
+ int index, type;
178
+ char units[MAXUNITS];
179
+ double aTol, rTol;
180
+
181
+ if(!PyArg_ParseTuple(args, "i", &index)) {
182
+ return NULL;
183
+ }
184
+
185
+ int err = MSXgetspecies(index, &type, &units[0], &aTol, &rTol);
186
+
187
+ return PyTuple_Pack(5, PyLong_FromLong(err), PyLong_FromLong(type), PyUnicode_FromString(&units[0]), PyFloat_FromDouble(aTol), PyFloat_FromDouble(rTol));
188
+ }
189
+
190
+ PyObject* method_MSXgetconstant(PyObject* self, PyObject* args)
191
+ {
192
+ int index;
193
+ if(!PyArg_ParseTuple(args, "i", &index)) {
194
+ return NULL;
195
+ }
196
+
197
+ double value;
198
+ int err = MSXgetconstant(index, &value);
199
+
200
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyFloat_FromDouble(value));
201
+ }
202
+
203
+ PyObject* method_MSXgetparameter(PyObject* self, PyObject* args)
204
+ {
205
+ int type, index, param;
206
+ if(!PyArg_ParseTuple(args, "iii", &type, &index, &param)) {
207
+ return NULL;
208
+ }
209
+
210
+ double value;
211
+ int err = MSXgetparameter(type, index, param, &value);
212
+
213
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyFloat_FromDouble(value));
214
+ }
215
+
216
+ PyObject* method_MSXgetsource(PyObject* self, PyObject* args)
217
+ {
218
+ int node, species;
219
+ if(!PyArg_ParseTuple(args, "ii", &node, &species)) {
220
+ return NULL;
221
+ }
222
+
223
+ int type, pat;
224
+ double level;
225
+ int err = MSXgetsource(node, species, &type, &level, &pat);
226
+
227
+ return PyTuple_Pack(4, PyLong_FromLong(err), PyLong_FromLong(type), PyFloat_FromDouble(level), PyLong_FromLong(pat));
228
+ }
229
+
230
+ PyObject* method_MSXgetpatternlen(PyObject* self, PyObject* args)
231
+ {
232
+ int pat, len;
233
+ if(!PyArg_ParseTuple(args, "i", &pat)) {
234
+ return NULL;
235
+ }
236
+
237
+ int err = MSXgetpatternlen(pat, &len);
238
+
239
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyLong_FromLong(len));
240
+ }
241
+
242
+ PyObject* method_MSXgetpatternvalue(PyObject* self, PyObject* args)
243
+ {
244
+ int pat, period;
245
+ if(!PyArg_ParseTuple(args, "ii", &pat, &period)) {
246
+ return NULL;
247
+ }
248
+
249
+ double value;
250
+ int err = MSXgetpatternvalue(pat, period, &value);
251
+
252
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyFloat_FromDouble(value));
253
+ }
254
+
255
+ PyObject* method_MSXgetinitqual(PyObject* self, PyObject* args)
256
+ {
257
+ int type, index, species;
258
+ if(!PyArg_ParseTuple(args, "iii", &type, &index, &species)) {
259
+ return NULL;
260
+ }
261
+
262
+ double value;
263
+ int err = MSXgetinitqual(type, index, species, &value);
264
+
265
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyFloat_FromDouble(value));
266
+ }
267
+
268
+ PyObject* method_MSXgetqual(PyObject* self, PyObject* args)
269
+ {
270
+ int type, index, species;
271
+ if(!PyArg_ParseTuple(args, "iii", &type, &index, &species)) {
272
+ return NULL;
273
+ }
274
+
275
+ double value;
276
+ int err = MSXgetqual(type, index, species, &value);
277
+
278
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyFloat_FromDouble(value));
279
+ }
280
+
281
+ PyObject* method_MSXgeterror(PyObject* self, PyObject* args)
282
+ {
283
+ int code;
284
+ if(!PyArg_ParseTuple(args, "i", &code)) {
285
+ return NULL;
286
+ }
287
+
288
+ char msg[MAXLINE + 1];
289
+ int err = MSXgeterror(code, &msg[0], MAXLINE);
290
+
291
+ return PyTuple_Pack(2, PyLong_FromLong(err), PyUnicode_FromString(&msg[0]));
292
+ }
293
+
294
+ PyObject* method_MSXsetconstant(PyObject* self, PyObject* args)
295
+ {
296
+ int index;
297
+ double value;
298
+ if(!PyArg_ParseTuple(args, "id", &index, &value)) {
299
+ return NULL;
300
+ }
301
+
302
+ int err = MSXsetconstant(index, value);
303
+
304
+ return PyTuple_Pack(1, PyLong_FromLong(err));
305
+ }
306
+
307
+ PyObject* method_MSXsetparameter(PyObject* self, PyObject* args)
308
+ {
309
+ int type, index, param;
310
+ double value;
311
+ if(!PyArg_ParseTuple(args, "iiid", &type, &index, &param, &value)) {
312
+ return NULL;
313
+ }
314
+
315
+ int err = MSXsetparameter(type, index, param, value);
316
+
317
+ return PyTuple_Pack(1, PyLong_FromLong(err));
318
+ }
319
+
320
+ PyObject* method_MSXsetinitqual(PyObject* self, PyObject* args)
321
+ {
322
+ int type, index, species;
323
+ double value;
324
+ if(!PyArg_ParseTuple(args, "iiid", &type, &index, &species, &value)) {
325
+ return NULL;
326
+ }
327
+
328
+ int err = MSXsetinitqual(type, index, species, value);
329
+
330
+ return PyTuple_Pack(1, PyLong_FromLong(err));
331
+ }
332
+
333
+ PyObject* method_MSXsetsource(PyObject* self, PyObject* args)
334
+ {
335
+ int node, species, type, pat;
336
+ double level;
337
+ if(!PyArg_ParseTuple(args, "iiidi", &node, &species, &type, &level, &pat)) {
338
+ return NULL;
339
+ }
340
+
341
+ int err = MSXsetsource(node, species, type, level, pat);
342
+
343
+ return PyTuple_Pack(1, PyLong_FromLong(err));
344
+ }
345
+
346
+ PyObject* method_MSXsetpatternvalue(PyObject* self, PyObject* args)
347
+ {
348
+ int pat, period;
349
+ double value;
350
+ if(!PyArg_ParseTuple(args, "iid", &pat, &period, &value)) {
351
+ return NULL;
352
+ }
353
+
354
+ int err = MSXsetpatternvalue(pat, period, value);
355
+
356
+ return PyTuple_Pack(1, PyLong_FromLong(err));
357
+ }
358
+
359
+ PyObject* method_MSXsetpattern(PyObject* self, PyObject* args)
360
+ {
361
+ int pat, len;
362
+ PyListObject* mult = NULL;
363
+ if(!PyArg_ParseTuple(args, "iOi", &pat, &mult, &len)) {
364
+ return NULL;
365
+ }
366
+
367
+ double* multRaw = (double*) malloc(sizeof(double) * len);
368
+ for(int i=0; i != len; i++) {
369
+ multRaw[i] = PyFloat_AsDouble(PyList_GET_ITEM(mult, i));
370
+ }
371
+
372
+ int err = MSXsetpattern(pat, multRaw, len);
373
+ free(multRaw);
374
+
375
+ return PyTuple_Pack(1, PyLong_FromLong(err));
376
+ }
377
+
378
+ PyObject* method_MSXaddpattern(PyObject* self, PyObject* args)
379
+ {
380
+ char* id = NULL;
381
+ if(!PyArg_ParseTuple(args, "s", &id)) {
382
+ return NULL;
383
+ }
384
+
385
+ int err = MSXaddpattern(id);
386
+
387
+ return PyTuple_Pack(1, PyLong_FromLong(err));
388
+ }
@@ -0,0 +1,35 @@
1
+ #include <Python.h>
2
+
3
+
4
+ PyObject* method_MSXENopen(PyObject* self, PyObject* args);
5
+ PyObject* method_MSXopen(PyObject* self, PyObject* args);
6
+ PyObject* method_MSXsolveH(PyObject* self, PyObject* Py_UNUSED(args));
7
+ PyObject* method_MSXusehydfile(PyObject* self, PyObject* args);
8
+ PyObject* method_MSXsolveQ(PyObject* self, PyObject* Py_UNUSED(args));
9
+ PyObject* method_MSXinit(PyObject* self, PyObject* args);
10
+ PyObject* method_MSXstep(PyObject* self, PyObject* args);
11
+ PyObject* method_MSXsaveoutfile(PyObject* self, PyObject* args);
12
+ PyObject* method_MSXsavemsxfile(PyObject* self, PyObject* args);
13
+ PyObject* method_MSXreport(PyObject* self, PyObject* Py_UNUSED(args));
14
+ PyObject* method_MSXclose(PyObject* self, PyObject* Py_UNUSED(args));
15
+ PyObject* method_MSXENclose(PyObject* self, PyObject* Py_UNUSED(args));
16
+ PyObject* method_MSXgetindex(PyObject* self, PyObject* args);
17
+ PyObject* method_MSXgetIDlen(PyObject* self, PyObject* args);
18
+ PyObject* method_MSXgetID(PyObject* self, PyObject* args);
19
+ PyObject* method_MSXgetcount(PyObject* self, PyObject* args);
20
+ PyObject* method_MSXgetspecies(PyObject* self, PyObject* args);
21
+ PyObject* method_MSXgetconstant(PyObject* self, PyObject* args);
22
+ PyObject* method_MSXgetparameter(PyObject* self, PyObject* args);
23
+ PyObject* method_MSXgetsource(PyObject* self, PyObject* args);
24
+ PyObject* method_MSXgetpatternlen(PyObject* self, PyObject* args);
25
+ PyObject* method_MSXgetpatternvalue(PyObject* self, PyObject* args);
26
+ PyObject* method_MSXgetinitqual(PyObject* self, PyObject* args);
27
+ PyObject* method_MSXgetqual(PyObject* self, PyObject* args);
28
+ PyObject* method_MSXgeterror(PyObject* self, PyObject* args);
29
+ PyObject* method_MSXsetconstant(PyObject* self, PyObject* args);
30
+ PyObject* method_MSXsetparameter(PyObject* self, PyObject* args);
31
+ PyObject* method_MSXsetinitqual(PyObject* self, PyObject* args);
32
+ PyObject* method_MSXsetsource(PyObject* self, PyObject* args);
33
+ PyObject* method_MSXsetpatternvalue(PyObject* self, PyObject* args);
34
+ PyObject* method_MSXsetpattern(PyObject* self, PyObject* args);
35
+ PyObject* method_MSXaddpattern(PyObject* self, PyObject* args);
tests/test_epanet.py ADDED
@@ -0,0 +1,16 @@
1
+ """
2
+ This module tests the EPANET functions.
3
+ """
4
+ from epanet_plus import EpanetAPI, EpanetConstants
5
+
6
+
7
+ def test():
8
+ epanet_api = EpanetAPI()
9
+ epanet_api.open("net2-cl2.inp", "net2-cl2.rpt", "")
10
+
11
+ assert epanet_api.gettitle() is not None
12
+ assert epanet_api.getcount(EpanetConstants.EN_NODECOUNT) > 0
13
+ assert epanet_api.getcount(EpanetConstants.EN_LINKCOUNT) > 0
14
+ assert epanet_api.getcount(EpanetConstants.EN_TANKCOUNT) > 0
15
+
16
+ epanet_api.close()
@@ -0,0 +1,36 @@
1
+ """
2
+ This module tests EPANET-MSX functions.
3
+ """
4
+ from epanet_plus import EPyT, EpanetAPI, EpanetConstants
5
+
6
+
7
+ def test_msx_basic():
8
+ epanet_api = EpanetAPI()
9
+ epanet_api.MSXENopen("net2-cl2.inp", "net2-cl2.rpt", "")
10
+ epanet_api.MSXopen("net2-cl2.msx")
11
+
12
+ epanet_api.gettitle()
13
+ epanet_api.MSXgetspecies(1)
14
+ epanet_api.MSXgetID(3, 1)
15
+
16
+ epanet_api.MSXclose()
17
+ epanet_api.MSXENclose()
18
+
19
+
20
+ def test_simulation():
21
+ with EPyT("net2-cl2.inp", use_project=False) as epanet_api:
22
+ epanet_api.load_msx_file("net2-cl2.msx")
23
+
24
+ epanet_api.MSXsolveH()
25
+
26
+ epanet_api.MSXinit(0)
27
+ while True:
28
+ _, tleft = epanet_api.MSXstep()
29
+
30
+ for idx in epanet_api.get_all_nodes_idx():
31
+ assert epanet_api.MSXgetqual(EpanetConstants.MSX_NODE, idx, 1) >= 0
32
+ for idx in epanet_api.get_all_pipes_idx():
33
+ assert epanet_api.MSXgetqual(EpanetConstants.MSX_LINK, idx, 1) >= 0
34
+
35
+ if tleft == 0:
36
+ break