Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Grid Modeling

If the example circuits we’ve seen so far seem complicated to analyze, then this pales in comparison to the complexity of analyzing and operating the electrical grid. The electrical grid may be just another circuit, but it has rapid, far-reaching, and expensive consequences if it fails. If the grid is operated incorrectly, its voltages and frequencies can be put in jeopardy in a matter of seconds or less, creating a risk of cascading failure. Understanding the grid and how it behaves depending on how it’s operated is crucial to be able to control it correctly. Grid modeling allows operators to not only stay in control of grid voltages and frequencies, but also to dispatch generators in a way that is cost-optimal.

The grid is modeled as a network of NN electrical buses connected by LL branches. Power System Model · JuliaGrid, 2026 A bus is a shared point of connection that has minimal electrical impedance. Generators and loads are attached to the buses. Each pair of buses (i,k)(i, k)[1] may be connected by a branch—such as a power line or transformer—which has nonzero impedance and can result in voltage and phase differences between buses ii and kk. In the grid, each bus has a specific nominal voltage, typically 4 kV to 765 kV per phase depending on whether it is in the transmission or distribution part of the grid. The sets of buses and branches are denoted N\mathcal{N} and L\mathcal{L}, respectively.

For example, consider Figure 1. It shows a simple electrical grid with three buses N={1,2,3}\mathcal{N} = \{1, 2, 3\}, two generators (at buses 1 and 2), and a load (at bus 3). Buses 1 and 2 are connected by a line branch, and buses 2 and 3 are connected by a transformer branch. This type of diagram is called a single-line diagram because it depicts the parallel conductors in a single-phase system or balanced three-phase system—like the electrical grid—as single lines for the sake of simplicity.

Single-line diagram of an example electrical grid. (The symbol for “Load” should not be confused with the symbol for electrical ground.)

Figure 1:Single-line diagram of an example electrical grid. (The symbol for “Load” should not be confused with the symbol for electrical ground.)

Figure 2 shows the circuit diagram that corresponds to the above single-line diagram for a three-phase system. Each bus in the single-line diagram corresponds to a set of three nodes in the circuit (one per phase).

Circuit diagram of the example electrical grid in .

Figure 2:Circuit diagram of the example electrical grid in Figure 1.

Each branch ikik has a known series impedance zikz_{ik} and shunt impedance zikShz_{ik}^\text{Sh} according to the Π\Pi (Pi) branch model. In grid modeling, these parameters are often expressed as admittance: series admittance yik=1/ziky_{ik} = 1 / z_{ik} and shunt admittance yikSh=1/zikShy_{ik}^\text{Sh} = 1 / z_{ik}^\text{Sh}. The Π\Pi branch model applies the shunt admittance in equal parts on the left and right sides, as shown in Figure 3. This results in a single/per-phase circuit diagram that looks like the Greek letter Π\Pi, hence the name.

Per-phase power line model (the \Pi branch model).

Figure 3:Per-phase power line model (the Π\Pi branch model).

Transformer branches build upon this in order to model nonideal transformers. Transformer branches are modeled as ideal transformers paired with the Π\Pi branch model, as shown in Figure 4. A complex-valued voltage ratio aika_{ik} is used to model both the transformer’s voltage ratio Tik=∣aik∣T_{ik} = |a_{ik}| and, in the case of a phase-shifting transformer such as a zigzag transformer, its phase shift φik=arg⁡(aik)\varphi_{ik} = \arg(a_{ik}). With the ideal transformer adjacent to bus ii, bus ii is known as the tap bus and bus kk as the impedance bus or ZZ bus.

Per-phase transformer model (the \Pi branch model + ideal transformer).

Figure 4:Per-phase transformer model (the Π\Pi branch model + ideal transformer).

The Power Flow (PF) Problem

At any given time, a grid operator must dispatch generators to serve the loads in its grid. Each load ll consists of a given active power PlP_l and reactive power QlQ_l. A dispatch specifies the active power P ⁣gP_{\! g} at which to operate each generator gg. Once a grid operator has decided the generator setpoints, they must be able to validate those setpoints subject to how power will flow through the grid. The grid operator must do this at regular operating intervals (typically 5-minute or 1-hour intervals) because the predicted load and available generation change over time. This consists of:

  1. Validating that power generation will satisfy the loads.

  2. Validating that not too much power is flowing through a given line or transformer. This is to avoid overloading/overheating it.

  3. Validating that voltages are within acceptable margins. This is for the sake of the loads.

The task of determining how power will flow through the grid and whether it will satisfy the loads is known as the power flow (PF) problem Mones, 2020Power Flow · PyPSA, 2026.

Because the grid is a circuit, we can solve the power flow problem the same as we solve any other circuit, by doing nodal analysis and solving a system of KCL equations to determine the voltage at each bus, denoted V ⁣i=∣V ⁣i∣∠δiV_{\! i} = |V_{\! i}| \angle \delta_i. In the three-phase case, the voltage magnitude ∣V ⁣i∣|V_{\! i}| can be assumed to be the same across the three phases at each bus, and the voltage angle δi\delta_i can be taken for the first phase only, knowing that the other two phases will be ±2π/3\pm 2 \pi / 3 radians apart.

For generality, we will model all branches as transformer branches. For line branches, we can simply set Tik=1T_{ik} = 1 and φik=0\varphi_{ik} = 0. We will call branch ikik an ii-forward branch if bus ii is the tap bus, or an ii-reverse branch if bus ii is the impedance bus. In this sense, the grid model becomes a directed graph rather than an undirected graph, and we must account for the forward and reverse branch directions distinctly. We do this by deriving the current IikI_{ik} flowing into branch ikik from bus ii (that is, flowing directly into the ideal transformer), as well as the current IkiI_{ki} flowing into the branch from the opposite bus kk. To determine IikI_{ik}, we apply KCL by summing the currents out of node i′i' in Figure 4:

− ⁣Iik′+V ⁣i′ yikSh2+(V ⁣i′−Vk) yik=0  ⟹  Iik′=V ⁣i′(yikSh2+yik)−Vk yik  ⟹  Iikaik∗=V ⁣i 1aik(yikSh2+yik)−Vk yik  ⟹  Iik=V ⁣i 1 ∣aik∣2(yikSh2+yik)−Vk 1aik∗yik\begin{aligned} & - \! I_{ik}' + V_{\! i}' \, \frac{y_{ik}^\text{Sh}}{2} + (V_{\! i}' - V_k) \, y_{ik} = 0 \\ & \implies I_{ik}' = V_{\! i}' \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) - V_k \, y_{ik} \\ & \implies I_{ik} a_{ik}^* = V_{\! i} \, \frac{1}{a_{ik}} \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) - V_k \, y_{ik} \\ & \implies I_{ik} = V_{\! i} \, \frac{1}{\, |a_{ik}|^2} \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) - V_k \, \frac{1}{a_{ik}^*} y_{ik} \end{aligned}

And to determine IkiI_{ki}, we apply KCL by summing the currents out of node k′k':

− ⁣Iki+(Vk−V ⁣i′) yik+VkyikSh2=0  ⟹  Iki=Vk(yik+yikSh2)−V ⁣i′ yik  ⟹  Iki=Vk(yik+yikSh2)−V ⁣i 1aikyik\begin{aligned} & - \! I_{ki} + (V_k - V_{\! i}') \, y_{ik} + V_k \frac{y_{ik}^\text{Sh}}{2} = 0 \\ & \implies I_{ki} = V_k \left( y_{ik} + \frac{y_{ik}^\text{Sh}}{2} \right) - V_{\! i}' \, y_{ik} \\ & \implies I_{ki} = V_k \left( y_{ik} + \frac{y_{ik}^\text{Sh}}{2} \right) - V_{\! i} \, \frac{1}{a_{ik}} y_{ik} \end{aligned}

The Bus Injection Model

To define the power flow problem, we need to formulate a set of power flow equations. The most common formulation is known as the bus injection model. We start with KCL, which tells us that at a bus ii with nominal voltage V ⁣iV_{\! i}, the current (Si/V ⁣i)∗(S_i / V_{\! i})^* injected due to attached generation and/or load SiS_i must equal the sum of currents flowing out of the bus:

(Si/V ⁣i)∗=total current out of bus i via i-forward branches +total current out of bus i via i-reverse branches= ⁣ ⁣∑k:(i,k)∈L ⁣ ⁣ ⁣Iik + ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣ ⁣Iik\begin{aligned} (S_i / V_{\! i})^* & = \text{total current out of bus $i$ via $i$-forward branches} \\ & \, + \text{total current out of bus $i$ via $i$-reverse branches} \\ & = \!\! \sum_{k : (i, k) \in \mathcal{L}} \!\!\! I_{ik} \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\!\! I_{ik} \end{aligned}

The subscript “k ⁣: ⁣(i,k) ⁣∈ ⁣Lk \! : \! (i, k) \! \in \! \mathcal{L}” means “for each bus kk to which bus ii is connected by an ii-forward branch” and the subscript “k ⁣: ⁣(k,i) ⁣∈ ⁣Lk \! : \! (k, i) \! \in \! \mathcal{L}” means “for each bus kk to which bus ii is connected by an ii-reverse branch”. Substituting IikI_{ik} and IkiI_{ki} from equations (1) and (2) gives us:

(Si/V ⁣i)∗= ⁣ ⁣∑k:(i,k)∈L ⁣(V ⁣i 1 ∣aik∣2(yikSh2+yik)−Vk 1aik∗yik) + ⁣ ⁣∑k:(k,i)∈L ⁣(V ⁣i(ykiSh2+yki)−Vk 1akiyki)\begin{aligned} (S_i / V_{\! i})^* & = \!\! \sum_{k : (i, k) \in \mathcal{L}} \! \left( V_{\! i} \, \frac{1}{\, |a_{ik}|^2} \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) - V_k \, \frac{1}{a_{ik}^*} y_{ik} \right) \\ & \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \! \left( V_{\! i} \left( \frac{y_{ki}^\text{Sh}}{2} + y_{ki} \right) - V_k \, \frac{1}{a_{ki}} y_{ki} \right) \end{aligned}

Splitting up the summations and rearranging:

(Si/V ⁣i)∗=V ⁣i ( ∑k:(i,k)∈L ⁣ ⁣1 ∣aik∣2(yikSh2+yik) + ⁣ ⁣∑k:(k,i)∈L ⁣(ykiSh2+yki)) − ⁣ ⁣∑k:(i,k)∈L ⁣ ⁣ ⁣Vk 1aik∗yik − ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣ ⁣Vk 1akiyki\begin{aligned} (S_i / V_{\! i})^* & = V_{\! i} \, \Biggl( \, \sum_{k : (i, k) \in \mathcal{L}} \!\! \frac{1}{\, |a_{ik}|^2} \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \! \left( \frac{y_{ki}^\text{Sh}}{2} + y_{ki} \right) \Biggr) \\ & \, - \!\! \sum_{k : (i, k) \in \mathcal{L}} \!\!\! V_k \, \frac{1}{a_{ik}^*} y_{ik} \, - \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\!\! V_k \, \frac{1}{a_{ki}} y_{ki} \end{aligned}

The bus injection model is typically expressed in a way that allows some complexity to be moved into a new N ⁣× ⁣NN \! \times \! N matrix Y ⁣Y \!, called the bus admittance matrix, which allows the above equation to be rewritten succinctly as:

(Si/V ⁣i)∗=∑k∈NVk Y ⁣ik(S_i / V_{\! i})^* = \sum_{k \in \mathcal{N}} V_k \, Y_{\! ik}

Or, even more simply, as a matrix equation:

S=(Y ⁣ V)∗∘VS = (Y \!\: V)^* \circ V

where “∘\displaystyle\circ” indicates element-wise vector multiplication and Y ⁣Y \! is defined as having the following diagonal and off-diagonal elements:

Yii= ⁣ ⁣∑k:(i,k)∈L ⁣ ⁣1 ∣aik∣2(yikSh2+yik) + ⁣ ⁣∑k:(k,i)∈L ⁣(ykiSh2+yki)Y ⁣ik={−yik/aik∗if branch ik is an i-forward branch−yki/akiif branch ik is an i-reverse branch     0if branch ik does not exist (no branch)\begin{aligned} Y_{ii} & = \!\! \sum_{k : (i, k) \in \mathcal{L}} \!\! \frac{1}{\, |a_{ik}|^2} \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \! \left( \frac{y_{ki}^\text{Sh}}{2} + y_{ki} \right) \\ Y_{\! ik} & = \begin{cases} - y_{ik} / a_{ik}^* & \text{if branch $ik$ is an $i$-forward branch} \\ - y_{ki} / a_{ki} & \text{if branch $ik$ is an $i$-reverse branch} \\ \,\,\,\; 0 & \text{if branch $ik$ does not exist (no branch)} \end{cases} \end{aligned}

Thus, the admittance matrix does not only specify the admittance values between buses in its off-diagonal elements. Its off-diagonal elements additionally specify whether a branch is present between any ikik-pair of buses (Y ⁣ik≠0Y_{\! ik} \neq 0), whether a branch is a transformer (aik≠1a_{ik} \neq 1), and its voltage ratio if it is a transformer (Tik≠1T_{ik} \neq 1), and even its phase shift if it is also a phase-shifting transformer (φik≠0\varphi_{ik} \neq 0). Furthermore, the diagonal elements specify, for each bus, the shunt admittances of neighboring branches.

Just as how a branch admittance yy can be split into real and imaginary parts g+jbg + j b, where gg is conductance[2] and bb is susceptance, the admittance matrix Y ⁣Y \! can be split into G+jBG + j B, which we will leverage shortly.

The bus injection equations are typically arranged as equations for active and reactive power P+jQ=SP + j Q = S. To describe the power at a given bus ii, we take the conjugate of Equation (6) and multiply both sides by V ⁣iV_{\! i}:

Pi+jQi=∑k∈NV ⁣i Vk∗ Y ⁣ik∗P_i + j Q_i = \sum_{k \in \mathcal{N}} V_{\! i} \, V_k^* \, Y_{\! ik}^*

Solver software often expects real-valued equations, so we work towards splitting this equation into a real part and an imaginary part. Furthermore, the bus injection model most commonly uses polar coordinates for voltage and rectangular coordinates for admittance. To satisfy this, we substitute V=∣V∣ejδ=∣V∣∠δV = |V| \mathrm{e}^{j \delta} = |V| \angle \delta and Y=G+jBY = G + j B in the above equation, giving us the following. We will eventually be able to take the imaginary unit jj out of the picture.

Pi+jQi=∑k∈N (∣V ⁣i∣∠δi) (∣Vk∣∠ ⁣− ⁣δk) (Gik−jBik)=∑k∈N [∣V ⁣i∣ ∣Vk∣ ∠ (δi−δk)] (Gik−jBik)=∑k∈N∣V ⁣i∣ ∣Vk∣ (cos⁡(δi−δk)+jsin⁡(δi−δk)) (Gik−jBik)\begin{aligned} P_i + j Q_i & = \sum_{k \in \mathcal{N}} \, (|V_{\! i}| \angle \delta_i) \, (|V_k| \angle \! - \! \delta_k) \, (G_{ik} - j B_{ik}) \\ & = \sum_{k \in \mathcal{N}} \, [|V_{\! i}| \, |V_k| \, \angle \, (\delta_i - \delta_k)] \, (G_{ik} - j B_{ik}) \\ & = \sum_{k \in \mathcal{N}} |V_{\! i}| \, |V_k| \, (\cos(\delta_i - \delta_k) + j \sin(\delta_i - \delta_k)) \, (G_{ik} - j B_{ik}) \end{aligned}

Expanding yields:

Pi+jQi=∣V ⁣i∣∑k∈N∣Vk∣(Gikcos⁡(δi−δk)−jBikcos⁡(δi−δk)+jGiksin⁡(δi−δk)+Biksin⁡(δi−δk))P_i + j Q_i = |V_{\! i}| \sum_{k \in \mathcal{N}} |V_k| \left( \begin{aligned} & G_{ik} \cos(\delta_i - \delta_k) - j B_{ik} \cos(\delta_i - \delta_k) \\ & + j G_{ik} \sin(\delta_i - \delta_k) + B_{ik} \sin(\delta_i - \delta_k) \end{aligned} \right)

Finally, we are able to split this complex-valued equation into the following real-valued power flow equations, for each bus ii. These are suitable for use with solver software.

Pi=∣V ⁣i∣∑k∈N∣Vk∣ (Gikcos⁡(δi−δk)+Biksin⁡(δi−δk))Qi=∣V ⁣i∣∑k∈N∣Vk∣ (Giksin⁡(δi−δk)−Bikcos⁡(δi−δk))\boxed{ \begin{aligned} P_i & = |V_{\! i}| \sum_{k \in \mathcal{N}} |V_k| \, (G_{ik} \cos(\delta_i - \delta_k) + B_{ik} \sin(\delta_i - \delta_k)) \\ Q_i & = |V_{\! i}| \sum_{k \in \mathcal{N}} |V_k| \, (G_{ik} \sin(\delta_i - \delta_k) - B_{ik} \cos(\delta_i - \delta_k)) \end{aligned} }

For a branch ll from bus ii to bus kk, the power flowing into the branch from bus ii is:

Pik=∣V ⁣i∣ ∣Vk∣ (Gikcos⁡(δi−δk)+Biksin⁡(δi−δk))+∣V ⁣i∣2Gl,ifQik=∣V ⁣i∣ ∣Vk∣ (Giksin⁡(δi−δk)−Bikcos⁡(δi−δk))+∣V ⁣i∣2Bl,if\begin{aligned} P_{ik} & = |V_{\! i}| \, |V_k| \, (G_{ik} \cos(\delta_i - \delta_k) + B_{ik} \sin(\delta_i - \delta_k)) + |V_{\! i}|^2 G^\text{f}_{l, i} \\ Q_{ik} & = |V_{\! i}| \, |V_k| \, (G_{ik} \sin(\delta_i - \delta_k) - B_{ik} \cos(\delta_i - \delta_k)) + |V_{\! i}|^2 B^\text{f}_{l, i} \end{aligned}

And the power flowing into the branch from bus kk is:

Pki=∣Vk∣ ∣V ⁣i∣ (Gkicos⁡(δk−δi)+Bkisin⁡(δk−δi))+∣Vk∣2Gl,ktQki=∣Vk∣ ∣V ⁣i∣ (Gkisin⁡(δk−δi)−Bkicos⁡(δk−δi))+∣Vk∣2Bl,kt\begin{aligned} P_{ki} & = |V_k| \, |V_{\! i}| \, (G_{ki} \cos(\delta_k - \delta_i) + B_{ki} \sin(\delta_k - \delta_i)) + |V_k|^2 G^\text{t}_{l, k} \\ Q_{ki} & = |V_k| \, |V_{\! i}| \, (G_{ki} \sin(\delta_k - \delta_i) - B_{ki} \cos(\delta_k - \delta_i)) + |V_k|^2 B^\text{t}_{l, k} \end{aligned}

Where Gf ⁣G^\text{f} \!, Bf ⁣B^\text{f} \!, Gt ⁣G^\text{t} \!, and BtB^\text{t} are the real and imaginary components of the branch-from-bus admittance matrix YfY^\text{f} and the branch-to-bus admittance matrix Yt ⁣Y^\text{t} \!, detailed in this chapter’s appendix.

Applying the Per-Unit System

The per-unit system is the practice in electrical engineering of normalizing quantities like voltage and power to a dimensionless value between 0 and 1. Each quantity xx is expressed as a fraction, denoted xpu ⁣x^\text{pu} \!, of some base quantity, xbase ⁣x^\text{base} \!, such that x=xpuxbase ⁣x = x^\text{pu} x^\text{base} \!. This can be done with many electrical engineering quantities:

V=VpuVbaseS=SpuSbaseI=IpuIbasey=ypuybaseZ=ZpuZbase\begin{gathered} V = V^\text{pu} V^\text{base} \qquad S = S^\text{pu} S^\text{base} \qquad I = I^\text{pu} I^\text{base} \\ y = y^\text{pu} y^\text{base} \qquad Z = Z^\text{pu} Z^\text{base} \qquad \end{gathered}

For example, in the per-unit system with a base of Sbase=100 MV ⁣AS^\text{base} = 100 \ \mathrm{MV\!A}, a quantity of S=90 MV ⁣AS = 90 \ \mathrm{MV\!A} would become Spu=0.9 per unitS^\text{pu} = 0.9 \ \mathrm{per \ unit} or 0.9 pu ⁣0.9 \ \mathrm{pu} \!.

The per-unit system makes it easier to interpret quantities relative to the voltage and power ratings of equipment such as buses and generators. And when applied to the power flow problem, the per-unit system offers additional advantages Per-Unit System · JuliaGrid, 2026:

To express the power flow equations in the per-unit system, we select the nominal bus voltage as the base voltage V ⁣ibaseV_{\! i}^\text{base} at each bus ii, and an arbitrary value SbaseS^\text{base} as the base power everywhere. We substitute SipuSbaseS_i^\text{pu} S^\text{base} for SiS_i and V ⁣ipuV ⁣ibaseV_{\! i}^\text{pu} V_{\! i}^\text{base} for V ⁣iV_{\! i} in Equation (5) as follows. We also split the transformer voltage ratio aika_{ik} into nominal voltage ratio V ⁣ibase/VkbaseV_{\! i}^\text{base} / V_k^\text{base} (which we denote aikbasea_{ik}^\text{base}) times an off-nominal factor (which we denote aikpua_{ik}^\text{pu}). It is not typical to represent transformer voltage ratios in the per-unit system as such—they are dimensionless quantities to begin with—but we use the notation aik=aikpuaikbasea_{ik} = a_{ik}^\text{pu} a_{ik}^\text{base} nonetheless for consistency.

(SipuSbaseV ⁣ipuV ⁣ibase) ⁣∗=V ⁣ipuV ⁣ibase ( ∑k:(i,k)∈L ⁣ ⁣1 ∣aikpuaikbase∣2(yikSh2+yik) + ⁣ ⁣∑k:(k,i)∈L ⁣(ykiSh2+yki)) − ⁣ ⁣∑k:(i,k)∈L ⁣ ⁣ ⁣VkpuVkbase1(aikpuaikbase)∗ yik − ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣ ⁣VkpuVkbase1akipuakibase yki\begin{aligned} & \left( \frac{S_i^\text{pu} S^\text{base}}{V_{\! i}^\text{pu} V_{\! i}^\text{base}} \right)^{\! *} \\ & = V_{\! i}^\text{pu} V_{\! i}^\text{base} \, \Biggl( \, \sum_{k : (i, k) \in \mathcal{L}} \!\! \frac{1}{\, |a_{ik}^\text{pu} a_{ik}^\text{base}|^2} \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \! \left( \frac{y_{ki}^\text{Sh}}{2} + y_{ki} \right) \Biggr) \\ & \, - \!\! \sum_{k : (i, k) \in \mathcal{L}} \!\!\! V_k^\text{pu} V_k^\text{base} \frac{1}{(a_{ik}^\text{pu} a_{ik}^\text{base})^*} \, y_{ik} \, - \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\!\! V_k^\text{pu} V_k^\text{base} \frac{1}{a_{ki}^\text{pu} a_{ki}^\text{base}} \, y_{ki} \end{aligned}

Substituting aikbase=V ⁣ibase/Vkbase ⁣a_{ik}^\text{base} = V_{\! i}^\text{base} / V_k^\text{base} \!, multiplying both sides by V ⁣ibase/SbaseV_{\! i}^\text{base} / S^\text{base} and simplifying:

(SipuV ⁣ipu) ⁣∗=V ⁣ipu ( ∑k:(i,k)∈L ⁣ ⁣1 ∣aikpu∣2(Vkbase)2Sbase(yikSh2+yik) + ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣(V ⁣ibase)2Sbase(ykiSh2+yki)) − ⁣ ⁣∑k:(i,k)∈L ⁣ ⁣ ⁣Vkpu(Vkbase)2Sbase1(aikpu)∗ yik − ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣ ⁣Vkpu(Vkbase)2Sbase1akipu yki\begin{aligned} & \left( \frac{S_i^\text{pu}}{V_{\! i}^\text{pu}} \right)^{\! *} \\ & = V_{\! i}^\text{pu} \, \Biggl( \, \sum_{k : (i, k) \in \mathcal{L}} \!\! \frac{1}{\, |a_{ik}^\text{pu}|^2} \frac{(V_k^\text{base})^2}{S^\text{base}} \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\! \frac{(V_{\! i}^\text{base})^2}{S^\text{base}} \left( \frac{y_{ki}^\text{Sh}}{2} + y_{ki} \right) \Biggr) \\ & \, - \!\! \sum_{k : (i, k) \in \mathcal{L}} \!\!\! V_k^\text{pu} \frac{(V_k^\text{base})^2}{S^\text{base}} \frac{1}{(a_{ik}^\text{pu})^*} \, y_{ik} \, - \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\!\! V_k^\text{pu} \frac{(V_k^\text{base})^2}{S^\text{base}} \frac{1}{a_{ki}^\text{pu}} \, y_{ki} \end{aligned}

We now apply the per-unit system to the admittances, defining yik=yikpuyikbase ⁣y_{ik} = y_{ik}^\text{pu} y_{ik}^\text{base} \!. If we select Sbase/(Vkbase)2S^\text{base} / (V_k^\text{base})^2 as the base admittance yikbase ⁣y_{ik}^\text{base} \!, all base terms conveniently cancel out, leaving something that looks exactly like Equation (5), but with “pu” scripts:

(SipuV ⁣ipu) ⁣∗=V ⁣ipu ( ∑k:(i,k)∈L ⁣ ⁣1 ∣aikpu∣2 (yikSh,pu2+yikpu) + ⁣ ⁣∑k:(k,i)∈L(ykiSh,pu2+ykipu)) − ⁣ ⁣∑k:(i,k)∈L ⁣ ⁣ ⁣Vkpu1(aikpu)∗ yikpu − ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣ ⁣Vkpu1akipu ykipu\begin{aligned} \left( \frac{S_i^\text{pu}}{V_{\! i}^\text{pu}} \right)^{\! *} & = V_{\! i}^\text{pu} \, \Biggl( \, \sum_{k : (i, k) \in \mathcal{L}} \!\! \frac{1}{\, |a_{ik}^\text{pu}|^2} \, \Biggl( \frac{y_{ik}^\text{Sh,pu}}{2} + y_{ik}^\text{pu} \Biggr) \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \Biggl( \frac{y_{ki}^\text{Sh,pu}}{2} + y_{ki}^\text{pu} \Biggr) \Biggr) \\ & \, - \!\! \sum_{k : (i, k) \in \mathcal{L}} \!\!\! V_k^\text{pu} \frac{1}{(a_{ik}^\text{pu})^*} \, y_{ik}^\text{pu} \, - \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\!\! V_k^\text{pu} \frac{1}{a_{ki}^\text{pu}} \, y_{ki}^\text{pu} \end{aligned}

When the voltage ratio of a transformer ikik is nominal—that is, equal to the ratio between the nominal voltage at bus ii and the nominal voltage at bus kk, then aikpu=1a_{ik}^\text{pu} = 1 and the equation’s terms concerning the transformer branch simplify to those of a line branch. This is because the differing bus voltages V ⁣ibase≠VkbaseV_{\! i}^\text{base} \neq V_k^\text{base} are now accounted for as part of ykibase≠yikbase ⁣y_{ki}^\text{base} \neq y_{ik}^\text{base} \!, respectively. The power flow problem is typically expressed in the per-unit system because of this advantage, as well as the advantage of improved numerical stability.

Bus Classifications

Our grid model, expressed by the power flow equations, currently has too many unknown variables to be able to solve it. We know the branch admittances, but we do not yet know how the loads should behave or how the bus voltages can be controlled. We now have a model of the grid, but as-is, we cannot use this model to determine how power will flow through the grid. In this section, we will narrow down our definition of the power flow problem.

Each bus and thus each pair of (Pi,Qi)(P_i, Q_i) equations (12) has four variables: voltage magnitude ∣V ⁣i∣|V_{\! i}|, voltage angle δi\delta_i, active power PiP_i, and reactive power QiQ_i. Each bus contributes two equations, for a total of 2N2 N independent equations making up the system of equations. There are 4N4 N unique variables, so half of them must be fixed in order for the system of equations to have an exactly determined solution. The other half of the variables must be left as free variables that can take on whatever values are required to satisfy the system of equations. Which variables we fix and which variables we allow to vary depends on the type of each bus, as we will discuss. In order to support different numbers of buses of each type, half of the variables at each bus must be fixed and the other half free. At most buses, we don’t care about the voltage angle, so we leave δi\delta_i as a free variable.

Load bus. A bus to which only load(s) are attached is known as a load bus. At a load bus, PiP_i and QiQ_i are fixed based on the demands of the load (or loads). Although we wish we could fix ∣V ⁣i∣|V_{\! i}| to the exact nominal voltage of the bus for the sake of the attached load(s), this is not generally possible without making the system of equations under- or over-determined. Because of this, loads generally accept a voltage range, and system operators are required to keep ∣V ⁣i∣|V_{\! i}| within an even narrower range. Because only variables PiP_i and QiQ_i are fixed at a load bus, a load bus is also known as a PQ bus.

Generator bus. A bus to which only generator(s) are attached is known as a generator bus. At a generator bus, PiP_i is fixed based on the generator setpoints and ∣V ⁣i∣|V_{\! i}| is fixed to the bus nominal voltage. QiQ_i is allowed to vary at a generator bus to whatever value satisfies the system. Because only variables PiP_i and ∣V ⁣i∣|V_{\! i}| are fixed at a generator bus, a generator bus is also known as a PV bus or voltage-controlled bus.

What if a bus has both generator(s) and load(s) attached? The net active power PiP_i must be fixed because the active powers of both the generator(s) and loads(s) are fixed. The net reactive power QiQ_i must be free to vary because, while the reactive powers of the load(s) are fixed, those of the generator(s) are not. And ∣V ⁣i∣|V_{\! i}| is fixed, just as in a generator bus. Indeed, if we were to model a combined generator/load bus as a separate generator bus ii and a separate load bus kk, connected by a line ikik with zero impedance, then ∣V ⁣i∣|V_{\! i}| would end up equalling ∣Vk∣|V_k| anyway. So, a combined generator/load bus is treated as a generator bus.

And what if a bus has neither generators nor loads attached? In this case, the bus is treated as a load bus with fixed Pi=0P_i = 0 and Qi=0Q_i = 0.

Slack bus. So far, the classifications of variables as fixed versus free means that the number of free variables equals the number of equations. However, this does not necessarily mean that the system of equations has a solution that is feasible or that it has a solution that is unique. Indeed, with only the two bus types we’ve defined so far, there is a feasibility issue and a uniqueness issue. Firstly, active power losses due to electrical resistance in the power lines and transformers mean that the total power supplied by the generators does not necessarily equal the total power demanded by the loads plus the power losses. The deficit must be made up for by one or more generators at one or more buses, at which PP must thus be free to vary. Otherwise, there would not necessarily be a feasible solution. Secondly, voltage angles are relative, so at one bus, δi\delta_i must be fixed to 0∘0^\circ as a reference against which all other δi\delta_is are measured. Otherwise, there would be no unique solution. By convention, both the feasibility issue and the uniqueness issue are solved by the same bus. This third type of bus is known as a slack bus, also known as a swing bus, reference bus, or Vδ bus.

Table 1 summarizes the bus types and their variable classifications.

Table 1:Bus types and their variable classifications.

Bus typePiP_iQiQ_iV ⁣iV_{\! i}δi\delta_i
Load/PQFixed by loadFixed by loadFreeFree
Generator/PVFixed by dispatchFreeFixed by grid operating requirementFree
Slack/VδFreeFreeFixed by grid operating requirementFixed to 0∘0^\circ reference

As an example of how these bus classifications would apply, consider the electrical grid of Figure 5. Buses 2 and 3 are both load buses (even though bus 2 has no attached load). Either of buses 1 and 4 can be a generator bus (even though bus 4 has an attached load), but one of them must be a slack bus.

Single-line diagram of another example electrical grid.

Figure 5:Single-line diagram of another example electrical grid.

Power Flow Validation

After solving the power flow problem, a grid operator is able to validate their generator dispatch according to the three requirements listed under The Power Flow (PF) Problem:

  1. Validating that power generation will satisfy the loads. More specifically, validating that the slack generation—which is free to vary to whatever value is required to satisfy the loads—is within the maximum power of slack generator gg:

    Sg≤Sgmax ∀ g∈GS_g \leq S_g^\text{max} \ \forall \ g \in \mathcal{G}
  2. Validating that not too much power is flowing into or out of a branch (a line or transformer):

    ∣Sik∣≤Slmax ⁣, ∣Ski∣≤Slmax ∀ (i,k)∈L|S_{ik}| \leq S_l^\text{max} \!, \, |S_{ki}| \leq S_l^\text{max} \ \forall \ (i, k) \in \mathcal{L}

    We refer to this as the branch flow constraint.

  3. Validating that voltages are within acceptable margins:

    V ⁣imin≤∣V ⁣i∣≤V ⁣imax ∀ i∈NV_{\! i}^\text{min} \leq |V_{\! i}| \leq V_{\! i}^\text{max} \ \forall \ i \in \mathcal{N}

The branch flow constraint’s ∣Sik∣|S_{ik}| is derived as follows:

(Sik/V ⁣i)∗=V ⁣iYl,if−VkYl,kf(S_{ik} / V_{\! i})^* = V_{\! i} Y^\text{f}_{l,i} - V_k Y^\text{f}_{l,k}
Sik=V ⁣i (ViYl,if−VkYl,kf)∗S_{ik} = V_{\! i} \, (V_i Y^\text{f}_{l,i} - V_k Y^\text{f}_{l,k})^*
∣Sik∣=∣Vi∣ ∣ViYl,if−VkYl,kf∣=∣Vi∣∣ ∣Vi∣ ∣Yl,if∣(cos⁡(δi+arg⁡(Yl,if))+jsin⁡(δi+arg⁡(Yl,if)))−∣Vk∣ ∣Yl,kf∣(cos⁡(δk+arg⁡(Yl,kf))+jsin⁡(δi+arg⁡(Yl,kf))) ∣=∣Vi∣  ⁣[∣Vi∣ ∣Yl,if∣cos⁡(δi+arg⁡(Yl,if))+∣Vk∣ ∣Yl,kf∣cos⁡(δk+arg⁡(Yl,kf))]2+[∣Vi∣ ∣Yl,if∣sin⁡(δi+arg⁡(Yl,if))+∣Vk∣ ∣Yl,kf∣sin⁡(δi+arg⁡(Yl,kf))]2 \begin{aligned} & |S_{ik}| \\ & = |V_i| \, |V_i Y^\text{f}_{l,i} - V_k Y^\text{f}_{l,k}| \\ & = |V_i| \left| \begin{aligned} & \, |V_i| \, |Y^\text{f}_{l,i}| \left( \cos(\delta_i + \arg(Y^\text{f}_{l,i})) + j \sin(\delta_i + \arg(Y^\text{f}_{l,i})) \right) \\ & - |V_k| \, |Y^\text{f}_{l,k}| \left( \cos(\delta_k + \arg(Y^\text{f}_{l,k})) + j \sin(\delta_i + \arg(Y^\text{f}_{l,k})) \right) \end{aligned} \, \right| \\ & = |V_i| \, \sqrt{ \! \begin{aligned} & \left[ |V_i| \, |Y^\text{f}_{l,i}| \cos(\delta_i + \arg(Y^\text{f}_{l,i})) + |V_k| \, |Y^\text{f}_{l,k}| \cos(\delta_k + \arg(Y^\text{f}_{l,k})) \right]^2 \\ & + \left[ |V_i| \, |Y^\text{f}_{l,i}| \sin(\delta_i + \arg(Y^\text{f}_{l,i})) + |V_k| \, |Y^\text{f}_{l,k}| \sin(\delta_i + \arg(Y^\text{f}_{l,k})) \right]^2 \end{aligned} } \\ \, \end{aligned}

The same is done for ∣Ski∣|S_{ki}| by replacing YfY^\text{f} with YtY^\text{t}.

The Economic Dispatch (ED) Problem

The power flow problem is intended to determine whether generator setpoints are valid, but it alone does not help determine what generator setpoints to use in the first place. When a grid operator decides how to dispatch generators, their goal—within the requirement of satisfying the grid’s loads—is to minimize their operating cost incurred during a given operating interval. Different types of generators have different costs per MWh of electrical energy; for example, operating a hydroelectric generator is less expensive than fuel for a natural-gas-powered generator. Furthermore, a given generator gg can also have a cost per MWh that increases with the setpoint P ⁣gP_{\! g}, in MW, at which the generator is operated. Thus, each generator has its own cost function Cg(P ⁣g)C_g (P_{\! g}), and the total operating cost for a given interval of time depends on both on which generators are dispatched, and what setpoint each of those generators is operated at.

The grid operator can achieve their goal of minimizing their operating cost by solving an optimization problem in which the objective function—to be minimized—is the total operating cost, and the decision variables are the generator setpoints. This optimization problem is what is known as the economic dispatch (ED) problem:

min⁡∑g∈GCg(P ⁣g)\boxed{\min \sum_{g \in \mathcal{G}} C_g \bigl( P_{\! g} \bigr)}

How the cost function CgC_g is formulated depends on the application. If the application is research or planning purposes, then a quadratic fit is typically used to approximately model how the cost per MWh increases as P ⁣gP_{\! g} increases. For day-to-day and real-time dispatch by the grid operator, a piecewise linear function is often used for greater accuracy.

So far, we have assumed that all generators are dispatchable (controllable power) and that all loads are non-dispatchable (uncontrollable power). There do exist non-dispatchable generators whose power production cannot be controlled, as well as dispatchable loads (such as smart thermostats and smart EV charging in some cases) whose power consumption can be controlled by the grid operator. Biddle, 2024 However, this does not mean that the grid model discussed so far cannot represent these resources. Non-dis­patchable generators can be modeled as loads whose fixed power is positive rather than negative. As for dispatchable loads, they can be modeled as generators whose maximum power is negative rather than positive, and with cost functions that intake and output negative values. This negative cost—associated with consuming, rather than producing—is called utility in economics. Utility quantifies the economic value delivered to consumers (loads) when they are dispatched by the grid operator, in contrast to the cost incurred by producers (generators) by being dispatched.[3]

The Optimal Power Flow (OPF) Problem

Not just any solution to the economic dispatch problem will do. Operating costs cannot be minimized without ensuring that the setpoints are valid per the power flow equations (12) and the criteria in the previous section (equations (19), (20), (21)). These become equality and inequality constraints in the optimization problem, respectively. The result of pairing the objective function for economic dispatch with the power flow constraints is known as the optimal power flow (OPF) problem Frank & Rebennack, 2016Mones, 2021:

 ⁣min⁡P∑g∈GCg(P ⁣g)subject to:Pi=∣V ⁣i∣∑k∈N∣Vk∣ (Giksin⁡(δi−δk)−Bikcos⁡(δi−δk)) ⁣ ⁣∀ i∈NQi=∣V ⁣i∣∑k∈N∣Vk∣ (Gikcos⁡(δi−δk)+Biksin⁡(δi−δk)) ⁣ ⁣∀ i∈NSgmin≤Sg≤Sgmax ⁣ ⁣∀ g∈G∣Sik∣≤Slmax ⁣, ∣Ski∣≤Slmax ⁣ ⁣∀ (i,k)∈LV ⁣imin≤∣V ⁣i∣≤V ⁣imax ⁣ ⁣∀ i∈N\boxed{ \quad \begin{aligned} & \\ & \! \min_{\mathbf{P}} \sum_{g \in \mathcal{G}} C_g \bigl( P_{\! g} \bigr) \\ & \text{subject to:} \\ & P_i = |V_{\! i}| \sum_{k \in \mathcal{N}} |V_k| \, (G_{ik} \sin(\delta_i - \delta_k) - B_{ik} \cos(\delta_i - \delta_k)) && \!\! \forall \, i \in \mathcal{N} \\ & Q_i = |V_{\! i}| \sum_{k \in \mathcal{N}} |V_k| \, (G_{ik} \cos(\delta_i - \delta_k) + B_{ik} \sin(\delta_i - \delta_k)) && \!\! \forall \, i \in \mathcal{N} \\ & S_g^\text{min} \leq S_g \leq S_g^\text{max} && \!\! \forall \, g \in \mathcal{G} \\ & |S_{ik}| \leq S_l^\text{max} \!, \, |S_{ki}| \leq S_l^\text{max} && \!\! \forall \, (i, k) \in \mathcal{L} \\ & V_{\! i}^\text{min} \leq |V_{\! i}| \leq V_{\! i}^\text{max} && \!\! \forall \, i \in \mathcal{N} \\ & \phantom{} \end{aligned} \quad }

This OPF problem (26) must be solved for every operating interval, making a dispatch decision and minimizing the total cost incurred over that interval independent of any other interval. However, as we will see, there are OPF variants that require considering multiple intervals in one optimization problem, making a dispatch decision for every interval simultaneously and minimizing the total cost incurred over all intervals. For these purposes, we add an interval index tt to all time-variant quantities and denote the interval duration as Δt\Delta t.

Ramp rate limits. The first multi-interval OPF variant that we will discuss involves limits on generators’ ramp rates. How quickly a generator’s power output (in MW) changes from one interval to the next is referred to as its ramp rate (e.g., in MW per minute). If the power output is analogous to velocity, then ramp rate’s analog is acceleration, and there are limits to both. Some generators may not be able to change their power output very quickly. To keep the dispatch decision within such physical limitations, the following constraint is added to respect each generator’s ramp rate limit when ramping up, P˙gU\dot{P}_g^\text{U}, and when ramping down, P˙gD\dot{P}_g^\text{D}:

P˙gD≤Pgt−Pg, t−1Δt≤P˙gU\dot{P}_g^\text{D} \leq \frac{P_{gt} - P_{g,\,t-1}}{\Delta t} \leq \dot{P}_g^\text{U}

Ramp rate limits P˙gU\dot{P}_g^\text{U} and P˙gD\dot{P}_g^\text{D} are positive and negative values, respectively. For a given tt, only one side of this two-sided inequality constraint can be active.

The Unit Commitment Problem

The basic OPF problem (26) accounts for the power cost that is incurred by operating a generator at a certain setpoint (e.g., incurred due to fuel use). However, there are additional standby costs which depend on whether a generator is in a running state versus an off state over a given operating interval, and there are additional startup and shutdown costs which depend on whether the generator is transitioning from an off state to a running state (or vice versa) from one interval to the next. In order to account for these additional costs in our objective function, we must introduce additional binary decision variables, wgtw_{gt}, specifying whether generator gg is running (wgt=1w_{gt} = 1) or not (wgt=0w_{gt} = 0) over interval tt. This requires modifying constraint (19) as:

wgtSgmin≤Sgt≤wgtSgmaxw_{gt} S_g^\text{min} \leq S_{gt} \leq w_{gt} S_g^\text{max}

The variant of the OPF problem that includes standby, startup, and shutdown costs is thus a scheduling problem, and is known as the unit commitment (UC) problem Unit Commitment · PyPSA, 2026. Unit commitment refers to whether a generating unit (that is, a generator) has committed to be running—and thus able to supply power—at a given time.

Standby cost. In addition to a power cost, a generator might have a cost that is incurred as long as it is running, regardless of the generator’s setpoint. This is known as standby cost, CgSBC_g^\text{SB}, and it disincentivizes a generator from being run (and thus from generating any power) if there is a favorable alternative in terms of cost. For example, the grid operator may be willing to pay a disproportionately higher price to operate an already-running generator at a higher setpoint, rather than running a second generator to supply the extra power, if that second generator’s standby cost is high. Accounting for standby cost, the objective becomes:

min⁡P, w∑t∈T∑g∈Gwgt(Cg(P ⁣g)+CgSB)\min_{\mathbf{P}, \, \mathbf{w}} \sum_{t \in \mathcal{T}} \sum_{g \in \mathcal{G}} w_{gt} \left( C_g \bigl( P_{\! g} \bigr) + C_g^\text{SB} \right)

Startup and shutdown costs. In addition to a power cost and a standby cost, a generator might have costs associated with starting up and shutting down, denoted CgSUC_g^\text{SU} and CgSDC_g^\text{SD}, respectively. Startup and shutdown costs only matter if there are standby costs; if there were no standby costs, there would be no reason to shut down generators and thus no reason to incur startup or shutdown costs. Accounting for startup and shutdown costs in addition to standby cost, the objective function becomes:

∑t∈T∑g∈G[wgt(Cg(P ⁣g)+CgSB)+wgt(wg, t−1−1)CgSU+(wgt−1)wg, t−1CgSD]\sum_{t \in \mathcal{T}} \sum_{g \in \mathcal{G}} \left[ w_{gt} \left( C_g \bigl( P_{\! g} \bigr) + C_g^\text{SB} \right) + w_{gt} (w_{g,\,t-1} - 1) C_g^\text{SU} + (w_{gt} - 1) w_{g,\,t-1} C_g^\text{SD} \right]

where wgt(wg, t−1−1)w_{gt} (w_{g,\,t-1} - 1) and (wgt−1)wg, t−1(w_{gt} - 1) w_{g,\,t-1} indicate whether a generator has started up or shut down from one interval to the next, respectively.

Startup and shutdown ramp rate limits. Some generators have stricter ramp rate limits that apply specifically when starting up or shutting down, which can be accounted for using the following constraints:

P˙gSD≤wgt(wg, t−1−1)Pgt−Pg, t−1Δt(wgt−1)wg, t−1Pgt−Pg, t−1Δt≤P˙gSU\begin{gathered} \dot{P}_g^\text{SD} \leq w_{gt} (w_{g,\,t-1} - 1) \frac{P_{gt} - P_{g,\,t-1}}{\Delta t} \\ (w_{gt} - 1) w_{g,\,t-1} \frac{P_{gt} - P_{g,\,t-1}}{\Delta t} \leq \dot{P}_g^\text{SU} \end{gathered}

Minimum uptime and downtime. It may be required that a generator be in a standby/running state, or in an off state, for a minimum number of operating intervals. This can be accounted for using the following constraints:

minimum uptime≤∑t∈Twgtminimum downtime≤∑t∈T(1−wgt)\begin{gathered} \text{minimum uptime} \leq \sum_{t \in \mathcal{T}} w_{gt} \\ \text{minimum downtime} \leq \sum_{t \in \mathcal{T}} (1 - w_{gt}) \end{gathered}

The Linear Optimal Power Flow (LOPF) Problem

The power flow equations (12) contain quadratic terms multiplied with trigonometric functions, and branch flow constraint (20) is even more complicated. The power flow equations being nonlinear is easy enough when solving them as a system of equations, and the branch flow constraint being nonlinear is easy enough when evaluating the power flow solution, but when used as constraints in OPF, the nonlinearity makes the optimization problem significantly more difficult. To simplify (linearize) the power flow equations and branch flow constraint, thereby making the optimization problem easier, the following approximations are applied:

  1. Series resistance is negligible compared to series reactance: gik≈0g_{ik} \approx 0 and yik≈jbiky_{ik} \approx j b_{ik}. This approximation is reasonable for transmission lines and, combined with approximation 2, assumes a lossless network.

  2. Shunt conductance and susceptance are negligible: gikSh≈bikSh≈0g_{ik}^\text{Sh} \approx b_{ik}^\text{Sh} \approx 0.

  3. Turns ratios are approximately nominal: ∣aik∣≈1|a_{ik}| \approx 1.

  4. Voltage angle differences and transformer phase shifts are small: sin⁡(δi−δk−φik)≈δi−δk−φik\sin(\delta_i - \delta_k - \varphi_{ik}) \approx \delta_i - \delta_k - \varphi_{ik} and cos⁡(δi−δk)≈1\cos(\delta_i - \delta_k) \approx 1.

  5. Voltage magnitudes are approximately nominal: ∣V ⁣i∣≈∣Vk∣≈1 pu|V_{\! i}| \approx |V_k| \approx 1 \ \mathrm{pu} everywhere. This supports approximation 3 and holds for a lossless network.

We start by applying approximations 1–3 to equation (5) as follows. We will apply approximations 4 and 5 later.

(Si/V ⁣i)∗=V ⁣i ( ∑k:(i,k)∈L ⁣ ⁣ ⁣jbik + ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣ ⁣jbki) − ⁣ ⁣∑k:(i,k)∈L ⁣ ⁣ ⁣Vk (jbik ∠ φik) − ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣ ⁣Vk (jbki ∠ ⁣− ⁣φki)\begin{aligned} (S_i / V_{\! i})^* & = V_{\! i} \, \Biggl( \, \sum_{k : (i, k) \in \mathcal{L}} \!\!\! j b_{ik} \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\!\! j b_{ki} \Biggr) \\ & \, - \!\! \sum_{k : (i, k) \in \mathcal{L}} \!\!\! V_k \, (j b_{ik} \, \angle \, \varphi_{ik}) \, - \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\!\! V_k \, (j b_{ki} \, \angle \! - \! \varphi_{ki}) \end{aligned}

We redefine the bus admittance matrix Y ⁣Y \! as:

Y ⁣ii=jBii ∠Φii= ⁣ ⁣∑k:(i,k)∈L ⁣ ⁣ ⁣jbik + ⁣ ⁣∑k:(k,i)∈L ⁣ ⁣ ⁣jbkiY ⁣ik=jBik ∠Φik={−jbik ∠ φikif branch ik is an i-forward branch−jbki ∠ ⁣− ⁣φkiif branch ik is an i-reverse branch     0if branch ik does not exist (no branch)\begin{aligned} Y_{\! ii} = j B_{ii} \, \angle \Phi_{ii} & = \!\! \sum_{k : (i, k) \in \mathcal{L}} \!\!\! j b_{ik} \, + \!\! \sum_{k : (k, i) \in \mathcal{L}} \!\!\! j b_{ki} \\ Y_{\! ik} = j B_{ik} \, \angle \Phi_{ik} & = \begin{cases} - j b_{ik} \, \angle \, \varphi_{ik} & \text{if branch $ik$ is an $i$-forward branch} \\ - j b_{ki} \, \angle \! - \! \varphi_{ki} & \text{if branch $ik$ is an $i$-reverse branch} \\ \,\,\,\; 0 & \text{if branch $ik$ does not exist (no branch)} \end{cases} \end{aligned}

Equation (33) becomes:

(Si/V ⁣i)∗=∑k∈NVk (jBik ∠Φik)(S_i / V_{\! i})^* = \sum_{k \in \mathcal{N}} V_k \, (j B_{ik} \, \angle \Phi_{ik})

We take the conjugate and multiply both sides by V ⁣iV_{\! i}:

Si=∑k∈NV ⁣i Vk∗ (jBik ∠ ⁣− ⁣Φik)=∑k∈N [∣V ⁣i∣ ∣Vk∣ ∠ (δi−δk)] (jBik ∠ ⁣− ⁣Φik)=∑k∈N∣V ⁣i∣ ∣Vk∣ jBik ∠ (δi−δk−Φik)=∑k∈N∣V ⁣i∣ ∣Vk∣ jBik (cos⁡(δi−δk−Φik)+jsin⁡(δi−δk−Φik))\begin{aligned} S_i & = \sum_{k \in \mathcal{N}} V_{\! i} \, V_k^* \, (j B_{ik} \, \angle \! - \! \Phi_{ik}) \\ & = \sum_{k \in \mathcal{N}} \, [|V_{\! i}| \, |V_k| \, \angle \, (\delta_i - \delta_k)] \, (j B_{ik} \, \angle \! - \! \Phi_{ik}) \\ & = \sum_{k \in \mathcal{N}} |V_{\! i}| \, |V_k| \, j B_{ik} \, \angle \, (\delta_i - \delta_k - \Phi_{ik}) \\ & = \sum_{k \in \mathcal{N}} |V_{\! i}| \, |V_k| \, j B_{ik} \, (\cos(\delta_i - \delta_k - \Phi_{ik}) + j \sin(\delta_i - \delta_k - \Phi_{ik})) \end{aligned}

Splitting SiS_i into active and reactive power gives us:

Pi= ⁣ ⁣ ⁣ ⁣−∣V ⁣i∣∑k∈N∣Vk∣ Biksin⁡(δi−δk−Φik)Qi= ⁣ ⁣ ⁣ ⁣∣V ⁣i∣∑k∈N∣Vk∣ Bikcos⁡(δi−δk−Φik)\begin{aligned} P_i = \!\!\!\! && - & |V_{\! i}| \sum_{k \in \mathcal{N}} |V_k| \, B_{ik} \sin(\delta_i - \delta_k - \Phi_{ik}) \\ Q_i = \!\!\!\! &&& |V_{\! i}| \sum_{k \in \mathcal{N}} |V_k| \, B_{ik} \cos(\delta_i - \delta_k - \Phi_{ik}) \end{aligned}

For a branch between buses ii and kk, the power flowing into the branch from bus ii is as follows. (PikP_{ik} assumes sin⁡Φik≈0\sin \Phi_{ik} \approx 0.)

Pik= ⁣ ⁣ ⁣ ⁣−∣V ⁣i∣ ∣Vk∣ Biksin⁡(δi−δk−Φik)Qik= ⁣ ⁣ ⁣ ⁣∣V ⁣i∣ ∣Vk∣ Bikcos⁡(δi−δk−Φik)−∣V ⁣i∣2Bik\begin{aligned} P_{ik} = \!\!\!\! && - & |V_{\! i}| \, |V_k| \, B_{ik} \sin(\delta_i - \delta_k - \Phi_{ik}) \\ Q_{ik} = \!\!\!\! &&& |V_{\! i}| \, |V_k| \, B_{ik} \cos(\delta_i - \delta_k - \Phi_{ik}) - |V_{\! i}|^2 B_{ik} \end{aligned}

Applying approximation 4 yields:

Pik= ⁣ ⁣ ⁣ ⁣−∣V ⁣i∣ ∣Vk∣ Bik ⁣ (δi−δk−Φik)Qik= ⁣ ⁣ ⁣ ⁣∣V ⁣i∣ ∣Vk∣ Bik−∣V ⁣i∣2Bik\begin{aligned} P_{ik} = \!\!\!\! && - & |V_{\! i}| \, |V_k| \, B_{ik} \!\: (\delta_i - \delta_k - \Phi_{ik}) \\ Q_{ik} = \!\!\!\! &&& |V_{\! i}| \, |V_k| \, B_{ik} - |V_{\! i}|^2 B_{ik} \end{aligned}

And, finally, applying approximation 5 gives us:

Pik=Bik ⁣ (δi−δk−Φik)Qik=0\begin{aligned} P_{ik} & = B_{ik} \!\: (\delta_i - \delta_k - \Phi_{ik}) \\ Q_{ik} & = 0 \end{aligned}

Now, when we once again sum the power flowing out of every bus ii, it includes only active power:

Pi= ⁣ ⁣ ⁣∑k∈N ⁣, k≠i ⁣ ⁣ ⁣ ⁣Pik=− ⁣ ⁣ ⁣∑k∈N ⁣, k≠i ⁣ ⁣ ⁣ ⁣Bik(δi−δk−Φik)P_i = \!\!\! \sum_{k \in \mathcal{N} \! , \, k \neq i} \!\!\!\! P_{ik} = - \!\!\! \sum_{k \in \mathcal{N} \! , \, k \neq i} \!\!\!\! B_{ik} (\delta_i - \delta_k - \Phi_{ik})

This is the linear power flow equation, which applies to every bus ii and is much simpler than the original (nonlinear) power flow equation due to the approximations applied. Because the linear power flow equation approximates voltage magnitudes as nominal and assumes zero reactive power, there is no differentiating between PQ and PV buses. Furthermore, the lack of reactive power allows us to simplify the branch flow constraint (20):

−Plmax≤Pik≤Plmax ∀ (i,k)∈L- P_l^\text{max} \leq P_{ik} \leq P_l^\text{max} \ \forall \ (i, k) \in \mathcal{L}

When OPF uses the linear power flow equation and the correspondingly simplified branch flow constraint, it is known as linear optimal power flow (LOPF).

Table 2:Linear power flow is analogous to DC circuit analysis.

Linear power flowDC circuit analysis
Conservation of power flowConservation of current flow (KCL)
PiP_i, PikP_{ik}IiI_i, IikI_{ik}
θi\theta_i, θk\theta_kV ⁣iV_{\! i}, VkV_k
Φik\Phi_{ik}ΔV ⁣ik{\Delta V}_{\! ik}
−1/Bik-1 / B_{ik}RikR_{ik}

Cycle-Based Formulation

The LOPF problem uses bus voltage angles as decision variables, but there are advantages to using the branch power flows instead. For such an alternate formulation, we are still constraining the net power injected at each bus ii to equal the total power flowing into the bus from each connected branch, but we do so in terms of the branch power flow PlP_l. We refer to the signed incidence matrix (C t−C fC^{\, \text{t}} - C^{\, \text{f}}) to indicate whether PlP_l is flowing into or out of bus ii (+1 or -1, or 0 if ll is not connected to it):

Pi= ⁣ ⁣ ⁣∑k∈N ⁣, k≠i ⁣ ⁣ ⁣ ⁣Pik=∑l∈L (Cl,i t−Cl,i f) PlP_i = \!\!\! \sum_{k \in \mathcal{N} \! , \, k \neq i} \!\!\!\! P_{ik} = \sum_{l \in \mathcal{L}} \, (C^{\, \text{t}}_{l, i} - C^{\, \text{f}}_{l, i}) \, P_l

This increases the number of variables while the number of equations in the system stays the same. To make the system solvable, we apply Kirchhoff’s Voltage Law (KVL), which states that the net voltage difference around each loop or cycle in the circuit/grid is zero. This means that if we add up the voltage difference Vi−VkV_i - V_k across every branch ikik in a given cycle, they must add up to zero. Because we assume V=1 puV = 1 \ \mathrm{pu}, this becomes 1∠δi−1∠δk1 \angle \delta_i - 1 \angle \delta_k. Ensuring these sum to zero around a given cycle is equivalent to just ensuring that the cycle’s voltage angle differences (Δδl=δi−δk{\Delta \delta}_l = \delta_i - \delta_k) sum to zero, or:

∑l∈LCl,c Δδl=0∀ c∈C\sum_{l \in \mathcal{L}} C_{l, c} \, {\Delta \delta}_l = 0 \quad \forall \ c \in \mathcal{C}

where C\mathcal{C} is the set of cycles, and Cl,cC_{l, c} indicates whether branch ll is in cycle cc (+1 or -1 depending on the direction, or 0 if absent). Using Equation (40), we can express this in terms of the decision variables PlP_l as follows, thereby completing the system of equations.

∑l∈LCl,c(Plbl+φl)=0∀ c∈C\sum_{l \in \mathcal{L}} C_{l, c} \left( \frac{P_l}{b_l} + \varphi_l \right) = 0 \quad \forall \ c \in \mathcal{C}

Summary

We’ve introduced many concepts; Figure 6 provides a summary of these concepts and how they relate to each other.

This chapter’s concepts and how they inter-relate.

Figure 6:This chapter’s concepts and how they inter-relate.

Appendix: Branch-From-Bus and Branch-To-Bus Admittance Matrices

The bus admittance matrix Y ⁣Y \! is a convenient way to encapsulate the complexity of series admittances (yy), shunt admittances (yShy^\text{Sh}), and transformer ratios (aa). However, because each diagonal element Y ⁣iiY_{\! ii} is a sum over every ii-connected branch, the bus admittance matrix does not allow us to calculate individual branch current and power values (IikI_{ik} and SikS_{ik}). This can be overcome using the bus admittance matrix with a “branch-from-bus” admittance matrix YfY^\text{f} and a “branch-to-bus” admittance matrix Yt ⁣Y^\text{t} \!. Both of these matrices are sparse matrices of dimension N ⁣× ⁣LN \! \times \! L, where NN is the number of buses and LL is the number of branches; both matrices have a row for each branch and a column for each bus. For a branch ll from bus ii to bus kk, row ll of each matrix has nonzero entries only in columns ii and kk:

Yl,if=1 ∣aik∣2(yikSh2+yik)Yl,kf=−yikaik∗Yl,it=−yikaikYl,kt=yikSh2+yik\begin{aligned} Y^\text{f}_{l, i} & = \frac{1}{\, |a_{ik}|^2} \left( \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \right) \qquad & Y^\text{f}_{l, k} & = - \frac{y_{ik}}{a_{ik}^*} \\ % \qquad % & Y^\text{f}_{l, m} & = 0 \ \forall \ m \neq i, m \neq k \\ Y^\text{t}_{l, i} & = - \frac{y_{ik}}{a_{ik}} \qquad & Y^\text{t}_{l, k} & = \frac{y_{ik}^\text{Sh}}{2} + y_{ik} \\ % \qquad % & Y^\text{t}_{l, m} & = 0 \ \forall \ m \neq i, m \neq k \end{aligned}

The familiar bus admittance matrix can be reconstructed from these as follows, using branch-from-bus and branch-to-bus incidence matrices C fC^{\, \text{f}} and C tC^{\, \text{t}}:

Y=(C f ) ⁣⊤Yf+(C t) ⁣⊤YtY = (C^{\, \text{f} \,})^{\! \top} Y^\text{f} + (C^{\, \text{t}})^{\! \top} Y^\text{t}

Matrices C fC^{\, \text{f}} and C tC^{\, \text{t}} are also N ⁣× ⁣LN \! \times \! L sparse matrices, consisting mostly of zeroes. C fC^{\, \text{f}} contains a “1” entry indicating the bus that each branch originates from. Similarly, C tC^{\, \text{t}} indicates which bus each branch goes to.

Footnotes
  1. Index kk is used instead of jj to distinguish it from the imaginary unit.

  2. Not to be confused with generator index gg.

  3. To learn more about the economics of operating the electrical grid, see How Electricity Markets Work.

References
  1. Power System Model · JuliaGrid. (n.d.). Retrieved June 6, 2026, from https://mcosovic.github.io/JuliaGrid.jl/stable/tutorials/powerSystemModel/
  2. Mones, L. (2020, December 4). A Gentle Introduction to Power Flow. Invenia Blog. https://invenia.github.io/blog/2020/12/04/pf-intro/
  3. Power Flow · PyPSA. (n.d.). Retrieved July 4, 2026, from https://docs.pypsa.org/latest/user-guide/power-flow/
  4. Per-Unit System · JuliaGrid. (n.d.). Retrieved July 4, 2026, from https://mcosovic.github.io/JuliaGrid.jl/stable/tutorials/perunit/
  5. Biddle, C. J. (2024, May 1). Understanding the Differences Between Non-Dispatchable and Dispatchable Generation. PCI Energy Solutions. https://www.pcienergysolutions.com/2024/05/01/understanding-the-differences-between-non-dispatchable-and-dispatchable-generation/
  6. Frank, S., & Rebennack, S. (2016). An Introduction to Optimal Power Flow: Theory, Formulation, and Examples. IIE Transactions, 48(12), 1172–1197. 10.1080/0740817X.2016.1189626
  7. Mones, L. (2021, June 18). A Gentle Introduction to Optimal Power Flow. Invenia Blog. https://invenia.github.io/blog/2021/06/18/opf-intro/
  8. Unit Commitment · PyPSA. (n.d.). Retrieved July 28, 2026, from https://docs.pypsa.org/latest/user-guide/optimization/unit-commitment/