← Physics-informed GNN course

Physics-informed GNN · Microgrids & distribution systems

Unbalanced Power Flow

Three customers can draw the same total power as a balanced load and still produce very different phase voltages. What changes when most demand sits on phase A, or a rooftop inverter supplies only one phase? This chapter keeps all three phases and the neutral conductor, then lets you test the answer.

1. From one equivalent phase to four conductors

In the Balanced Power Flow chapter, phase magnitudes were equal and phase angles were separated by 120°. A single equivalent phase described the network. Single-phase customers and inverters break that symmetry: each phase now has its own complex power, voltage, and current.

An unequal load also produces neutral return current. If the neutral conductor has finite impedance, its local voltage differs from the grounded source neutral. A customer’s voltage is the phase-to-local-neutral voltage, not just the phase-conductor voltage measured against the source reference. Explicit four-wire modeling is therefore useful for low-voltage feeders; see the four-wire modeling study by Claeys, Geth, and Deconinck.

First observe the three phase voltages at a load terminal. Dashed rays show an ideal 1 pu balanced source; solid rays show voltages relative to the local neutral. Both magnitudes and angle separations can differ. The operating point follows the experiment below; the feeder and observation bus are introduced in the worked example.

Modeling assumptions

This chapter uses a phase-domain, four-wire AC model. Its equations and experiments make the following assumptions:

  • Sinusoidal steady state: voltages and currents are fundamental-frequency RMS complex phasors; harmonics are excluded.
  • Radial network: retain the a, b, c phase conductors and the n neutral, and calculate branch currents and conductor voltages along the feeder.
  • One balanced ideal source: its phase-voltage magnitudes and angles are fixed, and its neutral is grounded. Downstream neutrals return through the neutral wire, without additional grounding or earth-return paths.
  • Wye constant-PQ devices: loads specify P and Q per phase; solar inverters inject specified active power with Q = 0. They connect phase to local neutral and do not regulate bus voltage.
  • Series four-conductor lines: retain phase and neutral resistance and reactance, plus adjustable phase-phase mutual reactance. Phase-neutral mutual terms are zero; shunts and transformers are omitted.

These assumptions define the general model. First derive its equations with generic labels i, j, and k; the worked example then introduces the feeder, bus numbers, and phase demands.

Before moving a slider, predict: if phase A demand increases, must phases B and C both fall by the same amount? The shared neutral makes that assumption unreliable.

2. Derive the phase-domain equations

Step A — Separate conductor and load-terminal voltages

Use RMS complex phasors. Let Vi,a, Vi,b, Vi,c, Vi,n denote conductor voltages against the source reference. The wye load terminals see:

Load voltage depends on both the phase and local neutral

Line Z (4×4) abcn Vⱼ,ₐVⱼ,ᵦVⱼ,𝒸Vⱼ,ₙVᵢ,ₙ = 0IₐIₙ = −Σ IφUⱼ,ₐ

Swipe sideways to see the full diagram.

A voltage difference is a phasor difference
ReIm0VφVₙUφ
Two things to notice

Uφ = Vφ − Vₙ

The green vector starts at the local neutral. A shifted neutral changes the load voltage even when the phase-to-reference voltage changes little.

Neutral current is the negative phasor sum of the phase currents, not a sum of magnitudes. The line's Z includes its self impedances and the modeled coupling terms.

The conductor diagram shows connectivity; the phasor diagram shows voltage references. Phasor lengths are illustrative. All conductor currents use i → j as their reference direction, hence Iₙ = −ΣIφ. The shared local neutral returns through finite wire impedance, without downstream grounding.

Let SB,3φ be the three-phase power base and VB,LL the line-to-line voltage base. Phase-specific powers need corresponding per-phase bases:

Divide each phase’s power by the per-phase power base, and divide total three-phase power by the three-phase base. The worked example substitutes numerical values to check both conversions.

Step B — Convert each constant-PQ demand into current

Define positive net demand as consumption. For the unity-power-factor PV used here, si,φ = (PD,i,φ − PPV,i,φ) + jQD,i,φ. This demand convention is the negative of the previous chapter’s net-injection convention. QD = PD tan(arccos PF).

