# Linear DC optimal power flow time series¶

General indices and dimensions

Variable Description
n Number of nodes
m Number of branches
ng Number of generators
nb Number of batteries
nt Number of time steps
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 Matrix of active power per node and time step. n, nt Float + LP p.u. Bus-Generators connectivity matrix. n, ng int 1/0 Matrix of generators active power per time step. ng, nt LP p.u. Bus-Batteries connectivity matrix. nb int 1/0 Matrix of batteries active power per time step. nb, nt LP p.u. Bus-Generators connectivity matrix. n, nl int 1/0 Matrix of active power loads per time step. nl, nt Float p.u. Matrix of active power load slack variables per time step. nl, nt 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. Remember to set the slack-node voltage angles to zero! Otherwise the generator power will no be used by the solver to provide voltage values. Variable Description Dimensions Type Units Matrix of susceptances. Ideally if the imaginary part of Ybus. n, n Float p.u. Matrix of active power per node and per time step. n, nt Float + LP p.u. Matrix of generators voltage angles per node and per time step. n, nt LP radians.

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 Matrix of bus voltage angles at the “from” end of the branches per bus and time step. m, nt LP radians. Matrix of bus voltage angles at the “to” end of the branches per bus and time step. m, nt LP radians. Matrix of bus voltage angles per bus and time step. n, nt LP radians. Matrix of branch ratings per branch and time step. m, nt Float p.u. Matrix of branch rating slacks in the from->to sense per branch and time step. m, nt LP p.u. Matrix of branch rating slacks in the to->from sense per branch and time step. m, nt LP p.u.

## Battery discharge restrictions¶

The first value of the batteries’ energy is the initial state of charge ( ) times the battery capacity. The capacity in the subsequent time steps is the previous capacity minus the power dispatched. Note that the convention is that the positive power is discharged by the battery and the negative power values represent the power charged by the battery. The batteries’ energy has to be kept within the batteries’ operative ranges. Variable Description Dimensions Type Units Matrix of energy stored in the batteries. nb, nt LP p.u. Vector of initial states of charge. nb Float p.u. Vector of maximum states of charge. nb Float p.u. Vector of minimum states of charge. nb Float p.u. Vector of battery capacities. nb Float h  Time increment in the interval [t-1, t]. 1 Float Vector of battery power injections. nb LP p.u. Vector of Battery efficiency for charge and discharge. nb Float p.u.