Skip to main content

Hydraulic Engine

Testing CI - Test
Package PyPI Latest Release PyPI Downloads
Meta License - GNU GPL3

Python toolkit to run SWMM and EPANET simulations, work with their input and result files, and export results to a Giswater PostgreSQL database or a FROST SensorThings endpoint.

Features

  • Run SWMM (pyswmm) and EPANET (WNTR) simulations, with optional progress callbacks
  • Read and write SWMM / EPANET INP models
  • Read SWMM RPT and OUT results, and EPANET BIN results
  • Export simulation results to PostgreSQL (Giswater) or FROST
  • Connect to PostgreSQL, SQLite, and GeoPackage

Installation

pip install hydraulic-engine

From source:

git clone https://github.com/bgeo-gis/hydraulic-engine.git
cd hydraulic-engine
pip install -e .

For development:

pip install -e ".[dev]"

Quick start

Run a simulation

import hydraulic_engine as he
from hydraulic_engine.utils.enums import RunStatus

# SWMM
swmm = he.swmm.SwmmRunner(inp_path="drainage.inp")
swmm_result = swmm.run()

# EPANET
epanet = he.epanet.EpanetRunner(inp_path="network.inp")
epanet_result = epanet.run()

if swmm_result.status == RunStatus.SUCCESS:
    print(f"SWMM finished in {swmm_result.duration_seconds:.2f}s")

run() uses a hybrid error contract: load/validation failures and unexpected engine crashes raise (FileLoadError, ValidationError, SimulationError); cancel via step_callback returning False raises SimulationCancelled. Finished runs still return a result whose status may be SUCCESS, WARNING, or ERROR from RPT/output checks.

Pass progress_callback=fn to either runner to receive progress updates during the run.

Work with model files

from hydraulic_engine.swmm import SwmmInpHandler
from hydraulic_engine.epanet import EpanetInpHandler

swmm_inp = SwmmInpHandler()
swmm_inp.load_file("drainage.inp")
print(swmm_inp.get_summary())

epanet_inp = EpanetInpHandler()
epanet_inp.load_file("network.inp")
print(epanet_inp.get_summary())

Result files use the matching handlers: SwmmRptHandler, SwmmOutHandler, and EpanetBinHandler.

Export results

After a successful run, push results to the database or to FROST:

import hydraulic_engine as he

runner = he.swmm.SwmmRunner(inp_path="drainage.inp")
runner.run()

dao = he.create_pg_connection(
    host="localhost",
    port=5432,
    dbname="hydraulic_db",
    user="user",
    password="pass",
    schema="my_schema",
)

runner.export_result(
    to=he.ExportDataSource.DATABASE,
    result_id="my_result",  # must already exist in rpt_cat_result
    client=dao,
)

The same export_result(..., to=he.ExportDataSource.FROST) path works for SensorThings via he.create_frost_connection(...). EPANET uses the same pattern on EpanetRunner.

Exported SWMM time series follow what the model’s [REPORT] section requests (nodes, links, subcatchments).

Database connections

import hydraulic_engine as he

pg = he.create_pg_connection(host="localhost", port=5432, dbname="db", user="u", password="p")
gpkg = he.create_gpkg_connection("project.gpkg")
sqlite = he.create_sqlite_connection("local.db")

he.close_connection()

Package layout

Module Role
hydraulic_engine.swmm SWMM runner, INP / RPT / OUT handlers
hydraulic_engine.epanet EPANET runner, INP / BIN handlers
hydraulic_engine.utils DB / API / logging helpers, ExportDataSource, RunStatus
hydraulic_engine.config Package configuration

Development

pytest tests/
black src/
ruff check src/

License

GNU General Public License v3.0 or later — see LICENSE.

Authors

BGEO — info@bgeo.es

Metadata

Release files for hydraulic-engine 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hydraulic-engine 0.8.0
File Size Uploaded
hydraulic_engine-0.8.0.tar.gz 107.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hydraulic-engine 0.8.0
File Interpreter ABI Platform
hydraulic_engine-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 212.1 kB

Release files / hydraulic_engine-0.8.0.tar.gz

Download URL hydraulic_engine-0.8.0.tar.gz
Size 107.1 kB
Tags Source
SHA-256 checksum
How to use checksums
328443407cbe41261d94c5684017bf57c4134a23fb3f5a0ee38ac5b06ffdd730
BLAKE2b-256 checksum
How to use checksums
f14bbaee5549f741dba13dffcf57fdd0c2f492d486e95d04b43d785b12a532ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release files / hydraulic_engine-0.8.0-py3-none-any.whl

Download URL hydraulic_engine-0.8.0-py3-none-any.whl
Size 104.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dacf8833d90f9a47029500d6d579aeabe4b48ba8667beb3674c11c60100b2c1a
BLAKE2b-256 checksum
How to use checksums
b3e5b6cf365b2cce4583f978c8e7e6808afb8e3032acdf5f5bd3ac60c37d3207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.10.1

2 release files

0.10.0

2 release files

0.9.0

2 release files

This release

0.8.0 This release

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page