# Single-Phase Transformer


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Executive Summary

**Purpose:** Analyse a single-phase, core-type transformer from its
geometry and materials.

**What it does:** Computes the peak flux density, the no-load current
waveform (with optional hysteresis and dynamic loop widening), core
loss, the magnetising branch, winding resistances, leakage inductance
and the load performance (voltage regulation, losses, efficiency). The
equivalent circuit can also be built from open- and short-circuit test
data and solved directly; that solver is checked against published
worked examples.

### Why It Matters

The no-load current of a transformer is set by the non-linear core. With
an analytical chain from B(t) to i₀(t), the open-circuit characteristic,
the magnetising current harmonics and the efficiency follow from
datasheet-level data without FEA.

### Quick Start

**Inputs:** `TransformerCore` (limb, stack, window, stacking factor,
joint gap), two `TransformerWinding`s, `CoreMaterial` (Takács loop and
Bertotti coefficients), `Supply` (V₁, f).

**Outputs:** dictionaries of currents, waveforms, losses and circuit
parameters.

### Scope and assumptions

- Single-phase, core-type, two concentric windings, sinusoidal supply,
  steady state (no inrush).
- Uniform flux density along one mean path; limbs and yokes have the
  same width.
- Winding resistance at DC (no skin or proximity effect); leakage flux
  linear.
- Load analysis uses the fundamental of the magnetising current.

## How It Fits Into the Motor Design Workflow

**Upstream:** `emachines.magnetics` — `TakacsModel` and
`DynamicLoopModel` (hysteresis), `bertotti` (core loss).

**Downstream:** design decisions; a future transformer design (sizing)
module.

## Inputs

<figure>
<img src="images/single_phase_core.svg"
alt="Single-phase core-type transformer: front view with the core and winding dimensions, and section A–A through the limb." />
<figcaption aria-hidden="true">Single-phase core-type transformer: front
view with the core and winding dimensions, and section A–A through the
limb.</figcaption>
</figure>

<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr>
<th>Symbol</th>
<th>Meaning</th>
<th>Where it is set</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="math inline"><em>a</em></span></td>
<td>limb width, also the yoke width</td>
<td><code>TransformerCore.limb_width</code></td>
</tr>
<tr>
<td><span class="math inline"><em>d</em></span></td>
<td>stack depth</td>
<td><code>TransformerCore.stack_depth</code></td>
</tr>
<tr>
<td><span class="math inline"><em>w</em></span>, <span
class="math inline"><em>h</em></span></td>
<td>window width and height</td>
<td><code>TransformerCore.window_width</code>,
<code>window_height</code></td>
</tr>
<tr>
<td><span
class="math inline"><em>k</em><sub><em>s</em></sub></span></td>
<td>stacking factor (iron fraction of the stack)</td>
<td><code>TransformerCore.stacking_factor</code></td>
</tr>
<tr>
<td><span class="math inline"><em>g</em></span></td>
<td>total equivalent air gap of the joints along <span
class="math inline"><em>l</em><sub><em>c</em></sub></span> (not
drawn)</td>
<td><code>TransformerCore.joint_gap_total</code></td>
</tr>
<tr>
<td><span class="math inline"><em>N</em><sub>1</sub></span>, <span
class="math inline"><em>N</em><sub>2</sub></span></td>
<td>primary (inner) and secondary (outer) turns</td>
<td><code>TransformerWinding.turns</code></td>
</tr>
<tr>
<td><span class="math inline"><em>a</em><sub>1</sub></span>, <span
class="math inline"><em>a</em><sub>2</sub></span></td>
<td>radial builds of the primary and secondary</td>
<td><code>TransformerWinding.radial_build</code></td>
</tr>
<tr>
<td><span
class="math inline"><em>l</em><sub><em>m</em><em>t</em></sub></span></td>
<td>mean turn length of each winding</td>
<td><code>TransformerWinding.mean_turn_length</code></td>
</tr>
<tr>
<td><span class="math inline"><em>δ</em></span></td>
<td>radial gap between the windings</td>
<td><code>gap</code> argument of <code>leakage_inductance</code>,
<code>load_performance</code></td>
</tr>
<tr>
<td><span
class="math inline"><em>h</em><sub><em>w</em></sub></span></td>
<td>winding height</td>
<td><code>winding_height</code> argument of
<code>leakage_inductance</code>, <code>load_performance</code></td>
</tr>
</tbody>
</table>

The core is described by its limb width *a*, stack depth *d*, window
width *w* and height *h* and stacking factor *k*<sub>*s*</sub>:

*A*<sub>*f**e*</sub> = *k*<sub>*s*</sub> *a* *d*,   *l*<sub>*c*</sub> = 2(*w* + *a*) + 2(*h* + *a*),   *V*<sub>*f**e*</sub> = *A*<sub>*f**e*</sub> *l*<sub>*c*</sub>

*l*<sub>*c*</sub> is the mean flux path round one window, assuming limbs
and yokes of equal width *a*. `joint_gap_total` is the total equivalent
air gap of the joints in that path; it depends on how the core is built
(butt, mitred, step-lap) and is not on a steel datasheet, so it defaults
to 0.

`CoreMaterial` holds the static Takács loop and the Bertotti
coefficients of the same steel; the dynamic loop is built from them
(`DynamicLoopModel.from_bertotti`).

------------------------------------------------------------------------

### Supply

``` python
def Supply(
    voltage:float, frequency:float
)->None:
```

*Sinusoidal supply.*

------------------------------------------------------------------------

### CoreMaterial

``` python
def CoreMaterial(
    static:TakacsModel, k_h:float, k_e:float, k_a:float, density:float
)->None:
```

*Core steel: static Takács loop plus Bertotti loss coefficients of the
same steel.*

------------------------------------------------------------------------

### TransformerWinding

``` python
def TransformerWinding(
    turns:int, conductor_area:float, mean_turn_length:float, radial_build:float
)->None:
```

*One winding (SI units).*

------------------------------------------------------------------------

### TransformerCore

``` python
def TransformerCore(
    limb_width:float, stack_depth:float, window_width:float, window_height:float, stacking_factor:float=0.96,
    joint_gap_total:float=0.0
)->None:
```

*Core geometry of a single-phase core-type transformer (SI units).*

