Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”‹βš‘ ADMM-based Distributed AC Optimal Power Flow

Python Pyomo OpenDSS License

Distributed AC Optimal Power Flow using Alternating Direction Method of Multipliers (ADMM)

This repository implements a fully distributed optimization framework for coordinating 37 prosumers (households with solar PV, battery storage, and reactive power control) in a distribution network using the ADMM algorithm.


πŸ“‹ Table of Contents


🎯 Overview

Modern distribution networks face increasing challenges with high penetration of Distributed Energy Resources (DERs) such as:

  • β˜€οΈ Rooftop solar PV
  • πŸ”‹ Battery energy storage systems
  • πŸ”Œ Electric vehicles
  • 🏭 Controllable loads

This project demonstrates a privacy-preserving, distributed optimization approach using ADMM to coordinate these resources while:

  • βœ… Maintaining voltage regulation (0.95-1.05 p.u.)
  • βœ… Minimizing energy costs through Time-of-Use (ToU) pricing
  • βœ… Optimizing battery charging/discharging schedules
  • βœ… Reducing PV curtailment
  • βœ… Providing reactive power support (Volt-VAR Control)

✨ Key Features

πŸ—οΈ Distributed Architecture

  • Network-level coordinator (utility/DSO) manages voltage and grid constraints
  • 37 prosumer-level optimizers make independent decisions
  • Consensus achieved through ADMM dual variable updates
  • Privacy-preserving: prosumers don't share detailed consumption data

πŸ”‹ Multi-Period Energy Management

  • 24 time periods (12-hour horizon, half-hour intervals)
  • Battery scheduling for peak shaving and energy arbitrage
  • PV curtailment optimization to avoid overvoltage
  • Reactive power dispatch for voltage support

⚑ Technical Capabilities

  • AC Power Flow accuracy (nonlinear, not DC approximation)
  • Voltage regulation: 100% compliance with ANSI C84.1 (0.95-1.05 p.u.)
  • Scalability: Linear computation time scaling with network size
  • Solver: IPOPT (Interior Point Optimizer) for nonlinear programming

πŸ’° Economic Optimization

  • Time-of-Use pricing integration
  • Demand response capability
  • Cost savings: 25-35% reduction vs. uncoordinated operation
  • Grid export compensation (feed-in tariff)

🌐 Network Description

Montreal Custom Feeder

  • Voltage Level: 12.47 kV (primary), 0.48 kV (secondary)
  • Topology: Radial distribution network
  • Total Buses: 72 (in OpenDSS physical model)
  • Load Buses: 37 (active residential loads)
  • Total Loads: 46 (37 active + 9 EV chargers commented out)

Prosumer Specifications

  • Number: 37 households
  • PV Capacity: 5-60 kW per household
  • Battery: 7.5 kWh capacity, Β±1.75 kW power
  • Inverter: Sized at 1.1Γ— max(PV), 10% reactive capability
  • All prosumers have PV + Battery + VVC capability

πŸ”¬ Methodology

ADMM Formulation

The distributed optimization problem is formulated as:

minimize    f(x) + Ξ£α΅’ gα΅’(zα΅’)
subject to  x = zα΅’,  βˆ€i

Where:

  • x: Network variables (voltages, grid power)
  • zα΅’: Prosumer i variables (battery, PV, reactive power)
  • f(x): Network cost function (grid energy cost + voltage deviation)
  • gα΅’(zα΅’): Prosumer i cost function (energy cost + ADMM penalties)

Iterative Algorithm

for iteration k = 1, 2, ..., max_iterations:
    # 1. X-update (Network Aggregator)
    x^(k+1) = argmin_x { f(x) + (ρ/2)Σᡒ ||x - zᡒ^k + λᡒ^k||² }
    
    # 2. Z-update (Prosumer Optimizations - Parallel)
    for each prosumer i:
        zᡒ^(k+1) = argmin_zᡒ { gᡒ(zᡒ) + (ρ/2)||x^(k+1) - zᡒ + λᡒ^k||² }
    
    # 3. Ξ»-update (Dual Variables)
    λᡒ^(k+1) = λᡒ^k + ρ(x^(k+1) - zᡒ^(k+1))
    
    # 4. Check Convergence
    if ||x^(k+1) - zα΅’^(k+1)||Β² < Ξ΅:
        break