The four terminal currents sum to zero. An ideal zero-impedance neutral can still carry a nonzero current. The zero-current result applies to balanced fundamental-frequency phase currents; this chapter does not include harmonics.

Step C — Apply KVL to the four-wire line

For each branch, collect conductor voltages and currents into four-component vectors. A general series model uses a 4 × 4 impedance matrix:

The interactive line matrix is symmetric, with identical phase self impedances zs, phase mutual impedance zm = jxm, and neutral self impedance zn:

The control μ sets the mutual/self reactance ratio. This illustrative matrix is not a cable specification. Setting zn = 0 fixes downstream neutral voltages at zero in this network; it does not disconnect the neutral. Real grounding and neutral connections must be modeled explicitly, as discussed in OpenDSS’s neutral conventions.

Why can phase A change phases B and C?

Since Iₙ = −(Iₐ + Iᵦ + I𝒸), subtracting the neutral-conductor KVL equation from each phase equation gives:

The shared-neutral term contains the sum of all three phase currents. Even with μ = 0, a finite neutral couples the load-terminal phase voltages. Three independent single-phase calculations reproduce this model only when both neutral impedance and phase mutual coupling are zero.

Step D — Solve a radial feeder by backward/forward sweep

Why switch from Newton–Raphson to backward/forward sweep here?

The previous chapter also studies a distribution feeder. Balanced/unbalanced describes the phase model; radial/meshed describes topology; Newton–Raphson (NR)/backward-forward sweep (BFS) describes the numerical method. These are separate choices. Unbalanced power flow can use NR, and a balanced radial feeder can use BFS.

The previous chapter uses NR to derive a general Jacobian-based solution from nodal admittance and P/Q mismatch. Its experiment also allows a tie to close and form a loop. NR computes voltage corrections through simultaneous equations without requiring a tree topology.

This chapter instead fixes one source, a radial feeder and constant-PQ devices. Every downstream bus has one path back to the source, so currents can be accumulated upstream and voltages updated downstream. We use the current-summation form of BFS; see the radial current-summation procedure in the MATPOWER distribution power-flow manual.

Phase model and topologyRadial: no closed loopClosed loops present
Balanced single-phase equivalentNR or BFSNR; BFS needs a loop extension
Three-phase unbalancedPhase-domain NR or multi-conductor BFSPhase-domain NR; BFS needs a loop extension

The table describes algorithm frameworks. This lesson implements radial four-wire BFS: it updates a, b, c and n together, retaining the full 4 × 4 impedance matrix and shared-neutral relationship. These are not three independent single-phase solves. PV export can reverse current direction without changing the tree topology.

The same AC physical constraints, two ways to organize iteration

The model specifies constant-PQ relations S = UI*, nodal KCL, branch KVL and a source-voltage reference. Keep those physical conditions consistent when changing algorithms.

Newton–Raphson

Network voltage estimate → equation mismatch → Jacobian → simultaneous correction → updated voltages

Here Δs retains the previous chapter's specified-minus-calculated power convention. A three-phase version can use conductor-voltage real/imaginary parts with the corresponding power or current residuals and Jacobian.

BFS · current summation

Current four-wire voltages → load currents → backward branch-current sums → forward four-wire voltage update → repeat

Two tree traversals replace a global Jacobian assembly. Constant-PQ currents depend on unknown load-terminal voltages, so one sweep generally does not complete the solution.

Both solve nonlinear AC power flow. With matching physical models and convergence to the same operating point, voltages, currents and losses should agree; iteration paths and stopping criteria may differ.

A larger R/X ratio does not rule out full NR. Resistance makes it important to retain active/reactive and voltage cross-coupling; distinguish full NR from fast-decoupled methods that approximate weak coupling. Both lesson solvers retain R and X without assuming X ≫ R.

Here BFS offers a clear structure for teaching the four-wire return path, rather than a guarantee of better speed or convergence in every case. Heavy demand and large voltage drops can affect convergence, so this implementation uses damping and checks residuals. Loops need extensions such as loop compensation. PV-type buses specifying P and voltage magnitude need additional reactive-power/voltage updates; the solar inverter here is fixed PQ. Failure of either iteration alone does not establish that power flow has no solution.