``` python
# Example transformer used below: about 1 kVA, 230 V / 115 V, 50 Hz.
# Illustrative dimensions and material values only — not a real or validated design.
core = TransformerCore(limb_width=40e-3, stack_depth=50e-3, window_width=40e-3, window_height=100e-3)
primary = TransformerWinding(turns=385, conductor_area=1.45e-6, mean_turn_length=0.22, radial_build=8e-3)
secondary = TransformerWinding(turns=193, conductor_area=2.9e-6, mean_turn_length=0.28, radial_build=8e-3)
supply = Supply(voltage=230.0, frequency=50.0)
steel = TakacsModel(B_s=1.6, h0=50.0, a0=0.8)        # illustrative Takács parameters
rho = 7650.0
# k_h chosen so that the Bertotti hysteresis term equals the Takács loop energy at 1.4 T;
# in practice both come from fitting the same datasheet (fit_takacs, fit_bertotti).
k_h = steel.loop_energy(steel.tip_H(1.4)) / (rho * 1.4 ** 2)
material = CoreMaterial(static=steel, k_h=k_h, k_e=5e-5, k_a=5e-4, density=rho)

assert np.isclose(core.area, 0.96 * 0.04 * 0.05)
assert np.isclose(core.path_length, 2 * 0.08 + 2 * 0.14)
print(f"A_fe = {core.area * 1e4:.2f} cm², l_c = {core.path_length * 100:.1f} cm, "
      f"iron mass = {core.volume * rho:.2f} kg, k_h = {k_h:.4f} W/(kg·Hz·T²)")
```

    A_fe = 19.20 cm², l_c = 44.0 cm, iron mass = 6.46 kg, k_h = 0.0114 W/(kg·Hz·T²)

## Magnetic Equivalent Circuit

<figure>
<img src="images/single_phase_mec.svg"
alt="Magnetic equivalent circuit of the single-phase transformer drawn on the front view of a U-I core: reluctances as resistors, winding MMFs as sources." />
<figcaption aria-hidden="true">Magnetic equivalent circuit of the
single-phase transformer drawn on the front view of a U-I core:
reluctances as resistors, winding MMFs as sources.</figcaption>
</figure>

The magnetic circuit is drawn on the front view of a U-I core (see *Core
construction and joints* below), with reluctances ℛ = *l*/(*μ**A*) as
resistors and the winding MMFs *N**i* as sources. Fluxes play the part
of currents. Between nodes A, B and C there are three branches:

- **C–B, limb inside both windings:** ℛ<sub>*l**i**m**b*, 1</sub> in
  series with *N*<sub>1</sub>*i*<sub>1</sub>.
- **C–B, duct between the windings:** the leakage reluctance
  ℛ<sub>*σ*</sub>, **in parallel** with the limb branch.
- **A–C:** *N*<sub>2</sub>*i*<sub>2</sub>, common to the limb and duct
  fluxes, because the secondary (outer) winding encloses both.
- **A–B, return path:**
  ℛ<sub>*y**o**k**e*</sub> + ℛ<sub>*l**i**m**b*, 2</sub> + ℛ<sub>*g*</sub>/2 + ℛ<sub>*y**o**k**e*</sub> + ℛ<sub>*g*</sub>/2
  **in series**. The two ℛ<sub>*g*</sub>/2 are the joints where the legs
  of the U stand on the I. Both joints lie outside the winding region
  (below node B), so they belong to the return path and can be reordered
  within it.

Each loop encloses exactly the windings it should: limb + duct encloses
the primary only, duct + return the secondary only, and limb + return
both. With the fluxes as drawn,
*Φ*<sub>*m*</sub> = *Φ*<sub>1</sub> + *Φ*<sub>*σ*</sub>.

<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr>
<th>Reluctance</th>
<th>Expression</th>
<th>Path</th>
</tr>
</thead>
<tbody>
<tr>
<td><span
class="math inline">ℛ<sub><em>l</em><em>i</em><em>m</em><em>b</em>, 1</sub> = ℛ<sub><em>l</em><em>i</em><em>m</em><em>b</em>, 2</sub></span></td>
<td><span class="math inline">$\dfrac{h + a}{\mu\,A_{fe}}$</span></td>
<td>one limb of the mean path</td>
</tr>
<tr>
<td><span
class="math inline">ℛ<sub><em>y</em><em>o</em><em>k</em><em>e</em></sub></span></td>
<td><span class="math inline">$\dfrac{w + a}{\mu\,A_{fe}}$</span></td>
<td>one yoke of the mean path</td>
</tr>
<tr>
<td><span class="math inline">ℛ<sub><em>g</em></sub></span></td>
<td><span class="math inline">$\dfrac{g}{\mu_0\,A_{fe}}$</span></td>
<td>all joints together, <span class="math inline"><em>g</em></span> =
<code>joint_gap_total</code> (U-I core: two joints of <span
class="math inline">ℛ<sub><em>g</em></sub>/2</span> each)</td>
</tr>
<tr>
<td><span class="math inline">ℛ<sub><em>σ</em></sub></span></td>
<td><span class="math inline">$\dfrac{h_w}{\mu_0\,k_R\,l_{mt}\,(\delta +
a_1/3 + a_2/3)}$</span></td>
<td>duct between the windings</td>
</tr>
</tbody>
</table>

The four iron reluctances add up to
*l*<sub>*c*</sub>/(*μ**A*<sub>*f**e*</sub>). Since the steel is
non-linear, *μ* = *B*/*H* is taken from the B–H loop.

**How the steps below use it:** - **No load (*i*<sub>2</sub> = 0, Steps
2–4):** the duct branch is neglected, and the series loop gives
*N*<sub>1</sub>*i*<sub>0</sub> = *H* *l*<sub>*c*</sub> + *B* *g*/*μ*<sub>0</sub>. -
**Leakage (Step 7):** ℛ<sub>*σ*</sub> gives
*L*<sub>*σ*</sub> = *N*<sub>1</sub><sup>2</sup>/ℛ<sub>*σ*</sub>.

### Core construction and joints

The module models only the shape: a rectangular core-type core with two
limbs and two yokes of the same width *a*. Several common constructions
give that shape. They differ in how many joints the flux crosses:

<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr>
<th>Construction</th>
<th>Pieces</th>
<th>Joints in the flux path</th>
</tr>
</thead>
<tbody>
<tr>
<td>U-I (or C-I) laminations</td>
<td>a U (both limbs and the top yoke) and an I (bottom yoke)</td>
<td>2, where the U’s legs stand on the I</td>
</tr>
<tr>
<td>Strip laminations</td>
<td>4 straight strips: 2 limbs and 2 yokes, butt, interleaved or mitred
at 45°</td>
<td>4, one at each corner</td>
</tr>
<tr>
<td>Cut C-core</td>
<td>wound steel tape, cut into two C halves</td>
<td>2, one through each limb</td>
</tr>
<tr>
<td>Uncut wound core</td>
<td>continuous wound tape</td>
<td>0</td>
</tr>
</tbody>
</table>

