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.4.tar.gz (18.9 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.4-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: grid_feedback_optimizer-0.1.4.tar.gz
  • Upload date:
  • Size: 18.9 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.4.tar.gz
Algorithm Hash digest
SHA256 c70aefdfb0b8bc605fa2e01e12c4a0108ab482cb1769a07672f0630d7e7789f8
MD5 4e0e75749a2850efae222847c06a85cd
BLAKE2b-256 2b223d5fdedee608e9ddf31ad49114bb95c45834ddfa8c04cf10faf35ca0b77b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grid_feedback_optimizer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b1750ef8fe48c9ba0867b8ba571d955f9bd7445248029020b9e555e36e48bd0d
MD5 40476cf5a02b6d19560ee6d4d6727e03
BLAKE2b-256 f9cc37713c3e59cd8e2c697e62685568b64a867b9c2b67190aaa8545799500ca

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