Skip to main content

Power system configuration and optimization toolkit.

Project description

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/.

Project details


Download files

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

Source Distribution

powergridforge-1.1.3.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

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

powergridforge-1.1.3-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

Details for the file powergridforge-1.1.3.tar.gz.

File metadata

  • Download URL: powergridforge-1.1.3.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.18

File hashes

Hashes for powergridforge-1.1.3.tar.gz
Algorithm Hash digest
SHA256 0c954847671fd4c80db72e7e8ad495eced8dbeb110b1206eb4e47f77850fe3bb
MD5 8ef12c937e7ea03088ac4ab97bfa1faa
BLAKE2b-256 fc42b9b2d9685c8fcd026d11e56d248b96ba08cb34a5d3c0ab614ecc75562222

See more details on using hashes here.

File details

Details for the file powergridforge-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: powergridforge-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 58.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.18

File hashes

Hashes for powergridforge-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b8c1ed8ca77f46a6b4d842a3faf25f4d2ff51a3703ab208f89ca7c860659cd34
MD5 7bbc2ea06be4dd33b793bdef45c6148b
BLAKE2b-256 ee8c6929e1417edeb79a56351c904eb48c036807b209e787a6a687e445992a0d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page