# Air-Gap Inductance


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

## Executive Summary

**Purpose:** The part of the stator inductance whose flux crosses the
air gap, for any `WindingPattern` on any `StatorGeometry`, and a report
of how unequal the phases are.

**What it does:** `winding_function` turns the slot turns into the turns
around each tooth. `airgap_inductance` integrates the product of two
winding functions over the gap, giving the full m × m phase matrix. It
can be split into the working-harmonic part (the magnetising inductance)
and the rest (air-gap harmonic, or differential, leakage).
`phase_imbalance` reports the spread of the self and mutual inductances
and how strongly a positive-sequence current couples into the other
sequences.

**Background:** what the parts of a winding’s inductance are, and what a
measurement contains, is on the [Inductance
Theory](inductance_theory.html) page.

**Assumptions:** iron of infinite permeability, a smooth non-salient
rotor, and a uniform effective gap
*g*<sub>*e*</sub> = *k*<sub>*C*</sub> *g* (Carter). For a surface-PM
rotor pass `g_eff` =
*k*<sub>*C*</sub>(*g* + *h*<sub>*m*</sub>/*μ*<sub>*r*</sub>). Slot
openings are treated as narrow, so the winding function steps at the
slot centres; the opening width enters through Carter only. Slot,
tooth-tip and end-winding leakage are separate parts, added in the next
steps.

## How It Fits Into the Motor Design Workflow

**Upstream:** `emachines.winding.WindingPattern` (turns per slot) and
`emachines.inductance.StatorGeometry` (bore, gap, stack, slot opening).

**Downstream:** the total stator inductance (air gap + slot leakage +
tooth tip + end winding), dq inductances for motor models, and the
comparison of candidate windings.

## Theory

**What “air-gap inductance” means.** A phase current drives flux along
several paths (see [Inductance Theory](inductance_theory.html), section
2). The *air-gap inductance* is the part due to the flux that crosses
the air gap into the rotor and back. It is the largest part, and the
only one that couples the stator to the rotor. The slot, tooth-tip and
end-winding leakage never reach the gap; they are separate notebooks.

The derivation takes five steps: the winding function (turns enclosed),
the flux density it drives across the gap, the flux linkage, the
harmonic split into magnetising and harmonic leakage, and Carter’s
correction for the slot openings.

### Step 1 — winding function: the MMF a phase puts across the gap

<figure>
<img src="images/winding_function_steps.svg"
alt="Top: a 12-slot, 2-pole single-layer winding unrolled, with phase-A conductors in slots 0, 1 (current out of the page) and 6, 7 (into the page) and their turns N_i; the teeth are numbered between slots. Bottom: the winding function W_i of phase A, a staircase over the teeth that steps down by N_i at each slot, with equal areas above and below zero, and its fundamental." />
<figcaption aria-hidden="true">Top: a 12-slot, 2-pole single-layer
winding unrolled, with phase-A conductors in slots 0, 1 (current out of
the page) and 6, 7 (into the page) and their turns N_i; the teeth are
numbered between slots. Bottom: the winding function W_i of phase A, a
staircase over the teeth that steps down by N_i at each slot, with equal
areas above and below zero, and its fundamental.</figcaption>
</figure>

Number the slots *i* = 0…*Q* − 1 at angles
*θ*<sub>*i*</sub> = 2*π**i*/*Q*; tooth *i* lies between slot *i* and
slot *i* + 1. Let *N*<sub>*x*, *i*</sub> be the turns of phase *x* in
slot *i* per ampere of phase current. It is signed (positive for current
out of the page, ⊙), summed over every position in the slot, and divided
by the number of parallel paths.

Take a closed path that goes down tooth *i* − 1, across the gap, along
the rotor, back up tooth *i* and through the yoke. With iron of infinite
permeability, all the MMF is spent in the two gap crossings, and
Ampère’s law says the difference between them equals the current
enclosed, which is the current in slot *i*. So the gap MMF steps by the
slot current at every slot:

*W*<sub>*x*, *i*</sub> = *W*<sub>*x*, *i* − 1</sub> − *N*<sub>*x*, *i*</sub>.

The MMF across the gap over tooth *i* is
*F*<sub>*i*</sub> = *W*<sub>*x*, *i*</sub> *i*<sub>*x*</sub>. The
staircase is fixed up to a constant; the constant is set by Gauss’s law.
No net flux can leave the rotor, so the flux into the rotor over all
teeth sums to zero, and with a uniform gap that means

$$\sum\_{i=0}^{Q-1} W\_{x,i} = 0 \qquad \text{(zero mean: equal areas above and below in the figure).}$$

*W*<sub>*x*, *i*</sub> has a second meaning that the next steps use: it
is also the number of turns of phase *x* that *enclose* tooth *i*,
i.e. that link the flux crossing the gap at tooth *i*.

### Step 2 — flux density and flux per tooth

The gap is uniform, of effective length *g*<sub>*e*</sub> (step 5), so
the flux density over tooth *i* is

$$B_i = \frac{\mu_0 F_i}{g_e} = \frac{\mu_0}{g_e} \sum_y W\_{y,i}\\ i_y.$$

The flux through the gap surface of tooth *i* is *B*<sub>*i*</sub> times
that surface: arc *r*<sub>*g*</sub> (2*π*/*Q*) at mid-gap radius
*r*<sub>*g*</sub> = *r*<sub>*b**o**r**e*</sub> − *g*/2, times the stack
length *l*<sub>*s**t**k*</sub>:

$$\Phi_i = B_i\\ r_g\\ \frac{2\pi}{Q}\\ l\_{stk}.$$

### Step 3 — flux linkage and the inductance matrix

Phase *x* links the flux of tooth *i* *W*<sub>*x*, *i*</sub> times (step
1), so
*λ*<sub>*x*</sub> = ∑<sub>*i*</sub>*W*<sub>*x*, *i*</sub> *Φ*<sub>*i*</sub>.
Substituting step 2 and dividing by *i*<sub>*y*</sub>:

$$\boxed{L\_{ag,xy} = \frac{\mu_0 r_g l\_{stk}}{g_e}\\\frac{2\pi}{Q} \sum\_{i=0}^{Q-1} W\_{x,i}\\W\_{y,i} = \frac{\mu_0 r_g l\_{stk}}{g_e} \int_0^{2\pi} w_x(\theta)\\w_y(\theta)\\d\theta}$$

The first factor,
*μ*<sub>0</sub>*r*<sub>*g*</sub>*l*<sub>*s**t**k*</sub>/*g*<sub>*e*</sub>,
is the permeance of the gap per radian. The rest is a purely geometric
overlap of the two winding functions:

<figure>
<img src="images/winding_function_product.svg"
alt="Left: W_a times W_a is never negative, its sum gives the self inductance L_aa. Right: W_a times W_b is positive over some teeth and negative over others; the net sum is negative, giving a negative mutual inductance L_ab." />
<figcaption aria-hidden="true">Left: W_a times W_a is never negative,
its sum gives the self inductance L_aa. Right: W_a times W_b is positive
over some teeth and negative over others; the net sum is negative,
giving a negative mutual inductance L_ab.</figcaption>
</figure>

- **Self** (*x* = *y*): *W*<sub>*x*</sub><sup>2</sup> ≥ 0 everywhere, so
  *L*<sub>*x**x*</sub> \> 0.
- **Mutual**: where the two phases’ MMFs have the same sign the product
  adds, where they oppose it subtracts. For 3-phase windings the net is
  negative (≈ −*L*<sub>*x**x*</sub>/2).
- In matrix form,
  $\mathbf{L}\_{ag} = \dfrac{\mu_0 r_g l\_{stk}}{g_e}\\\dfrac{2\pi}{Q}\\ \mathbf{W}\mathbf{W}^T$,
  with **W** the *m* × *Q* array returned by `winding_function`.

### Step 4 — split into magnetising and harmonic leakage

<figure>
<img src="images/harmonic_split.svg"
alt="Left: the winding function of a 36-slot 4-pole distributed winding and a 12-slot 10-pole tooth-coil winding, each with its fundamental (nu = p) and the remainder shaded. Right: share of the synchronous inductance carried by each harmonic. The distributed winding is almost all fundamental (sigma_delta = 0.011); the tooth-coil winding has only about half its synchronous inductance in the working harmonic 5, with large 1st and 7th harmonics (sigma_delta = 0.968)." />
<figcaption aria-hidden="true">Left: the winding function of a 36-slot
4-pole distributed winding and a 12-slot 10-pole tooth-coil winding,
each with its fundamental (nu = p) and the remainder shaded. Right:
share of the synchronous inductance carried by each harmonic. The
distributed winding is almost all fundamental (sigma_delta = 0.011); the
tooth-coil winding has only about half its synchronous inductance in the
working harmonic 5, with large 1st and 7th harmonics (sigma_delta =
0.968).</figcaption>
</figure>

Write the winding function as a Fourier series,
*w*<sub>*x*</sub>(*θ*) = ∑<sub>*ν* ≥ 1</sub>(*a*<sub>*x**ν*</sub>*e*<sup>*j**ν**θ*</sup> + c.c.),
where *ν* is the number of pole pairs of a harmonic round the whole gap.
Parseval’s theorem turns the integral of step 3 into a sum over
harmonics:

$$L\_{ag,xy} = \frac{\mu_0 r_g l\_{stk}}{g_e}\\ 4\pi \sum\_{\nu \ge 1} \operatorname{Re}\\\left(a\_{x\nu}\\ a\_{y\nu}^\*\right).$$

- The term *ν* = *p* has the rotor’s pole count. It makes the torque and
  is the **magnetising inductance** (`part='magnetising'`).
- Every other term, including the sub-harmonics (*ν* \< *p*) of
  fractional-slot windings, is **air-gap harmonic (differential)
  leakage** (`part='harmonic'`). This flux does cross the gap, but it
  cannot make steady torque with a *p*-pole-pair rotor.
- The **harmonic leakage factor**
  *σ*<sub>*δ*</sub> = *L*<sub>*δ*</sub>/*L*<sub>*m*</sub> is taken on
  the synchronous inductance
  *L*<sub>*a**a*</sub> − *L*<sub>*a**b*</sub>. Triplen harmonics cancel
  there for 3-phase windings.

The winding function is a staircase, so its Fourier coefficients are
exact sums, with no numerical integration:

$$a\_{x\nu} = \frac{1}{2\pi} \sum_i W\_{x,i}\\ \frac{e^{-j\nu\theta_i} - e^{-j\nu\theta\_{i+1}}}{j\nu}, \qquad \theta_i = \frac{2\pi i}{Q}.$$

For a winding with sinusoidally distributed turns, the magnetising part
reduces to the textbook closed form
$L_m = \dfrac{4}{\pi}\\\dfrac{\mu_0 r_g l\_{stk}}{g_e} \left(\dfrac{k\_{w1} N_s}{p}\right)^2$.
The validation section checks that.

### Step 5 — Carter: slot openings make the gap look longer

<figure>
<img src="images/carter.svg"
alt="Top: field lines under two teeth and a slot opening of width b0; under the teeth they cross the gap g straight, over the opening they fringe into the sides of the tooth tips. Bottom: flux density along one slot pitch, flat at B_max under the teeth with a dip under the opening; its average equals B_max over k_C, the same average as a smooth gap of length k_C g." />
<figcaption aria-hidden="true">Top: field lines under two teeth and a
slot opening of width b0; under the teeth they cross the gap g straight,
over the opening they fringe into the sides of the tooth tips. Bottom:
flux density along one slot pitch, flat at B_max under the teeth with a
dip under the opening; its average equals B_max over k_C, the same
average as a smooth gap of length k_C g.</figcaption>
</figure>

Over a slot opening the flux has further to go, so the flux density dips
there. The average flux over a slot pitch is the same as for a smooth
(slotless) stator with a longer gap:

$$g_e = k_C\\ g, \qquad k_C = \frac{\tau_s}{\tau_s - \gamma g}, \qquad \gamma = \frac{(b_0/g)^2}{5 + b_0/g},$$

with *τ*<sub>*s*</sub> the slot pitch at the bore and *b*<sub>0</sub>
the slot opening (the full slot width *b*<sub>*s*</sub> for an open
slot). This is the same formula as
`emachines.motors.calculate_carter_coefficient`. For a surface-PM rotor
the magnet is almost like air to the stator flux, so pass `g_eff`
 = *k*<sub>*C*</sub> (*g* + *h*<sub>*m*</sub>/*μ*<sub>*r*</sub>).

**Simplification:** the winding function steps at the slot centres, as
if the openings were narrow. The opening width enters only through
*k*<sub>*C*</sub>.

## Phase Imbalance

For a balanced m-phase winding the inductance matrix is circulant: every
self inductance is equal, and the mutual inductance depends only on how
many phases apart two phases are. `phase_imbalance` measures how far a
matrix is from that:

- **self spread**
  $= (\max L\_{kk} - \min L\_{kk}) / \overline{L\_{kk}}$;
- **mutual spread** — the same for each set of mutuals one, two, …
  phases apart, the largest reported, relative to the mean self
  inductance;
- **sequence coupling** — transform with the unitary DFT matrix
  $F\_{jk} = e^{-j 2\pi jk/m}/\sqrt{m}$, so
  *L*<sub>*s**e**q*</sub> = *F**L**F*<sup>*H*</sup>. A circulant matrix
  becomes diagonal: *L*<sub>*s**e**q*, 11</sub> is the positive-sequence
  (synchronous) inductance, equal to
  *L*<sub>*a**a*</sub> − *L*<sub>*a**b*</sub> for three phases. The
  largest off-diagonal entry over |*L*<sub>*s**e**q*, 11</sub>| says how
  much flux a balanced positive-sequence current drives into the other
  sequences. That is what makes unbalanced currents and torque ripple.

Star-of-slots windings come out balanced to rounding error; it is a
check of the method. Imbalance appears in hand-made windings
(`from_slot_table`, `custom`).

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

## Winding function

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

### winding_function_harmonics

``` python
def winding_function_harmonics(
    pattern:WindingPattern, nu
)->np.ndarray:
```

*Complex Fourier coefficients a_ν of the (step) winding function of each
phase.*

w_x(θ) = Σ_ν≥1 (a_xν e^{jνθ} + c.c.). Exact for the step function.

## Parameters

pattern : WindingPattern nu : int or array of int \>= 1 Mechanical
harmonic orders

## Returns

np.ndarray, complex, shape (m,) for scalar nu or (m, len(nu))

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

### winding_function

``` python
def winding_function(
    pattern:WindingPattern
)->np.ndarray: # W[x, i] for tooth i, which lies between slot i and slot i + 1.
```

*Turns around each tooth per ampere of phase current, zero mean.*

## Returns

np.ndarray, shape (m, Q) W\[x, i\] for tooth i, which lies between slot
i and slot i + 1.

``` python
# Examples: a full-pitch coil of 10 turns on 12 slots, 2 poles, steps from +5 to −5 turns
pat1 = WindingPattern.custom(12, 2, [Coil(0, 0, "full", 6, "full", 10)], m=1, layout="single")
assert np.allclose(winding_function(pat1), [[-5] * 6 + [5] * 6])
# its fundamental is 4/π of the 5-turn square wave, split over e^{jθ} and e^{-jθ}
assert np.isclose(2 * abs(winding_function_harmonics(pat1, 1)[0]), 4 / np.pi * 5, rtol=2e-2)
```

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

## Effective air gap and `airgap_inductance`

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

### airgap_inductance

``` python
def airgap_inductance(
    pattern:WindingPattern, stator:StatorGeometry,
    part:str='total', # or 'harmonic' (all other harmonics: differential leakage)
    g_eff:float | None=None, # For a surface-PM rotor use k_C (g + h_m / μr).
)->np.ndarray:
```

*Air-gap inductance matrix of the phases \[H\].*

## Parameters

pattern : WindingPattern Winding (its Q must match the stator) stator :
StatorGeometry Bore, gap, stack and slot opening part : str ‘total’
(default), ‘magnetising’ (harmonic ν = p only) or ‘harmonic’ (all other
harmonics: differential leakage) g_eff : float | None Effective gap
\[m\]; None -\> Carter-corrected k_C·g. For a surface-PM rotor use k_C
(g + h_m / μr).

## Returns

np.ndarray, shape (m, m) L\[x, y\], symmetric

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

### effective_air_gap

``` python
def effective_air_gap(
    stator:StatorGeometry, g_eff:float | None=None
)->float:
```

*g_eff if given, else k_C · g.*

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

### carter_coefficient

``` python
def carter_coefficient(
    stator:StatorGeometry
)->float:
```

*Carter coefficient of the stator slot openings (opening b0, slot pitch
at the bore).*

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

## `phase_imbalance`

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

### phase_imbalance

``` python
def phase_imbalance(
    L:np.ndarray
)->dict: # self_spread        : float   (max − min) / mean of the self inductances
mutual_spread      : float   Largest (max − min) among the mutuals k phases apart,
                             relative to the mean self inductance
sequence_coupling  : float   Largest off-diagonal |L_seq| / |L_seq[1, 1]|
L_positive         : float   Positive-sequence (synchronous) inductance, Re L_seq[1, 1]
L_seq              : np.ndarray   F L F^H with the unitary DFT matrix F
```

*How far a phase inductance matrix is from that of a balanced winding.*

## Parameters

L : np.ndarray, shape (m, m) Phase inductance matrix

## Returns

dict with keys: self_spread : float (max − min) / mean of the self
inductances mutual_spread : float Largest (max − min) among the mutuals
k phases apart, relative to the mean self inductance sequence_coupling :
float Largest off-diagonal |L_seq| / |L_seq\[1, 1\]| L_positive : float
Positive-sequence (synchronous) inductance, Re L_seq\[1, 1\] L_seq :
np.ndarray F L F^H with the unitary DFT matrix F

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

## Examples

The 36-slot stator from the geometry notebook with a short-pitched
double-layer winding, 10 turns per coil, 2 parallel paths:

``` 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)
L = airgap_inductance(pat, stator)
Lm = airgap_inductance(pat, stator, "magnetising")
Lh = airgap_inductance(pat, stator, "harmonic")
print(f"Carter k_C = {carter_coefficient(stator):.4f}, g_e = {effective_air_gap(stator) * 1e3:.4f} mm")
print(f"L_aa = {L[0, 0] * 1e3:.4f} mH, L_ab = {L[0, 1] * 1e3:.4f} mH")
print(f"positive sequence: magnetising {phase_imbalance(Lm)['L_positive'] * 1e3:.4f} mH "
      f"+ harmonic leakage {phase_imbalance(Lh)['L_positive'] * 1e3:.4f} mH")
assert np.allclose(L, Lm + Lh) and np.allclose(L, L.T)
```

    Carter k_C = 1.1011, g_e = 0.8809 mm
    L_aa = 8.1617 mH, L_ab = -3.8582 mH
    positive sequence: magnetising 11.8880 mH + harmonic leakage 0.1318 mH

The winding function of phase A under its slot diagram, with the
fundamental that gives the magnetising part:

``` python
fig, axes = plt.subplots(2, 1, figsize=(10, 5), gridspec_kw=dict(height_ratios=[1, 1.3]))
pat.plot(ax=axes[0])
W = winding_function(pat)[0]
x = np.arange(pat.Q + 1)
axes[1].step(x + 0.4, np.append(W, W[0]), where="post", color="C0", label="W_A (step, per tooth)")
th = np.linspace(0, 2 * np.pi, 721)
a = winding_function_harmonics(pat, pat.p)[0]
axes[1].plot(th * pat.Q / (2 * np.pi) + 0.4, 2 * np.real(a * np.exp(1j * pat.p * th)), "k--", lw=1,
             label=f"fundamental ν = p = {pat.p}")
axes[1].set_xlim(-0.3, pat.Q + 0.1); axes[1].set_xlabel("slot"); axes[1].set_ylabel("turns per A of phase current")
axes[1].legend(fontsize=8); axes[1].grid(alpha=0.3)
plt.tight_layout()
```

![](03_airgap_files/figure-commonmark/cell-10-output-1.png)

A hand-made winding that is **not** balanced: the same table as a
balanced 12-slot, 2-pole double layer, but with one phase-A coil side
moved into the neighbouring slot. The report shows the imbalance, and
the air gap alone already sees it:

``` python
table = np.array([[1, 1, -3, -3, 2, 2, -1, -1, 3, 3, -2, -2],
                  [1, -3, -3, 2, 2, -1, -1, 3, 3, -2, -2, 1]])
st12 = StatorGeometry(Q=12, r_bore=40e-3, g=0.6e-3, l_stk=60e-3, h_y=10e-3, slot=SlotGeometry.open(8e-3, 15e-3))
ok = WindingPattern.from_slot_table(table, P=2, turns=20)
bad_table = table.copy(); bad_table[1, 0], bad_table[1, 1] = bad_table[1, 1], bad_table[1, 0]   # swap A and −C in the bottom layer
bad = WindingPattern.from_slot_table(bad_table, P=2, turns=20)
for name, p in [("balanced", ok), ("one side moved", bad)]:
    r = phase_imbalance(airgap_inductance(p, st12))
    print(f"{name:15s} self spread {100 * r['self_spread']:6.3f} %, mutual spread {100 * r['mutual_spread']:6.3f} %, "
          f"sequence coupling {100 * r['sequence_coupling']:6.3f} %")
assert phase_imbalance(airgap_inductance(ok, st12))["sequence_coupling"] < 1e-12
assert phase_imbalance(airgap_inductance(bad, st12))["sequence_coupling"] > 0.01
```

    balanced        self spread  0.000 %, mutual spread  0.000 %, sequence coupling  0.000 %
    one side moved  self spread  8.909 %, mutual spread 11.798 %, sequence coupling  4.273 %

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

## Validation

1.  **Magnetising inductance against the closed form.** For any balanced
    winding the working-harmonic self inductance is
    $L_m = \dfrac{4}{\pi}\\\dfrac{\mu_0 r_g l\_{stk}}{g_e}\left(\dfrac{k\_{w1} N_s}{p}\right)^2$,
    with mutuals *L*<sub>*m*</sub>cos (2*π**k*/*m*), so
    −*L*<sub>*m*</sub>/2 for three phases (Krause, Wasynczuk & Sudhoff;
    Pyrhönen et al.). Here *k*<sub>*w*1</sub> and *N*<sub>*s*</sub> come
    from the star-of-slots phasors (`WindingPattern.winding_factor`,
    `series_turns`), an independent route from the winding function.
2.  **Air-gap harmonic leakage of full-pitch integer-slot windings.**
    For three phases,
    $\sigma\_\delta = L\_{pos}/L\_{pos,1} - 1 = \dfrac{\pi^2 (5q^2 + 1)}{54\\ q^2 k\_{w1}^2} - 1$,
    which gives the classical tabulated values 0.0966, 0.0284, 0.0141,
    0.0089 for q = 1 … 4 (Richter; Pyrhönen et al.).
3.  **Parseval.** The harmonic sum converges to the direct integral.

``` python
# 1. magnetising inductance = closed form, for distributed, fractional-slot and tooth-coil windings
cases = [(36, 4, dict(kind="distributed", pitch=7)), (24, 4, dict(kind="distributed", pitch=6)),
         (24, 4, dict(kind="distributed", layers=1)), (36, 8, dict(kind="sos")), (12, 10, dict(kind="concentrated")),
         (12, 10, dict(kind="concentrated", all_teeth=False)), (9, 8, dict(kind="concentrated", layout="over_under"))]
for Q, P, kw in cases:
    kind = kw.pop("kind")
    p_ = {"distributed": WindingPattern.distributed, "sos": WindingPattern.from_star_of_slots,
          "concentrated": WindingPattern.concentrated}[kind](Q, P, turns=7, **kw)
    st = StatorGeometry(Q=Q, r_bore=55e-3, g=0.7e-3, l_stk=80e-3, h_y=10e-3, slot=SlotGeometry.open(3e-3, 15e-3))
    Lm_ = airgap_inductance(p_, st, "magnetising")
    k = MU0 * (st.r_bore - st.g / 2) * st.l_stk / effective_air_gap(st)
    closed = 4 / np.pi * k * (p_.winding_factor()[0] * p_.series_turns()[0] / p_.p) ** 2
    assert np.allclose(np.diag(Lm_), closed, rtol=1e-10), (Q, P, kind)
    assert np.allclose(Lm_[0, 1], closed * np.cos(2 * np.pi / 3), rtol=1e-10), (Q, P, kind)
    print(f"{Q:2d}s/{P:2d}p {kind:12s}: L_m = {closed * 1e3:8.4f} mH (closed form) — matched")

# 2. differential leakage of full-pitch integer-slot windings
for q, tab in zip(range(1, 6), [0.0966, 0.0284, 0.0141, 0.0089, 0.0065]):
    p_ = WindingPattern.distributed(6 * q, 2)
    st = StatorGeometry(Q=6 * q, r_bore=55e-3, g=0.7e-3, l_stk=80e-3, h_y=10e-3, slot=SlotGeometry.open(2e-3, 15e-3))
    sigma = phase_imbalance(airgap_inductance(p_, st))["L_positive"] / phase_imbalance(airgap_inductance(p_, st, "magnetising"))["L_positive"] - 1
    closed = np.pi ** 2 * (5 * q ** 2 + 1) / (54 * q ** 2 * p_.winding_factor()[0] ** 2) - 1
    assert np.isclose(sigma, closed, rtol=1e-9) and np.isclose(sigma, tab, atol=5e-5), (q, sigma)
    print(f"q = {q}: σ_δ = {sigma:.4f} (tabulated {tab})")
```

    36s/ 4p distributed : L_m =  12.2710 mH (closed form) — matched
    24s/ 4p distributed : L_m =   6.6069 mH (closed form) — matched
    24s/ 4p distributed : L_m =   1.6517 mH (closed form) — matched
    36s/ 8p sos         : L_m =   3.3694 mH (closed form) — matched
    12s/10p concentrated: L_m =   0.2597 mH (closed form) — matched
    12s/10p concentrated: L_m =   0.0696 mH (closed form) — matched
     9s/ 8p concentrated: L_m =   0.2372 mH (closed form) — matched
    q = 1: σ_δ = 0.0966 (tabulated 0.0966)
    q = 2: σ_δ = 0.0284 (tabulated 0.0284)
    q = 3: σ_δ = 0.0141 (tabulated 0.0141)
    q = 4: σ_δ = 0.0089 (tabulated 0.0089)
    q = 5: σ_δ = 0.0065 (tabulated 0.0065)

Tooth-coil windings carry far more harmonic leakage than distributed
ones, which is why their synchronous inductance is high:

``` python
for Q, P in [(12, 10), (9, 8), (12, 8), (24, 22)]:
    p_ = WindingPattern.concentrated(Q, P)
    st = StatorGeometry(Q=Q, r_bore=55e-3, g=0.7e-3, l_stk=80e-3, h_y=10e-3, slot=SlotGeometry.open(3e-3, 15e-3))
    s = phase_imbalance(airgap_inductance(p_, st))["L_positive"] / phase_imbalance(airgap_inductance(p_, st, "magnetising"))["L_positive"] - 1
    print(f"{Q}s/{P}p all teeth: σ_δ = {s:.3f}")
```

    12s/10p all teeth: σ_δ = 0.968
    9s/8p all teeth: σ_δ = 1.182
    12s/8p all teeth: σ_δ = 0.462
    24s/22p all teeth: σ_δ = 1.300

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

## Tests

## References

- Sudhoff, S.D. *Power Magnetic Devices* (2nd ed.), §8.1–8.5, and
  [*Distributed Windings and Rotating
  Fields*](https://engineering.purdue.edu/~sudhoff/ee595s/TADES-chapter4.pdf),
  Purdue notes, §4.3–4.6 — discrete winding function, air-gap
  inductance.
- Krause, P.C., Wasynczuk, O., Sudhoff, S.D., Pekarek, S. (2013).
  *Analysis of Electric Machinery and Drive Systems* (3rd ed.).
  Wiley-IEEE Press — magnetising inductance of sinusoidally distributed
  windings.
- Pyrhönen, J., Jokinen, T., Hrabovcová, V. (2014). *Design of Rotating
  Electrical Machines* (2nd ed.). Wiley — Carter factor, air-gap
  (harmonic) leakage factor σ_δ.
- Scuiller, F., Semail, E., Charpentier, J.-F. (2010). [General modeling
  of the windings for multi-phase ac
  machines](https://www.epjap.org/articles/epjap/pdf/2010/06/ap09444.pdf).
  *Eur. Phys. J. Appl. Phys.* 50:31102 — air-gap inductance matrix as a
  product of sampled winding functions.
