Optimal power flow problems¶
Optimal power flow problems are comprised of the following elements
- Network
- Load case
- Power flow surrogate
- Optimization objective
- Controllable loads
- Specification of voltage at PCC
- Constraints on voltage magnitude
- (Optional) additional constraints (e.g., on the PCC load or line currents)
As is common for the Toolkit, there is a class to specify the problem @OPFspec.OPFspec and one for the actual problem @OPFproblem.OPFproblem.
uot.OPFspec: Specify OPF problems¶
-
class
OPFspec(pf_surrogate_spec, controllable_load_spec_array, objective_spec, pcc_voltage_spec, voltage_magnitude_spec, varargin)¶ Bases:
uot.ProblemSpecClass to specify an
uot.OPFproblem.Synopsis:
spec = uot.OPFspec(pf_surrogate_spec,controllable_load_spec_array,objective_spec,... pcc_voltage_spec,voltage_magnitude_spec,'pcc_load_spec',pcc_load_spec)
- Description:
- This class incorporates several specifications needed to specify an
uot.OPFproblem
Parameters: - pf_surrogate_spec (
uot.AbstractPowerFlowSurrogateSpec) – Power flow surrogate specification - controllable_load_spec_array (
uot.ControllableLoadSpec) – Array of controllable load specifications - objective_spec (
uot.ObjectiveSpec) – Objective specification - pcc_voltage_spec (
uot.PCCvoltageSpec) – Voltage at the PCC specification - voltage_magnitude_spec (
uot.VoltageMaginitudeSpec) – Specification of constraints on voltage magnitude
Keyword Arguments: ‘pcc_load_spec’ (
uot.PCCloadSpec) – Specification of constraints on the PCC loadSee also
-
OPFspec(pf_surrogate_spec, controllable_load_spec_array, objective_spec, pcc_voltage_spec, voltage_magnitude_spec, varargin)¶ Allow no-argument constructor for preallocation
-
controllable_load_spec_array= None¶ Array of controllable load specifications (
uot.ControllableLoadSpec)
-
objective_spec= None¶ Array of controllable load specifications (
uot.ControllableLoadSpec)
-
pcc_load_spec= 'uot.PCCloadSpec()'¶ Specification of constraints on voltage magnitude (
uot.PCCloadSpec)
-
pcc_voltage_spec= None¶ Array of controllable load specifications (
uot.PCCvoltageSpec)
-
pf_surrogate_spec= None¶ Power flow surrogate specification (
uot.AbstractPowerFlowSurrogateSpec)
-
voltage_magnitude_spec= None¶ Specification of constraints on the PCC load (
uot.VoltageMaginitudeSpec)
uot.OPFproblem: Solve OPF problems¶
-
class
OPFproblem(spec, load_case)¶ Bases:
uot.ProblemClass to represent Optimal Power Flow problems
Synopsis:
opf_problem = uot.OPFproblem(spec,load_case)
- Description:
- This class helps to formulate and solve unbalanced OPF problems
Parameters: - spec (
uot.OPFspec) – Specification of the OPF problem - load_case (
uot.LoadCasePy) – Model of uncontrollable loads
Note
The OPF formulation considers only wye-connected constant power loads, represented in an
uot.LoadCasePyobject. The reason is that more detailed models are typically non-convex [Taylor2015]. If loads are specified using the ZIP model, delta-to-wye conversions for some loads and approximating constant current and constant impedance loads as constant power ones is necessary. This can be done usinguot.LoadCaseZip.ConvertToLoadCasePy.-
OPFproblem(spec, load_case)¶ Allow no-argument constructor for preallocation
-
n_time_step= None¶ This is just for convenience
-
network= None¶ This is just for convenience
-
s_base_va= None¶ This is just for convenience
-
t_pcc_array= None¶ This is just for convenience
-
u_pcc_array= None¶ This is just for convenience
-
AssertConstraintSatisfaction(obj)¶ Verify that specified constraints are fulfilled
Synopsis:
opf_problem.AssertConstraintSatisfaction()
- Description:
- The specification of the OPF problem
uot.OPFspeccontains several constraints which we want the solution to fulfill. This method verifies that the solution does indeed fulfill these constraints.
Note
- This method requires solving the optimization problem first
- This method is meant to be used for debugging
-
AssignBaseCaseSolution(obj)¶ Assign no load solution to OPF problem
Synopsis:
[U_array,T_array,p_pcc_array,q_pcc_array] = opf_problem.AssignBaseCaseSolution()
- Description:
- This methods assigns zero load to the controllable loads. It then requests the power flow surrogate to assign the no load solution (i.e., only including the uncontrollable loads. Finally, it sets the pcc load to the no load solution.
Returns: - U_array (double) - Voltage magnitude array of the no-load solution
- T_array (double) - Voltage angle array of the no-load solution
- p_pcc_array (double) - Real power of the swing load in the no-load solution
- q_pcc_array (double) - Reactive power of the swing load in the no-load solution
Note
This method is meant for debugging infeasible problems. Typically, the no load solution should be feasible. After calling this method, we can use YALMIP’s
check()function to find out what constraints are infeasible.
-
EvaluatePowerInjectionFromPCCload(obj)¶ Compute the current value of the PCC load
Synopsis:
[p_pcc_array_val,q_pcc_array_val] = opf_problem.EvaluatePowerInjectionFromPCCload()
- Description:
- Compute the current value of the PCC load (which is an sdpvar) and return it
Returns: - p_pcc_array_val (double) - Array(n_time_step,n_phase) with active power due to the PCC load
- q_pcc_array_val (double) - Array(n_time_step,n_phase) with reactive power due to the PCC load
See also
uot.OPFproblem.GetPowerInjectionFromPCCload
-
GetConstraintArray(obj)¶ Assembles constraints for the OPF problem into an array
Synopsis:
constraint_array = opf_problem.GetConstraintArray()
- Description:
Requests constraints from controllable loads, PCC load and the used power flow surrogate. Then, puts them all into an array.
Implements
uot.ConstraintProvider.GetConstraintArray
Returns: - constraint_array (constraint) - Array of constraints
-
AssignControllableLoadsToNoLoad(obj)¶ (private) Assign no load solution to controllable loads
- Description:
- This methods assigns zero load to the controllable loads.
-
ComputeNodalPowerInjection(obj)¶ (private) Compute power injection at the buses from controllable and uncontrollable loads
Synopsis:
val = obj.ComputeNodalPowerInjection()
- Description:
- This method sums the power injection from the controllable loads, if there are any, with the power injection from the uncontrollable loads in the load case.
Returns: - P_inj_array (sdpvar) - Array(n_bus, n_phase, n_time_step) of active power injection
- Q_inj_array (sdpvar) - Array(n_bus, n_phase, n_time_step) of reactive power injection
-
CreateControllableLoadHashTable(obj)¶ (private) Instantiate controllable loads based on specifications and store them in a hash table
Synopsis:
controllable_load_hashtable = obj.CreateControllableLoadHashTable()
- Description:
- Instantiate controllable loads based on the specifications in
obj.spec.controllable_load_spec_array. Store the resulting controllable loads in a hash table.
Returns: - controllable_load_hashtable (
containers.Map) - Hash table of controllable loads
Note
- We use a hash table to store the controllable loads so that we can refer to them by name
- The hash table is implemented as a
containers.Map
-
CreateLoadSpecArrayWithControllableLoadValues(obj)¶ (private) Create an array of
uot.LoadPySpecwith the current value of the controllable loadsSynopsis:
load_spec_array = obj.CreateLoadSpecArrayWithControllableLoadValues()
- Description:
- This method first evaluates the current value of the controllable loads. Then,
these values are put into an array of
uot.LoadPySpec. This is part of the process to solve power flow with the current values of the controllable loads.
Returns: - load_spec_array (
uot.LoadPySpec) - Array(n_controllable_load) with the current value of the controllable loads
See also
uot.OPFproblem.SolvePFwithControllableLoadValues
-
DefineObjective_LoadCost(obj, objective_spec)¶ (private) Define objective of minimizing the cost of controllable loads.
Synopsis:
objective = obj.DefineObjective_LoadCost()
- Description:
- Compute the cost of the controllable loads according to the specification
in
uot.OPFobjectiveSpec_LoadCost.
Parameters: objective_spec ( uot.OPFobjectiveSpec_LoadCost) – Specification of controllable load costReturns: - objective (sdpvar) - Controllable load cost
See also
uot.OPFobjectiveSpec_LoadCostTodo
- Explain in
uot.OPFobjectiveSpec_LoadCostwhat the cost entails
-
GetControllableLoadConstraintArray(obj)¶ (private) Collects constraints from controllable loads into an array
Synopsis:
controllable_load_constraint_array = obj.GetControllableLoadConstraintArray()
- Description:
- Goes through all controllable loads requesting their constraints. Then, assembles all of them in an array.
Returns: - controllable_load_constraint_array (constraint) - Array of constraints from controllable loads
See also
uot.ControllableLoad.GetConstraintArray
Interfaces¶
uot.ConstraintProvider¶
-
class
ConstraintProvider(spec, decision_variables)¶ Bases:
uot.ObjectInterface to define building blocks of optimization problems, they are not necessarily solvable.
Synopsis:
obj = uot.ConstraintProvider(spec,decision_variables)
Parameters: - spec (
uot.Spec) – Object specification - decision_variables (struct) – Struct with decision variables (as sdpvars)
-
constraint_tol= '1e-6'¶ Tolerance for AssertConstraintSatisfaction
- spec (