At each joint the flux crosses a thin non-magnetic layer: the lamination
coating, burrs and imperfectly flat cut edges. That layer acts as an air
gap. How big it is depends on how the joint is made:

- **Butt joints** make all the flux cross the gap.
- **Interleaved and step-lap joints** let most of the flux bypass the
  gap through the neighbouring laminations, so the equivalent gap is
  much smaller.

`joint_gap_total` is the sum of the equivalent gaps of all joints. For
example, a U-I core with two butt joints of about 25 µm each gives
`joint_gap_total ≈ 50e-6`. These are typical orders of magnitude, not
measured values.

The gap matters despite its size. With a relative permeability of about
5000, a 50 µm gap needs as many ampere-turns as 0.25 m of steel, while
the example’s whole mean path *l*<sub>*c*</sub> is 0.44 m. It raises the
magnetising current but barely changes the core loss.

E-I laminations are **shell-type**: the windings sit on a centre limb,
and the flux divides between two outer limbs. That is a different
magnetic circuit, and this module does not model it.

## Step 1: Peak Flux Density from the Supply Voltage

The primary equation is
*v*<sub>1</sub> = *R*<sub>1</sub>*i*<sub>1</sub> + *L*<sub>*σ*1</sub> *d**i*<sub>1</sub>/*d**t* + *N*<sub>1</sub>*A*<sub>*f**e*</sub> *d**B*/*d**t*.
At no load the drop across *R*<sub>1</sub> and *L*<sub>*σ*1</sub> is
about the product of two small per-unit values (for example 2 %
resistive drop at rated current × 5 % no-load current ≈ 0.1 % of
*V*<sub>1</sub>), so it is neglected. For
$v_1 = \sqrt2 V_1 \sin\omega t$ in steady state (no DC offset):

$$B(t) = -\hat B\cos\omega t, \qquad \hat B = \frac{\sqrt2\\V_1}{\omega N_1 A\_{fe}}$$

Under load the voltage across the core is *E*<sub>1</sub> rather than
*V*<sub>1</sub>; `load_performance` handles that.

------------------------------------------------------------------------

### peak_flux_density

``` python
def peak_flux_density(
    core:TransformerCore, primary:TransformerWinding, voltage:float, frequency:float
)->float:
```

*Peak core flux density B̂ = √2 V / (ω N₁ A_fe) \[T\] for an rms voltage
across the core.*

``` python
# Examples
B_hat = peak_flux_density(core, primary, supply.voltage, supply.frequency)
assert np.isclose(B_hat, np.sqrt(2) * 230 / (2 * np.pi * 50 * 385 * core.area))
print(f"B̂ = {B_hat:.3f} T")
```

    B̂ = 1.401 T

## Steps 2–4: No-Load Current Waveform

The field in the core comes from the hysteresis module, *H*(*t*) =
`material.loop.field_waveform(B(t), dt, hysteresis, dynamic)`, and
Ampère’s law round the mean path, including the joints, gives

$$N_1\\i_0(t) = H(t)\\l_c + \frac{B(t)\\g_j}{\mu_0}$$

From *i*<sub>0</sub>(*t*): - rms and peak value, crest factor and the
odd harmonics (half-wave symmetry removes the even ones); - the
fundamental split against *v*<sub>1</sub>: the in-phase part
*I*<sub>*c*1</sub> carries the loop loss, the quadrature part
*I*<sub>*m*1</sub> magnetises.

With a sinusoidal voltage only the fundamental carries power, so the
mean of *v*<sub>1</sub>*i*<sub>0</sub> equals
*V*<sub>1</sub>*I*<sub>*c*1</sub> and equals the loop energy
*f* *V*<sub>*f**e*</sub>∮*H* *d**B*. The switches `hysteresis` and
`dynamic` change the waveform only; core loss is always taken from the
Bertotti formula (next step).

------------------------------------------------------------------------

### no_load_current

``` python
def no_load_current(
    core:TransformerCore, primary:TransformerWinding, material:CoreMaterial, supply:Supply, hysteresis:bool=True,
    dynamic:bool=True, n_samples:int=2000, n_harmonics:int=15
)->dict:
```

*No-load current waveform and its components, for sinusoidal supply
voltage.*

Returns a dict with the waveforms (‘t’, ‘v’, ‘B’, ‘H’, ‘i0’), ‘B_peak’,
‘I0_rms’, ‘I0_peak’, ‘crest_factor’, ‘I_c1’ and ‘I_m1’ (rms in-phase and
quadrature parts of the fundamental), ‘harmonics_rms’ (orders
1..n_harmonics) and ‘P_loop’ \[W\], the power drawn by the loop (mean of
v·i0).

``` python
# Examples
nl = no_load_current(core, primary, material, supply)
# energy check: power drawn = V·I_c1 = loop energy f·V_fe·∮H dB
assert np.isclose(nl["P_loop"], supply.voltage * nl["I_c1"], rtol=1e-3)
W_cycle = material.loop.cycle_energy(nl["B"], nl["t"][1])
assert np.isclose(nl["P_loop"], supply.frequency * core.volume * W_cycle, rtol=1e-3)
# half-wave symmetry: no even harmonics
assert np.all(nl["harmonics_rms"][1::2] < 1e-9 * nl["I0_rms"])
print(f"I0 = {nl['I0_rms'] * 1e3:.1f} mA rms, crest factor {nl['crest_factor']:.2f}, "
      f"I_c1 = {nl['I_c1'] * 1e3:.1f} mA, I_m1 = {nl['I_m1'] * 1e3:.1f} mA")
print("odd harmonics, % of fundamental:",
      {k: round(float(100 * nl['harmonics_rms'][k - 1] / nl['harmonics_rms'][0]), 1) for k in (3, 5, 7, 9)})
```

    I0 = 72.5 mA rms, crest factor 1.48, I_c1 = 46.6 mA, I_m1 = 54.1 mA
    odd harmonics, % of fundamental: {3: 16.0, 5: 5.7, 7: 2.7, 9: 1.5}

``` python
fig, ax = plt.subplots(figsize=(7, 3.8))
deg = np.degrees(2 * np.pi * supply.frequency * nl["t"])
for (h, d), style, label in [((False, False), "k:", "plain B–H"), ((True, False), "C1--", "static loop"),
                             ((True, True), "C0", "static loop + 50 Hz widening")]:
    r = no_load_current(core, primary, material, supply, hysteresis=h, dynamic=d)
    ax.plot(deg, r["i0"] * 1e3, style, lw=1.4, label=label)
ax2 = ax.twinx(); ax2.plot(deg, nl["v"], color="0.6", lw=0.8); ax2.set_ylabel("v₁ (V)", color="0.5")
ax.set_xlabel("ωt (deg)"); ax.set_ylabel("i₀ (mA)")
ax.set_title("No-load current, illustrative transformer"); ax.grid(True, alpha=0.4); ax.legend(fontsize=8)
plt.show()
```

