# Total Stator Inductance and Winding Comparison


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

## Executive Summary

**Purpose:** put every part together. For one winding, this gives the
full phase inductance matrix and resistance, the synchronous and
zero-sequence values, and the imbalance. For several candidate windings
on the same stator, it gives a side-by-side table.

**What it does:** `stator_inductances(pattern, stator, end, ...)`
returns a `StatorInductances`. It holds the magnetising, harmonic, slot,
tooth-tip and end-winding matrices, with `total`, `leakage`,
`positive()`, `zero()`, `imbalance()` and `summary()`.
`compare_windings(patterns, stator, end, ...)` puts the key numbers of
each winding in one table.

**Background:** what each part is and what a measurement contains:
[Inductance Theory](inductance_theory.html).

**Assumptions:** those of the parts: linear iron, a smooth rotor, a 1-D
slot field and an empirical end-winding factor.

## How It Fits Into the Motor Design Workflow

**Upstream:** [Air-Gap Inductance](inductance_airgap.html), [Slot and
Tooth-Tip Leakage](inductance_slot.html), [End Turns, Phase Resistance
and End-Winding Leakage](inductance_end_winding.html).

**Downstream:** motor models
(*L*<sub>*s*</sub> = *L*<sub>*d*</sub> = *L*<sub>*q*</sub> for a smooth
rotor, *R*<sub>*s*</sub>), winding selection, and the saturated MEC
model planned next.

## Theory

The total phase matrix is the sum of the parts, each computed with the
same turns per slot position:

$$\mathbf{L} = \underbrace{\mathbf{L}\_m + \mathbf{L}\_\delta}\_{\text{air gap}} + \mathbf{L}\_{slot} + \mathbf{L}\_{tt} + \mathbf{L}\_{ew}, \qquad \mathbf{L}\_\sigma = \mathbf{L} - \mathbf{L}\_m.$$

For each part, `positive(part)` gives the positive-sequence
(synchronous) value *L*<sub>*a**a*</sub> − *L*<sub>*a**b*</sub> (exactly
so for a balanced 3-phase winding), and `zero(part)` the zero-sequence
value $\tfrac1m \sum\_{xy} L\_{xy}$. `imbalance()` is `phase_imbalance`
of the total, plus the resistance spread.

<figure>
<img src="images/winding_comparison.svg"
alt="Stacked bars of the positive-sequence inductance of four windings on the same 48-slot stator, split into magnetising, harmonic, slot, tooth-tip and end-winding parts, with the self-inductance and resistance spread of each written above its bar." />
<figcaption aria-hidden="true">Stacked bars of the positive-sequence
inductance of four windings on the same 48-slot stator, split into
magnetising, harmonic, slot, tooth-tip and end-winding parts, with the
self-inductance and resistance spread of each written above its
bar.</figcaption>
</figure>

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

### stator_inductances

``` python
def stator_inductances(
    pattern:WindingPattern, stator:StatorGeometry, end:EndTurn | None=None, g_eff:float | None=None,
    **resistance, # none given -> resistance is None
)->StatorInductances:
```

*All parts of the stator inductance of a winding on a stator, and
optionally its resistance.*

## Parameters

pattern, stator end : EndTurn | None End-turn shape; None -\> no end
winding and no resistance g_eff : float | None Effective air gap for the
air-gap part (see `airgap_inductance`) resistance : keyword arguments
for `phase_resistance` (a_cond or fill, T, …); none given -\> resistance
is None

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

### StatorInductances

``` python
def StatorInductances(
    magnetising:np.ndarray, harmonic:np.ndarray, slot:np.ndarray, tooth_tip:np.ndarray, end_winding:np.ndarray,
    resistance:np.ndarray | None=None, name:str=''
)->None:
```

*Every part of a winding’s stator inductance, as m × m phase matrices
\[H\], and its resistance.*

Build it with `stator_inductances`.

## Attributes

magnetising : np.ndarray Air gap, working harmonic ν = p harmonic :
np.ndarray Air gap, all other harmonics (differential leakage) slot :
np.ndarray Slot body, opening and tooth-tip transition tooth_tip :
np.ndarray Tooth-tip leakage at the gap end_winding : np.ndarray
End-winding leakage (empirical, diagonal) resistance : np.ndarray | None
DC resistance per phase \[Ω\], if computed name : str

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

### compare_windings

``` python
def compare_windings(
    patterns, stator:StatorGeometry, end:EndTurn | None=None, g_eff:float | None=None, **resistance
)->pd.DataFrame:
```

*Side-by-side table of candidate windings on the same stator.*

Columns: winding factor, series turns, positive-sequence magnetising,
leakage and total inductance \[mH\], harmonic leakage factor σ_δ, self
spread and sequence coupling of the total \[%\], `even fill` (every used
slot position holds the same number of turns, a quick check that a
hand-made winding can be built), and with resistance arguments the mean
resistance \[mΩ\] and its spread \[%\].

## Parameters

patterns : iterable of WindingPattern (their names label the rows)
stator, end, g_eff, resistance : as `stator_inductances`

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

## Examples

The 36-slot example, all parts:

