AC ‘dc linear’ Optimal Power Flow Module¶
This module provides functions for AC ‘dc linear’ optimal power flow analysis [1].
functions are found in pyflow_acdc.AC_OPF_L_model
AC ‘dc linear’ Optimal Power Flow¶
Running the OPF¶
This flow sets up and solves the AC ‘dc linear’ OPF. It creates the model, optionally adds TEP/REC/CT investment variables, and solves with a Pyomo solver. Results are then exported back to the grid.
import pyflow_acdc as pyf
pyf.Optimal_L_PF(grid,ObjRule=None,PV_set=False,OnlyGen=True,Price_Zones=False,solver='glpk',tee=False)
Creating the Linear OPF model¶
- OPF_create_LModel_AC(model, grid, TEP=False)¶
Creates the AC ‘dc linear’ OPF model.
Parameter
Type
Description
modelModel
Pyomo model to populate
gridGrid
Grid to optimize
Price_Zonesbool
Enable price zone constraints (if applicable)
TEPbool
Enable TEP investment variables (lines/generators)
Variables
The linear OPF includes variables for:
AC node angles
Generator active power
Renewable generation via availability and curtailment factors
AC line active power flows
Constraints
The model enforces constraints for:
AC nodal active power balance (linearized)
Generator aggregation at nodes
Renewable injection aggregation at nodes
AC branch linearized power flow equations
Thermal limits (including linear big-M formulations for REC/CT states)
Slack angle constraints
Optional array network-flow conservation and investment-linking
Optional investment bounds for generators and lines (if TEP)
Example
from pyflow_acdc.AC_OPF_L_model import OPF_create_LModel_AC model = OPF_create_LModel_AC(model, grid, TEP=False)
TEP/REC/CT Parameters and Variables¶
- TEP_parameters(model, grid, AC_info, DC_info, Conv_info)¶
Sets parameters for TEP/REC/CT decisions (e.g., base multiplicities, initial configs, limits).
- TEP_variables(model, grid)¶
Adds investment variables: - Generator multiplicities (optional integer bounded by capability) - AC expansion line multiplicities (integer) - Reconfiguration branch selection (binary) - Cable-type selection (binary per type and line) - Optional type-usage flags and array flow variables
Exporting Results¶
- ExportACDC_Lmodel_toPyflowACDC(model, grid, Price_Zones, TEP=False, solver_results=None, tee=False)¶
Exports Pyomo solution back to the grid: - Generator dispatch and renewable gamma - AC node angles and injections - AC line flows and losses (linearized, zero reactive) - TEP/REC/CT selections and flows (including optional array network-flow) - Optional post-processing for time-limit cases (oversizing analysis and fixes)
Example
pyf.ExportACDC_Lmodel_toPyflowACDC(model, grid, Price_Zones=False, TEP=False, solver_results=results, tee=True)
Solvers¶
The linear OPF can be solved by LP/MIP solvers in Pyomo.
Tested with:
GLPK
Gurobi
Notes
If REC/CT/TEP or array flow variables are enabled, the problem becomes MIP. Prefer a MIP-capable solver (e.g.,
gurobi).