Next, write this current-summation procedure as explicit four-wire updates.

Starting with the source phasors at every bus, repeat three operations:

  1. Calculate each load’s four terminal currents from the current phase-to-neutral voltages.
  2. Backward sweep: add downstream currents to get each branch current.
  3. Forward sweep: start at the source bus and apply the four-wire KVL equations along the feeder.

Use a generic i → j → k chain to illustrate one update: i is the source, j and k have loads, and k is the end bus. Every voltage and current vector contains four components: a, b, c, and n.

One feeder, two calculation directions

Backward: end → source
ijkIᵢⱼIⱼₖ
Iᵢⱼ = Iⱼˡᵒᵃᵈ + Iⱼₖ

Calculate load currents from the current terminal voltages, then accumulate them from the end. Carry the neutral current as well.

Forward: source → end
ijkVᵢVⱼVₖ
Vⱼ = Vᵢ − Zᵢⱼ Iᵢⱼ

Use branch currents from the backward pass and the four-by-four impedance matrix to propagate voltage drops.

Arrows show the calculation order. Every V and I contains four complex components: a, b, c, and n. Damp the new voltages from the forward pass, then use them for the next current calculation.

The implementation damps the voltage update with α = 0.65:

It stops when the maximum complex conductor-voltage residual ‖Vsweep − V‖∞ is below 10−10 pu. It reports failure after 200 updates or a very low/nonfinite voltage. A failed iteration does not by itself prove voltage collapse or the absence of another solution. Branch disconnection is reported separately as an island outside this single-source model.

Step E — Recover conductor losses

For this line matrix, mutual terms are purely reactive. In physical units, total active conductor loss is:

These are amperes and ohms, so the result is watts. Do not multiply by three again: all three phase currents are already included. Power injected into the line at both ends, including the neutral conductor, gives the same total loss.

Step F — Decompose phase voltages into sequence components

What are sequence components?

Power flow first gives three complex voltage phasors Uₐ, Uᵦ and U𝒸 at the same bus. Sequence components express those same phasors in another coordinate system: a sum of three patterns with fixed internal phase relationships. They do not add physical conductors or split the fundamental into different frequencies.

Use ABC phase order and a = ej120°. Multiplication by a rotates a phasor counterclockwise by 120°; a² rotates it by 240°, equivalently −120°. The three patterns are positive, negative and zero sequence; see the phase-order conventions in MIT’s symmetrical-components notes.

Positive: ABC

ABC 0°, −120°, +120°

Negative: ACB

ABC 0°, +120°, −120°

Zero: all in phase

A = B = C 0°, 0°, 0°
Each pattern is illustrated with its A-phase coefficient equal to 1∠0°. A complex coefficient scales and rotates the whole pattern while preserving its internal angle relationships. Positive and negative describe phase order; zero sequence can have nonzero magnitude.

The subscripts in U₀, U₁ and U₂ identify sequences, not bus numbers. Each coefficient is the A-phase representative of its sequence. For example, U₁ is one complex number; its full positive-sequence triplet is [U₁, a²U₁, aU₁]. Positive follows ABC, negative follows ACB, and zero has identical magnitudes and angles in all three phases.

Why exactly these three patterns?

Three arbitrary complex phase voltages require three independent complex coefficients. Cycling the phase labels three times returns to the original ordering. Its three independent modes correspond to the roots of λ³ = 1: 1, a and a². The in-phase, ABC and ACB patterns therefore form a complete basis for any three-phase phasor set, with a unique decomposition.

Expand: independence and 1 + a + a² = 0

Write the basis vectors as bₖ = [1, a−k, a−2k]T, k = 0, 1, 2. The identity 1 + a + a² = 0 gives bₘ†bₙ = 3δₘₙ, where † denotes conjugate transpose. The three nonzero orthogonal vectors are independent. Projecting the voltage onto each basis and dividing by 3 extracts its coefficient.

From solved phase voltages to sequences, and back

Transform complex values, not just three magnitudes. Convert magnitude and angle to Uφ = |Uφ|ejθφ first. The ABC decomposition and its inverse are below; see also SEL’s symmetrical-components tutorial.