``` 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)
s = stator_inductances(pat, stator, EndTurn(l_ext=12e-3), fill=0.42, T=120)
print(s.summary().round(3))
print(f"zero sequence {s.zero() * 1e3:.4f} mH, R = {np.round(s.resistance * 1e3, 2)} mΩ at 120 °C")
```

                 L_positive [mH]  share of total [%]
    magnetising           11.888              95.630
    harmonic               0.132               1.061
    slot                   0.228               1.833
    tooth_tip              0.032               0.258
    end_winding            0.152               1.219
    leakage                0.543               4.370
    total                 12.431             100.000
    zero sequence 0.7205 mH, R = [118.91 118.91 118.91] mΩ at 120 °C

### Comparing windings on one stator

Three windings on the 48-slot stator of the patent example, each with 48
series turns per phase: - the patent’s one-phase-per-layer winding; - a
conventional double layer, short-pitched 10/12; - a single layer.

The end turns are the same shape for all three, with 8 mm tiers for the
three-layer winding. Resistance is at 120 °C with fill 0.45. The table
shows what the layer arrangement costs in balance, and what the
conventional windings give in exchange (higher *k*<sub>*w*1</sub>, so
more magnetising inductance per turn).

``` 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
end = EndTurn(l_ext=12e-3, tier={"1": 16e-3, "2": 8e-3, "3": 0.0})
candidates = [ep2237392(),
              WindingPattern.distributed(48, 4, pitch=10, turns=3),
              WindingPattern.distributed(48, 4, layers=1, turns=6)]
table = compare_windings(candidates, ep_stator, end, fill=0.45, T=120)
table.round(3)
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">kw1</th>
<th data-quarto-table-cell-role="th">N_s</th>
<th data-quarto-table-cell-role="th">L_m [mH]</th>
<th data-quarto-table-cell-role="th">sigma_delta</th>
<th data-quarto-table-cell-role="th">L_leak [mH]</th>
<th data-quarto-table-cell-role="th">L_s [mH]</th>
<th data-quarto-table-cell-role="th">self spread [%]</th>
<th data-quarto-table-cell-role="th">seq coupling [%]</th>
<th data-quarto-table-cell-role="th">even fill</th>
<th data-quarto-table-cell-role="th">R [mΩ]</th>
<th data-quarto-table-cell-role="th">R spread [%]</th>
</tr>
<tr>
<th data-quarto-table-cell-role="th">winding</th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">EP2237392</td>
<td>0.638</td>
<td>48.0</td>
<td>7.877</td>
<td>0.009</td>
<td>0.266</td>
<td>8.143</td>
<td>1.782</td>
<td>0.494</td>
<td>True</td>
<td>67.181</td>
<td>7.41</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">distributed, q=4, double layer,
pitch 10/12</td>
<td>0.925</td>
<td>48.0</td>
<td>16.536</td>
<td>0.006</td>
<td>0.396</td>
<td>16.932</td>
<td>0.000</td>
<td>0.000</td>
<td>True</td>
<td>75.422</td>
<td>0.00</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">distributed, q=4, single layer</td>
<td>0.958</td>
<td>48.0</td>
<td>17.723</td>
<td>0.009</td>
<td>0.490</td>
<td>18.213</td>
<td>0.000</td>
<td>0.000</td>
<td>True</td>
<td>81.591</td>
<td>0.00</td>
</tr>
</tbody>
</table>

</div>

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

## Validation

The parts add up to the total, the positive-sequence value of the sum is
the sum of the parts’ values, and a balanced winding has zero spread and
coupling. For a 3-phase balanced winding,
*L*<sub>*s*</sub> = *L*<sub>*a**a*</sub> − *L*<sub>*a**b*</sub> and
*L*<sub>0</sub> = *L*<sub>*a**a*</sub> + 2*L*<sub>*a**b*</sub>.

``` python
L = s.total
assert np.allclose(L, airgap_inductance(pat, stator) + slot_leakage_inductance(pat, stator)
                   + end_winding_inductance(pat, stator, EndTurn(l_ext=12e-3)))
assert np.isclose(s.positive(), sum(s.positive(p) for p in ("magnetising", "harmonic", "slot", "tooth_tip", "end_winding")))
assert np.isclose(s.positive(), L[0, 0] - L[0, 1]) and np.isclose(s.zero(), L[0, 0] + 2 * L[0, 1])
imb = s.imbalance()
assert imb["self_spread"] < 1e-12 and imb["sequence_coupling"] < 1e-12 and imb["R_spread"] < 1e-12
print("parts add up; balanced winding has no spread")
```

    parts add up; balanced winding has no spread

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

## Tests

## References

- Pyrhönen, J., Jokinen, T., Hrabovcová, V. (2014). *Design of Rotating
  Electrical Machines* (2nd ed.). Wiley, ch. 4 — synchronous inductance
  as magnetising plus leakage.
- Krause, P.C., Wasynczuk, O., Sudhoff, S.D., Pekarek, S. (2013).
  *Analysis of Electric Machinery and Drive Systems* (3rd ed.).
  Wiley-IEEE Press — phase, sequence and dq inductances.
