# End Turns, Phase Resistance and End-Winding Leakage


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

## Executive Summary

**Purpose:** the part of a winding outside the stack. Its end turns set
the length of copper, and so the **phase resistance**, and they carry
the **end-winding leakage** inductance. Phases whose end turns differ in
length or radius, such as one phase per layer, get different
resistances.

**What it does:** - `EndTurn` describes the end-turn shape: a straight
extension out of the slot, an optional axial tier offset for each slot
position, an arc across the coil span, and an empirical leakage
factor. - `coil_end_length` and `mean_turn_length` give the copper
length of each coil and phase. - `phase_resistance` gives the DC
resistance of each phase at a temperature, from either a copper area per
turn or a fill factor. - `end_winding_inductance` gives the empirical
end-winding leakage of each phase.

**Background:** the end-winding leakage path is shown on the [Inductance
Theory](inductance_theory.html) page.

**Assumptions:** DC resistance (no skin or proximity effect). The end
turns follow the simple shape below. The end-winding leakage uses an
empirical permeance factor, to be replaced by a filament (Biot–Savart)
model later.

## How It Fits Into the Motor Design Workflow

**Upstream:** `WindingPattern` built from coils (`custom` or a builder;
a slot table has no coils), and `StatorGeometry` (stack length, slot
regions for the radius and area of each position).

**Downstream:** `StatorInductances` and `compare_windings` ([Total
Stator Inductance](inductance_stator.html)), copper loss, the phase
resistance in motor models.

## Theory

<figure>
<img src="images/end_turn_geometry.svg"
alt="Left: side view of one coil leaving the stack. Each conductor runs straight out of the slot for l_ext, plus a tier offset for its layer, then turns across the coil span. Layers 1, 2 and 3 bend at different axial distances so they can cross. Right: end view, the arc across the span of the coil at the mean radius of the conductors." />
<figcaption aria-hidden="true">Left: side view of one coil leaving the
stack. Each conductor runs straight out of the slot for l_ext, plus a
tier offset for its layer, then turns across the coil span. Layers 1, 2
and 3 bend at different axial distances so they can cross. Right: end
view, the arc across the span of the coil at the mean radius of the
conductors.</figcaption>
</figure>

### Step 1 — length of one end turn

A coil leaves the slot, runs axially for *l*<sub>*e**x**t*</sub>,
crosses over to the other side’s slot, and comes back. Where conductors
of different layers have to cross, each layer bends at its own axial
distance: the **tier** offset *Δ*<sub>*p**o**s*</sub>. So the length of
one end turn is

$$l\_{end} = 2\\(l\_{ext} + \Delta\_{pos}) + k\_{arc}\\ \frac{2\pi\\ r\_{mid}}{Q}\\ s,$$

with *s* the coil span in slots (the shorter way round),
*r*<sub>*m**i**d*</sub> the mean radius of the coil’s conductors (deeper
layers sit at a larger radius, so their arc is longer), and
*k*<sub>*a**r**c*</sub> a shape factor (1 for a circular arc, about
1/cos *α* for a diamond end turn at angle *α*).

The mean turn length of a coil is
MLT = 2 *l*<sub>*s**t**k*</sub> + 2 *l*<sub>*e**n**d*</sub>.

**Which layer gets which tier depends on how the winding is made.** If
the bottom layer is inserted first it usually bends nearest the core, so
the layers further out (towards the air gap) bend further away. Both
orders are worked through in the example below.

### Step 2 — phase resistance

