gridoxide
Python bindings for gridoxide, a Rust AC power flow solver
using the Newton-Raphson method with a sparse Jacobian (via faer).
Grids are loaded from power-grid-model (PGM) JSON input files. Repeated solves against the same topology reuse a cached symbolic factorization, so scenario sweeps and time-series runs only pay the fill-reducing-ordering cost once.
Install
pip install gridoxide
Prebuilt wheels are published for Linux (x86_64), Windows, and macOS (arm64).
Quickstart
import gridoxide
model = gridoxide.PowerFlowModel.from_pgm_json("grid.json", backend="scalar")
model.solve()
print(model.voltage_mag()) # per-unit voltage magnitude, one entry per node
print(model.voltage_ang()) # voltage angle in radians, one entry per node
grid.json is a PGM-format input file, e.g.:
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 1, "u_rated": 10500.0},
{"id": 2, "u_rated": 10500.0}
],
"line": [
{"id": 3, "from_node": 1, "to_node": 2, "from_status": 1, "to_status": 1,
"r1": 0.25, "x1": 0.2, "c1": 1e-06, "tan1": 0.0,
"r0": 0.25, "x0": 0.2, "c0": 1e-06, "tan0": 0.0, "i_n": 1000.0}
],
"sym_load": [
{"id": 9, "node": 2, "status": 1, "type": 0, "p_specified": 10000.0, "q_specified": 2000.0}
],
"source": [
{"id": 4, "node": 1, "status": 1, "u_ref": 1.0, "sk": 1e10, "rx_ratio": 0.1, "z01_ratio": 1.0}
]
}
}
Reusing factorization across repeated solves
PowerFlowModel wraps gridoxide's PersistentSolver: construct one per topology, then call .solve()
as many times as needed. Only the first call pays for symbolic factorization; later calls only need
values (p_specified/q_specified) to change, not the topology.
model = gridoxide.PowerFlowModel.from_pgm_json("grid.json", backend="scalar")
for scenario in scenarios:
apply_scenario(model, scenario) # e.g. edit and re-load p/q values
model.solve()
results.append(model.voltage_mag())
Call model.reset() if the topology itself changes between solves (not just bus values).
Building input grids
Two helpers produce or convert PGM JSON, so a working grid doesn't require hand-writing one:
-
gridoxide.generate_grid— generates a synthetic radial MV/LV distribution grid at any scale, no extra dependencies needed:from gridoxide.generate_grid import generate generate(target_nodes=2200, seed=42, out_path="grid.json") # ~2,600 nodes
or from the shell:
gridoxide-generate-grid grid.json --target-nodes 2200 --seed 42. -
gridoxide.matpower(needspip install gridoxide[matpower]) — converts a raw MATPOWER case (.mor.mat) into PGM JSON:from gridoxide.matpower import convert convert("case14.m", "case14.json")
or
gridoxide-matpower case14.m case14.json.
gridoxide deliberately has no pandapower-based converter: it would need the full pandapower +
power-grid-model-io dependency chain, and gridoxide.matpower already covers the same real-world
test-case grids straight from their original MATPOWER source files without it. If you already have a
pandapower.pandapowerNet object and pandapower installed, see
scripts/bench/convert_pandapower_case.py
in the main repo for a standalone (not part of this package) converter.
API
PowerFlowModel.from_pgm_json(path, backend="scalar", tol=1e-6, max_iter=20, s_base_va=1e6, freq_hz=50.0)— loads a PGM JSON file and builds the Y-bus admittance matrix.model.n_nodes— number of buses, including one virtual slack bus per activesource.model.solve()— runs Newton-Raphson from a flat/linear-initial-guess start; raisesRuntimeErrorif it doesn't converge withinmax_iteriterations.model.reset()— discards the cached symbolic factorization; call before the nextsolve()if the topology has changed.model.voltage_mag()/model.voltage_ang()— per-bus results in node order (per-unit magnitude, radians).
Backends
backend selects the linear solver used inside the Newton-Raphson Jacobian:
| Backend | Notes |
|---|---|
"scalar" (default) |
Sparse LU via faer, no special build requirements. |
"block" |
Block-structured variant of the same solver (one 2×2 block per bus); faster on some topologies. |
"klu_native" |
From-scratch Rust translation of SuiteSparse KLU, always available in this wheel. |
Two additional backends exist in the source tree but are not included in the published wheel, since they need extra system dependencies at build time — build gridoxide from source with the matching Cargo feature to use them:
"klu"— links vendored SuiteSparse C directly (--features python,klu)."pardiso"— Intel oneMKL's PARDISO solver (--features python,pardiso, needsMKLROOTset).
License
gridoxide's own code is Apache-2.0. A default build (and this published wheel) also always bundles
src/klu_native/, a from-scratch Rust translation of vendored SuiteSparse AMD/BTF/KLU source
(BSD-3-Clause for the AMD-derived pieces, LGPL-2.1-or-later for the BTF/KLU-derived pieces) — see the
main README's License section for the full breakdown.
Metadata
Release files for gridoxide 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gridoxide-0.0.2.tar.gz | 524.1 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gridoxide-0.0.2-cp314-cp314-macosx_11_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 11.0+ ARM64 | Details |
| gridoxide-0.0.2-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| gridoxide-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.17+ x86-64 | Details |
Total release size: 3.9 MB
Release files / gridoxide-0.0.2.tar.gz
| Download URL | gridoxide-0.0.2.tar.gz |
|---|---|
| Size | 524.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19f9ef42a6268415a0ef16bc15a77b0b539b9ababd974c6651f37bbb0061f60e
|
|
BLAKE2b-256 checksum How to use checksums |
35452560069ec1bc876b4a883ef871aaedbf85b29f1e0bb4b003a15343f07fea
|
| 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 Jul 31, 2026.
Transparency logRelease files / gridoxide-0.0.2-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | gridoxide-0.0.2-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 838.1 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ed73da53b7bd0e0b06fae1199a73980a75c4a59c4e533971245084a1295d95ff
|
|
BLAKE2b-256 checksum How to use checksums |
254aad6402a9d9c89a584866ace722c5a42313da42278bbe1aaede49d3c914d7
|
| 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 Jul 31, 2026.
Transparency logRelease files / gridoxide-0.0.2-cp312-cp312-win_amd64.whl
| Download URL | gridoxide-0.0.2-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2b5175dbcccc480c3bc6492127db422967e7e543b899f59ebf471df79f4e588d
|
|
BLAKE2b-256 checksum How to use checksums |
14e1d4034bd7c8505fc56d27fc65b12ce7841ef98bf3a5956f210d14961d5842
|
| 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 Jul 31, 2026.
Transparency logRelease files / gridoxide-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | gridoxide-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
632853eec859b9e6c76a847635ee63f525892e326394c3c99aa1c53714e6fb8f
|
|
BLAKE2b-256 checksum How to use checksums |
9375524e4500bacaba05034d52793b9573259490d9190d35c12dde8b10469a8c
|
| 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 Jul 31, 2026.
Transparency log