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):
Networkwith 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
.mcases 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:
- Network model — every entity, field, unit, and validation code
- File formats — native JSON, MATPOWER, pandapower JSON, PyPSA, PSS/E RAW, CSV bundles
- Numerics —
NetworkArrays, Ybus, Bbus, PTDF, LODF and bridges - Power flow — the DC formulation and the AC solver's contract
- DC-OPF and N-1 screening
- Market clearing: nodal, multiperiod, zonal
- Agent-based bidding — strategies, offered-vs-true cost, the fixed-point loop
- Results — result tables,
provenance, JSON round-trip,
to_arrays() - Jobs API — the stateless
SolveRequest/SolveResultsurface - API reference, Design, Changelog, Contributing
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6a0f07824208246372b42b763c0aafd03acf98f3df781b37537a55c2c4ead6c
|
|
| MD5 |
3c3f63bbc78c60c3e63b63203a1f03cc
|
|
| BLAKE2b-256 |
91d5ba516e9c288ddefe2359c873e189ebe2868b047179768ae8014326a5138e
|
Provenance
The following attestation bundles were made for mambo_power-0.1.0.tar.gz:
Publisher:
publish.yml on mambo10005/mambo-power
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mambo_power-0.1.0.tar.gz -
Subject digest:
e6a0f07824208246372b42b763c0aafd03acf98f3df781b37537a55c2c4ead6c - Sigstore transparency entry: 2681520647
- Sigstore integration time:
-
Permalink:
mambo10005/mambo-power@98207270482e78e8263f2608c40a813809603bf7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mambo10005
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@98207270482e78e8263f2608c40a813809603bf7 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cbfa06cd708ae7868711fa3321c68d7529536c931e44ee028df694549f797c3
|
|
| MD5 |
6dbb1553f7b696cb15840eec503b462d
|
|
| BLAKE2b-256 |
89b73ddd8b2dcfba06fc4dbf72e909d8d75cd7d8b126c3415b03b3d99ce46c5f
|
Provenance
The following attestation bundles were made for mambo_power-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mambo10005/mambo-power
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mambo_power-0.1.0-py3-none-any.whl -
Subject digest:
3cbfa06cd708ae7868711fa3321c68d7529536c931e44ee028df694549f797c3 - Sigstore transparency entry: 2681520720
- Sigstore integration time:
-
Permalink:
mambo10005/mambo-power@98207270482e78e8263f2608c40a813809603bf7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mambo10005
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@98207270482e78e8263f2608c40a813809603bf7 -
Trigger Event:
push
-
Statement type: