Skip to main content

GridForge

GridForge Logo

GridForge helps build optimization-ready power-system cases from standard PYPOWER/MATPOWER grids. It lets you describe grid edits in YAML, generate a structured Excel workbook, attach bus-level time-series data, and load the result into Python for your own optimization model.

GridForge is useful when a standard test case is not enough: for example, when you need custom assets such as load, solar, wind, or storage, time-series data attached to selected buses, and convenient access to the final case in CVXPY.

Read the full documentation at xuwkk.github.io/gridforge.

Workflow

base PYPOWER/MATPOWER case
  -> grid configuration YAML
  -> generated Excel workbook
  -> bus-data assignment YAML
  -> bus_<BUS_IDX>.csv files
  -> Grid(...) and Data(...) classes for efficient access to the case and data
  -> user-defined optimization model

The grid configuration YAML can be written manually or created with the visual app. The bus-data assignment step is separate because it depends on the generated BUS_IDX values in the workbook.

Installation

Install the latest release from PyPI:

pip install powergridforge

To run the examples and edit the docs, clone the repository:

git clone https://github.com/xuwkk/gridforge.git
cd gridforge
python -m venv .venv
source .venv/bin/activate
pip install -e ".[full]"

What You Need First

GridForge does not invent the grid design automatically. Before constructing a case, prepare:

  • a grid configuration YAML that selects a base case and describes static grid edits, see configuration.md for details.
  • a bus-data assignment YAML that declares which time-series signals should be mapped to generated buses, see bus-data-assignment.md for details.
  • source CSV files if you want to materialize time-series data.

For a first run, use the prepared 14-bus example in a source checkout of this repository.

14-Bus Example

The worked unit-commitment example is in examples/14bus_uc/.

Important files:

Run the example from the repository root:

python examples/14bus_uc/14bus_example.py

Or open the notebook:

jupyter lab examples/14bus_uc/14bus_uc.ipynb

The same workflow can be called from Python:

from gridforge.construct import construct_grid_config
from gridforge.data import (
    load_bus_data_assignment,
    prepare_bus_data,
)
from gridforge.opt import Grid, Data

config_yaml = "examples/14bus_uc/14bus_config.yaml"
config_xlsx = "examples/14bus_uc/14bus_config.xlsx"
assignment_yaml = "examples/14bus_uc/14bus_data_assignment.yaml"
resolved_assignment_yaml = "examples/14bus_uc/14bus_data_assignment_resolved.yaml"
data_dir = "examples/14bus_uc/14bus_data"
source_data_dir = "data/bus_data"

construct_grid_config(config_yaml, config_xlsx, random_seed=404)

assignment_template = load_bus_data_assignment(assignment_yaml)
assignment, _ = prepare_bus_data(
    grid_xlsx_path=config_xlsx,
    source_data_dir=source_data_dir,
    signals=assignment_template["signals"],
    output_data_dir=data_dir,
    resolved_assignment_path=resolved_assignment_yaml,
    random_seed=404,
)

grid = Grid(config_xlsx, verbose=0)
data = Data(
    grid_xlsx_path=config_xlsx,
    data_dir=data_dir,
    sheet_names=["load", "solar", "wind"],
)

print(grid.gen.pmax)
print(grid.branch.ptdf.shape)
print(grid.load.Cbus.shape)
print(data.get_series("load").shape)

Visual Config App

The visual app helps create and inspect the grid configuration YAML used in the first stage.

GridForge Visual Config App

Launch it after installing the app dependencies, for example with pip install -e ".[full]" from a source checkout:

gridforge-app

From a local checkout:

streamlit run gridforge/config_app.py

Documentation

The published documentation is available at xuwkk.github.io/gridforge.

The source Markdown files for the site live in docs/.

Metadata

Release files for powergridforge 1.1.4

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

Source distribution (sdist)

Source distribution for powergridforge 1.1.4
File Size Uploaded
powergridforge-1.1.4.tar.gz 2.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for powergridforge 1.1.4
File Interpreter ABI Platform
powergridforge-1.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 2.9 MB

Release files / powergridforge-1.1.4.tar.gz

Download URL powergridforge-1.1.4.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
8467427e294111dbcd7e24784e9ead616828fa0eef1abe8c0ad989cad40e011a
BLAKE2b-256 checksum
How to use checksums
8e34490de5996a3edc36c5d92a326fdb652e1962841297b4566b32b52428d022
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.18

Release files / powergridforge-1.1.4-py3-none-any.whl

Download URL powergridforge-1.1.4-py3-none-any.whl
Size 58.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3511d201294e2eb8cac95f2baedf6253f91f0837efaae2fd5841bf96c27268b7
BLAKE2b-256 checksum
How to use checksums
0c6c8f50592436b3abde139e9fdfc7a38ae5867c3667cfd9efa8ee0a8c2594bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.18

Release history Release notifications | RSS feed

1.1.6

2 release files

1.1.5

2 release files

This release

1.1.4 This release

2 release files

1.1.3

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