Skip to main content

mambo-power

A fundamental Python package for power system analysis and electricity market modelling. It owns its network data model and implements its own solvers on numpy, scipy and HiGHS; pandapower and PyPSA serve only as test oracles.

Documentation: https://mambo10005.github.io/mambo-power/

What it is

  • A JSON-native network model (pydantic v2): Network with buses, branches, generators (with cost curves), loads, shunts, storage and zones; physical units, stable string ids, all-issues validation with named error codes, JSON schema generated from the model.
  • Importers that speak only the model: MATPOWER .m cases and the native JSON format, plus pandapower JSON, PyPSA, PSS/E RAW and CSV bundles.
  • Network matrices over scipy.sparse: NetworkArrays (the single per-unit conversion site), Ybus, Bbus, PTDF, LODF with bridge detection.
  • Solvers: DC power flow and AC Newton-Raphson with Q-limit enforcement; DC optimal power flow with duals on HiGHS; N-1 contingency screening; market clearing (nodal LMP, multiperiod with storage, zonal with redispatch, agent-based bidding).
  • Typed, id-keyed results stamped with provenance (engine version, solver, timings), never stored on the network; a stateless, JSON-serialisable jobs.run(SolveRequest) surface designed to sit behind a service.
  • Narrative tutorial notebooks (execution-tested in CI), an automated changelog, and PyPI trusted publishing.

Free in both senses: an open-source stack end to end with no paid solvers or licences, and built, tested, documented and published entirely on free infrastructure (GitHub Actions, GitHub Pages, PyPI trusted publishing).

Status

Wave Scope State
M1 Installable package, Network model, MATPOWER import, Ybus/Bbus/PTDF/LODF, CI matrix merged
M2 DC + AC Newton-Raphson power flow, typed results, jobs API, docs site, examples merged
M3 DC optimal power flow with duals on HiGHS, N-1 branch-contingency screening merged
M4 Nodal market: elastic-demand DC-OPF, LMP clearing, settlement merged
M5 Multiperiod market: 24-period horizon, ramp coupling, storage SoC, per-period settlement merged
M6 Zonal market: zonal clearing, min-cost redispatch, nodal-vs-zonal comparison merged
M7 Agent-based bidding: strategies, offered-vs-true cost overlay, fixed-point loop merged
M8 Interchange: pandapower JSON, PyPSA, PSS/E RAW, CSV bundle merged
M9 Tutorials, semantic-release changelog, PyPI 0.1.0 trusted publishing merged

On PyPI as of v0.1.0. See Getting started for the current install instructions, which is the live source of truth if this file is ever stale (this table is not covered by any automated freshness check — see the epic-close continuation record if you're reading this after a release and it still says otherwise; PyPI's own project page bakes in whatever this file said at the release that's currently latest, so a README.md fix here only reaches pypi.org on the next release, not retroactively). Runtime dependencies are exactly numpy, scipy, highspy, pydantic; Python 3.11 or newer.

Install

pip install mambo-power
# or: uv add mambo-power

The wheel ships only the package. The MATPOWER fixtures under fixtures/ and the test suite are in the sdist and the repository, not in the wheel, so the examples below assume a clone:

git clone https://github.com/mambo10005/mambo-power.git
cd mambo-power
uv sync                    # runtime deps only; add --all-groups for dev + docs tooling

Without uv: pip install -e . in any Python >= 3.11 environment.

Quick start

from mambo_power import pf
from mambo_power.io import matpower

net = matpower.load("fixtures/matpower/case14.m")  # validated Network, physical units
result = pf.solve_dc(net)  # typed result keyed by ids, MW
print(result.generators[0].p_mw)  # 219.0 -- slack generator balance
print(result.branches[0].p_from_mw)  # 147.84 -- flow bus-1 -> bus-2
print(result.provenance.version, result.provenance.solver)
text = result.model_dump_json()  # exact JSON round-trip
again = type(result).model_validate_json(text)
assert again == result

Then: Getting started walks through loading, validating, solving and reading results with real output.

Tutorials and manual

Tutorials are prose-heavy, narrative walkthroughs (a first power flow, DC-OPF + N-1, a nodal market, where to go next) — start there if you're new. The manual is the reference:

Development

uv sync --all-groups
uv run ruff check . && uv run ruff format --check . && uv run mypy
uv run pytest                      # tiers: -m unit | parity | property
uv run mkdocs serve                # docs at http://127.0.0.1:8000

Tests are tiered (tests/unit, tests/parity against pandapower/PyPSA/MATPOWER, tests/property with hypothesis). Every public symbol must carry a docstring; a unit test enforces it. The docs build with mkdocs build --strict in CI and deploy to GitHub Pages on pushes to epic/01-foundation and main.

Licence

MIT — see LICENSE. Bundled MATPOWER cases under fixtures/matpower/ are public IEEE test data as distributed by MATPOWER; see fixtures/matpower/PROVENANCE.md.

Download files

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

Source Distribution

mambo_power-0.1.1.tar.gz (554.9 kB view details)

Uploaded Source

Built Distribution

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

mambo_power-0.1.1-py3-none-any.whl (237.1 kB view details)

Uploaded Python 3

File details

Details for the file mambo_power-0.1.1.tar.gz.

File metadata

  • Download URL: mambo_power-0.1.1.tar.gz
  • Upload date:
  • Size: 554.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mambo_power-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ab0b986dd83650c57d7c3dec80e4645531f3cf872aa109455ac8594861e06861
MD5 e0a8be84ff0c4c180dc3ced768a7a596
BLAKE2b-256 74c144842c8e7292ac49e0c3c928ceebd253bd2dd6a091f15bbdd55ec39975d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mambo_power-0.1.1.tar.gz:

Publisher: publish.yml on mambo10005/mambo-power

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mambo_power-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mambo_power-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 237.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mambo_power-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a44a620b1d87a7c87a6eb352df7aae900b09fc4fdd27f7fa9cf6b1da6f70cbf3
MD5 b5dd4b22c50f3c584f448b9963f1d28d
BLAKE2b-256 8256772e8ddbffbab0b2450471522161380d4420277a9429cc702e9313e6bf34

See more details on using hashes here.

Provenance

The following attestation bundles were made for mambo_power-0.1.1-py3-none-any.whl:

Publisher: publish.yml on mambo10005/mambo-power

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 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