Skip to main content

Optimization methods for voltage and congestion management in modern power distribution grids.

Project description

Grid Feedback Optimizer

Python License: MIT

Overview

Grid Feedback Optimizer is a Python package that uses feedback optimization to optimize generator and device setpoints in electrical distribution grids. It reads a JSON/EXCEL network description and iteratively computes optimal setpoints.

This package is designed for experimenting with voltage regulation and congestion management, providing a flexible framework for feedback-based grid optimization.

Features

  • Load and simulate networks from JSON/EXCEL files.
  • Iterative feedback optimization using:
    • gradient projection (GP) algorithm,
    • primal-dual (PD) algorithm.
  • Structured input and output data.
  • Modular design (models, engine, utils) for extensions.

Repository Structure

grid_feedback_optimizer/
src/
    grid_feedback_optimizer/
        model/        # Loaders and I/O
        engine/       # Power flow / optimization logic
        utils/        # Helper functions
        main.py
examples/           # Example JSON/EXCEL network files
tests/              # Tests
requirements.txt    # Python dependencies
README.md

⚙️ Installation

Install from PyPI

pip install grid-feedback-optimizer

Usage

Python usage example:

from grid_feedback_optimizer.models.loader import load_network
from grid_feedback_optimizer.engine.solve import solve
from grid_feedback_optimizer.engine.powerflow import PowerFlowSolver

# Load network from example JSON
network = load_network("../examples/simple_example_with_transformer.json")

# Initialize and check power flow
power_flow_solver = PowerFlowSolver(network)

# Run optimization using the Gradient Projection (GP) algorithm
res_gp = solve(network, algorithm="gp")

# Display and store results
res_gp.print_summary()
res_gp.plot_iterations()
res_gp.save("gp_result.json")

Grid components

Follow power-grid-model for definition of buses (nodes), lines, transformers, and sources.

RenewGen

RenewGen models controllable generators and power-consuming devices.

  • Generator: p_max > 0 and p_min >= 0
  • Load: p_max < 0 and p_min <= 0
  • Flexible device: p_min < 0 < p_max (can generate or consume)

Key attributes:

  • index, bus: identifiers
  • p_max, p_min: active power limits
  • s_inv: apparent power rating
  • p_norm: normal active power (auto-computed if not set)
  • q_norm: normal reactive power (0.0 if not set)
  • c1_p: linear active power cost coefficients
  • c2_p: quadrtic active power cost coefficients for deviation from p_norm
  • c1_q: linear reactive power cost coefficients
  • c2_q: quadrtic reactive power cost coefficients for deviation from q_norm

Minimization cost function:

Cost = c1_p × p + c2_p × (p - p_norm)² + c1_q × q + c2_q × (q - q_norm)²

where p and q are the actual active and reactive power outputs.

p_norm is computed automatically:

  • Generator → p_norm = p_max
  • Load → p_norm = p_min
  • Flexible → p_norm = 0

Load

Load models non-controllable units, either a generator or a load.

  • Load: p_norm >= 0
  • Generator: p_norm < 0

Key attributes:

  • index, bus: identifiers
  • p_norm, q_norm: active and reactive power

License

This project is licensed under the MIT License.

Author

Developed and maintained by Sen Zhan
📧 Email: sen.zhan@outlook.com

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

grid_feedback_optimizer-0.1.1.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

grid_feedback_optimizer-0.1.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file grid_feedback_optimizer-0.1.1.tar.gz.

File metadata

  • Download URL: grid_feedback_optimizer-0.1.1.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for grid_feedback_optimizer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cacf9328e142421068a16eaf92c251f9ad8b3307708fe5d9c4b3db8dae8fb6b4
MD5 bf3d07b744b9c376c6cb3f298e3dc980
BLAKE2b-256 31303c874bfa40734d152d211d071968b5c4912c22e74aff528f273207c574e9

See more details on using hashes here.

File details

Details for the file grid_feedback_optimizer-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for grid_feedback_optimizer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8b9d34ac6d80bb36ffb392f25fa5eb3f9c8b7fa002a7a16811356f664d7c85e
MD5 f366a01c9df801adc645399823318c6c
BLAKE2b-256 e5b80ec0ec7b44280e1064465222ee546774cf0d80773841ca5ecf826c661151

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