U₀ is the complex average. To extract U₁, rotate B and C by a and a² before averaging: the positive pattern aligns and the other patterns cancel. Reverse the rotations for U₂. Reconstruction adds complex numbers; their magnitudes do not simply add. The same linear transform works in pu or volts when a common phase-voltage base is used.

Here the four-wire power flow is solved in the phase domain, then its result is analyzed in sequences. Decomposition always works. Separating the power-flow equations into independent sequence networks additionally requires suitable network symmetry; the transform alone does not establish independence.

How does zero-sequence voltage relate to neutral displacement?

With the source reference fixed, Vₐ, Vᵦ and V𝒸 are conductor voltages and Vₙ is the local neutral voltage. The load sees Uφ = Vφ − Vₙ. The common subtraction changes only zero sequence:

Thus U₀ is not Vₙ, and generally is not −Vₙ either: the phase conductors can already contain V₀. For branch currents all defined from upstream to downstream, I₀ = (Iₐ + Iᵦ + I𝒸)/3 and Iₙ = −3I₀. This is a return-current relationship, not an equality of zero-sequence and neutral voltages.

The voltage unbalance factor used here is:

This measures negative relative to positive sequence. Check zero sequence, absolute phase voltages and neutral displacement separately. It also differs from the magnitude-deviation metric in the OpenDSS NEMA-unbalance note. Unequal angles can create negative sequence even when all three magnitudes are equal.

3. Worked example: the same 300 kW, distributed unequally

Introduce the feeder and bus settings

Consider a three-bus, 400 V radial distribution feeder. Bus 1 is the upstream source, connected to bus 2 by line 1–2. Line 2–3 then supplies the end bus 3. Each branch has four conductors, a, b, c, and n; this example has no tie line.

Example network: a radial four-wire feeder

1–22–3 a, b, c, na, b, c, n 123 400 V LLBalanced source V₁,ₙ = 0 Loads A / B / C40 / 40 / 40 kWPF = 0.95 Loads A / B / C90 / 55 / 35 kWPV: 50/3 kW per phaseQɢ = 0

Swipe sideways to see the full diagram.

Each connection represents three phase wires and a neutral. The dashed stroke identifies the neutral; all conductors are connected in the baseline. Only the source neutral is grounded; line drops determine local neutral voltages. Bus 3 solar generation injects fixed PQ, and the four-wire power flow determines load-terminal voltages.
BusEquipment and specified quantitiesTreatment of voltage
1Balanced 400 V line-to-line source with grounded neutralFixed three-phase voltage phasors and neutral voltage
2Wye loads: 40 / 40 / 40 kW, 120 kW total, PF = 0.95 laggingSolve load-terminal voltages using the four-wire model
3Wye loads: 90 / 55 / 35 kW, 180 kW total, PF = 0.95 lagging; plus 50 kW solar generationSolve load-terminal voltages using the four-wire model

The inverter at bus 3 is a specified P, Q injection: the baseline distributes 50 kW equally across phases, with Q = 0 on each phase and no voltage regulation. Subtract its injection from the phase loads to obtain net demand. The phasor diagram above observes this bus’s phase-to-local-neutral voltages.

Substitute the bases and line parameters

Use a 1 MVA three-phase power base and a 400 V line-to-line voltage base. This gives SB,φ = 333.333 kVA, VB,φ ≈ 230.94 V, ZB = 0.16 Ω, and IB = 1443.38 A. A 90 kW single-phase load is 0.27 pu on the per-phase base; a 90 kW three-phase aggregate is 0.09 pu on the three-phase base.

The conductor self impedances and phase mutual impedances are:

BranchPhase self impedance (Ω)Neutral impedance (Ω)Phase mutual impedance (Ω)
1–20.012 + j0.0080.018 + j0.006j0.0016
2–30.008 + j0.0060.012 + j0.004j0.0012

Form phase demands and solve

1. Form each phase’s net demand. The PV supplies 50/3 kW per phase, so bus 3 has net active demands of 73.333 / 38.333 / 18.333 kW. Its load reactive demands remain PD,φ tan(arccos 0.95); PV does not supply Q in this example.

