openswmm 5.3.0.dev0__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.
@@ -0,0 +1,356 @@
1
+ # Description: Cython module for openswmmcore solver
2
+ # Created by: Caleb Buahin (EPA/ORD/CESER/WID)
3
+ # Created on: 2024-11-19
4
+
5
+ # cython: language_level=3
6
+
7
+ # cython imports
8
+ from cpython.datetime cimport datetime as cython_datetime
9
+
10
+ # third-party imports
11
+
12
+ # project imports
13
+
14
+ # Define the number of days since 01/01/00
15
+ cpdef double encode_swmm_datetime(cython_datetime pdatetime)
16
+
17
+ # Define the number of days since 01/01/00
18
+ cpdef cython_datetime decode_swmm_datetime(double swmm_datetime)
19
+
20
+ cdef extern from "Python.h":
21
+ object PyObject_CallObject(object, object)
22
+
23
+ cdef extern from "time.h":
24
+ ctypedef long clock_t
25
+ clock_t clock()
26
+
27
+ cdef extern from "openswmm_solver.h":
28
+ # SWMM object type enumeration
29
+ ctypedef enum swmm_Object:
30
+ swmm_GAGE # Rain gage
31
+ swmm_SUBCATCH # Subcatchment
32
+ swmm_NODE # Junction
33
+ swmm_LINK # Conduit
34
+ swmm_AQUIFER # Aquifers
35
+ swmm_SNOWPACK # Snowpack
36
+ swmm_UNIT_HYDROGRAPH # Unit hydrographs
37
+ swmm_LID # Low impact development
38
+ swmm_STREET # Streets
39
+ swmm_INLET # Inlets
40
+ swmm_TRANSECT # Transects
41
+ smmm_XSECTION_SHAPE # Cross-section shape
42
+ swmm_CONTROL_RULE # Control rules
43
+ swmm_POLLUTANT # Pollutants
44
+ swmm_LANDUSE # Land uses
45
+ swmm_CURVE # Curve
46
+ swmm_TIMESERIES # Time series
47
+ swmm_TIME_PATTERN # Time pattern
48
+ swmm_SYSTEM # General
49
+
50
+ # SWMM node type enumeration
51
+ ctypedef enum swmm_NodeType:
52
+ swmm_JUNCTION # Junction node
53
+ swmm_OUTFALL # Outfall node
54
+ swmm_STORAGE # Storage node
55
+ swmm_DIVIDER # Divider node
56
+
57
+ # SWMM link type enumeration
58
+ ctypedef enum swmm_LinkType:
59
+ swmm_CONDUIT # Conduit link
60
+ swmm_PUMP # Pump link
61
+ swmm_ORIFICE # Orifice link
62
+ swmm_WEIR # Weir link
63
+ swmm_OUTLET # Outlet link
64
+
65
+ # SWMM Rain Gage properties
66
+ ctypedef enum swmm_GageProperty:
67
+ swmm_GAGE_TOTAL_PRECIPITATION # Total precipitation
68
+ swmm_GAGE_RAINFALL # Snow depth
69
+ swmm_GAGE_SNOWFALL # Snowfall
70
+
71
+ # SWMM Subcatchment properties
72
+ ctypedef enum swmm_SubcatchProperty:
73
+ swmm_SUBCATCH_AREA # Area
74
+ swmm_SUBCATCH_RAINGAGE # Rain gage
75
+ swmm_SUBCATCH_RAINFALL # Rainfall
76
+ swmm_SUBCATCH_EVAP # Evaporation
77
+ swmm_SUBCATCH_INFIL # Infiltration
78
+ swmm_SUBCATCH_RUNOFF # Runoff
79
+ swmm_SUBCATCH_RPTFLAG # Reporting flag
80
+ swmm_SUBCATCH_WIDTH # Width
81
+ swmm_SUBCATCH_SLOPE # Slope
82
+ swmm_SUBCATCH_CURB_LENGTH # Curb length
83
+ swmm_SUBCATCH_API_RAINFALL # API rainfall
84
+ swmm_SUBCATCH_API_SNOWFALL # API snowfall
85
+ swmm_SUBCATCH_POLLUTANT_BUILDUP # Pollutant buildup
86
+ swmm_SUBCATCH_EXTERNAL_POLLUTANT_BUILDUP # External pollutant buildup
87
+ swmm_SUBCATCH_POLLUTANT_RUNOFF_CONCENTRATION # Pollutant ponded concentration
88
+ swmm_SUBCATCH_POLLUTANT_PONDED_CONCENTRATION # Pollutant runoff concentration
89
+ swmm_SUBCATCH_POLLUTANT_TOTAL_LOAD # Pollutant total load
90
+
91
+ # SWMM Node properties
92
+ ctypedef enum swmm_NodeProperty:
93
+ swmm_NODE_TYPE # Node type
94
+ swmm_NODE_ELEV # Elevation
95
+ swmm_NODE_MAXDEPTH # Max. depth
96
+ swmm_NODE_DEPTH # Depth
97
+ swmm_NODE_HEAD # Hydraulic head
98
+ swmm_NODE_VOLUME # Volume
99
+ swmm_NODE_LATFLOW # Lateral inflow
100
+ swmm_NODE_INFLOW # Total inflow
101
+ swmm_NODE_OVERFLOW # Flooding
102
+ swmm_NODE_RPTFLAG # Reporting flag
103
+ swmm_NODE_SURCHARGE_DEPTH # Surcharge depth
104
+ swmm_NODE_PONDED_AREA # Ponded area
105
+ swmm_NODE_INITIAL_DEPTH # Initial depth
106
+ swmm_NODE_POLLUTANT_CONCENTRATION # Pollutant concentration
107
+ swmm_NODE_POLLUTANT_LATMASS_FLUX # Pollutant lateral mass flux
108
+
109
+ # SWMM Link properties
110
+ ctypedef enum swmm_LinkProperty:
111
+ swmm_LINK_TYPE # Link type
112
+ swmm_LINK_NODE1 # Start node
113
+ swmm_LINK_NODE2 # End node
114
+ swmm_LINK_LENGTH # Length
115
+ swmm_LINK_SLOPE # Slope
116
+ swmm_LINK_FULLDEPTH # Full depth
117
+ swmm_LINK_FULLFLOW # Full flow
118
+ swmm_LINK_SETTING # Setting
119
+ swmm_LINK_TIMEOPEN # Time open
120
+ swmm_LINK_TIMECLOSED # Time closed
121
+ swmm_LINK_FLOW # Flow
122
+ swmm_LINK_DEPTH # Depth
123
+ swmm_LINK_VELOCITY # Velocity
124
+ swmm_LINK_TOPWIDTH # Top width
125
+ swmm_LINK_VOLUME # Volume
126
+ swmm_LINK_CAPACITY # Capacity
127
+ swmm_LINK_RPTFLAG # Reporting flag
128
+ swmm_LINK_OFFSET1 # Inlet offset
129
+ swmm_LINK_OFFSET2 # Outlet offset
130
+ swmm_LINK_INITIAL_FLOW # Initial flow
131
+ swmm_LINK_FLOW_LIMIT # Flow limit
132
+ swmm_LINK_INLET_LOSS # Inlet loss
133
+ swmm_LINK_OUTLET_LOSS # Outlet loss
134
+ swmm_LINK_AVERAGE_LOSS # Average depth
135
+ swmm_LINK_SEEPAGE_RATE # Seepage rate
136
+ swmm_LINK_HAS_FLAPGATE # Flap gate
137
+ swmm_LINK_POLLUTANT_CONCENTRATION # Pollutant concentration
138
+ swmm_LINK_POLLUTANT_LOAD # Pollutant load
139
+ swmm_LINK_POLLUTANT_LATMASS_FLUX # Pollutant lateral mass flux
140
+
141
+ # SWMM System properties
142
+ ctypedef enum swmm_SystemProperty:
143
+ swmm_STARTDATE # The start date of the simulation.
144
+ swmm_CURRENTDATE # The current date in the simulation.
145
+ swmm_ELAPSEDTIME # The elapsed time since the start of the simulation.
146
+ swmm_ROUTESTEP # The routing step size.
147
+ swmm_MAXROUTESTEP # The maximum routing step size.
148
+ swmm_REPORTSTEP # The reporting step size.
149
+ swmm_TOTALSTEPS # The total number of steps in the simulation.
150
+ swmm_NOREPORT # Flag indicating whether reporting is disabled.
151
+ swmm_FLOWUNITS # The flow units used in the simulation.
152
+ swmm_ENDDATE # The end date of the simulation.
153
+ swmm_REPORTSTART # The start date of the reporting period.
154
+ swmm_UNITSYSTEM # The unit system used in the simulation.
155
+ swmm_SURCHARGEMETHOD # The surcharge method used in the simulation.
156
+ swmm_ALLOWPONDING # Flag indicating whether ponding is allowed.
157
+ swmm_INERTIADAMPING # The inertia damping factor used in the simulation.
158
+ swmm_NORMALFLOWLTD # The normal flow limited flag.
159
+ swmm_SKIPSTEADYSTATE # Flag indicating whether steady state periods are skipped.
160
+ swmm_IGNORERAINFALL # Flag indicating whether rainfall is ignored.
161
+ swmm_IGNORERDII # Flag indicating whether RDII is ignored.
162
+ swmm_IGNORESNOWMELT # Flag indicating whether snowmelt is ignored.
163
+ swmm_IGNOREGROUNDWATER # Flag indicating whether groundwater is ignored.
164
+ swmm_IGNOREROUTING # Flag indicating whether routing is ignored.
165
+ swmm_IGNOREQUALITY # Flag indicating whether water quality is ignored.
166
+ swmm_ERROR_CODE # The error code.
167
+ swmm_RULESTEP # The rule step size.
168
+ swmm_SWEEPSTART # The start date of the sweep start.
169
+ swmm_SWEEPEND # The end date of the sweep end.
170
+ swmm_MAXTRIALS # The maximum number of trials.
171
+ swmm_NUMTHREADS # The number of threads used in the simulation.
172
+ swmm_MINROUTESTEP # The minimum routing step size.
173
+ swmm_LENGTHENINGSTEP # The lengthening step size.
174
+ swmm_STARTDRYDAYS # The number of start dry days.
175
+ swmm_COURANTFACTOR # The Courant factor.
176
+ swmm_MINSURFAREA # The minimum surface area.
177
+ swmm_MINSLOPE # The minimum slope.
178
+ swmm_RUNOFFERROR # The runoff error.
179
+ swmm_FLOWERROR # The flow error.
180
+ swmm_QUALERROR # The quality error.
181
+ swmm_HEADTOL # The head tolerance.
182
+ swmm_SYSFLOWTOL # The system flow tolerance.
183
+ swmm_LATFLOWTOL # The lateral flow tolerance.
184
+
185
+ # SWMM flow units enumeration
186
+ ctypedef enum swmm_FlowUnitsProperty:
187
+ swmm_CFS # Cubic feet per second
188
+ swmm_GPM # Gallons per minute
189
+ swmm_MGD # Million gallons per day
190
+ swmm_CMS # Cubic meters per second
191
+ swmm_LPS # Liters per second
192
+ swmm_MLD # Million liters per day
193
+
194
+ # SWMM API function return error codes
195
+ ctypedef enum swmm_API_Errors:
196
+ ERR_API_NOT_OPEN # API not open
197
+ ERR_API_NOT_STARTED # API not started
198
+ ERR_API_NOT_ENDED # API not ended
199
+ ERR_API_OBJECT_TYPE # Invalid object type
200
+ ERR_API_OBJECT_INDEX # Invalid object index
201
+ ERR_API_OBJECT_NAME # Invalid object name
202
+ ERR_API_PROPERTY_TYPE # Invalid property type
203
+ ERR_API_PROPERTY_VALUE # Invalid property value
204
+ ERR_API_TIME_PERIOD # Invalid time period
205
+ ERR_API_HOTSTART_FILE_OPEN # Error opening hotstart file
206
+ ERR_API_HOTSTART_FILE_FORMAT # Invalid hotstart file format
207
+ ERR_API_IS_RUNNING # Simulation is already running
208
+
209
+ # SWMM API function return simulation progress
210
+ ctypedef void (*progress_callback)(double progress);
211
+
212
+ # SWMM API function prototypes
213
+ # param: inp_file: input file name
214
+ # param: rpt_file: report file name
215
+ # param: out_file: output file name
216
+ # Returns: error code (0 if successful)
217
+ cdef int swmm_run(char* inp_file, char* rpt_file, char* out_file)
218
+
219
+
220
+ # SWMM API function prototypes
221
+ # param: inp_file: input file name
222
+ # param: rpt_file: report file name
223
+ # param: out_file: output file name
224
+ # param: progress: progress callback
225
+ # Returns: error code (0 if successful)
226
+ cdef int swmm_run_with_callback(char* inp_file, char* rpt_file, char* out_file, progress_callback progress)
227
+
228
+ # Open a SWMM input file
229
+ # param: inp_file: input file name
230
+ # param: rpt_file: report file name
231
+ # parm: out_file: output file name
232
+ # Returns: error code (0 if successful)
233
+ cdef int swmm_open(char* inp_file, char* rpt_file, char* out_file)
234
+
235
+ # Starts a SWMM simulation
236
+ # param: save_flag = TRUE if simulation results saved to binary file
237
+ # Returns: error code
238
+ cdef int swmm_start(int save_flag)
239
+
240
+ # Performs a single time step of a SWMM simulation
241
+ # param: elapsed_time: elapsed time in seconds
242
+ # Returns: error code
243
+ cdef int swmm_step(double* elapsed_time)
244
+
245
+ # Performs a single stride of a SWMM simulation
246
+ # param: strideStep: number of steps to perform
247
+ # param: elapsedTime: elapsed time in seconds
248
+ # Returns: error code
249
+ cdef int swmm_stride(int strideStep, double *elapsedTime)
250
+
251
+ # Uses provide hot start file to initialize the simulation
252
+ # param: hotStartFile: hot start file name
253
+ # Returns: error code
254
+ cdef int swmm_useHotStart(const char* hotStartFile)
255
+
256
+ # Saves the current simulation state to a hot start file
257
+ # param: hotStartFile: hot start file name
258
+ # Returns: error code
259
+ cdef int swmm_saveHotStart(const char* hotStartFile)
260
+
261
+ # Ends a SWMM simulation
262
+ # Returns: error code
263
+ cdef int swmm_end()
264
+
265
+ # Writes a report to the report file
266
+ # Returns: error code
267
+ cdef int swmm_report()
268
+
269
+ # Closes a SWMM simulation
270
+ # Returns: error code
271
+ cdef int swmm_close()
272
+
273
+ # Retrieves the mass balance errors
274
+ # param: runoffErr: runoff error
275
+ # param: flowErr: flow error
276
+ # param: qualErr: quality error
277
+ cdef int swmm_getMassBalErr(float *runoffErr, float *flowErr, float *qualErr)
278
+
279
+ # Gets the version of the SWMM engine
280
+ # Returns: version number
281
+ cdef int swmm_getVersion()
282
+
283
+ # Retrieves the error message from the SWMM engine
284
+ # param: errMsg: error message
285
+ # param: msgLen: length of the error message
286
+ # Returns: error code
287
+ cdef int swmm_getError(char *errMsg, int msgLen)
288
+
289
+ # Retrieves the error message from the SWMM engine
290
+ # param: error_code: error code
291
+ # param: outErrMsg: error message
292
+ # Returns: error code
293
+ cdef int swmm_getErrorFromCode(int error_code, char *outErrMsg[1024])
294
+
295
+ # Retrieves the number of warnings from the SWMM engine
296
+ cdef int swmm_getWarnings()
297
+
298
+ # Retrieves the number of objects of a given type
299
+ # param: objType: object type
300
+ cdef int swmm_getCount(int objType)
301
+
302
+ # Retrieves the name of an object of a given type and index
303
+ # param: objType: object type
304
+ # param: index: object index
305
+ # param: name: object name
306
+ # param: size: size of the object name
307
+ cdef int swmm_getName(int objType, int index, char *name, int size)
308
+
309
+ # Retrieves the index of an object of a given type and name
310
+ # param: objType: object type
311
+ # param: name: object name
312
+ cdef int swmm_getIndex(int objType, const char *name)
313
+
314
+ # Retrieves the value of a property for an object of a given type and index
315
+ # param: property: property type
316
+ # param: index: object index
317
+ cdef double swmm_getValue(int property, int index)
318
+
319
+
320
+
321
+ # Retrieves the value of a property for an object of a given type and index
322
+ # param: objType: object type
323
+ # param: property: property type
324
+ # param: index: object index
325
+ # param: subIndex: sub-index
326
+ # param: pollutantIndex: pollutant index
327
+ cdef double swmm_getValueExpanded(int objType, int property, int index, int subIndex, int pollutantIndex)
328
+
329
+ # Sets the value of a property for an object of a given type and index
330
+ # param: property: property type
331
+ # param: index: object index
332
+ # param: value: property value
333
+ cdef int swmm_setValue(int property, int index, double value)
334
+
335
+ # Sets the value of a property for an object of a given type and index
336
+ # param: objType: object type
337
+ # param: property: property type
338
+ # param: index: object index
339
+ # param: value: property value
340
+ cdef int swmm_setValueExpanded(int objType, int property, int index, int subindex, int pollutantIndex, double value)
341
+
342
+ # Retrieves the value of a property for an object of a given type and index
343
+ # param: property: property type
344
+ # param: index: object index
345
+ # param: period: time period
346
+ cdef double swmm_getSavedValue(int property, int index, int period)
347
+
348
+ # Writes a line to the SWMM report file
349
+ # param: line: line to write
350
+ cdef void swmm_writeLine(const char *line)
351
+
352
+ # Decodes a SWMM datetime into a datetime object
353
+ cdef void swmm_decodeDate(double date, int *year, int *month, int *day, int *hour, int *minute, int *second, int *dayOfWeek)
354
+
355
+ # Encodes a datetime object into a SWMM datetime
356
+ cdef double swmm_encodeDate(int year, int month, int day, int hour, int minute, int second)
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: openswmm
3
+ Version: 5.3.0.dev0
4
+ Summary: A python package for EPA SWMM preprocessing, solver, and post-processing.
5
+ Author-email: Caleb Buahin <caleb.buahin@gmail.com>
6
+ Maintainer-email: Caleb Buahin <caleb.buahin@gmail.com>
7
+ License: Copyright 2026 HydroCouple
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+
15
+ This project contains original material has been released as part of various USEPA SWMM software over the years. These reside in the
16
+ public domain and cannot be claimed. This project also contains new material prepared by the United States
17
+ Government for which domestic copyright protection is not available under 17
18
+ USC § 105.
19
+ Project-URL: Homepage, https://github.com/HydroCouple/Stormwater-Management-Model
20
+ Project-URL: Documentation, https://github.com/HydroCouple/Stormwater-Management-Model
21
+ Project-URL: Source Code, https://github.com/HydroCouple/Stormwater-Management-Model
22
+ Project-URL: Bug Tracker, https://github.com/HydroCouple/Stormwater-Management-Model/issues
23
+ Project-URL: Repository, https://github.com/HydroCouple/Stormwater-Management-Model
24
+ Project-URL: Changelog, https://github.com/HydroCouple/Stormwater-Management-Model/blob/master/CHANGELOG.md
25
+ Keywords: SWMM,storm water,modeling,water,hydrology,hydraulics,wastewater,machine learning,AI,GIS,environmental engineering,civil engineering
26
+ Classifier: Development Status :: 3 - Alpha
27
+ Classifier: Intended Audience :: Developers
28
+ Classifier: Intended Audience :: Science/Research
29
+ Classifier: Operating System :: OS Independent
30
+ Classifier: Programming Language :: Python :: 3.8
31
+ Classifier: Programming Language :: Python :: 3.9
32
+ Classifier: Programming Language :: Python :: 3.10
33
+ Classifier: Programming Language :: Python :: 3.11
34
+ Classifier: Programming Language :: Python :: 3.12
35
+ Classifier: Programming Language :: Python :: 3.13
36
+ Classifier: Programming Language :: C
37
+ Classifier: Programming Language :: C++
38
+ Classifier: Topic :: Scientific/Engineering
39
+ Classifier: Topic :: Scientific/Engineering :: Hydrology
40
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
41
+ Classifier: Topic :: Scientific/Engineering :: Physics
42
+ Classifier: Topic :: Software Development :: Libraries
43
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
44
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
45
+ Classifier: Topic :: Scientific/Engineering :: GIS
46
+ Requires-Python: >=3.8
47
+ Description-Content-Type: text/markdown
48
+ License-File: LICENSE
49
+ Dynamic: description
50
+ Dynamic: description-content-type
51
+ Dynamic: license-file
52
+
53
+ EPA ORD Stormwater Management Model (SWMM)
54
+ ==========================================
55
+
56
+ Stormwater Management Model (SWMM) computational engine and output post-processing codebase
57
+
58
+ ## Build Status
59
+ [![Build and Unit Testing](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/unit_testing.yml/badge.svg)](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/unit_testing.yml)
60
+ [![Build and Regression Testing](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/regression_testing.yml/badge.svg)](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/regression_testing.yml)
61
+ [![Docs](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/build_docs.yml/badge.svg)](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/build_docs.yml)
62
+ [![Deployment](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/deploy.yml/badge.svg)](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/deploy.yml)
63
+ [![Documentation](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/build-and-test.yml/badge.svg?branch=docs)](https://github.com/HydroCouple/Stormwater-Management-Model/actions/workflows/build-and-test.yml)
64
+ [![Issues](https://img.shields.io/github/issues/HydroCouple/Stormwater-Management-Model)](https://github.com/HydroCouple/Stormwater-Management-Model/issues)
65
+
66
+ ## Python Binding
67
+ [![PyPi](https://img.shields.io/pypi/v/openswmm.svg)](https://pypi.org/project/openswmm)
68
+ [![PythonVersion](https://img.shields.io/pypi/pyversions/openswmm.svg)](https://pypi.org/project/openswmm)
69
+ [![Wheel](https://img.shields.io/pypi/wheel/openswmm.svg)](https://pypi.org/project/openswmm)
70
+ [![Downloads](https://pepy.tech/badge/openswmm)](https://pepy.tech/project/openswmm)
71
+ [![Downloads](https://pepy.tech/badge/openswmm/month)](https://pepy.tech/project/openswmm)
72
+ [![Downloads](https://pepy.tech/badge/openswmm/week)](https://pepy.tech/project/openswmm)
73
+
74
+ ## Introduction
75
+ This is the official SWMM source code repository maintained by US EPA Office of Research and Development, Center For Environmental Solutions & Emergency Response, Water Infrastructure Division located in Cincinnati, Ohio.
76
+
77
+ SWMM is a dynamic hydrology-hydraulic water quality simulation model. It is used for single event or long-term (continuous) simulation of runoff quantity and quality from primarily urban areas. SWMM source code is written in the C Programming Language and released in the Public Domain.
78
+
79
+ ## Build Instructions
80
+
81
+ The 'src' folder of this repository contains the C source code for
82
+ version of Storm Water Management Model's computational
83
+ engine. Consult the included 'Roadmap.txt' file for an overview of
84
+ the various code modules. The code can be compiled into both a shared
85
+ object library and a command line executable. Under Windows, the
86
+ library file (swmm5.dll) is used to power SWMM's graphical user
87
+ interface.
88
+
89
+ Also included is a python interface for the SWMM computational engine and output
90
+ post-processing application programming interfaces located in the python folder.
91
+
92
+ The 'CMakeLists.txt' file is a script used by CMake (https://cmake.org/)
93
+ to build the SWMM binaries. CMake is a cross-platform build tool
94
+ that generates platform native build systems for many compilers. To
95
+ check if the required version is installed on your system, enter from
96
+ a console window and check that the version is 3.5 or higher.
97
+
98
+ ```bash
99
+ cmake --version
100
+ ```
101
+
102
+ To build the SWMM engine library and its command line executable
103
+ using CMake and the Microsoft Visual Studio C compiler on Windows:
104
+
105
+ 1. Open a console window and navigate to the directory where this
106
+ Readme file resides (which should have 'src' as a sub-directory
107
+ underneath it).
108
+
109
+ 2. Use the following command to create the directory for storing the built binaries:
110
+
111
+ ```bash
112
+ mkdir build
113
+ ```
114
+
115
+ 3. Then the following CMake commands to build the binaries:
116
+
117
+ ``` bash
118
+ cmake -G <compiler> -B build
119
+ cmake --build ./build --config Release
120
+ ```
121
+
122
+ where `<compiler>` is the name of the compiler being used
123
+ in double quotes (e.g., "Visual Studio 17 2022" for windows, "Ninja" for linux, or "Xcode" for macos). The resulting engine shared libraries (i.e., swmm5.dll), command line executable (i.e., runswmm.exe), and output processing libraries (i.e., swmm-output.dll)
124
+ will appear in the build\Release directory.
125
+
126
+ ### Python Bindings (Experimental)
127
+
128
+ Experimental python bindings for the SWMM API are being developed to support regression and benchmark testing as well as for other applications. _**These bindings are still under development and testing and has yet to be cleared through US EPA ORD's official quality assurance review process**_. The exprimental python bindings can be built and installed locally using the following command.
129
+
130
+ ```bash
131
+ cd python
132
+ python -m pip install -r requirements.txt
133
+ python -m pip install .
134
+ ```
135
+ Users may also build python wheels for installation or distribution. Once the python bindings
136
+ have been validated and cleared through EPA's quality assuracnce clearance process, they will be available for installation via package indexing repositories such as pypi.
137
+
138
+ Example usage of python bindings can be found below. More extensive documentation will be provided once cleared.
139
+
140
+ ```python
141
+
142
+ from openswmmcore import solver
143
+ from openswmmcore.solver import Solver
144
+ from openswmmcore.output import Output
145
+
146
+ # Alternative 1 to run SWMM
147
+
148
+ with Solver(inp_file="input_file.inp") as swmm_solver:
149
+
150
+ # Open swmm file and starts the simulation
151
+ swmm_solver.start()
152
+
153
+ # Set initialization parameters e.g., time step stride, start date, end date etc.
154
+ swmm_solver.time_stride = 600
155
+
156
+ for elapsed_time, current_datetime in swmm_solver:
157
+
158
+ # Get and set attributes per timestep
159
+ print(current_datetime)
160
+
161
+ swmm_solver.set_value(
162
+ object_type=solver.SWMMObjects.RAIN_GAGE,
163
+ property_type=solver.SWMMRainGageProperties.GAGE_RAINFALL,
164
+ index="RG1",
165
+ value=3.6
166
+ )
167
+
168
+ # Alternative 2 to run SWMM
169
+ swmm_solver = Solver(inp_file="input_file.inp")
170
+ swmm_solver.initialize()
171
+
172
+ for elapsed_time, current_datetime in swmm_solver:
173
+ # Get and set attributes per timestep
174
+ print(current_datetime)
175
+
176
+ swmm_solver.finalize()
177
+ # or
178
+ # swmm_solver.end()
179
+ # swmm_solver.report()
180
+ # swmm_solver.close()
181
+
182
+ # Alternative 3 to run SWMM
183
+ swmm_solver = Solver(inp_file="input_file.inp")
184
+ swmm_solver.execute()
185
+
186
+ # To read output file
187
+
188
+ swmm_output = Output(output_file='output_file.out')
189
+
190
+ # Dict[datetime, float]
191
+ link_timeseries = swmm_output.get_link_timeseries(
192
+ element_index="C1",
193
+ attribute=output.LinkAttribute.FLOW_RATE,
194
+ )
195
+
196
+ ```
197
+
198
+ ## Unit and Regression Testing
199
+
200
+ Unit tests and regression tests have been developed for both the natively compiled SWMM computational engine and output toolkit as well as their respective python bindings. Unit tests for the natively compiled toolkits use the Boost 1.67.0 library and can be compiled by adding DBUILD_TESTS=ON flag during the cmake build phase as shown below:
201
+
202
+ ```bash
203
+ ctest --test-dir . -DBUILD_TESTS=ON --config Debug --output-on-failure
204
+ ```
205
+
206
+ Unit testing on the python bindings may be executed using the following command after installation.
207
+
208
+ ```bash
209
+ cd python\tests
210
+ pytest .
211
+ ```
212
+
213
+ Regression tests are executed using the python bindings using the pytest and pytest-regressions extension using the following commands.
214
+
215
+ ```bash
216
+ cd ci
217
+ pytest --data-dir <path-to-regression-testing-files> --atol <absolute-tolerance> --rtol <relative-tolerance> --benchmark-compare --benchmark-json=PATH
218
+ ```
219
+
220
+ ## Find Out More
221
+ The source code distributed here is identical to the code found at the official [SWMM website](https://www.epa.gov/water-research/storm-water-management-model-swmm).
222
+ The SWMM website also hosts the official manuals and installation binaries for the SWMM software.
223
+
224
+ A live web version of the SWMM documentation of the API and user manuals can be found on the [SWMM GitHub Pages website](https://usepa.github.io/Stormwater-Management-Model). Note that this is an experimental version that is still under development and has yet to go through EPA'S official quality assurance review process.
225
+
226
+ ## Disclaimer
227
+ The United States Environmental Protection Agency (EPA) GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. EPA has relinquished control of the information and no longer has responsibility to protect the integrity, confidentiality, or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by EPA. The EPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by EPA or the United States Government.
228
+
@@ -0,0 +1,36 @@
1
+ openswmm/CMakeLists.txt,sha256=A_mLTvbKrRqNZ5SoAPhH0xu85xnq2DDP9yYV7mG70H4,760
2
+ openswmm/__init__.py,sha256=0N2CX2E9fmAyxp8sIKLVwk5rI4O4IML8rtH7aewPJvM,1370
3
+ openswmm/_openswmm.pyx,sha256=Iu-auvAriOBhm0LC8l38sDaoAPQ7WI-7J8EV9Rt3Okg,264
4
+ openswmm/openswmm.pxd,sha256=OMqMgHZmVYeaeIfMxuoUZAom_EC_sBav_V3MXvkK-9g,229
5
+ openswmm/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ openswmm/gym/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ openswmm/output/CMakeLists.txt,sha256=LuxgOUNV001ovki7m8jgS3l4g-9hivYxbe7IaJyCASg,1184
8
+ openswmm/output/__init__.pxd,sha256=P6aSBhYtq4_LcjyBO5jLgzxev7uhGVWDs_X3jp_0SP8,22
9
+ openswmm/output/__init__.py,sha256=QrGifWqsEpA21kA2LdemrQOn6X-rrIBl9BsgzZ_zjOk,234
10
+ openswmm/output/_output.pyi,sha256=qzbt0wJoKeMjH8L5CIL1bi9q41069EcuQSkO-MYL-Yc,23295
11
+ openswmm/output/_output.pyx,sha256=_9PKgrbDdXdakHntsh-VKlPInlrbrkfnnG-NMg80hU0,53961
12
+ openswmm/output/output.pxd,sha256=ZWU41p8DJMtE2g5tTX0NG2MjU4s_CO9WR7CuV4_q3yU,17355
13
+ openswmm/solver/CMakeLists.txt,sha256=5_rUGyggKj7u05KZan2G-KjqmKnQY_Z6xkhZc8Dz9mI,1207
14
+ openswmm/solver/__init__.pxd,sha256=c66v4fkTN-lP6A1fu8npq6NMbVY0YFSEG2ygkckxc0Y,22
15
+ openswmm/solver/__init__.py,sha256=lhuOzlodkJgHxhl2Ka92rlpPPfQzUknuEZVKqsQvUwQ,509
16
+ openswmm/solver/_solver.pyi,sha256=uIa_ogbdIl7qUp21Ew0dsU7_XbqKtkfy5sqGms9ezss,26817
17
+ openswmm/solver/_solver.pyx,sha256=xoYA_HRo57Ypa-fKT25AhnaxqaRfos5Jxt21g0PHNYI,54435
18
+ openswmm/solver/solver.pxd,sha256=u2QTMcqcnlb29Spd83-6Yr0-I21FIecfcm-K33bcfqg,14937
19
+ openswmm-5.3.0.dev0.dist-info/licenses/LICENSE,sha256=pyk0dQPNVU8Nr7nMpIJNOppXsEEe1nlGhTiXTj_DIfM,1389
20
+ tests/.DS_Store,sha256=vN93C6eZoK3-GKyUUv1QMNsGTWu6xkchU5AwXTaaEQw,6148
21
+ tests/__init__.py,sha256=g1vIT9Yhp2M6OJgLRzr6oB2psjt_V3ZJwx9MvLA8keY,88
22
+ tests/test_swmm_solver.py,sha256=wZ0-sITfrwOpSB05l8hDFGm6-wMQgPO3Lvn-S8sEAK4,26116
23
+ tests/test_swwm_output.py,sha256=aThj81Ptn4rCWezihxSRe5aT3fqV2sXKinh7IR8KrF4,37248
24
+ tests/data/.DS_Store,sha256=rzJQ_pMUQarbrfiMJi5XBuCMJFbMPNrGUbE2z7Bmf2M,6148
25
+ tests/data/__init__.py,sha256=siayQrR2VgBLjA6OmCUnPR_ce6EDTmfIkUevsjWRgBQ,67
26
+ tests/data/output/__init__.py,sha256=V8pp4cxOqbTOyFRr2ERitWrCvqTV8w7rf0lw_xokB7c,485
27
+ tests/data/output/example_output_1.out,sha256=L06BtY_yhe6lhaJROvI1GGPdwnwDV4VnPP-VROUcgsg,44018
28
+ tests/data/output/json_time_series.pickle,sha256=g1twKdx_6Er_fHSqAkqs9t_DRBgPFsG97iHoZSGptOQ,4122
29
+ tests/data/solver/__init__.py,sha256=HqluSGqEm-1d18UzfPLzXiv9rglPJqwFbdcW63fm1Xw,413
30
+ tests/data/solver/non_existent_input_file.rpt,sha256=KT3GMFWzj6zNhX5cBL2Amh9-Rx9JKHr0h4jM4ogCQQM,156405
31
+ tests/data/solver/site_drainage_example.inp,sha256=3xSxNmT8eVKqACHmeJfsC5ODksPPZrMr6bvJB2Vfg18,26004
32
+ tests/data/solver/site_drainage_example.rpt,sha256=RZs4sePs7l3t8tVOcbSHvKRv2X6iT3EVin-rwWI77yY,17841
33
+ openswmm-5.3.0.dev0.dist-info/METADATA,sha256=0HanNUpA7s_4HqoCW_eJ4fs8K_rovAFWTis1uCrWWpg,12528
34
+ openswmm-5.3.0.dev0.dist-info/WHEEL,sha256=m-nq1aIDeuxRdjfTNeALjyq_QDrHE03qCc8i5s_UmRs,86
35
+ openswmm-5.3.0.dev0.dist-info/top_level.txt,sha256=oBBb61VpbXAWx6CEnYYRQgwSvdrcqVqDuY3ocrC404A,15
36
+ openswmm-5.3.0.dev0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: skbuild 0.18.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,12 @@
1
+ Copyright 2026 HydroCouple
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
9
+ This project contains original material has been released as part of various USEPA SWMM software over the years. These reside in the
10
+ public domain and cannot be claimed. This project also contains new material prepared by the United States
11
+ Government for which domestic copyright protection is not available under 17
12
+ USC § 105.
@@ -0,0 +1,2 @@
1
+ openswmm
2
+ tests
tests/.DS_Store ADDED
Binary file
tests/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ # Description:
2
+ # Created by: Caleb Buahin (EPA/ORD/CESER/WID)
3
+ # Created on: 2024-11-19
tests/data/.DS_Store ADDED
Binary file
tests/data/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ import os
2
+
3
+ DATA_PATH = os.path.dirname(os.path.realpath(__file__))