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

AC Optimal Power Flow
DC Optimal Power Flow

AC Optimal Power Flow

JuliaGrid.acOptimalPowerFlowFunction
acOptimalPowerFlow(system::PowerSystem, optimizer;
    iteration, tolerance, bridge, name, magnitude, angle, active, reactive, verbose)

The function sets up the optimization model for solving the AC optimal power flow problem.

Arguments

The function requires the PowerSystem 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.

Keywords

Users can configure the following parameters:

  • iteration: Specifies the maximum number of iterations.
  • tolerance: Specifies the allowed deviation from the optimal solution.
  • bridge: Manage the bridging mechanism (default: false).
  • name: Manage the creation of string names (default: true).
  • verbose: Controls the output display, ranging from silent mode (0) to detailed output (3).

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.

Updates

If the AC model has not been created, the function automatically initiates an update within the ac field of the PowerSystem type.

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; iteration = 50, verbose = 1)
source
JuliaGrid.solve!Method
solve!(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)
source
JuliaGrid.setInitialPoint!Method
setInitialPoint!(source::Union{PowerSystem, Analysis}, target::ACOptimalPowerFlow)

The function can reset the initial point of the AC optimal power flow to values from the PowerSystem type. It can also initialize the AC optimal power flow based on results from the Analysis type, whether from an AC or DC analysis.

The function assigns the active and reactive power outputs of the generators, along with the bus voltage magnitudes and angles in the target argument, using data from the source argument. This allows users to initialize primal values as needed. Additionally, if source is of type ACOptimalPowerFlow, the function also assigns initial dual values in the target argument based on data from source.

If source comes from a DC analysis, only the active power outputs of the generators and bus voltage angles are assigned in the target argument, while the reactive power outputs of the generators and bus voltage magnitudes remain unchanged. Additionally, if source is of type DCOptimalPowerFlow, the corresponding dual variable values are also assigned in the target argument.

Updates

This function may modify the voltage, generator, and method.dual fields of the ACOptimalPowerFlow type.

Examples

Reset the initial point of the AC optimal power flow:

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)

setInitialPoint!(system, analysis)
solve!(system, analysis)

Use the AC power flow results to initialize the AC optimal power flow:

system = powerSystem("case14.h5")
acModel!(system)

powerFlow = newtonRaphson(system)
powerFlow!(system, powerFlow)

analysis = acOptimalPowerFlow(system, Ipopt.Optimizer)

setInitialPoint!(powerFlow, analysis)
solve!(system, analysis)
source
JuliaGrid.powerFlow!Method
powerFlow!(system::PowerSystem, analysis::ACOptimalPowerFlow;
    iteration, tolerance, power, current, verbose)

The function serves as a wrapper for solving AC optimal power flow and includes the functions:

It computes the active and reactive power outputs of the generators, as well as the bus voltage magnitudes and angles, with an option to compute the powers and currents related to buses and branches.

Keywords

Users can use the following keywords:

  • iteration: Specifies the maximum number of iterations.
  • tolerance: Specifies the allowed deviation from the optimal solution.
  • power: Enables the computation of powers (default: false).
  • current: Enables the computation of currents (default: false).
  • verbose: Controls the output display, ranging from the default silent mode (0) to detailed output (3).

Example

system = powerSystem("case14.h5")
acModel!(system)

analysis = acOptimalPowerFlow(system, Ipopt.Optimizer)
powerFlow!(system, analysis; power = true, verbose = 1)
source

DC Optimal Power Flow

JuliaGrid.dcOptimalPowerFlowFunction
dcOptimalPowerFlow(system::PowerSystem, optimizer;
    iteration, tolerance, bridge, name, angle, active, verbose)

The function sets up the optimization model for solving the DC optimal power flow problem.

Arguments

The function requires the PowerSystem 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.

Keywords

Users can configure the following parameters:

  • iteration: Specifies the maximum number of iterations.
  • tolerance: Specifies the allowed deviation from the optimal solution.
  • bridge: Manage the bridging mechanism (default: false).
  • name: Manage the creation of string names (default: true).
  • verbose: Controls the output display, ranging from the default silent mode (0) to detailed output (3).

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.

Updates

If the DC model has not been created, the function automatically initiates an update within the dc field of the PowerSystem type.

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, Ipopt.Optimizer)
source
JuliaGrid.solve!Method
solve!(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, Ipopt.Optimizer)
solve!(system, analysis)
source
JuliaGrid.setInitialPoint!Method
setInitialPoint!(source::Union{PowerSystem, Analysis}, target::DCOptimalPowerFlow)

The function can reset the initial point of the DC optimal power flow to values from the PowerSystem type. It can also initialize the DC optimal power flow based on results from the Analysis type, whether from an AC or DC analysis.

The function assigns the active power outputs of the generators, along with the bus voltage angles in the target argument, using data from the source argument. This allows users to initialize primal values as needed. Additionally, if source is of type ACOptimalPowerFlow or DCOptimalPowerFlow, the function also assigns initial dual values in the target argument based on data from source.

Updates

This function may modify the voltage, generator, and method.dual fields of the DCOptimalPowerFlow type.

Examples

Reset the initial point of the DC optimal power flow:

system = powerSystem("case14.h5")
dcModel!(system)

analysis = dcOptimalPowerFlow(system, Ipopt.Optimizer)
solve!(system, analysis)

updateBus!(system, analysis; label = 14, active = 0.1, angle = -0.17)

setInitialPoint!(system, analysis)
solve!(system, analysis)

Use the DC power flow results to initialize the DC optimal power flow:

system = powerSystem("case14.h5")
dcModel!(system)

powerFlow = dcPowerFlow(system)
solve!(system, powerFlow)

analysis = dcOptimalPowerFlow(system, Ipopt.Optimizer)

setInitialPoint!(powerFlow, analysis)
solve!(system, analysis)
source
JuliaGrid.powerFlow!Method
powerFlow!(system::PowerSystem, analysis::DCOptimalPowerFlow;
    iteration, tolerance, power, verbose)

The function serves as a wrapper for solving DC optimal power flow and includes the functions:

It computes the active power outputs of the generators, as well as the bus voltage angles, with an option to compute the powers related to buses and branches.

Keywords

Users can use the following keywords:

  • iteration: Specifies the maximum number of iterations.
  • tolerance: Specifies the allowed deviation from the optimal solution.
  • power: Enables the computation of powers (default: false).
  • verbose: Controls the output display, ranging from the default silent mode (0) to detailed output (3).

Example

system = powerSystem("case14.h5")
dcModel!(system)

analysis = dcOptimalPowerFlow(system, Ipopt.Optimizer)
powerFlow!(system, analysis; power = true, verbose = 1)
source