Each turn of a coil has copper area *A*<sub>*c*</sub>. A phase with *a*
parallel paths has 1/*a* of its turns in each path and *a* paths in
parallel:

$$R_x = \frac{\rho(T)}{a^2} \sum\_{\text{coils of } x} \frac{N_c\\ \text{MLT}\_c}{A_c}, \qquad \rho(T) = \rho\_{20}\\\bigl(1 + \alpha\\(T - 20\\^\circ\text{C})\bigr).$$

*A*<sub>*c*</sub> is either given, or set by a copper fill factor
*k*<sub>*f**i**l**l*</sub>:
*A*<sub>*c*</sub> = *k*<sub>*f**i**l**l*</sub> *A*<sub>*p**o**s*</sub>/*N*<sub>*p**o**s*</sub>,
the copper share of the position’s area divided by the turns in it (the
smaller value of the coil’s two sides). Copper:
*ρ*<sub>20</sub> = 1.724 × 10<sup>−8</sup> *Ω* m,
*α* = 3.93 × 10<sup>−3</sup> /K.

### Step 3 — end-winding leakage (empirical)

The end turns are in air, and the field around them is
three-dimensional. The usual design formula treats each end as a
conductor bundle of length *l*<sub>*e**n**d*</sub> with a permeance per
unit length *μ*<sub>0</sub>*λ*<sub>*w*</sub>. A phase has *p* coil
groups of *N*<sub>*s*</sub>/*p* turns in series, each with two ends, so

$$L\_{ew} = 2\\\mu_0\\ \frac{N_s^2}{p}\\ l\_{end}\\ \lambda_w.$$

*λ*<sub>*w*</sub> is empirical: about 0.2–0.5 depending on the winding
type and on how close the end turns are to the core and frame (Pyrhönen
et al., §4.3; Lipo, ch. 6). The default is 0.3. The factor is fitted to
measured *synchronous* inductances, so it already includes the coupling
between phases at the ends. The result is therefore placed on the
diagonal, and it adds directly to *L*<sub>*s*</sub>. Use it for
estimates and for comparing windings on the same end-turn shape, and
calibrate *λ*<sub>*w*</sub> against a measurement when you have one.
Note: `StatorGeometry.l_ew` (the overhang drawn in the geometry figure)
is a separate dimension; `EndTurn` carries the end-turn shape used here.

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

### mean_turn_length

``` python
def mean_turn_length(
    pattern:WindingPattern, stator:StatorGeometry, end:EndTurn
)->np.ndarray:
```

*Mean turn length of each phase \[m\], turn-weighted over its coils:*
MLT = 2 l_stk + 2 l_end.

## Returns

np.ndarray, shape (m,)

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

### coil_end_length

``` python
def coil_end_length(
    coil:Coil, pattern:WindingPattern, stator:StatorGeometry, end:EndTurn
)->float:
```

*Length of one end turn of a coil \[m\].*

The span is the shorter way round between the two slots. The arc is
taken at the mean radius of the two sides’ regions; the legs use the
mean tier offset of the two positions.

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

### EndTurn

``` python
def EndTurn(
    l_ext:float, tier:dict=<factory>, k_arc:float=1.0, lambda_ew:float=0.3
)->None:
```

*Shape of the end turns, for turn length and end-winding leakage.*

One end turn (one end of a coil) = 2 axial legs + an arc across the coil
span:

    l_end = 2 (l_ext + tier[pos]) + k_arc · span · 2π r_mid / Q

## Attributes

l_ext : float Straight axial extension out of the slot before the turn
\[m\] tier : dict Extra axial offset of each slot position \[m\], for
end turns that stack axially (e.g. {‘1’: 16e-3, ‘2’: 8e-3, ‘3’: 0.0});
default none k_arc : float Arc length factor: 1 = circular arc at the
conductors’ mean radius; \> 1 for diamond or involute end turns
(default 1) lambda_ew : float Empirical end-winding permeance factor λ_w
(default 0.3)

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

### end_winding_inductance

``` python
def end_winding_inductance(
    pattern:WindingPattern, stator:StatorGeometry, end:EndTurn
)->np.ndarray:
```

*Empirical end-winding leakage inductance \[H\], as a diagonal matrix.*

L_ew,x = 2 μ0 (N_s,x² / p) · l_end,x · λ_w

with N_s,x the series turns of phase x, l_end,x its mean end-turn length
(one end) and λ_w = `end.lambda_ew`. The factor λ_w is empirical and
already includes the coupling between phases at the ends, so the result
goes on the diagonal and adds directly to the synchronous inductance.
Calibrate λ_w against a measurement where you can.

## Returns

np.ndarray, shape (m, m)

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

### phase_resistance

``` python
def phase_resistance(
    pattern:WindingPattern, stator:StatorGeometry, end:EndTurn, a_cond:float | None=None,
    fill:float | None=None, # fill × area of its position / turns at that position in the slot
    # (the smaller of its two sides)
    T:float=20.0, rho20:float=1.724e-08, alpha:float=0.00393
)->np.ndarray:
```

*DC resistance of each phase \[Ω\].*

R_x = ρ(T) Σ_coils (turns · MLT_coil / A_coil) / a², with a the parallel
paths and ρ(T) = ρ20 (1 + α (T − 20)).

## Parameters

pattern, stator, end a_cond : float | None Copper area of one turn
\[m²\], the same for every coil; or fill : float | None Copper fill
factor of the slot positions: each coil gets fill × area of its position
/ turns at that position in the slot (the smaller of its two sides) T :
float Conductor temperature \[°C\] (default 20) rho20, alpha : float
Resistivity at 20 °C and its temperature coefficient (copper)

## Returns

np.ndarray, shape (m,)

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

## Examples

The 36-slot stator of the earlier notebooks, a short-pitched double
layer with 10 turns per coil and 2 parallel paths, at 20 °C and 120 °C.
The fill factor is 0.42:

``` python
stator = StatorGeometry(Q=36, r_bore=60e-3, g=0.8e-3, l_stk=100e-3, h_y=12e-3, l_ew=22e-3,
                        slot=SlotGeometry.semi_closed(b0=2.5e-3, h0=1e-3, h1=1.5e-3, bs=6e-3, hs=18e-3, t=0.5))
pat = WindingPattern.distributed(36, 4, pitch=7, turns=10, parallel_paths=2)
end = EndTurn(l_ext=12e-3)
print(f"one end turn {coil_end_length(pat.coils[0], pat, stator, end) * 1e3:.1f} mm, "
      f"MLT {mean_turn_length(pat, stator, end)[0] * 1e3:.1f} mm")
for T in (20, 120):
    print(f"R at {T:3d} °C: {np.round(phase_resistance(pat, stator, end, fill=0.42, T=T) * 1e3, 2)} mΩ")
Lew = end_winding_inductance(pat, stator, end)
print(f"end-winding leakage {Lew[0, 0] * 1e3:.4f} mH per phase "
      f"(λ_w = {end.lambda_ew}), air-gap synchronous {phase_imbalance(airgap_inductance(pat, stator))['L_positive'] * 1e3:.3f} mH")
```

    one end turn 111.7 mm, MLT 423.3 mm
    R at  20 °C: [85.37 85.37 85.37] mΩ
    R at 120 °C: [118.91 118.91 118.91] mΩ
    end-winding leakage 0.1516 mH per phase (λ_w = 0.3), air-gap synchronous 12.020 mH

### Resistance imbalance of a winding with one phase per layer (EP 2 237 392 B1)

The patent’s 48-slot winding puts each phase in its own layer
(dimensions assumed, as in the slot-leakage notebook). The deeper layers
sit at a larger radius, so their arcs are longer. How the end turns
stack axially then decides which phase gets the longest legs. Three
cases at 120 °C, fill 0.45:

``` python
def ep2237392(order=("1", "2", "3"), turns=2):
    """EP 2 237 392 B1: 48 slots, 4 poles, one phase per radial layer (phase k in layer order[k])."""
    coils = []
    for ph, (start, sign0) in enumerate([(0, 1), (4, -1), (8, 1)]):
        for pole in range(4):
            s0, sign = start + 12 * pole, sign0 * (-1) ** pole
            pos = order[ph]
            for k in range(6):                                   # concentric: spans 1, 3, ..., 11
                a, b = (s0 + 5 - k) % 48, (s0 + 6 + k) % 48
                if sign < 0:
                    a, b = b, a
                coils.append(Coil(ph, a, pos, b, pos, turns))
    return WindingPattern.custom(48, 4, coils, layout="over_under", n_layers=3,
                                 name="EP2237392")

ep_stator = StatorGeometry(Q=48, r_bore=80e-3, g=0.6e-3, l_stk=150e-3, h_y=15e-3, l_ew=30e-3,
                           slot=SlotGeometry.open(5e-3, 24e-3))
```

``` python
ep = ep2237392()
cases = {"radius only, no tiers": {},
         "bottom layer nearest core (8 mm tiers)": {"1": 16e-3, "2": 8e-3, "3": 0.0},
         "top layer nearest core (8 mm tiers)": {"1": 0.0, "2": 8e-3, "3": 16e-3}}
for label, tier in cases.items():
    e = EndTurn(l_ext=12e-3, tier=tier)
    R = phase_resistance(ep, ep_stator, e, fill=0.45, T=120)
    mlt = mean_turn_length(ep, ep_stator, e)
    Lew = np.diag(end_winding_inductance(ep, ep_stator, e))
    print(f"{label:40s} MLT A/B/C {np.round(mlt * 1e3, 1)} mm   R {np.round(R * 1e3, 1)} mΩ  "
          f"spread {100 * (R.max() - R.min()) / R.mean():4.1f}%   L_ew {np.round(Lew * 1e6, 1)} µH")
```

    radius only, no tiers                    MLT A/B/C [479.9 492.5 505.1] mm   R [61.5 63.1 64.7] mΩ  spread  5.1%   L_ew [78.1 83.6 89.1] µH
    bottom layer nearest core (8 mm tiers)   MLT A/B/C [543.9 524.5 505.1] mm   R [69.7 67.2 64.7] mΩ  spread  7.4%   L_ew [105.9  97.5  89.1] µH
    top layer nearest core (8 mm tiers)      MLT A/B/C [479.9 524.5 569.1] mm   R [61.5 67.2 72.9] mΩ  spread 17.0%   L_ew [ 78.1  97.5 116.9] µH

With no tiers, the radius alone gives a 5% resistance spread, with phase
C (at the slot bottom) longest. Tiers that put the bottom layer nearest
the core shorten C’s legs and lengthen A’s, reversing the order. Tiers
the other way add to the radius effect, and the spread grows to about
17%. The patent does not say which is used, so the real spread is
somewhere in this range.

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

## Validation

1.  **Turn length by hand.** For a single-layer full-pitch winding with
    no tiers, every end turn is
    2*l*<sub>*e**x**t*</sub> + (*Q*/*P*) 2*π**r*<sub>*m**i**d*</sub>/*Q*,
    with *r*<sub>*m**i**d*</sub> at the middle of the slot body.
2.  **Resistance by hand.** With a given copper area *A*<sub>*c*</sub>
    and equal coils,
    *R* = *ρ* *N*<sub>*c**o**i**l**s*</sub>*N*<sub>*c*</sub> MLT/(*A*<sub>*c*</sub> *a*<sup>2</sup>)
    per phase. Halving the area doubles *R*, two paths divide it by 4,
    and *R*(*T*)/*R*(20) = 1 + *α*(*T* − 20).
3.  **End-winding leakage.** It scales as *N*<sub>*s*</sub><sup>2</sup>
    and *l*<sub>*e**n**d*</sub>, and is the closed form
    2*μ*<sub>0</sub>*N*<sub>*s*</sub><sup>2</sup>*l*<sub>*e**n**d*</sub>*λ*<sub>*w*</sub>/*p*.

``` python
st1 = StatorGeometry(Q=24, r_bore=50e-3, g=0.6e-3, l_stk=80e-3, h_y=10e-3, slot=SlotGeometry.open(5e-3, 20e-3))
p1 = WindingPattern.distributed(24, 4, layers=1, turns=8)
e1 = EndTurn(l_ext=10e-3)
r_mid = st1.r_body + 10e-3
l_end = 2 * 10e-3 + 6 * 2 * np.pi * r_mid / 24
assert all(np.isclose(coil_end_length(c, p1, st1, e1), l_end) for c in p1.coils)
mlt = 2 * 80e-3 + 2 * l_end
assert np.allclose(mean_turn_length(p1, st1, e1), mlt)
R = phase_resistance(p1, st1, e1, a_cond=1e-6)
n_coils = len(p1.coils) // 3
assert np.allclose(R, RHO_CU_20 * n_coils * 8 * mlt / 1e-6)
print(f"by hand: l_end = {l_end * 1e3:.2f} mm, MLT = {mlt * 1e3:.2f} mm, R = {R[0] * 1e3:.3f} mΩ")
Lew = end_winding_inductance(p1, st1, e1)
assert np.allclose(np.diag(Lew), 2 * MU0 * p1.series_turns() ** 2 / 2 * l_end * 0.3)
```

    by hand: l_end = 114.25 mm, MLT = 388.50 mm, R = 214.325 mΩ

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

## Tests

## References

- Pyrhönen, J., Jokinen, T., Hrabovcová, V. (2014). *Design of Rotating
  Electrical Machines* (2nd ed.). Wiley, §4.3 (end-winding leakage
  factor) and §2 (winding geometry).
- Lipo, T.A. (2017). *Introduction to AC Machine Design*. Wiley-IEEE
  Press, ch. 6 — end-winding leakage, end-turn length.
- IEC 60028 — resistivity of annealed copper, 1/58 Ω mm²/m at 20 °C.
- EP 2 237 392 B1, *AC motor winding pattern* — the one-phase-per-layer
  winding of the example (dimensions assumed).
