Newton–Raphson Load Flow
Gauss–Seidel needs 19 sweeps for N4 and hundreds to thousands for a real grid. Every industrial load-flow program today (and every optimal power flow, contingency analysis and state estimator built on it) uses Newton–Raphson instead: it linearises all the equations at once around the present guess and solves for the whole correction in one step. Its convergence is quadratic: the number of correct digits roughly doubles every iteration, and three to five iterations suffice whether the network has four buses or forty thousand.
Safety. The network is a system: calculation and simulation only. The bench analogue at the end uses a current-limited supply and an electronic load.
The method itself is in Newton's Method for Systems; here it is applied to the power-flow equations.
Mismatches and the Jacobian
Collect the unknowns in a vector : the angles of all PV and PQ buses and the magnitudes of the PQ buses. The mismatches are specified minus calculated powers:
with one for every non-slack bus and one for every PQ bus. Newton's step solves the linearised equations
and updates , . From the polar power equations, with , the off-diagonal elements () are
and the diagonal elements can be written neatly with the calculated injections:
The Jacobian has the same sparsity as , so sparse LU factorisation keeps each iteration cheap. On transmission networks and dominate (because and angles are small): depends on angles, on magnitudes, the coupling the reactive-power lesson found. Dropping and and freezing the rest gives the fast decoupled load flow (Stott and Alsac, 1974), which needs a few more iterations but factorises its matrices only once.
Worked example: one diagonal element by hand
Given: N4 at the flat start (, all angles 0), .
Find: the calculated and the Jacobian element .
Solve: at the flat start all angles are zero, so :
Check: the element is close to , the "short-circuit" susceptance at bus 3, as the DC load flow will assume. A positive means advancing bus 3's angle pushes power out of the bus into the network. The calculated at the flat start is negative because the higher voltages at buses 1 and 2 already push reactive power into bus 3 through the lines.
In Python: Newton–Raphson with the analytic Jacobian
import numpy as np
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
G, B = Y.real, Y.imag
Psp = np.array([0.0, 1.0, -1.5, -1.0]) # specified injections, pu
Qsp = np.array([0.0, 0.0, -0.6, -0.4])
pv, pq = [1], [2, 3] # 0-based: bus 2 is PV, buses 3 and 4 PQ
ang = pv + pq # buses with unknown angle
def injections(Vm, th):
V = Vm * np.exp(1j * th)
S = V * np.conj(Y @ V)
return S.real, S.imag
def jacobian(Vm, th):
P, Q = injections(Vm, th)
J1 = np.zeros((n, n)); J2 = np.zeros((n, n)); J3 = np.zeros((n, n)); J4 = np.zeros((n, n))
for i in range(n):
for k in range(n):
t = th[i] - th[k]
if i != k:
J1[i, k] = Vm[i] * Vm[k] * (G[i, k] * np.sin(t) - B[i, k] * np.cos(t)) # dP/dtheta
J2[i, k] = Vm[i] * (G[i, k] * np.cos(t) + B[i, k] * np.sin(t)) # dP/d|V|
J3[i, k] = -Vm[i] * Vm[k] * (G[i, k] * np.cos(t) + B[i, k] * np.sin(t)) # dQ/dtheta
J4[i, k] = Vm[i] * (G[i, k] * np.sin(t) - B[i, k] * np.cos(t)) # dQ/d|V|
J1[i, i] = -Q[i] - B[i, i] * Vm[i] ** 2
J2[i, i] = P[i] / Vm[i] + G[i, i] * Vm[i]
J3[i, i] = P[i] - G[i, i] * Vm[i] ** 2
J4[i, i] = Q[i] / Vm[i] - B[i, i] * Vm[i]
return np.block([[J1[np.ix_(ang, ang)], J2[np.ix_(ang, pq)]],
[J3[np.ix_(pq, ang)], J4[np.ix_(pq, pq)]]])
Vm = np.array([1.04, 1.02, 1.0, 1.0]) # flat start
th = np.zeros(n)
for it in range(10):
P, Q = injections(Vm, th)
mis = np.r_[Psp[ang] - P[ang], Qsp[pq] - Q[pq]]
print(f"iteration {it}: largest mismatch {np.abs(mis).max():.3e} pu")
if np.abs(mis).max() < 1e-8:
break
dx = np.linalg.solve(jacobian(Vm, th), mis)
th[ang] += dx[:len(ang)]
Vm[pq] += dx[len(ang):]
for i in range(n):
print(f"bus {i+1}: |V| = {Vm[i]:.4f} pu, angle {np.degrees(th[i]):7.3f} deg")
V = Vm * np.exp(1j * th)
print("line flows (sending end) and losses:")
total = 0
for i, k, r, x, b in lines:
a, c = i - 1, k - 1
y = 1 / complex(r, x)
Iik = (V[a] - V[c]) * y + V[a] * 0.5j * b # current leaving bus i into the line
Iki = (V[c] - V[a]) * y + V[c] * 0.5j * b
Sik, Ski = V[a] * np.conj(Iik), V[c] * np.conj(Iki)
total += (Sik + Ski).real
print(f" {i}-{k}: {100*Sik.real:7.2f} MW {100*Sik.imag:+7.2f} Mvar, loss {100*(Sik+Ski).real:.2f} MW")
print(f"total losses {100*total:.2f} MW")iteration 0: largest mismatch 1.304e+00 pu
iteration 1: largest mismatch 3.927e-02 pu
iteration 2: largest mismatch 8.504e-05 pu
iteration 3: largest mismatch 5.924e-10 pu
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
line flows (sending end) and losses:
1-2: 59.37 MW +28.23 Mvar, loss 0.41 MW
1-3: 95.67 MW +39.07 Mvar, loss 2.02 MW
2-3: 76.78 MW +28.37 Mvar, loss 0.98 MW
2-4: 82.17 MW +31.03 Mvar, loss 1.52 MW
3-4: 19.45 MW +4.65 Mvar, loss 0.11 MW
total losses 5.04 MW
The mismatch falls from to , , : the exponent roughly doubles each time, the signature of quadratic convergence. The answer is the one Gauss–Seidel found. The line table is the useful engineering output: line 1–3 carries and loses , the most of any line, so it would be the first candidate for reinforcement; line 3–4 is almost idle. The total loss, or of the load, is what the slack generator supplies on top of its share.
Guided lab: a constant-power load on a DC grid
Hand calculation. Take the bench DC grid of the previous lessons ( at node 1; , , , , lines; at node 4) and replace the at node 3 by a constant-power load of . Node 3's equation becomes : nonlinear, like the AC load flow. Write the Jacobian (it is with added to the node-3 diagonal).
Simulation. A ten-line NR program started from converges in 5 iterations to , , . Started from it finds a second, low-voltage solution: , with a large current at a small voltage. Both satisfy the equations; only the high-voltage one is a normal operating point. That second root is the seed of voltage collapse.
What you would measure. Set a bench electronic load to constant-power mode at (check its minimum operating voltage, typically about ), supply with the current limit at . Expect node voltages within about of the prediction and a load current of . Load regulators settle in milliseconds; read after a second.
Hazards and safe setup. DC, current-limited, resistors: parts for the lines (each below ), for the load, which dissipates about . Never turn the load's power setting up to the point where the voltage collapses with a supply that is not current-limited.
Pitfalls
- Including the slack bus in the unknowns, or a equation for a PV bus: the Jacobian becomes singular or wrong.
- Degrees and radians. The Jacobian is per radian; convert only for printing.
- Sign of the mismatch. Specified minus calculated, and ; flipping one sign makes the iteration diverge.
- Trusting the first converged answer. A flat start almost always reaches the normal solution, but near the loadability limit Newton–Raphson can converge to the low-voltage root or not at all.
- Ignoring PV-bus limits (as in Gauss–Seidel): check after convergence, switch to PQ, and repeat.
Practice
- How many equations and unknowns does N4's Newton–Raphson have? What would they be if bus 2 were a PQ bus?
- At the solution, which line carries the most reactive power, and why might bus 1's generator be the one supplying it?
- A 1000-bus system has 100 PV buses and one slack. What is the size of its Jacobian?
Answer
- Five: for . With bus 2 as PQ, six (add and ).
- Line 1–3 with : bus 1 has the highest voltage () and reactive power flows from high to low voltage, towards the biggest load at bus 3.
- angle unknowns plus magnitude unknowns: , with only a few nonzeros per row.
Test yourself
Newton–Raphson load flow converges…
- linearly, like Gauss–Seidel
- quadratically near the solution: correct digits roughly double each iteration
- in exactly one iteration
- only for radial networks
Which Jacobian blocks dominate on a high-voltage transmission network?
- and
- and
- all are equal
- only
For a PV bus, the Newton–Raphson equations include…
- and
- only (its angle is unknown, its magnitude is fixed)
- only
- nothing
Why is the Jacobian cheap to factorise for a large grid?
- it is diagonal
- it has the sparsity pattern of the Y-bus
- it is always positive definite
- it is computed only once