# power_loadflow

Perform positive-sequence load flow or unbalanced load flow and initialize models containing load flow blocks

## Syntax

`LF = power_loadflow(sys,'solve')`

LF = power_loadflow(sys,'noupdate')

power_loadflow(sys,'solve','report')

power_loadflow(sys,'solve','report',fname)

power_loadflow(sys,'solve','ExcelReport',fname)

power_loadflow(sys,'AddBuses')

## Description

`LF = power_loadflow(sys,'solve')`

computes the load flow of
`sys`

. The model is initialized with the load flow solution.

`LF = power_loadflow(sys,'noupdate')`

computes the load flow but does
not initialize the model with the load flow solution.

`power_loadflow(sys,'solve','report')`

computes the load flow and opens
the editor to save the load flow report.

`power_loadflow(sys,'solve','report',fname)`

computes the load flow and
saves detailed information in the `fname`

file.

`power_loadflow(sys,'solve','ExcelReport',fname)`

computes the load
flow and saves detailed information in the `fname`

Excel^{®} file. This capability is available only for the positive-sequence load
flow.

`power_loadflow(sys,'AddBuses')`

adds Load Flow Bus
blocks to the model `sys`

. The added blocks are single-connector Load
Flow Bus blocks, which specify bus parameters for a positive-sequence load
flow.

**Note**

Before release R2021a, this function provided access to the machine tool initialization.
Although this is still possible, use this function in release R2021a and later to initialize
models containing electric machines. Although this function continues to support the
`-v2`

option, this option is no longer required to perform load flows.
You can remove this option from your scripts and M functions.

## Algorithms

The `power_loadflow`

function computes the positive-sequence load flow
or the unbalanced load flow of a Simscape™
Electrical™ Specialized Power Systems model and initializes the load flow blocks to start
simulation in steady-state. Load flow blocks are Simscape
Electrical Specialized Power Systems blocks in which you can specify active power (P) and
reactive power (Q) to solve the positive-sequence load flow.

The `power_loadflow`

function uses the Newton-Raphson method to provide
a robust and fast convergence solution and offers most of the functionality of other load flow
software available in the power utility industry.

The `power_loadflow`

function applies the load flow solution to the
model by initializing these block parameters:

The

**Phase-to-phase voltage**and**Phase angle of phase A**parameters of Three-Phase Source blocksThe

**Positive-sequence: [Amplitude Phase]**parameter of Three-Phase Programmable Voltage Source blocksThe

**Nominal phase-to-phase voltage**parameter of Three-Phase Parallel RLC Load and Three-Phase Series RLC Load blocksThe

**Active and reactive power at initial voltage [Po Qo]**parameter and**Initial positive-sequence voltage Vo [Mag(pu) Phase (deg.)]**parameter of Three-Phase Dynamic Load blocksThe

**Initial Conditions [slip, th, ia,ib,ic, pha,phb,phc]**parameter of Asynchronous Machine blocksThe

**Initial conditions [dw th ia,ib,ic pha,phb,phc Vf ]**parameter of Synchronous Machine and Simplified Synchronous Machine blocks

The function also initializes the following parameters of the blocks that are connected to
the **Pm**, **Vf**, and **Tm** inputs of
the Synchronous Machine and Asynchronous Machine blocks:

The

**Constant value**parameter of Constant blocksThe

**Initial Value**parameter of Step blocksThe

**Initial mechanical power**parameter of Hydraulic Turbine and Governor blocksThe

**Initial power and generator rotor angle**of the Steam Turbine and Governor blocks

The type of load flow solution (positive-sequence or unbalanced) is determined by the Load Flow Bus blocks present in the model. For more information on how to use the Load Flow Bus blocks in your model, see Load Flow Bus.

## Load Flow Parameters

The load flow parameters and solution are returned in a structure with the following fields.

Field | Description |
---|---|

`model` | The name of the model. |

`frequency` | The load flow frequency, in hertz. This value corresponds to the Load
flow frequency parameter of the powergui block. |

