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.3.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.3-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: grid_feedback_optimizer-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 a4fc621016d20a4662d71c69b1cd199ab7556c296b5bf7062bfb5fd8d9ab6c4e
MD5 8f7460885e6d83909a61118ce930cf49
BLAKE2b-256 a1d132625fb014f8931fe8ceebc625af74a10e7b317c1af07d5a1d0de9f494c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grid_feedback_optimizer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 08177be57f92f61b2f216e6c3d4ed5e0dd28f6665e3b29ef04246aabbf6bb180
MD5 f42c59cdfbf7ef3771b0872ac7ebaabf
BLAKE2b-256 774532f6ed1821f89c3d6c62c39c235688093a6e5ffe474d84ef54d9287d1489

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