Skip to main content

A python package for EPA SWMM5 preprocessing, solver, and post-processing.

Project description

EPA ORD Stormwater Management Model (SWMM)

Stormwater Management Model (SWMM) computational engine and output post-processing codebase

Build Status

Build and Unit Testing Build and Regression Testing Deployment Documentation PythonVersion PyPi

Introduction

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.

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.

Build Instructions

The 'src' folder of this repository contains the C source code for version of Storm Water Management Model's computational engine. Consult the included 'Roadmap.txt' file for an overview of the various code modules. The code can be compiled into both a shared object library and a command line executable. Under Windows, the library file (swmm5.dll) is used to power SWMM's graphical user interface.

Also included is a python interface for the SWMM computational engine and output post-processing application programming interfaces located in the python folder.

The 'CMakeLists.txt' file is a script used by CMake (https://cmake.org/) to build the SWMM binaries. CMake is a cross-platform build tool that generates platform native build systems for many compilers. To check if the required version is installed on your system, enter from a console window and check that the version is 3.5 or higher.

cmake --version

To build the SWMM engine library and its command line executable using CMake and the Microsoft Visual Studio C compiler on Windows:

  1. Open a console window and navigate to the directory where this Readme file resides (which should have 'src' as a sub-directory underneath it).

  2. Use the following command to create the directory for storing the built binaries:

mkdir build
  1. Then the following CMake commands to build the binaries:
cmake -G <compiler> .. -A <platform> -B .\build
cmake --build . --config Release

where <compiler> is the name of the compiler being used in double quotes (e.g., "Visual Studio 15 2017", "Visual Studio 16 2019", or "Visual Studio 17 2022") and <platform> (e.g., Win32 for a 32-bit build or x64 for a 64-bit build). 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) will appear in the build\Release directory.

For other platforms, such as Linux or MacOS, Step 3 can be replaced with:

cmake .
cmake --build .\build

The resulting shared object library (libswmm5.so or libswmm5.dylib) and command line executable (runswmm) will be compiled to the build directory.

Python Bindings (Experimental)

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.

cd python
python -m pip install -r requirements.txt
python -m pip install . 

Users may also build python wheels for installation or distribution. Once the python bindings 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.

Example usage of python bindings can be found below. More extensive documentation will be provided once cleared.

from epaswmm import solver
from epaswmm.solver import Solver 
from epaswmm.output import Output

# Alternative 1 to run SWMM

with Solver(inp_file="input_file.inp") as swmm_solver:
   
   # Open swmm file and starts the simulation
   swmm_solver.start()

   # Set initialization parameters e.g., time step stride, start date, end date etc.
   swmm_solver.time_stride = 600 

   for elapsed_time, current_datetime in swmm_solver:

      # Get and set attributes per timestep
      print(current_datetime)

      swmm_solver.set_value(
         object_type=solver.SWMMObjects.RAIN_GAGE,
         property_type=solver.SWMMRainGageProperties.GAGE_RAINFALL,
         index=0,
         value=3.6
      )

# Alternative 2 to run SWMM
swmm_solver = Solver(inp_file="input_file.inp")
swmm_solver.initialize()

for elapsed_time, current_datetime in swmm_solver:
   # Get and set attributes per timestep
   print(current_datetime)

swmm_solver.finalize()
# or
# swmm_solver.end()
# swmm_solver.report()
# swmm_solver.close()

# Alternative 3 to run SWMM
swmm_solver = Solver(inp_file="input_file.inp")
swmm_solver.execute()

# To read output file

swmm_output = Output(output_file='output_file.out')

# Dict[datetime, float]
link_timeseries = swmm_output.get_link_timeseries(
   element_index=5,
   attribute=output.LinkAttribute.FLOW_RATE,
)

Unit and Regression Testing

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:

ctest --test-dir .  -DBUILD_TESTS=ON --config Debug --output-on-failure

Unit testing on the python bindings may be executed using the following command after installation.

cd python\tests
pytest .

Regression tests are executed using the python bindings using the pytest and pytest-regressions extension using the following commands.

cd ci
pytest --data-dir <path-to-regression-testing-files> --atol <absolute-tolerance> --rtol <relative-tolerance> --benchmark-compare --benchmark-json=PATH

Find Out More

The source code distributed here is identical to the code found at the official SWMM website. The SWMM website also hosts the official manuals and installation binaries for the SWMM software.

A live web version of the SWMM documentation of the API and user manuals can be found on the SWMM GitHub Pages website. 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.