Network Variables (X-update)

  • Bus voltages: Vα΅’, ΞΈα΅’
  • Grid power: Pβ‚˜α΅£α΅’π’Ή, Qβ‚˜α΅£α΅’π’Ή
  • Prosumer injections: Pα΅’, Qα΅’

Prosumer Variables (Z-update)

  • Battery: P_bat_charge, P_bat_discharge, SoC
  • PV: P_pv, P_curtail
  • Reactive: Q_reactive
  • Grid: P_import, P_export

πŸ’» Installation

Prerequisites

# Python 3.8 or higher
python --version

# Required packages
pip install numpy pandas matplotlib seaborn
pip install pyomo
pip install dss-python

# Install IPOPT solver (one of the following):

# Option 1: Using conda (recommended)
conda install -c conda-forge ipopt

# Option 2: Using pip
pip install cyipopt

# Option 3: System package manager
# Ubuntu/Debian:
sudo apt-get install coinor-libipopt-dev

# macOS:
brew install ipopt

Clone Repository

git clone https://github.com/yourusername/Custom_Feeder_ADMM.git
cd Custom_Feeder_ADMM

Verify Installation

import pyomo.environ as pyo
from pyomo.opt import SolverFactory

solver = SolverFactory('ipopt')
assert solver.available(), "IPOPT solver not available"
print("βœ… All dependencies installed successfully!")

πŸš€ Usage

Quick Start

  1. Open Jupyter Notebook:

    jupyter notebook Custom_Design.ipynb
  2. Run All Cells:

    • Click Kernel β†’ Restart & Run All
    • Or run cells sequentially (Shift+Enter)
  3. Expected Runtime:

    • OpenDSS baseline: ~5 seconds
    • Centralized AC-OPF: ~10 seconds
    • ADMM (100 iterations): ~70 seconds

Customization

Modify Number of Prosumers

# In Cell 13
n_prosumers = 25  # Change from 37 to any value ≀ 37
prosumer_ids = list(range(1, n_prosumers + 1))

Adjust Time Horizon

# In Cell 13
T_periods = list(price_data.index[:48])  # Full 24 hours (48 half-hour periods)

Tune ADMM Parameters

# In Cell 15 (Network Model)
rho_P_network = 100.0  # Increase for faster convergence (default: 50.0)
rho_Q_network = 20.0   # Increase for better reactive power consensus (default: 10.0)

Change Battery Parameters

# In Cell 14 (Prosumer Models)
battery_params = {
    'P_max': 3.5,      # kW (default: 1.75)
    'E_capacity': 15.0, # kWh (default: 7.5)
    'eta_charge': 0.95, # efficiency (default: 0.92)
    'eta_discharge': 0.95,
    'SoC_min': 0.20,   # 20% (default: 0.10)
    'SoC_max': 0.90,   # 90% (default: 0.90)
}

πŸ“Š Results

Performance Summary (37 Prosumers, 24 Time Periods)

Category Metric Value
Network Scale Total Prosumers 37
Network Buses 38 (37 prosumer + 1 slack)
Time Periods 24 (0-11.5 hours)
Decision Variables ~3,360
Energy Flows Total Demand ~450-500 kWh
Total PV Available ~550-600 kWh
PV Curtailment 20-25%
Grid Dependency 55-65%
Battery Total Charged ~40-45 kWh
Total Discharged ~40-45 kWh
Round-trip Efficiency ~90-95%
Voltage Compliance Rate 100%
Min Voltage 0.95-0.98 p.u.
Max Voltage 1.02-1.05 p.u.
Economics Grid Cost (12h) $20-25
Avg Energy Price $0.07-0.09/kWh
Cost Savings 25-35%
Computation Total Time (100 iter) ~70 seconds
Time per Iteration ~0.7 seconds
Solver Success Rate 100%

Key Insights

βœ… Scalability: Linear scaling - 37 prosumers solved in ~0.7 sec/iteration (vs. 0.47 sec for 5 prosumers)

βœ… Voltage Regulation: Perfect compliance (0/888 violations) across all buses and time periods

βœ… Battery Utilization: Optimal charging during low ToU prices, discharging during peak

βœ… PV Integration: High PV penetration (>100% of demand) managed through coordinated curtailment

βœ… Convergence: ADMM typically converges or stabilizes within 50-100 iterations


πŸ“ Project Structure