2. Find currents and the return path. Divide each complex demand by its own phase-to-local-neutral voltage and conjugate. Sum phase currents as complex phasors to obtain the neutral return current. Adding current magnitudes would give an incorrect neutral current.

3. Sweep and check the operating point. The baseline converges to these bus 3 load-terminal voltages:

PhaseMagnitude (pu)Magnitude (V RMS)Angle (°)
A0.91917212.27+0.1180
B0.98032226.39−122.0550
C1.00438231.95+121.2865

Neutral displacement is about 7.637 V; branch 1–2 neutral current is about 242.81 A. Total active loss is 9.5971 kW, and the source supplies 259.5971 kW: 259.5971 + 50 − 300 = 9.5971 kW. VUF at bus 3 is only 0.9028%, yet phase A is below the experiment’s 0.95 pu teaching limit.

Decompose the solved voltages and check reconstruction

4. Use the same complex voltages. Convert both magnitude and angle from the table into complex numbers, then apply the sequence matrix. Bus 3 gives the following coefficients. The calculation uses the unrounded power-flow result; displayed values are approximate.

A-phase coefficientComplex value (pu)Magnitude (pu)Angle (°)
U₀ · zero−0.040906 + j0.0097880.042061+166.543
U₁ · positive0.967660 − j0.0035700.967666−0.211
U₂ · negative−0.007590 − j0.0043260.008736−150.322

For phase A, no additional rotation is needed. Add the three representative coefficients:

Magnitude and angle recover approximately 0.91917∠0.118° pu. For B and C, rotate the positive and negative terms as specified by the inverse before adding them. The inspector below checks each phase without solving another operating point.

The coefficients give VUF ≈ 0.9028%, while |U₀|/|U₁| ≈ 4.3466%. VUF alone therefore misses this example’s substantial zero sequence and phase-voltage deviations. Here |U₀| ≈ 9.7135 V and |Vₙ| ≈ 7.6370 V: they are different quantities.

Select Same total load, balanced phases below. The bus 3 load becomes 60 / 60 / 60 kW, keeping total demand and PV unchanged. Observe the neutral current, neutral displacement, per-phase voltage, and loss together. To reproduce the previous chapter’s baseline exactly, also set μ = 0; equal phase currents then see the same uncoupled series impedance.

4. Experiment: change one phase, observe all three

Move a phase-load slider, change PV connection, or compare finite and ideal neutral impedance. The network, phasors, voltage profiles, current loading, and numerical tables use the same solved operating point. The voltage band, VUF threshold, and current limits are teaching settings, not a compliance assessment.

A three-phase, four-wire feeder

400 V LL · 1 MVA
● A● B● C◆ N

Solid wires are phases A/B/C; the dashed wire is neutral. Width follows current magnitude. Bus voltages are RMS phase-to-local-neutral values. Bus 2 has 40 kW per phase before the demand multiplier.

Minimum phase voltage—
Bus 3 VUF—
Bus 3 neutral displacement—
Total conductor loss—

Initializing…

Source, conductor coupling, and current limits

Phase-voltage profiles

Conductor current loading

The 0.95–1.05 pu band, 2% VUF, and adjustable current limits are teaching references. VUF measures negative sequence; also inspect each phase voltage and neutral displacement.

Phase results, sequence components, and iteration history
Bus / phase|U| (pu)U (V)θ (°)P demand (kW)Q demand (kvar)

Positive net demand consumes; negative net demand generates. Reference-source power is reported separately below.

Bus|U₁| (pu)|U₂| (pu)|U₀| (pu)VUF (%)|Vₙ| (V)
BranchIₐ (A)Iᵦ (A)I𝒸 (A)Iₙ (A)Loss (kW)N loss (kW)

Iteration‖V sweep − V‖∞ (pu)min |U| (pu)

Decompose and reconstruct the current power-flow voltages

The load, PV and neutral controls above change the operating point. This inspector automatically reads that same solution. Compare balanced demand with the baseline, then change voltage reference and observe which sequence changes.

① Original phase voltages

② Positive triplet · ABC

③ Negative triplet · ACB

④ Zero triplet · in phase

Plots use independent scales so small negative and zero sequences remain visible. Compare the stated circle radii and numerical values. A/B/C use orange circles, blue squares and green triangles; zero-sequence phases coincide. Near-zero phasors have no meaningful angle, shown as —.

