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

Not yet on PyPI — this changes in the same action as the v0.1.0 tag; 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 wave M9 continuation record if you're reading this after a release and it still says otherwise). Runtime dependencies are exactly numpy, scipy, highspy, pydantic; Python 3.11 or newer.

Install from source

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.0.tar.gz (554.7 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.0-py3-none-any.whl (236.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mambo_power-0.1.0.tar.gz
  • Upload date:
  • Size: 554.7 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.0.tar.gz
Algorithm Hash digest
SHA256 e6a0f07824208246372b42b763c0aafd03acf98f3df781b37537a55c2c4ead6c
MD5 3c3f63bbc78c60c3e63b63203a1f03cc
BLAKE2b-256 91d5ba516e9c288ddefe2359c873e189ebe2868b047179768ae8014326a5138e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mambo_power-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: mambo_power-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 236.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3cbfa06cd708ae7868711fa3321c68d7529536c931e44ee028df694549f797c3
MD5 6dbb1553f7b696cb15840eec503b462d
BLAKE2b-256 89b73ddd8b2dcfba06fc4dbf72e909d8d75cd7d8b126c3415b03b3d99ce46c5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mambo_power-0.1.0-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

0.1.1

2 files

This release

0.1.0 This release

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