`basePower` | The base power used by the Load Flow Analyzer. This value corresponds
to the Base power Pbase parameter of the powergui
block. |

`tolerance` | The tolerance used by the Load Flow Analyzer. This value corresponds
to the PQ Tolerance parameter of the powergui
block. |

`bus` | `[1 x Nbus]` structure with fields defining the bus parameters.
For a positive-sequence load flow, `Nbus` is the number of
three-phase buses in the model. For an unbalanced load flow, `Nbus`
is the total number of single-phase buses in the model. |

`sm` | `[1 x Nsm]` structure with fields defining the load flow
parameters of the Synchronous Machine blocks. `Nsm` is the number of
Synchronous Machine blocks in the model. |

`asm` | `[1 x Nasm]` structure with fields defining the load flow
parameters of the Asynchronous Machine blocks. `Nasm` is the number
of Asynchronous Machine blocks in the model. |

`vsrc` | `[1 x Nsrc]` structure with fields defining the load flow
parameters of the Three-Phase Source, Three-Phase Programmable
Voltage Source, and AC Voltage Source blocks.
`Nsrc` is the number of single-phase and three-phase voltage source
blocks in the model. |

`pqload` | `[1 x Npq]` structure with fields defining the load flow
parameters of the Three-Phase Dynamic Load blocks. `Npq` is the
number of Three-Phase Dynamic Load blocks in the model. |

`rlcload` | `[1 x Nrlc]` structure with fields defining the load flow
parameters of the Three-Phase Parallel RLC Load, Three-Phase
Series RLC Load, Parallel RLC Load, and Series RLC
Load blocks. `Nrlc` is the number of three-phase and
single-phase blocks in the model. |

`Ybus1` | `[Nbus x Nbus]` positive-sequence complex admittance matrix in
pu/Pbase used for positive-sequence load flow solution. |

`Ybus` | `[Nbus x Nbus]` complex admittance matrix in pu/Pbase used for
unbalanced load flow solution. |

`Networks` | The bus numbers of each independent network. |

`status` | Returns `1` when a solution is found, and `-1`
when no solution is found. |

`iterations` | The number of iterations that the solver took to solve the load flow. |

`error` | Displays an error message when no solution is found. |

`LoadFlowSolver` | The type of load flow solver: `'PositiveSequence'` or
`'Unbalanced'` |

## Examples

### Performing Load Flow Analysis at the Command Line

As an alternative to using the Load Flow Analyzer to perform a load flow, you
can use this function at the command line. For example, to perform the positive-sequence
load flow on the `power_LFnetwork_5bus`

model, enter:

LF = power_loadflow('-v2','power_LFnetwork_5bus','solve')

LF = model: 'power_LFnetwork_5bus' frequency: 60 basePower: 100000000 tolerance: 0.0001 Ybus1: [5x5 double] bus: [1x7 struct] sm: [1x1 struct] asm: [1x1 struct] vsrc: [1x1 struct] pqload: [1x1 struct] rlcload: [1x2 struct] Networks: [1x1 struct] status: 1 iterations: 2 error: '' LoadFlowSolver: 'PositiveSequence'

The `power_loadflow`

function returns the solution in the
`LF`

structure, and the model is initialized to start in steady state.
You can obtain a detailed load flow report by entering:

LF = power_loadflow('-v2','power_LFnetwork_5bus','solve','report');

The function prompts you to save the report in a file that is displayed in the
MATLAB^{®} Editor.

You can use the same command to perform an unbalanced load flow on the
`power_13NodeTestFeeder`

model:

LF = power_loadflow('-v2','power_13NodeTestFeeder','solve')

LF = model: 'power_13NodeTestFeeder' frequency: 60 basePower: 100000 tolerance: 0.0001 Ybus: [29x29 double] bus: [1x29 struct] sm: [1x1 struct] asm: [1x1 struct] vsrc: [1x1 struct] pqload: [1x1 struct] rlcload: [1x1 struct] Networks: [1x1 struct] status: 1 iterations: 3 error: '' LoadFlowSolver: 'Unbalanced'