![](01_single_phase_files/figure-commonmark/cell-11-output-1.png)

## Step 5: Core Loss and the Magnetising Branch

Core loss is always taken from the Bertotti formula,
*P*<sub>*f**e*</sub> = *p*(*f*, *B̂*) *ρ* *V*<sub>*f**e*</sub>, whatever
the switches. With both switches on and a loop fitted to the same steel
the two agree (the loop area equals the Bertotti loss per cycle); with a
switch off the waveform no longer carries all of the loss, but the loss
is still counted.

The magnetising branch at that voltage:

$$R_c = \frac{V_1^2}{P\_{fe}}, \qquad X_m = \frac{V_1}{I\_{m1}}$$

Both depend on *V*<sub>1</sub> because the iron is non-linear;
evaluating them over a range of voltages gives the open-circuit
characteristic.

------------------------------------------------------------------------

### magnetising_branch

``` python
def magnetising_branch(
    core:TransformerCore, primary:TransformerWinding, material:CoreMaterial, supply:Supply, hysteresis:bool=True,
    dynamic:bool=True
)->dict:
```

*Shunt branch at the supply voltage: ‘R_c’ and ‘X_m’ \[Ω\] (primary
side), ‘P_fe’ \[W\], ‘I_m1’ \[A\].*

R_c = V²/P_fe with P_fe from the Bertotti formula; X_m = V/I_m1 with
I_m1 the quadrature fundamental of the no-load current.

------------------------------------------------------------------------

### core_loss

``` python
def core_loss(
    core:TransformerCore, material:CoreMaterial, frequency:float, B_peak:float
)->float:
```

*Core loss \[W\] from the Bertotti formula over the iron volume.*

``` python
# Examples
mb = magnetising_branch(core, primary, material, supply)
P_fe = core_loss(core, material, 50.0, mb["B_peak"])
assert np.isclose(mb["R_c"], 230 ** 2 / P_fe)
# at 1.4 T k_h was matched to the loop, so the loop power equals the Bertotti loss there
V_14 = supply.voltage * 1.4 / B_hat                     # voltage giving B̂ = 1.4 T
nl14 = no_load_current(core, primary, material, Supply(V_14, 50.0))
assert np.isclose(nl14["P_loop"], core_loss(core, material, 50.0, 1.4), rtol=2e-3)
print(f"P_fe = {mb['P_fe']:.2f} W, loop power = {nl['P_loop']:.2f} W at {B_hat:.3f} T; "
      f"R_c = {mb['R_c']:.0f} Ω, X_m = {mb['X_m']:.0f} Ω")
```

    P_fe = 10.70 W, loop power = 10.71 W at 1.401 T; R_c = 4942 Ω, X_m = 4249 Ω

``` python
V_sweep = np.linspace(0.4, 1.1, 15) * supply.voltage
occ = [no_load_current(core, primary, material, Supply(V, 50.0)) for V in V_sweep]
fig, ax = plt.subplots(figsize=(7, 3.8))
ax.plot([r["I0_rms"] * 1e3 for r in occ], V_sweep, "o-", ms=3, label="I₀ rms")
ax.plot([r["I_m1"] * 1e3 for r in occ], V_sweep, "s--", ms=3, label="I_m1 (fundamental, magnetising)")
ax.set_xlabel("current (mA)"); ax.set_ylabel("V₁ (V)")
ax.set_title("Open-circuit characteristic, illustrative transformer"); ax.grid(True, alpha=0.4); ax.legend(fontsize=8)
plt.show()
```

![](01_single_phase_files/figure-commonmark/cell-15-output-1.png)

## Steps 6–7: Winding Resistance and Leakage Inductance

**Resistance** of a winding with *N* turns of copper area
*A*<sub>*c**u*</sub> and mean turn length *l*<sub>*m**t*</sub>, at
temperature *T*:

$$R = \rho\_{20}\\\[1 + \alpha\_{20}(T - 20)\]\\\frac{N\\l\_{mt}}{A\_{cu}}$$

with annealed copper *ρ*<sub>20</sub> = 1.7241 ⋅ 10<sup>−8</sup> *Ω*m
and *α*<sub>20</sub> = 0.00393 /K (IEC 60028). DC resistance: skin and
proximity effects are not included.

**Leakage inductance** of two concentric windings, referred to the
primary (Rogowski):

$$L\_\sigma = \frac{\mu_0 N_1^2\\l\_{mt}}{h_w}\left(\frac{a_1}{3} + \frac{a_2}{3} + \delta\right)k_R, \qquad k_R = 1 - \frac{1 - e^{-\pi h_w/\lambda}}{\pi h_w/\lambda}, \quad \lambda = a_1 + a_2 + \delta$$

*a*<sub>1</sub>, *a*<sub>2</sub> are the radial builds, *δ* the gap
between the windings and *h*<sub>*w*</sub> the winding height;
*l*<sub>*m**t*</sub> is taken as the mean of the two windings’ mean turn
lengths. *k*<sub>*R*</sub> corrects for the fringing of the leakage flux
at the winding ends.

------------------------------------------------------------------------

### leakage_inductance

``` python
def leakage_inductance(
    primary:TransformerWinding, secondary:TransformerWinding, gap:float, winding_height:float
)->float:
```

*Total leakage inductance \[H\] of two concentric windings, referred to
the primary.*

------------------------------------------------------------------------

### rogowski_factor

``` python
def rogowski_factor(
    winding_height:float, radial_width:float
)->float:
```

*Rogowski factor k_R for a leakage channel of total radial width λ =
a1 + a2 + δ.*

------------------------------------------------------------------------

### winding_resistance

``` python
def winding_resistance(
    winding:TransformerWinding, temperature_C:float=75.0, resistivity_20C:float=1.7241e-08, alpha_20C:float=0.00393
)->float:
```

*DC resistance \[Ω\] of a winding at temperature_C (annealed copper
defaults, IEC 60028).*

