Optimal Power Flow
For further information on this topic, please see the AC Optimal Power Flow or DC Optimal Power Flow sections of the Manual. Below, we have provided a list of functions that can be utilized for optimal power flow analysis.
To load optimal power flow API functionalities into the current scope, one can employ the following command:
using JuliaGrid, Ipopt, HiGHS
AC Optimal Power Flow
DC Optimal Power Flow
AC Optimal Power Flow
JuliaGrid.acOptimalPowerFlow
— FunctionacOptimalPowerFlow(system::PowerSystem, optimizer; bridge, name,
magnitude, angle, active, reactive)
The function sets up the optimization model for solving the AC optimal power flow problem.
Arguments
The function requires the PowerSystem
composite type to establish the framework. Next, the optimizer
argument is also required to create and solve the optimization problem. Specifically, JuliaGrid constructs the AC optimal power flow using the JuMP package and provides support for commonly employed solvers. For more detailed information, please consult the JuMP documentation.
Updates
If the AC model has not been created, the function automatically initiates an update within the ac
field of the PowerSystem
type.
Keywords
JuliaGrid offers the ability to manipulate the jump
model based on the guidelines provided in the JuMP documentation. However, certain configurations may require different method calls, such as:
bridge
: manage the bridging mechanism (default:false
),name
: manage the creation of string names (default:true
).
Additionally, users can modify variable names used for printing and writing through the keywords magnitude
, angle
, active
, and reactive
. For instance, users can choose magnitude = "V"
and angle = "θ"
to display equations in a more readable format.
Returns
The function returns an instance of the ACOptimalPowerFlow
type, which includes the following fields:
voltage
: The bus voltage magnitudes and angles.power
: The variable allocated to store the active and reactive powers.current
: The variable allocated to store the currents.method
: The JuMP model, references to the variables, constraints, and objective.
Example
system = powerSystem("case14.h5")
acModel!(system)
analysis = acOptimalPowerFlow(system, Ipopt.Optimizer)
JuliaGrid.solve!
— Methodsolve!(system::PowerSystem, analysis::ACOptimalPowerFlow)
The function solves the AC optimal power flow model, computing the active and reactive power outputs of the generators, as well as the bus voltage magnitudes and angles.
Updates
The calculated active and reactive powers, as well as voltage magnitudes and angles, are stored in the power.generator
and voltage
fields of the ACOptimalPowerFlow
type.
Example
system = powerSystem("case14.h5")
acModel!(system)
analysis = acOptimalPowerFlow(system, Ipopt.Optimizer)
solve!(system, analysis)
JuliaGrid.startingPrimal!
— MethodstartingPrimal!(system::PowerSystem, analysis::ACOptimalPowerFlow)
The function retrieves the active and reactive power outputs of the generators, as well as the voltage magnitudes and angles from the PowerSystem
composite type. It then assigns these values to the ACOptimalPowerFlow
type, allowing users to initialize starting primal values as needed.
Updates
This function only updates the voltage
and generator
fields of the ACOptimalPowerFlow
type.
Example
system = powerSystem("case14.h5")
acModel!(system)
analysis = acOptimalPowerFlow(system, Ipopt.Optimizer)
solve!(system, analysis)
updateBus!(system, analysis; label = 14, reactive = 0.13, magnitude = 1.2, angle = -0.17)
startingPrimal!(system, analysis)
solve!(system, analysis)
JuliaGrid.startingDual!
— MethodstartingDual!(system::PowerSystem, analysis::ACOptimalPowerFlow)
The function removes all values of the dual variables.
Updates
This function only updates the dual
field of the ACOptimalPowerFlow
type.
Example
system = powerSystem("case14.h5")
acModel!(system)
analysis = acOptimalPowerFlow(system, Ipopt.Optimizer)
solve!(system, analysis)
updateBus!(system, analysis; label = 14, reactive = 0.13, magnitude = 1.2, angle = -0.17)
startingDual!(system, analysis)
solve!(system, analysis)
DC Optimal Power Flow
JuliaGrid.dcOptimalPowerFlow
— FunctiondcOptimalPowerFlow(system::PowerSystem, optimizer; bridge, name, angle, active)
The function sets up the optimization model for solving the DC optimal power flow problem.
Arguments
The function requires the PowerSystem
composite type to establish the framework. Next, the optimizer
argument is also required to create and solve the optimization problem. Specifically, JuliaGrid constructs the DC optimal power flow using the JuMP package and provides support for commonly employed solvers. For more detailed information, please consult the JuMP documentation.
Updates
If the DC model has not been created, the function automatically initiates an update within the dc
field of the PowerSystem
type.
Keywords
JuliaGrid offers the ability to manipulate the jump
model based on the guidelines provided in the JuMP documentation. However, certain configurations may require different method calls, such as:
bridge
: manage the bridging mechanism (default:false
),name
: manage the creation of string names (default:true
).
Additionally, users can modify variable names used for printing and writing through the keywords angle
and active
. For instance, users can choose angle = "θ"
to display equations in a more readable format.
Returns
The function returns an instance of the DCOptimalPowerFlow
type, which includes the following fields:
voltage
: The variable allocated to store the bus voltage angle,power
: The variable allocated to store the active powers,method
: The JuMP model, references to the variables, constraints, and objective.
Example
system = powerSystem("case14.h5")
dcModel!(system)
analysis = dcOptimalPowerFlow(system, HiGHS.Optimizer)
JuliaGrid.solve!
— Methodsolve!(system::PowerSystem, analysis::DCOptimalPowerFlow)
The function solves the DC optimal power flow model, computing the active power outputs of the generators, as well as the bus voltage angles.
Updates
The calculated active powers, as well as voltage angles, are stored in the power.generator
and voltage
fields of the DCOptimalPowerFlow
type.
Example
system = powerSystem("case14.h5")
dcModel!(system)
analysis = dcOptimalPowerFlow(system, HiGHS.Optimizer)
solve!(system, analysis)
JuliaGrid.startingPrimal!
— MethodstartingPrimal!(system::PowerSystem, analysis::DCOptimalPowerFlow)
The function retrieves the active power outputs of the generators and the bus voltage angles from the PowerSystem
composite type. These values are then assigned to the DCOptimalPowerFlow
type, enabling users to initialize starting primal values according to their requirements.
Updates
This function only updates the voltage
and generator
fields of the DCOptimalPowerFlow
type.
Example
system = powerSystem("case14.h5")
dcModel!(system)
analysis = dcOptimalPowerFlow(system, HiGHS.Optimizer)
solve!(system, analysis)
updateBus!(system, analysis; label = 14, active = 0.1, angle = -0.17)
startingPrimal!(system, analysis)
solve!(system, analysis)
JuliaGrid.startingDual!
— MethodstartingDual!(system::PowerSystem, analysis::DCOptimalPowerFlow)
The function removes all values of the dual variables.
Updates
This function only updates the dual
field of the DCOptimalPowerFlow
type.
Example
system = powerSystem("case14.h5")
dcModel!(system)
analysis = dcOptimalPowerFlow(system, HiGHS.Optimizer)
solve!(system, analysis)
updateBus!(system, analysis; label = 14, active = 0.1, angle = -0.17)
startingDual!(system, analysis)
solve!(system, analysis)