Decomposition input: magnitude and angle → complex voltage

PhaseComplex voltage (pu)|·| (pu)∠ (°)

A-phase representatives of the three sequences

SequenceComplex coefficient (pu)|·| (pu)∠ (°)|·| (V RMS)

Reconstruction: add the three complex contributions

TermComplex contribution to this phase (pu)

5. Edit and run the four-wire solver

Read how the phase inputs enter the four-wire model, then let main() call the solver and inspect its answer. Run the default program first, then uncomment parameters.update(p3_a_kw=60, p3_b_kw=60, p3_c_kw=60) to keep bus 3 at 180 kW total while comparing phase voltages, VUF and neutral shift. The sliders keep the original JavaScript reference; the Python panel runs the editable four-wire source.

How the code fits together

  1. caseControls provide an input dictionary
  2. unbalanced_power_flow.pySource defines the model functions
  3. main(case) → resultMain computes, prints and returns a result to plot

When you press Run, the page copies the controls into case, executes the folded model source, then executes your editable main program. This makes the source's functions available directly to main(), without a separate import statement. Read the three parts in that order.

1 · Inputs: expand the current case and parameter meanings

These are the inputs for the next run and update with the controls. Copying them into parameters inside main() lets you test another case without changing the controls.

Reading parameters…
ParameterMeaning and units
p3_a_kw / p3_b_kw / p3_c_kwBus 3 base phase demands in kW, before multiplying by load_scale.
load_scale / power_factorDemand multiplier and load power factor; bus 2 starts at 40 kW per phase.
dg_kw / dg_phaseTotal PV kW and connection: balanced divides it equally; a/b/c puts it on one phase.
slack_pu / r_scale / x_scaleSource phase-voltage pu and branch resistance / reactance multipliers.
neutral_mode / neutral_scale / mutual_ratiofinite or ideal neutral; neutral-impedance multiplier; phase mutual-reactance ratio.
current_limit_a / neutral_limit_aPhase-conductor / neutral current limits in A.
open12 / open23True opens the branch and disconnects downstream buses.
2 · Model source: unbalanced_power_flow.py (expand to inspect / edit)

Dependencies: Only the standard-library modules cmath and math are used. The four-wire solver is defined in this chapter's source.

This is the source actually executed by Python. Use the table to connect its functions to this chapter's equations. Edits take effect on the next main-program run. The slider lab keeps the original JavaScript model as a reference.

Function in the sourceWhat it does
network(options)Settings → four-conductor source, phase demands and each branch's 4 × 4 impedance matrix.
local(voltage)Conductor voltages → local phase-to-neutral voltages Uφ = Vφ − Vn.
sweep(demand, edges, source, voltage)One backward current summation and forward voltage update, including the neutral.
sequence(phases)Three phase voltages → sequence components and VUF = 100 |U₂| / |U₁|.
phase_components(components) / reconstruct_sequence(components)Sequence coefficients → each phase's zero/positive/negative contributions → reconstructed complex A/B/C voltages.
solve(options)Repeats the damped sweep, checks convergence, and returns per-phase voltages, neutral shift and losses.

3 · Main program: what does main() do?

The main program copies / changes inputs → calls the model → checks the solution → prints → returns the result. solved is the result dictionary inside the function; the final result = main(case) passes it to the page's plot. print() writes to the output panel and does not draw the plot.

First run the example unchanged and compare it with the worked example. Then uncomment the phase-demand edit, keeping bus 3's total at 180 kW, and compare phase voltages and VUF.

Download solver

The first run needs internet access to download Python. Computation stays in your browser; the solver uses only the standard library.

Ready to run.

How to read the output

buses[2] is physical bus 3 because Python lists start at zero. Each phase's u_pu is [real, imaginary], while vm_pu and voltage_v are magnitudes. components stores zero_pu, positive_pu and negative_pu as complex pairs; vuf_pct is 100 |U₂| / |U₁|. neutral_v is neutral shift in V; loss_kw is total active loss. Check ok before reading these fields.

Download experiment includes the current inputs, model source and main program in one runnable .py file.