``` python
# Examples
R1, R2 = winding_resistance(primary), winding_resistance(secondary)
assert np.isclose(R1, 1.7241e-8 * (1 + 3.93e-3 * 55) * 385 * 0.22 / 1.45e-6)
assert np.isclose(winding_resistance(primary, 20.0) / winding_resistance(primary, 75.0), 1 / (1 + 3.93e-3 * 55))
assert 0 < rogowski_factor(90e-3, 18e-3) < 1 and rogowski_factor(10.0, 18e-3) > 0.999   # → 1 for tall windings
L_s = leakage_inductance(primary, secondary, gap=2e-3, winding_height=90e-3)
print(f"R1 = {R1:.3f} Ω, R2 = {R2:.3f} Ω at 75 °C; L_σ = {L_s * 1e3:.2f} mH "
      f"(X_σ = {2 * np.pi * 50 * L_s:.2f} Ω) referred to the primary")
```

    R1 = 1.225 Ω, R2 = 0.391 Ω at 75 °C; L_σ = 3.55 mH (X_σ = 1.12 Ω) referred to the primary

## Step 8: Equivalent Circuit from Parameters or Test Data

`EquivalentCircuit` holds the T circuit with every value referred to one
side: the series halves *R*<sub>1</sub> + *j**X*<sub>1</sub> and
*R*<sub>2</sub><sup>′</sup> + *j**X*<sub>2</sub><sup>′</sup> and the
shunt branch *R*<sub>*c*</sub> ∥ *j**X*<sub>*m*</sub>.

**From tests.** The open-circuit test gives the shunt branch and the
short-circuit test the series impedance, each on the side where it was
measured:

$$R_c = \frac{V\_{oc}^2}{P\_{oc}}, \quad X_m = \frac{V\_{oc}^2}{Q\_{oc}}, \qquad R\_{eq} = \frac{P\_{sc}}{I\_{sc}^2}, \quad X\_{eq} = \frac{Q\_{sc}}{I\_{sc}^2}, \qquad Q = \sqrt{(VI)^2 - P^2}$$

`EquivalentCircuit.from_series` splits *R*<sub>*e**q*</sub> and
*X*<sub>*e**q*</sub> between the windings (equally by default).

**Solving for a load.** Given the load voltage *V*<sub>2</sub>, current
*I*<sub>2</sub> and power factor (all referred to the circuit’s side,
*V*<sub>2</sub> as the phase reference), `solve_equivalent_circuit`
works back to the source:

<table>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr>
<th>Model</th>
<th>Equations</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"T"</code> (exact for the circuit)</td>
<td><span
class="math inline"><em>E</em> = <em>V</em><sub>2</sub> + <em>I</em><sub>2</sub><em>Z</em><sub>2</sub></span>,
<span
class="math inline"><em>I</em><sub>1</sub> = <em>I</em><sub>2</sub> + <em>E</em> <em>Y</em><sub><em>m</em></sub></span>,
<span
class="math inline"><em>V</em><sub>1</sub> = <em>E</em> + <em>I</em><sub>1</sub><em>Z</em><sub>1</sub></span>,
<span
class="math inline"><em>P</em><sub><em>c</em><em>o</em><em>r</em><em>e</em></sub> = |<em>E</em>|<sup>2</sup>/<em>R</em><sub><em>c</em></sub></span>,
<span
class="math inline"><em>P</em><sub><em>c</em><em>u</em></sub> = |<em>I</em><sub>1</sub>|<sup>2</sup><em>R</em><sub>1</sub> + |<em>I</em><sub>2</sub>|<sup>2</sup><em>R</em><sub>2</sub></span></td>
</tr>
<tr>
<td><code>"cantilever"</code> (shunt at the source terminals, the usual
textbook approximation)</td>
<td><span
class="math inline"><em>V</em><sub>1</sub> = <em>V</em><sub>2</sub> + <em>I</em><sub>2</sub><em>Z</em><sub><em>e</em><em>q</em></sub></span>,
<span
class="math inline"><em>I</em><sub>1</sub> = <em>I</em><sub>2</sub> + <em>V</em><sub>1</sub><em>Y</em><sub><em>m</em></sub></span>,
<span
class="math inline"><em>P</em><sub><em>c</em><em>o</em><em>r</em><em>e</em></sub> = |<em>V</em><sub>1</sub>|<sup>2</sup>/<em>R</em><sub><em>c</em></sub></span>,
<span
class="math inline"><em>P</em><sub><em>c</em><em>u</em></sub> = |<em>I</em><sub>2</sub>|<sup>2</sup><em>R</em><sub><em>e</em><em>q</em></sub></span></td>
</tr>
</tbody>
</table>

with *Y*<sub>*m*</sub> = 1/*R*<sub>*c*</sub> − *j*/*X*<sub>*m*</sub>.

**Voltage regulation** follows the standard definition (IEEE C57.12.80,
Chapman): the rise of the output voltage from full load to no load at
the same source voltage, as a fraction of the full-load voltage,

$$\text{VR} = \frac{V\_{2,nl} - V_2}{V_2}, \qquad V\_{2,nl} = \left|\frac{V_1}{1 + Z_1 Y_m}\right| \\(\text{T}), \qquad V\_{2,nl} = |V_1| \\(\text{cantilever})$$

------------------------------------------------------------------------

### solve_equivalent_circuit

``` python
def solve_equivalent_circuit(
    circuit:EquivalentCircuit, V2:float, I2:float, power_factor:float, lagging:bool=True, model:str='T'
)->dict:
```

*Source-side quantities for a load V2 \[V\], I2 \[A\] at power_factor,
all referred to the circuit’s side.*

model “T” solves the T circuit exactly; “cantilever” puts the shunt
branch at the source terminals. Returns ‘V1’, ‘V1_angle_deg’, ‘I1’,
‘I1_angle_deg’, ‘regulation’ (standard definition, (V2_nl - V2)/V2),
‘P_out’, ‘P_cu’, ‘P_core’, ‘P_in’, ‘efficiency’.

------------------------------------------------------------------------

### series_from_short_circuit

``` python
def series_from_short_circuit(
    voltage:float, current:float, power:float
)->tuple[float, float]:
```

*(R_eq, X_eq) \[Ω\] from a short-circuit test (rms V, A and W), on the
side the test was made.*

------------------------------------------------------------------------

### shunt_from_open_circuit

``` python
def shunt_from_open_circuit(
    voltage:float, current:float, power:float
)->tuple[float, float]:
```

*(R_c, X_m) \[Ω\] from an open-circuit test (rms V, A and W), on the
side the test was made.*

------------------------------------------------------------------------

### EquivalentCircuit

``` python
def EquivalentCircuit(
    R1:float, X1:float, R2:float, X2:float, R_c:float, X_m:float
)->None:
```

*T equivalent circuit of a two-winding transformer, every value referred
to one side \[Ω\].*

