S10 · Lesson 52 · Project
Finishing the power-flow program with polar Newton–Raphson including generator (PV) buses, branch flows and losses from the solved voltages, and three-phase fault currents and voltages from the bus impedance matrix
With the admittance matrix and injections from the lab, you have what you need for a real power-flow program. This project adds the three parts that make it useful: a Newton–Raphson solver that handles generator buses holding their voltage, a branch-flow report that shows how power actually moves and where it's lost, and a fault calculator built on the bus impedance matrix. The test network is small enough to check by hand and lossy enough that shortcuts show.
Predict
The three-bus test case has a slack at 1.05 pu and a generator bus held at 1.02 pu delivering 0.5 pu, feeding a 1 + j0.4 pu load. Will the generator at 1.02 pu supply vars or absorb them?
Reactive power flows from higher voltage magnitude to lower (lesson 7). With the slack at 1.05 and its neighbor held at 1.02, the generator must absorb vars to keep its voltage that low: the solution has = −0.153 pu, while the slack supplies 0.622 pu. Moving the setpoint to 1.05 would turn the generator into a var source.
Name it
The test network
Bus 0 is the slack at 1.05∠0°; bus 1 is PV with P = 0.5 pu and |V| = 1.02; bus 2 is PQ with a load of 1 + j0.4 pu. Branches: 0–1 with 0.02 + j0.10, 0–2 with 0.03 + j0.15 and 0.02 of charging, 1–2 with 0.025 + j0.12 (all per unit).
Newton–Raphson in polar form
Unknowns: the angles of PV and PQ buses and the magnitudes of PQ buses. With , the derivatives of the injections are compact in matrix form:
Their real and imaginary parts, restricted to the right rows and columns, are the four Jacobian blocks. Solve, update, repeat until the largest mismatch is below 10⁻¹⁰.
Branch flows
For branch (i, j, r, x, b, a), the currents leaving each end are and , and the flows are , . Their sum is the branch's loss, real and reactive.
Faults
With each generator's subtransient admittance added to its bus's diagonal, , and (lesson 36).
Worked example
What does the solution look like?
Show the solution
- Convergence. It takes four Newton steps from a flat start.
- Bus voltages. They are 1.05∠0°, 1.02∠0.0957° and 0.99149∠−3.3835°.
- Power balance. The slack supplies 0.5183 + j0.6220 pu, the generator 0.5 − j0.1527, the load takes 1 + j0.4, and the network loses 0.01833 pu of real power (1.8 MW on 100 MVA).
- Cross-check. An independent Gauss–Seidel with PV handling agrees to ten digits.
Answer after four Newton steps the voltages are 1.05∠0°, 1.02∠0.0957° and 0.99149∠−3.3835°, and the network loses 0.01833 pu (1.8 MW).
Worked example
How can you check a branch-flow routine without another program?
Show the solution
- At every bus. The flows leaving into its branches must add up to its injection.
- Over the whole network. The sum over all branches of must equal the sum of all injections, which is the total loss.
- What they catch. Both checks catch the common mistakes, a missing half of the charging or a tap applied on the wrong end.
Answer check conservation: at each bus the branch flows must add up to the injection, and the branch losses, summed, must equal the sum of all injections.
Check
Step 1. Write newton(Y, types, P, Q, Vm, Va): polar Newton–Raphson with PV buses.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 2. Write branch_flows(V, branches): power at both ends of every branch.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 3. Write fault(Y, k): three-phase fault current and bus voltages from the bus impedance matrix.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why does a PV bus contribute a row to the angle equations but not to the voltage-magnitude equations?
At a PV bus the generator's controls fix two things: the real power, set by its turbine, and the voltage magnitude, held by its exciter. The magnitude is therefore known, not an unknown, so there's no ΔQ equation to solve for it; the generator supplies whatever reactive power that voltage takes, which comes out of the solution. The angle, though, depends on how power flows through the network and must be solved for, using the real-power mismatch at that bus. Each PV bus thus contributes one unknown and one equation, compared with two of each at a PQ bus.
Practice
Keep practicing
3 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.