Output appears here.

Verify sequences and reconstruction in Python

Replace the whole main program with this example. solve, sequence and reconstruct_sequence are defined in the complete folded solver source above: they solve power flow, decompose phasors and perform the inverse transform. u_pu stores [real, imaginary], so read it with complex(*pair). The magnitude-only vm_pu is not a substitute for a complex voltage.

def main(input_case):
    # 1. Solve the current slider case; skip decomposition on failure.
    solved = solve(input_case)
    if not solved["ok"]:
        print("Power flow failed:", solved["reason"])
        return solved

    # 2. Read bus 3 phase-to-local-neutral COMPLEX voltages.
    bus = solved["buses"][2]  # zero-based index 2 -> bus 3
    phases = [complex(*phase["u_pu"]) for phase in bus["phases"]]

    # 3. Extract the A-phase zero, positive and negative coefficients.
    components = sequence(phases)
    for name in ("zero_pu", "positive_pu", "negative_pu"):
        coefficient = complex(*components[name])
        print(name, coefficient, "|U| =", abs(coefficient), "pu")

    # 4. Transform back to ABC and compare against each solved voltage.
    rebuilt = reconstruct_sequence(components)
    for label, original, recovered in zip("ABC", phases, rebuilt):
        print(label, "solved =", original, "rebuilt =", recovered)
    error = max(abs(u - restored) for u, restored in zip(phases, rebuilt))
    print("Maximum reconstruction error:", error, "pu")

    # Return the full power-flow result for the page voltage plot.
    return solved

result = main(case)

Compare PV connections

After the default experiment, replace the entire main program with this scan to compare PV connections at otherwise fixed inputs. It returns the last successful solution for plotting:

def main(input_case):
    last_successful = None
    for connection in ("balanced", "a", "b", "c"):
        trial = dict(input_case, dg_phase=connection)
        solved = solve(trial)
        if solved["ok"]:
            end = solved["buses"][2]  # Bus 3
            print(connection, end["components"]["vuf_pct"], end["neutral_v"])
            last_successful = solved
        else:
            print(connection, solved["reason"])
    return last_successful

# If no case converged, None leaves the voltage plot empty.
result = main(case)

6. Practice and explain

What does the ideal-neutral setting enforce?

  1. Neutral coupling: set μ = 0 and keep finite neutral impedance. Increase phase A load by 10 kW. Record all three voltages. Repeat with an ideal neutral and explain the difference using the shared-neutral matrix term.
  2. Same total demand: compare 90 / 55 / 35 kW with 60 / 60 / 60 kW. Keep PF, PV output/connection, and impedances fixed. Explain the changes in neutral loss and minimum voltage.
  3. One metric is insufficient: find a converged point with VUF below 2% and a phase voltage outside 0.95–1.05 pu. Use U₀, U₂, and neutral displacement to discuss what VUF does and does not describe.
  4. Single-phase PV: place 50 kW on phases A, B, and C in turn. Determine which placement improves the minimum voltage at this operating point; then repeat under high demand. Avoid assuming the same placement is best for every case.
  5. N-1 labels: open branch 2–3. Distinguish isolation from numerical nonconvergence and from a connected but limit-violating solution. Fixed-PQ PV does not become a grid-forming source when the feeder opens.

  6. Sequences and references: select the source bus and explain why only positive sequence remains. Then select the baseline end bus, switch U/V and check U₀ = V₀ − Vₙ. Reconstruct A, B and C: why do their rotation coefficients differ?

7. Scope and the next implementation module

This fundamental-frequency, radial teaching model excludes delta loads, voltage-dependent loads, asymmetrical conductor geometry, phase-neutral mutual impedance, downstream grounding/earth return, transformers, regulators, harmonics, inverter limits, and dynamic/protection behavior. Opening a branch opens all four conductors; an open-neutral-only fault is not modeled. An isolated section has no voltage reference in this model.

The PandaPower-based Implementation chapter maps equipment to library functions and compares the modeling assumptions explicitly. In particular, pandapower’s runpp_3ph documentation describes a sequence-frame solver and its earth-return/wye conventions; its results should not be assumed identical to this explicit neutral-wire case without matching those assumptions.

References