``` python
# Examples
ec = EquivalentCircuit.from_series(R_eq=2.0, X_eq=4.0, R_c=2000.0, X_m=800.0)
assert (ec.R1, ec.X2, ec.R_eq) == (1.0, 2.0, 2.0)
for model in ("T", "cantilever"):
    s = solve_equivalent_circuit(ec, V2=220.0, I2=4.0, power_factor=0.8, model=model)
    assert np.isclose(s["P_in"], s["P_out"] + s["P_cu"] + s["P_core"])    # power balance
    print(f"{model:>10}: V1 = {s['V1']:.2f} V, regulation {100 * s['regulation']:.2f} %, "
          f"η = {100 * s['efficiency']:.2f} %")
```

             T: V1 = 236.82 V, regulation 7.32 %, η = 92.12 %
    cantilever: V1 = 236.14 V, regulation 7.33 %, η = 92.16 %

## Step 9: Load Performance from the Geometry

The load is given as an apparent power *S* at power factor cos *φ* on
the rated secondary voltage
*V*<sub>2*n*</sub> = *V*<sub>1</sub>*N*<sub>2</sub>/*N*<sub>1</sub>,
which fixes a constant load impedance
*Z*<sub>*L*</sub> = (*V*<sub>2*n*</sub><sup>2</sup>/*S*) *e*<sup>±*j**φ*</sup>
(+ lagging). Everything is referred to the primary with
*k* = *N*<sub>1</sub>/*N*<sub>2</sub>:

- series impedances
  *Z*<sub>1</sub> = *R*<sub>1</sub> + *j**X*<sub>*σ*</sub>/2,
  *Z*<sub>2</sub><sup>′</sup> = *k*<sup>2</sup>*R*<sub>2</sub> + *j**X*<sub>*σ*</sub>/2
  (leakage split equally between the windings), load
  *Z*<sub>*L*</sub><sup>′</sup> = *k*<sup>2</sup>*Z*<sub>*L*</sub>;
- shunt admittance at the core voltage,
  *Y*<sub>*m*</sub>(*E*<sub>1</sub>) = 1/*R*<sub>*c*</sub>(*E*<sub>1</sub>) − *j*/*X*<sub>*m*</sub>(*E*<sub>1</sub>).

*Y*<sub>*m*</sub> depends on |*E*<sub>1</sub>|, so the circuit is solved
by fixed-point iteration from *E*<sub>1</sub> = *V*<sub>1</sub>:

$$E_1 = \frac{V_1}{1 + Z_1\left\[Y_m(E_1) + 1/(Z_2' + Z_L')\right\]}$$

Then
*I*<sub>2</sub><sup>′</sup> = *E*<sub>1</sub>/(*Z*<sub>2</sub><sup>′</sup> + *Z*<sub>*L*</sub><sup>′</sup>),
*I*<sub>1</sub> = *E*<sub>1</sub>\[*Y*<sub>*m*</sub> + 1/(*Z*<sub>2</sub><sup>′</sup> + *Z*<sub>*L*</sub><sup>′</sup>)\],
the core flux density is *B̂*(|*E*<sub>1</sub>|), and

$$\eta = \frac{P\_{out}}{P\_{out} + P\_{cu} + P\_{fe}}, \qquad \text{regulation} = \frac{V\_{2,nl} - V_2}{V_2}$$

