Optimal Power Flow Module¶
This module provides functions for AC/DC hybrid optimal power flow analysis [1].
functions are found in pyflow_acdc.ACDC_OPF and pyflow_acdc.ACDC_OPF_model
AC/DC Hybrid Optimal Power Flow¶
Running the OPF¶
This function runs the AC/DC hybrid optimal power flow calculation. It creates the model, chooses an objective function, and solves the model.
- Optimal_PF(grid, ObjRule=None, PV_set=False, OnlyGen=True, Price_Zones=False)¶
Performs AC/DC hybrid optimal power flow calculation.
Parameter
Type
Description
Default
gridGrid
Grid to optimize
Required
ObjRuledict
Objective function weights
None
PV_setbool
Sets PV and Slack voltage as fixed variables
False
OnlyGenbool
Only generators are considered in the cost function
True
Price_Zonesbool
Enable price zone constraints
False
Example
model, model_res , timing_info, solver_stats =pyf.Optimal_PF(grid, ObjRule=None, PV_set=False, OnlyGen=True, Price_Zones=False)
Creating the OPF model¶
- OPF_createModel_ACDC(model, grid, PV_set, Price_Zones)¶
Creates the OPF model.
Parameter
Type
Description
modelModel
Model to create
gridGrid
Grid to optimize
PV_setbool
Sets PV and Slack voltage as fixed variables
Price_Zonesbool
Enable price zone constraints
Variables
The optimization model includes variables for:
AC node voltages and angles
DC node voltages
Generator active/reactive power
Renewable generation and curtailment
Line flows
Converter power flows
Price zone variables
Constraints
The model enforces constraints for:
Voltage and angle limits
For more details on the constraints, please refer to the System Modelling page.
Example
model = pyf.OPF_createModel_ACDC(model,grid,PV_set,Price_Zones)
Objective Functions¶
The user can define the objective by setting the weight of each sub objective. The objective function is defined as:
- OPF_obj(model, grid, ObjRule, OnlyGen, OnlyAC=False)¶
This function creates a weighted sum of the different sub objectives.
\[\min \frac{\sum_{i \in O} \left( w_i \cdot f_i \right)}{\sum_{i \in O} w_i}\]where \(f_i\) is the sub objective and \(w_i\) is the weight.
The following table shows the pre-built objective functions as defined in [1] :
Weight
Description
Formula
Ext_GenExternal generation minimization or maximum export
\(\sum_{g \in G} \cdot P_{g}\)
Energy_costEnergy cost
\(\sum_{g \in \mathcal{G}_{ac}} \left(P_{g}^2 \cdot \alpha_g + P_{g} \cdot \beta_g \right)\)
Curtailment_RedRenewable curtailment reduction
\(\sum_{rg \in \mathcal{RG}_{ac}}\left((1-\gamma_rg)P_{rg}\cdot \rho_{rg} \sigma_{rg}\right)\)
AC_lossesAC transmission losses
\(\sum_{j \in \mathcal{B}_{ac}} \left( P_{j,\text{from}} +P_{j,\text{to}} \right)\)
DC_lossesDC transmission losses
\(\sum_{e \in \mathcal{B}_{dc}} \left( P_{e,\text{from}} +P_{e,\text{to}} \right)\)
Converter_LossesConverter losses
\(\sum_{cn \in \mathcal{C}_{n}} \left( P_{loss_{cn}} + |\left(P_{c_{cn}}-P_{s_{cn}}\right)| \right)\)
General_LossesGeneration minus demand
\(\left(\sum_{g \in \mathcal{G}} P_{g}+\sum_{rg \in \mathcal{RG}} P_{rg}*\gamma_{rg}- \sum_{l \in \mathcal{L}} P_{L} \right)\)
The following table shows the pre-built objective functions as defined in [2]:
Weight
Description
Formula
PZ_cost_of_generationPrice zone generation cost
\(\sum_{m \in \mathcal{M}} CG(P_N)_m\)
The following table shows the pre-built objective functions in development:
Weight
Description
Formula
Renewable_profitRenewable generation profit
\(- \left(\sum_{rg \in \mathcal{RG}} P_{rg}*\gamma_{rg} + \sum_{cn \in \mathcal{C}} \left(P_{loss,cn} + P_{AC,loss,cn}\right)\right)\)
Gen_set_devGenerator setpoint deviation
\(\sum_{g \in G} \left(P_g -P_{g,set}\right)^2\)
Example
weights_def = { 'Ext_Gen': {'w': 0}, 'Energy_cost': {'w': 0}, 'Curtailment_Red': {'w': 0}, 'AC_losses': {'w': 0}, 'DC_losses': {'w': 0}, 'Converter_Losses': {'w': 0}, 'PZ_cost_of_generation': {'w': 0}, 'Renewable_profit': {'w': 0}, 'Gen_set_dev': {'w': 0} }
Solvers¶
The OPF module supports pyomo solvers.
To see the available solvers, use the following command:
pyomo help --solvers
Tested with:
IPOPT
Bonmin
- OPF_solve(model, grid, solver='ipopt')¶
Solves the OPF model using the specified solver.
- Parameters:
model – The optimization model
grid – The grid to optimize
solver – The solver to use
Example
results, solver_stats =pyf.OPF_solve(model,grid)
References