Custom_Feeder_ADMM/
β”œβ”€β”€ Custom_Design.ipynb          # Main notebook with full implementation
β”œβ”€β”€ README.md                     # This file
β”œβ”€β”€ Montreal_Custom.dss           # OpenDSS network definition
β”œβ”€β”€ Custom_2xy.csv                # Bus coordinates for plotting
β”œβ”€β”€ LineCodes.DSS                 # Line impedance parameters
β”œβ”€β”€ Montreal_BusXY.csv            # Bus location data
β”‚
β”œβ”€β”€ Networks/
β”‚   └── NetworkMontreal.csv       # 25 households Γ— 48 time periods
β”‚
β”œβ”€β”€ Households/
β”‚   └── NetworkMontreal/
β”‚       β”œβ”€β”€ 1.csv                 # Household 1 load/PV profile
β”‚       β”œβ”€β”€ 2.csv                 # Household 2 load/PV profile
β”‚       └── ...                   # Up to 36.csv
β”‚
β”œβ”€β”€ Prices/
β”‚   └── PriceSignal_Montreal.csv  # Time-of-Use tariff (48 periods)
β”‚
β”œβ”€β”€ Results/
β”‚   β”œβ”€β”€ ADMM_Performance_Summary.csv
β”‚   β”œβ”€β”€ ADMM_Convergence_History.csv
β”‚   └── ADMM_Voltage_Results.csv
β”‚
└── plots/
    β”œβ”€β”€ OpenDSS_Voltage_Analysis.png
    β”œβ”€β”€ ADMM_Convergence_Results.png
    └── Voltage_Comparison_OpenDSS_vs_Pyomo.csv

πŸ“š References

ADMM Theory

  • Boyd, S., Parikh, N., Chu, E., Peleato, B., & Eckstein, J. (2011). Distributed optimization and statistical learning via the alternating direction method of multipliers. Foundations and Trends in Machine Learning, 3(1), 1-122.
  • Erseghe, T. (2014). Distributed optimal power flow using ADMM. IEEE Transactions on Power Systems, 29(5), 2370-2380.

Power System Standards

  • IEEE Std 1547-2018: Standard for Interconnection and Interoperability of Distributed Energy Resources with Associated Electric Power Systems Interfaces
  • ANSI C84.1-2020: Electric Power Systems and Equipmentβ€”Voltage Ratings (60 Hertz)

Software Tools

  • OpenDSS: Dugan, R. C., & Montenegro, D. (2020). OpenDSS PVSystem and InvControl Element Models. EPRI.
  • Pyomo: Hart, W. E., Laird, C. D., Watson, J. P., Woodruff, D. L., et al. (2017). Pyomo–optimization modeling in Python (Vol. 67, p. 277). Berlin: Springer.
  • IPOPT: WΓ€chter, A., & Biegler, L. T. (2006). On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming. Mathematical Programming, 106(1), 25-57.

πŸ“– Citation

If you use this code in your research, please cite:

@software{admm_acopf_montreal_2025,
  author       = {Khan, B.},
  title        = {{ADMM-based Distributed AC Optimal Power Flow 
                   for Distribution Networks}},
  year         = 2025,
  publisher    = {GitHub},
  url          = {https://github.com/yourusername/Custom_Feeder_ADMM},
  note         = {Montreal Custom Feeder Case Study with 37 Prosumers}
}

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2025 B. Khan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Potential Contributions

  • Extend to full 48-period day-ahead optimization
  • Implement complete IEEE 1547 Q(V) curves
  • Add Volt-Watt control (VWC)
  • Incorporate uncertainty quantification for PV
  • Add electric vehicle (EV) charging optimization
  • Implement multi-day rolling horizon optimization
  • Create real-time ADMM variant
  • Add network reconfiguration capability

πŸ“§ Contact

Author: B. Khan
Email: [your.email@domain.com]
GitHub: @yourusername

For questions, issues, or collaboration opportunities:


πŸ™ Acknowledgments

  • OpenDSS Team at EPRI for the powerful distribution system simulator
  • Pyomo Development Team for the flexible optimization modeling framework
  • IPOPT Team for the robust nonlinear solver
  • Montreal Utility for providing the network topology and load data

⭐ If you find this project helpful, please consider giving it a star! ⭐

Made with ❀️ and β˜• by B. Khan

About

Extending the work of Daniel Gebbran and Co. to custom MOntreal Feeder!

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages