Gauss–Seidel Load Flow
The load-flow equations are nonlinear because loads and generators are given as powers. The oldest practical way to solve them, used on the first digital computers in the 1950s, is to guess every voltage and then sweep through the buses, correcting one voltage at a time with the latest values of its neighbours. That is the Gauss–Seidel method (Jacobi and Gauss–Seidel Iteration) applied to . It is simple, needs almost no memory, and still serves as a teaching method and as a starter for Newton–Raphson; its weakness is slow convergence on large systems.
Safety. The network is a system, so this lesson is calculation and simulation only. The bench analogue at the end is a resistor grid on a current-limited supply.
The update for a PQ bus
From , solve for the term with :
The right-hand side uses the newest voltages available: buses already updated in this sweep, old values for the rest. A flat start sets every unknown voltage to (PV buses at their setpoint), which is close to any normal operating point.
PV buses
At a PV bus, is unknown but is fixed. Each sweep:
- compute from the present voltages,
- update with the formula above using that ,
- keep the new angle but scale the magnitude back to the setpoint.
If goes beyond the generator's reactive limit, the generator can no longer hold its voltage: fix at the limit and treat the bus as a PQ bus from then on (a production program also checks whether it can switch back later).
Acceleration
The plain update often creeps towards the solution. Over-relaxation takes a larger step, with an acceleration factor between 1 and 2. Textbooks often quote for large systems, but the best value depends on the network: for N4 it is about to (11 sweeps at , 9 at ), and is much worse than no acceleration at all. The number of iterations of Gauss–Seidel grows roughly in proportion to the number of buses, which is why Newton–Raphson replaced it for real grids.
Worked example: the first sweep by hand
Given: N4 (The Load-Flow Problem), flat start , .
Find: the first estimates of , and .
Solve: with , and the other entries from the Y-bus, the current injected at bus 2 at the flat start is , and
Check: bus 3 drops below and lags, as a load bus should. Bus 2's angle starts positive and only turns negative over later sweeps, once the loads at buses 3 and 4 have pulled their angles down: Gauss–Seidel moves information one neighbour per sweep, which is why it is slow. The converged values are in the program's output: , .
In Python: Gauss–Seidel with PV buses, acceleration and a limit
import numpy as np
import matplotlib.pyplot as plt
lines = [(1, 2, 0.01, 0.05, 0.04), (1, 3, 0.02, 0.08, 0.05), (2, 3, 0.015, 0.06, 0.04),
(2, 4, 0.02, 0.08, 0.05), (3, 4, 0.025, 0.10, 0.06)]
n = 4
Y = np.zeros((n, n), dtype=complex)
for i, k, r, x, b in lines:
i, k = i - 1, k - 1
y = 1 / complex(r, x)
Y[i, i] += y + 0.5j * b; Y[k, k] += y + 0.5j * b
Y[i, k] -= y; Y[k, i] -= y
P = np.array([0.0, 1.0, -1.5, -1.0]) # specified injections (pu); bus 1 = slack
Qs = np.array([0.0, 0.0, -0.6, -0.4])
pv = {1: 1.02} # bus index (0-based): voltage setpoint
def gauss_seidel(alpha=1.0, qmax=None, tol=1e-6, maxit=500, hist=None):
V = np.array([1.04, 1.02, 1.0, 1.0], dtype=complex) # flat start
Q = Qs.copy()
is_pv = dict(pv)
for it in range(1, maxit + 1):
dmax = 0.0
for i in range(1, n):
if i in is_pv: # PV bus: Q from the present voltages
Q[i] = -np.imag(np.conj(V[i]) * (Y[i] @ V))
if qmax is not None and Q[i] > qmax: # limit hit: becomes a PQ bus
Q[i] = qmax
del is_pv[i]
sigma = Y[i] @ V - Y[i, i] * V[i]
Vgs = ((P[i] - 1j * Q[i]) / np.conj(V[i]) - sigma) / Y[i, i]
Vnew = V[i] + alpha * (Vgs - V[i])
if i in is_pv:
Vnew *= is_pv[i] / abs(Vnew) # hold |V| at the setpoint
dmax = max(dmax, abs(Vnew - V[i]))
V[i] = Vnew
if hist is not None:
hist.append(dmax)
if dmax < tol:
return V, Q, it
return V, Q, maxit
for a in [1.0, 1.2, 1.4, 1.6, 1.8]:
V, Q, it = gauss_seidel(alpha=a)
print(f"alpha = {a:.1f}: converged in {it:3d} iterations")
V, Q, it = gauss_seidel(alpha=1.2)
S = V * np.conj(Y @ V)
for i in range(n):
print(f"bus {i+1}: |V| = {abs(V[i]):.4f} pu, angle = {np.degrees(np.angle(V[i])):7.3f} deg")
print(f"slack: P = {S[0].real:.4f}, Q = {S[0].imag:.4f} pu; bus 2 Q = {S[1].imag:.4f} pu; losses {S.real.sum():.4f} pu")
V, Q, it = gauss_seidel(alpha=1.2, qmax=0.25)
print(f"with Q2 <= 0.25 pu: bus 2 is PQ, |V2| = {abs(V[1]):.4f}, |V3| = {abs(V[2]):.4f}, |V4| = {abs(V[3]):.4f} pu")
for a in [1.0, 1.2, 1.6]:
h = []
gauss_seidel(alpha=a, hist=h)
plt.semilogy(range(1, len(h) + 1), h, marker="o", ms=3, label=f"alpha = {a}")
plt.xlabel("iteration"); plt.ylabel("largest voltage change (pu)")
plt.title("Gauss-Seidel on N4"); plt.legend(); plt.grid(True, which="both", alpha=0.3)
plt.show()alpha = 1.0: converged in 19 iterations
alpha = 1.2: converged in 11 iterations
alpha = 1.4: converged in 13 iterations
alpha = 1.6: converged in 23 iterations
alpha = 1.8: converged in 54 iterations
bus 1: |V| = 1.0400 pu, angle = 0.000 deg
bus 2: |V| = 1.0200 pu, angle = -1.439 deg
bus 3: |V| = 0.9916 pu, angle = -3.791 deg
bus 4: |V| = 0.9792 pu, angle = -4.826 deg
slack: P = 1.5504, Q = 0.6731 pu; bus 2 Q = 0.2897 pu; losses 0.0504 pu
with Q2 <= 0.25 pu: bus 2 is PQ, |V2| = 1.0186, |V3| = 0.9907, |V4| = 0.9780 pu
At the method converges (largest change below ) in 11 sweeps. The slack generator supplies and , bus 2 produces to hold its , and the lines lose . If bus 2's generator can give only , its voltage falls to and every load bus sags a little with it. The plot shows the convergence: nearly a straight line on the log scale (linear convergence, a constant factor per sweep), steepest for .
Guided lab: iterate a resistor grid by hand
Hand calculation. The DC resistor grid of the previous lesson ( at node 1; , , , , for lines 1–2, 1–3, 2–3, 2–4, 3–4; loads at node 3 and at node 4) is the linear version of the same problem: . Starting from everywhere, the first sweep gives , , , the second , , . Do these two sweeps by hand.
Simulation. Adapt the program (real conductances, no PV bus): it needs 15 sweeps to settle within at , and , the values the netlist lab in the previous lesson shows.
What you would measure. On the breadboard grid ( resistors, supply , current limit ), a DMM reads the node voltages within about , i.e. : the iteration's answer, not its intermediate sweeps, is what the circuit "computes" instantly. In a real control room, the equivalent check is comparing the load-flow result with SCADA measurements: VT and transducer chains are accurate to roughly to , and the mismatch is handled by the state estimator.
Hazards and safe setup. DC with a current limit; check resistor values before switching on, since a wrong low value across the supply overheats. The load resistors dissipate about () and (): use or larger parts there (the line resistors stay below ).
Pitfalls
- Forgetting to reset the PV magnitude after each update: the bus then drifts like a PQ bus with from the last sweep.
- Using the conjugate wrongly. The update needs .
- Ignoring limits. A generator that "holds" with more reactive power than it can produce is a fiction; the voltages it supports are optimistic.
- Too much acceleration. Over-relaxation beyond the optimum slows convergence and can make it diverge.
- A loose tolerance. A change below per sweep does not mean the voltages are within of the answer when convergence is slow; check the power mismatches at the end.
Practice
- Why does the slack bus never get updated?
- What is at the converged solution, and is the generator producing or absorbing reactive power?
- Gauss–Seidel takes 19 sweeps on N4 without acceleration. Roughly how would that scale for a 1000-bus network?
Answer
- Its voltage magnitude and angle are both specified; its and are computed once at the end from the converged voltages.
- , positive in the generator convention: it produces reactive power (over-excited).
- Roughly in proportion to the number of buses, so hundreds to thousands of sweeps; this is why Newton–Raphson, whose iteration count barely depends on size, took over.
Test yourself
In a Gauss–Seidel sweep, the update of bus uses…
- only the voltages from the previous sweep
- the newest available voltages, including those already updated in this sweep
- only the slack voltage
- the Jacobian matrix
At a PV bus, after computing the new complex voltage, the method…
- keeps it as is
- keeps its magnitude and resets the angle to zero
- keeps its angle and rescales the magnitude to the setpoint
- discards it
A generator at a PV bus reaches its reactive power limit. The load flow should…
- stop with an error
- fix at the limit and treat the bus as PQ
- raise its voltage setpoint
- make it the slack bus
For N4, which acceleration factor converged fastest?
- 1.0
- 1.2
- 1.6
- 1.8