# Linear optimal power flow¶

General indices and dimensions

Variable | Description |
---|---|

n | Number of nodes |

m | Number of branches |

ng | Number of generators |

nb | Number of batteries |

nl | Number of loads |

pqpv | Vector of node indices of the the PQ and PV buses. |

vd | Vector of node indices of the the Slack (or VD) buses. |

## Objective function¶

The objective function minimizes the cost of generation plus all the slack variables set in the problem.

## Power injections¶

This equation is not a restriction but the computation of the power injections (fix and LP variables) that are injected per node, such that the vector is dimensionally coherent with the number of buses.

Variable | Description | Dimensions | Type | Units |
---|---|---|---|---|

Vector of active power per node. | n | Float + LP | p.u. | |

Bus-Generators connectivity matrix. | n, ng | int | 1/0 | |

Vector of generators active power. | ng | LP | p.u. | |

Bus-Batteries connectivity matrix. | nb | int | 1/0 | |

Vector of batteries active power. | nb | LP | p.u. | |

Bus-Generators connectivity matrix. | n, nl | int | 1/0 | |

Vector of active power loads. | nl | Float | p.u. | |

Vector of active power load slack variables. | nl | LP | p.u. |

## Nodal power balance¶

These two restrictions are set as hard equality constraints because we want the electrical balance to be fulfilled.

Note that this formulation splits the slack nodes from the non-slack nodes. This is faithful to the original DC power flow formulation which allows for implicit losses computation.

Equilibrium at the non slack nodes.

Equilibrium at the slack nodes.

Variable | Description | Dimensions | Type | Units |
---|---|---|---|---|

Matrix of susceptances. Ideally if the imaginary part of Ybus. | n, n | Float | p.u. | |

Vector of active power per node. | n | Float + LP | p.u. | |

Vector of generators voltage angles. | n | LP | radians. |

## Branch loading restriction¶

Something else that we need to do is to check that the branch flows respect the established limits. Note that because of the linear simplifications, the computed solution in active power might actually be dangerous for the grid. That is why a real power flow should counter check the OPF solution.

First we compute the arrays of nodal voltage angles for each of the “from” and “to” sides of each branch. This is not a restriction but a simple calculation to aid the next restrictions that apply per branch.

Now, these are restrictions that define that the “from->to” and the “to->from” flows must respect the branch rating.

Another restriction that we may impose is that the loading slacks must be equal, since they represent the extra line capacity required to transport the power in both senses of the transportation.

Variable | Description | Dimensions | Type | Units |
---|---|---|---|---|

Vector of series susceptances of the branches. Can be computed as |
m | Float | p.u. | |

Branch-Bus connectivity matrix at the “from” end of the branches. | m, n | int | 1/0 | |

Branch-Bus connectivity matrix at the “to” end of the branches. | m, n | int | 1/0 | |

Vector of bus voltage angles at the “from” end of the branches. | m | LP | radians. | |

Vector of bus voltage angles at the “to” end of the branches. | m | LP | radians. | |

Vector of bus voltage angles. | n | LP | radians. | |

Vector of branch ratings. | m | Float | p.u. | |

Vector of branch rating slacks in the from->to sense. | m | LP | p.u. | |

Vector of branch rating slacks in the to->from sense. | m | LP | p.u. |