with
*V*<sub>2, *n**l*</sub> = |*E*<sub>1, *n**l*</sub>| *N*<sub>2</sub>/*N*<sub>1</sub>
the no-load output voltage at the same *V*<sub>1</sub>, found by the
same iteration with the load removed (standard definition, as in Step
8). The circuit solved at load is returned as an `EquivalentCircuit` in
`'circuit'`.

The magnetising branch uses only the fundamental of the no-load current.

------------------------------------------------------------------------

### load_performance

``` python
def load_performance(
    core:TransformerCore, primary:TransformerWinding, secondary:TransformerWinding, material:CoreMaterial,
    supply:Supply, load_va:float, power_factor:float, gap:float, winding_height:float, lagging:bool=True,
    temperature_C:float=75.0, hysteresis:bool=True, dynamic:bool=True, tol:float=1e-09, max_iter:int=50
)->dict:
```

*Steady-state load performance from the T equivalent circuit, referred
to the primary.*

The load is load_va \[VA\] at power_factor on the rated secondary
voltage V1·N2/N1 (a constant impedance). The magnetising branch is
evaluated at the core voltage E1 by fixed-point iteration. Returns
currents, voltages, losses, efficiency, regulation (standard definition,
(V2_nl - V2)/V2) and the solved ‘circuit’ (EquivalentCircuit, referred
to the primary, shunt branch at the load point).

``` python
# Examples
lp = load_performance(core, primary, secondary, material, supply, load_va=1000.0, power_factor=0.8,
                      gap=2e-3, winding_height=90e-3)
assert np.isclose(lp["P_in"], lp["P_out"] + lp["P_cu"] + lp["P_fe"], rtol=1e-9)   # power balance
assert lp["E1"] < supply.voltage and lp["B_peak"] < B_hat                          # core sees E1 < V1
print(f"1 kVA, pf 0.8 lagging: V2 = {lp['V2']:.1f} V (regulation {100 * lp['regulation']:.2f} %), "
      f"I1 = {lp['I1']:.2f} A, P_cu = {lp['P_cu']:.1f} W, P_fe = {lp['P_fe']:.2f} W, η = {100 * lp['efficiency']:.2f} %, "
      f"B̂ = {lp['B_peak']:.3f} T")
```

    1 kVA, pf 0.8 lagging: V2 = 109.3 V (regulation 5.48 %), I1 = 4.19 A, P_cu = 47.9 W, P_fe = 10.22 W, η = 92.52 %, B̂ = 1.367 T

## Validation Against Published Worked Examples

These checks compare `shunt_from_open_circuit`,
`series_from_short_circuit` and `solve_equivalent_circuit` with
published solutions. They validate the circuit arithmetic and the
test-data formulas, **not** the magnetic chain from geometry to circuit
parameters (Steps 1–7), for which no published case with complete data
was found.

The textbook solutions use the cantilever approximation, so they are
compared with `model="cantilever"`; the exact T result is printed beside
them to show the size of the approximation. Each published value is
matched to the precision it is printed with.

<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr>
<th>Case</th>
<th>Source</th>
<th>Compared</th>
</tr>
</thead>
<tbody>
<tr>
<td>Chapman, <em>Electric Machinery Fundamentals</em>, Problem 2-6: 1000
VA, 230/115 V</td>
<td>worked solution by D. Winkler, <a
href="https://notebook.community/dietmarw/EK5312_ElectricalMachines/Chapman/Ch2-Problem_2-06">notebook.community</a></td>
<td><span
class="math inline"><em>R</em><sub><em>c</em></sub>, <em>X</em><sub><em>m</em></sub>, <em>R</em><sub><em>e</em><em>q</em></sub>, <em>X</em><sub><em>e</em><em>q</em></sub></span>
from tests; regulation at 0.8 lag, 1.0, 0.8 lead; copper and core loss;
efficiency</td>
</tr>
<tr>
<td>Chapman, Problem 2-2: 20 kVA, 8000/277 V</td>
<td>uOttawa ELG3311 Tutorial 2, <a
href="https://www.site.uottawa.ca/~rhabash/ELG3311T2.pdf">PDF</a></td>
<td>input voltage and angle, regulation, copper and core loss,
efficiency</td>
</tr>
<tr>
<td>uOttawa Tutorial 2, Problem 2-3: 2000 VA, 230/115 V</td>
<td>same PDF</td>
<td><span
class="math inline"><em>R</em><sub><em>c</em></sub>, <em>X</em><sub><em>m</em></sub>, <em>X</em><sub><em>T</em></sub></span>
from tests; <span
class="math inline"><em>R</em><sub><em>T</em></sub></span> (see
note)</td>
</tr>
<tr>
<td>Measured 1150 VA, 230/115 V, 50 Hz transformer</td>
<td>Olayinka et al., <em>Confirmatory Test on a Single-Phase
Transformer</em>, <a
href="https://www.appropedia.org/w/images/4/42/Confirmatory_Test_on_a_Single%E2%80%93Phase_Transformer.pdf">Appropedia</a></td>
<td><span
class="math inline"><em>R</em><sub><em>c</em></sub>, <em>X</em><sub><em>m</em></sub>, <em>R</em><sub><em>e</em><em>q</em></sub>, <em>X</em><sub><em>e</em><em>q</em></sub></span>
from measured OC/SC data</td>
</tr>
</tbody>
</table>

**Note on Problem 2-3.** The tutorial prints
*R*<sub>*T*</sub> = 0.588 *Ω*, but its own data give
*P*<sub>*s**c*</sub>/*I*<sub>*s**c*</sub><sup>2</sup> = 20.1/6<sup>2</sup> = 0.558 *Ω*;
its secondary-side value 0.140 *Ω* = 0.558/2<sup>2</sup> confirms 0.558,
so 0.588 is a typo. The check uses the secondary-side value.

``` python
# Chapman Problem 2-6 (OC on the LV side, SC on the HV side; I_sc = 8.7 A as given in the problem)
R_c, X_m = shunt_from_open_circuit(115.0, 0.11, 3.9)
R_eq, X_eq = series_from_short_circuit(17.1, 8.7, 38.1)
assert np.isclose(R_c, 3391.0256, atol=5e-5) and np.isclose(X_m, 1098.9873, atol=5e-5)
assert np.isclose(R_eq, 0.5034, atol=5e-5) and np.isclose(X_eq, 1.9000, atol=5e-5)
a = 230 / 115
c26 = EquivalentCircuit.from_series(R_eq / a ** 2, X_eq / a ** 2, R_c, X_m)   # referred to the LV side
I_n = 1000 / 115
for (pf, lag), vr_pub in {(0.8, True): 2.94, (1.0, True): 1.02, (0.8, False): -1.33}.items():
    s = solve_equivalent_circuit(c26, 115.0, I_n, pf, lagging=lag, model="cantilever")
    t = solve_equivalent_circuit(c26, 115.0, I_n, pf, lagging=lag, model="T")
    assert np.isclose(100 * s["regulation"], vr_pub, atol=0.005), (pf, lag)
    print(f"2-6  pf {pf} {'lag' if lag else 'lead'}: VR published {vr_pub:+.2f} %, "
          f"cantilever {100 * s['regulation']:+.3f} %, T {100 * t['regulation']:+.3f} %")
s = solve_equivalent_circuit(c26, 115.0, I_n, 0.8, model="cantilever")
assert np.isclose(s["P_cu"], 9.5155, atol=5e-5) and np.isclose(s["P_core"], 4.1328, atol=5e-5)
assert np.isclose(100 * s["efficiency"], 98.3, atol=0.05)
print(f"2-6  0.8 lag: P_cu {s['P_cu']:.4f} W (9.5155), P_core {s['P_core']:.4f} W (4.1328), "
      f"η {100 * s['efficiency']:.2f} % (98.3)")

# Chapman Problem 2-2, all values referred to the 8000 V side
a = 8000 / 277
c22 = EquivalentCircuit(32.0, 45.0, a ** 2 * 0.05, a ** 2 * 0.06, 250e3, 30e3)
s = solve_equivalent_circuit(c22, 8000.0, 20e3 / 8000, 0.8, model="cantilever")
t = solve_equivalent_circuit(c22, 8000.0, 20e3 / 8000, 0.8, model="T")
assert np.isclose(s["V1"], 8290, atol=1) and np.isclose(s["V1_angle_deg"], 0.55, atol=0.005)
assert np.isclose(100 * s["regulation"], 3.63, atol=0.005)
assert np.isclose(s["P_cu"], 461, atol=0.5) and np.isclose(s["P_core"], 275, atol=0.5)
assert np.isclose(100 * s["efficiency"], 95.6, atol=0.05)
print(f"2-2  V1 {s['V1']:.1f} V ∠{s['V1_angle_deg']:.3f}° (8290 ∠0.55°), VR {100 * s['regulation']:.3f} % (3.63), "
      f"P_cu {s['P_cu']:.1f} W (461), P_core {s['P_core']:.1f} W (275), η {100 * s['efficiency']:.2f} % (95.6); "
      f"T model: V1 {t['V1']:.1f} V, VR {100 * t['regulation']:.3f} %, η {100 * t['efficiency']:.2f} %")

# uOttawa Problem 2-3 (both tests on the 230 V side)
R_c, X_m = shunt_from_open_circuit(230.0, 0.45, 30.0)
R_T, X_T = series_from_short_circuit(13.2, 6.0, 20.1)
assert np.isclose(R_c, 1763, atol=0.5) and np.isclose(X_m, 534, atol=0.5) and np.isclose(X_T, 2.128, atol=5e-4)
assert np.isclose(R_T / 2 ** 2, 0.140, atol=5e-4) and np.isclose(X_T / 2 ** 2, 0.532, atol=5e-4)
print(f"2-3  R_c {R_c:.1f} Ω (1763), X_m {X_m:.1f} Ω (534), R_T {R_T:.4f} Ω (printed 0.588, typo), "
      f"X_T {X_T:.4f} Ω (2.128)")

# Measured transformer (Appropedia): OC on the LV side, SC on the HV side
R_c, X_m = shunt_from_open_circuit(115.1, 0.435, 11.9)
R_eq, X_eq = series_from_short_circuit(13.4, 5.0, 63.7)
assert np.isclose(R_c, 1113.28, atol=5e-3) and np.isclose(X_m, 272.4, atol=0.05)
assert np.isclose(R_eq, 2.548, atol=5e-4) and np.isclose(X_eq, 0.8307, atol=5e-5)
print(f"meas R_c {R_c:.2f} Ω (1113.28), X_m {X_m:.2f} Ω (272.4), R_eq {R_eq:.4f} Ω (2.548), X_eq {X_eq:.4f} Ω (0.8307)")
print("✓ All published values reproduced")
```

    2-6  pf 0.8 lag: VR published +2.94 %, cantilever +2.942 %, T +2.942 %
    2-6  pf 1.0 lag: VR published +1.02 %, cantilever +1.015 %, T +1.015 %
    2-6  pf 0.8 lead: VR published -1.33 %, cantilever -1.334 %, T -1.333 %
    2-6  0.8 lag: P_cu 9.5155 W (9.5155), P_core 4.1328 W (4.1328), η 98.32 % (98.3)
    2-2  V1 8290.4 V ∠0.550° (8290 ∠0.55°), VR 3.630 % (3.63), P_cu 460.7 W (461), P_core 274.9 W (275), η 95.60 % (95.6); T model: V1 8303.6 V, VR 3.626 %, η 95.47 %
    2-3  R_c 1763.3 Ω (1763), X_m 534.0 Ω (534), R_T 0.5583 Ω (printed 0.588, typo), X_T 2.1280 Ω (2.128)
    meas R_c 1113.28 Ω (1113.28), X_m 272.40 Ω (272.4), R_eq 2.5480 Ω (2.548), X_eq 0.8307 Ω (0.8307)
    ✓ All published values reproduced

## Tests

``` python
# switches: plain B–H draws no loop power; static loop draws less than the dynamic loop
r_off = no_load_current(core, primary, material, supply, hysteresis=False, dynamic=False)
r_static = no_load_current(core, primary, material, supply, dynamic=False)
assert abs(r_off["P_loop"]) < 1e-9 and abs(r_off["I_c1"]) < 1e-9
assert 0 < r_static["P_loop"] < nl["P_loop"]
# core loss does not depend on the switches
assert magnetising_branch(core, primary, material, supply, False, False)["P_fe"] == mb["P_fe"]

# joints: add B g_j / (μ0 N1) to the current, raising the magnetising current
core_j = replace(core, joint_gap_total=80e-6)
nl_j = no_load_current(core_j, primary, material, supply)
assert np.allclose(nl_j["i0"] - nl["i0"], nl["B"] * 80e-6 / MU0 / primary.turns)
assert nl_j["I_m1"] > nl["I_m1"] and np.isclose(nl_j["P_loop"], nl["P_loop"], rtol=1e-6)

# B̂ scales as V / (f N)
assert np.isclose(peak_flux_density(core, primary, 115, 50), B_hat / 2)
assert np.isclose(peak_flux_density(core, primary, 230, 60), B_hat * 50 / 60)

# load: unity pf and a lighter load give smaller regulation; efficiency below 1
lp_light = load_performance(core, primary, secondary, material, supply, 250.0, 1.0, 2e-3, 90e-3)
assert lp_light["regulation"] < lp["regulation"] and 0 < lp_light["efficiency"] < 1
assert np.isclose(lp_light["P_in"], lp_light["P_out"] + lp_light["P_cu"] + lp_light["P_fe"], rtol=1e-9)

# the two solvers agree: the circuit solved by load_performance, loaded with its own V2 and I2,
# gives back the supply voltage and primary current
kr = primary.turns / secondary.turns
s = solve_equivalent_circuit(lp["circuit"], lp["V2"] * kr, lp["I2"] / kr, 0.8, model="T")
assert np.isclose(s["V1"], supply.voltage, rtol=1e-6) and np.isclose(s["I1"], lp["I1"], rtol=1e-6)
assert np.isclose(s["P_core"], lp["P_fe"], rtol=1e-6) and np.isclose(s["P_cu"], lp["P_cu"], rtol=1e-6)
# regulation is referred to the full-load voltage, from the no-load voltage at the same V1
assert np.isclose(lp["regulation"], (lp["V2_no_load"] - lp["V2"]) / lp["V2"])
assert lp["V2_no_load"] < supply.voltage / kr                 # no-load current drops a little across Z1
# T and cantilever agree when the shunt branch is very large; no load gives zero regulation in the cantilever model
big = EquivalentCircuit.from_series(2.0, 4.0, 1e12, 1e12)
sT, sC = (solve_equivalent_circuit(big, 220.0, 4.0, 0.8, model=m) for m in ("T", "cantilever"))
assert np.isclose(sT["V1"], sC["V1"]) and np.isclose(sT["regulation"], sC["regulation"])
assert solve_equivalent_circuit(ec, 220.0, 0.0, 1.0, model="cantilever")["regulation"] == 0.0

for bad in [lambda: peak_flux_density(core, primary, 0, 50), lambda: rogowski_factor(0, 1e-2),
            lambda: shunt_from_open_circuit(115, 0.1, 20), lambda: series_from_short_circuit(10, 0, 1),
            lambda: solve_equivalent_circuit(ec, 220, 4, 0.8, model="pi"),
            lambda: solve_equivalent_circuit(ec, 0, 4, 0.8), lambda: EquivalentCircuit.from_series(1, 1, 1, 1, 1.5),
            lambda: leakage_inductance(primary, secondary, -1e-3, 0.09),
            lambda: load_performance(core, primary, secondary, material, supply, 1000, 1.2, 2e-3, 0.09)]:
    try:
        bad()
    except ValueError:
        pass
    else:
        raise AssertionError("no ValueError")
print("✓ Transformer tests passed")
```

    ✓ Transformer tests passed

## References

- McLyman, C.W.T. (2004). *Transformer and Inductor Design Handbook*
  (3rd ed.). Marcel Dekker.
- Kulkarni, S.V., Khaparde, S.A. (2004). *Transformer Engineering:
  Design and Practice*. Marcel Dekker — leakage reactance, Rogowski
  factor.
- Chapman, S.J. (2012). *Electric Machinery Fundamentals* (5th ed.).
  McGraw-Hill — Problems 2-2 and 2-6 used for validation.
- IEEE Std C57.12.80 — Standard terminology for power and distribution
  transformers (voltage regulation).
- Say, M.G. (1976). *Alternating Current Machines*. Pitman — equivalent
  circuit, regulation, efficiency.
- IEC 60028 — International standard of resistance for copper (ρ₂₀,
  α₂₀).
