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

Clone the repository:

git clone https://github.com/senzhanopt/grid_feedback_optimizer.git
cd grid_feedback_optimizer

Install dependencies for all parts:

pip install -r requirements.txt

Install the project in editable mode

pip install -e .

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: grid_feedback_optimizer-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 057eb454b48114259876499ad081e22ffcb746b5bd969c4988b6bb0237b66a1e
MD5 ef00759fa868c38f0c5083517d3aef8a
BLAKE2b-256 6610592aae3b9b92fa6032cc8b56226d67938327833c98fb24c755d374171957

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grid_feedback_optimizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bdaef3ca6367a4e5063d4d3669d32ba17560820a9d74de09dc64eeac0d9899b
MD5 affd5071e29dd27537169ef212f3199b
BLAKE2b-256 075930c7c0f5f55eadae4262fbe257d96adf75285891094dd9d7297ba8d625e4

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