Disclaimer

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epaswmm-5.3.0.dev7.tar.gz (393.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

epaswmm-5.3.0.dev7-cp313-cp313-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.13Windows x86-64

epaswmm-5.3.0.dev7-cp313-cp313-win32.whl (1.5 MB view details)

Uploaded CPython 3.13Windows x86

epaswmm-5.3.0.dev7-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

epaswmm-5.3.0.dev7-cp312-cp312-win32.whl (1.5 MB view details)

Uploaded CPython 3.12Windows x86

epaswmm-5.3.0.dev7-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11Windows x86-64

epaswmm-5.3.0.dev7-cp311-cp311-win32.whl (1.5 MB view details)

Uploaded CPython 3.11Windows x86

epaswmm-5.3.0.dev7-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10Windows x86-64

epaswmm-5.3.0.dev7-cp310-cp310-win32.whl (1.5 MB view details)

Uploaded CPython 3.10Windows x86

epaswmm-5.3.0.dev7-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9Windows x86-64

epaswmm-5.3.0.dev7-cp39-cp39-win32.whl (1.5 MB view details)

Uploaded CPython 3.9Windows x86

epaswmm-5.3.0.dev7-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8Windows x86-64

epaswmm-5.3.0.dev7-cp38-cp38-win32.whl (1.5 MB view details)

Uploaded CPython 3.8Windows x86

File details

Details for the file epaswmm-5.3.0.dev7.tar.gz.

File metadata

  • Download URL: epaswmm-5.3.0.dev7.tar.gz
  • Upload date:
  • Size: 393.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7.tar.gz
Algorithm Hash digest
SHA256 18bb417e961db9d9a60f3802dbe4f88ff58f615c7ffec8ac1f4444a861efeb5e
MD5 3578d466112af68ba54e91b1aeb4a29d
BLAKE2b-256 547b574561f0e85edd4819c7fb80ccfac4c613e38d9577c398887022dccb98e8

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for epaswmm-5.3.0.dev7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e8816f94de95b7d4282bb12dadde4c849d60fb46afcd07917548bfa8843f119b
MD5 591388b2020a3f5e1361b310649e78a3
BLAKE2b-256 524d333469f6205fa1efa3383ca00dbc09fd7447e91919a9635b53a370cf9e62

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp313-cp313-win32.whl.

File metadata

  • Download URL: epaswmm-5.3.0.dev7-cp313-cp313-win32.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.13, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 c44f3c111c98d6843f42577d4be0319f539b24455e45a6d3729ea01879ee66f1
MD5 46f7ae5a0ee8bb63158785f5299469f4
BLAKE2b-256 00830e610b9a277877d8092c834944cb6b1f85fbf0f4ff280e6ab16b6c90e2d2

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for epaswmm-5.3.0.dev7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b8fa8f84ecf77c68c9bc3d3c01c7abc23b4e2564889cbc33835aa724c19af0da
MD5 a8f8969130276850a966369f7cc2cfbe
BLAKE2b-256 a09169906620f0509e5432dd55a8e41d5788c4fda24f429d9d7a44c525490f28

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp312-cp312-win32.whl.

File metadata

  • Download URL: epaswmm-5.3.0.dev7-cp312-cp312-win32.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 25e4ec0ab534d27c4147bf9bf6c2df6aeca620008049990e59e99903c43d8010
MD5 f778707bda57d39dba72de24d33d3761
BLAKE2b-256 f10b7fd4f74c01806477d559dc866143ac8108bb710f8139cfc6a7f0f9b9d781

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for epaswmm-5.3.0.dev7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 29db5b48ab73bdbcc6c836925482fe02d26cb949af1f57c28d1fb7a8846850b4
MD5 fda61a796b7fac415fdba857ed5b2fb3
BLAKE2b-256 2b7f5b3d2171aac1fb75c1a99461e482671c64709c8bad5dddf14b9e955e520f

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp311-cp311-win32.whl.

File metadata

  • Download URL: epaswmm-5.3.0.dev7-cp311-cp311-win32.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 9119bfb3140f13ada37c770d0631d58eb3fc1ac9b8b80ca8c03b0cc54adc2a37
MD5 c43f4fa9003e2f625b8f772e9028e56a
BLAKE2b-256 ad374b82b07f7b1657e4394c312e22f00863f791271f3e479f412fe105cffc64

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for epaswmm-5.3.0.dev7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 df8b36dfddf1ee41bf26b04fbd8295c7f5bc0fab58aab5a3a630b62418c9de4f
MD5 62b7d49e85a7336f870a2fd3de63d375
BLAKE2b-256 10bb4ae3f1449f546b57acbff022c335be6d866312d55a87c7d9d4b6655beafa

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp310-cp310-win32.whl.

File metadata

  • Download URL: epaswmm-5.3.0.dev7-cp310-cp310-win32.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 2607ee0b548b7f562ec83018a03286c71c4544415d04b8df2bd629901eeb4251
MD5 d0d8ab995cb49708c1ae56d4a3400cba
BLAKE2b-256 be4f0fd778b97e27077cc573766ed8a96445e71fe755855084ccfa1ee4de7304

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: epaswmm-5.3.0.dev7-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 afd5f1d225193f439a87bff112d704906b0edb4b151513b65dcf29bd9e2a44c0
MD5 11ec741eb4a464bad1ca4706fba2239a
BLAKE2b-256 e32ac4d1982f8cd92b112de6dffe7aca8c12b6e0f8a0ad6ce284172d623bfdb0

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp39-cp39-win32.whl.

File metadata

  • Download URL: epaswmm-5.3.0.dev7-cp39-cp39-win32.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 41e1c5c98aac9aa6d0e0134ae9e8bf2ccf2c34defaa5bff07268cf0967bbc373
MD5 c4575a3812165aa1948989470eabce17
BLAKE2b-256 2fee4b5c8f9a7641877f3ff537f968c43ee985e26a8b440140d035cd635b7a2e

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: epaswmm-5.3.0.dev7-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9525d98b181025c79602ba59eb2a312a1586cd574c0ee2475262a45fa029e218
MD5 47431ff93b43bc19f37b2dc7e668d504
BLAKE2b-256 545515a9cb90e268378b2309a0f4153573be46e4c51ec62fae2e7e8d3f8e525e

See more details on using hashes here.

File details

Details for the file epaswmm-5.3.0.dev7-cp38-cp38-win32.whl.

File metadata

  • Download URL: epaswmm-5.3.0.dev7-cp38-cp38-win32.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for epaswmm-5.3.0.dev7-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 d579293733d26a83a27f1fa693645a1336848312d499a749c975c2d3fd614cea
MD5 fbf9c83e0ea67a7dffa0426f26d018f0
BLAKE2b-256 9181b2c37a52ffe80d63186ebb222db813c0b02ebeb9c261f57098ec5f7334d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page