Skip to main content

MMF Analysis of AC Windings

Executive Summary

This notebook computes the magnetomotive force (MMF) waveform and harmonic spectrum produced by an AC stator winding.

Why It Matters

The spatial shape of the airgap MMF directly determines: - Torque production — the working harmonic (ν = p) drives the fundamental torque. - Torque ripple — sub- and super-harmonics create pulsating torque components. - Rotor losses — higher-order harmonics induce eddy currents in the rotor magnets and back-iron, causing heating and efficiency loss. - Acoustic noise — MMF harmonics that coincide with structural resonances generate audible noise.

Designers use the MMF spectrum to compare winding configurations, choose slot/pole combinations, and decide between single- and double-layer layouts before running finite-element analysis.

How It Fits Into Motor Design

emachines workflow:

  01_winding.ipynb
  (winding factors, star-of-slots)
        │
        ▼
  01_winding_mmf.ipynb   ←── YOU ARE HERE
  (MMF waveform & spectrum)
        │
        ▼
  02_pmsm.ipynb          (torque, back-EMF via kw and MMF)
  04_mec_solver.ipynb    (flux linkage in magnetic circuit)

Depends on: 01_winding.ipynb — uses build_coil_matrix, get_valid_coil_spans from emachines.winding.sos.

Feeds into: 02_pmsm.ipynb, 04_mec_solver.ipynb.

What You Provide (Inputs)

Parameter Symbol Description Units Typical Range
Stator slots Q Total number of stator slots — 6 – 72
Poles P Number of poles (even) — 2 – 20
Phases m Number of phases — 3 (three-phase)
Layers layers Single- or double-layer winding — 1 or 2
Coil span w Span of each coil in slots slots 1 – Q/p
Time angle θ_e Electrical time angle rad 0 – 2π
Mode mode "three_phase", "single_phase", "winding_factor" — —
Max harmonic nu_max Highest spatial harmonic to evaluate — 20 – 50

What You Get (Outputs)

Result Symbol Meaning
Conductor distribution n[i] Signed A·turns per slot at angle θ_e
MMF waveform F(θ) Staircase MMF along the airgap
Winding factor spectrum kw(ν)
MMF harmonic amplitudes F̂(ν) kw(ν)·p/ν, balanced 3-phase cancellation applied

Quick Example

from emachines.winding.mmf import mmf_waveform, mmf_harmonics

# 12-slot / 10-pole double-layer FSCW at θ_e = 0
angles, F = mmf_waveform(12, 10, layers=2)

# Three-phase MMF harmonic spectrum, normalised
nu, amp = mmf_harmonics(12, 10, layers=2)

Abbreviations and Notation

Symbol Definition Units
Q Number of stator slots —
P Number of poles —
p Pole pairs, p = P/2 —
m Number of phases —
ν Mechanical spatial harmonic order —
w Coil span in slots slots
θ_e Electrical time angle rad
n_i Signed ampere-conductor value at slot i A·turns (pu)
F(θ) MMF waveform along the airgap A·turns (pu)
kw(ν) Winding factor magnitude at harmonic ν —
F̂(ν) MMF harmonic amplitude = kw(ν)·p/ν A·turns (pu)
t Winding periodicity = gcd(Q, p) —

Imports and Setup

Background: MMF in AC Windings

When alternating current flows through a stator winding, each conductor contributes a localised magnetomotive force proportional to the current it carries and its winding direction. Summing these contributions around the airgap circumference via Ampere’s law yields the MMF waveform F(θ).

For a sinusoidal balanced three-phase supply: \[ i_k(\theta_e) = \hat{I}\cos\!\left(\theta_e - \frac{2\pi k}{m}\right),\quad k = 0,1,\ldots,m-1 \]

The MMF waveform is computed in three steps:

  1. Slot assignment — build_coil_matrix maps each slot conductor to a phase and current direction.
  2. Ampere-conductor distribution — multiply signed conductor occupancy by instantaneous phase currents to get n[i] at each slot.
  3. Cumulative sum — integrate n[i] around the circumference (Ampere’s law) and remove the DC offset.

The resulting staircase is then decomposed by spatial Fourier analysis into its harmonic spectrum.


mmf_distribution: Ampere-Conductor Distribution

Theory

The ampere-conductor distribution n(θ) is a step function that equals the net signed conductor current at each slot position:

\[ n_i = \sum_{\text{layer}} \operatorname{sign}(\text{code}_{i,\text{layer}}) \cdot i_{\,|\text{code}|-1}(\theta_e) \]

where code is the signed conductor occupancy from build_coil_matrix (+k = phase k forward, −k = phase k return), and \(i_k(\theta_e)\) is the instantaneous current of phase k.

Physical meaning: n(θ) is the “source density” of MMF. The MMF itself is its spatial running integral (cumulative sum around the bore).

Design insight: The distribution of conductors across slots determines which spatial harmonics are present and how strongly. Distributed windings spread conductors to suppress low-order harmonics; concentrated windings concentrate them for high torque density at the cost of richer harmonic content.

References: Pyrhönen et al. (2014), §2.4; Müller, Vogt & Ponick (2008), §3.4.

mmf_distribution: Implementation


mmf_distribution

def mmf_distribution(
    Q:int, P:int, m:int=3, layers:int | None=None, # None → the best buildable, balanced candidate.
    w:int | None=None, # Coil span in slots. ``None`` → coil span that
    # maximises the fundamental winding factor.
    theta_electrical:float=0.0
)->np.ndarray: # Signed ampere-conductor value at each slot. Per-unit (peak = 1 A·turn).

Instantaneous signed ampere-conductor distribution along the airgap.

For each slot position i (mechanical angle θᵢ = 2π·i/Q), n[i] is the sum of signed conductor currents across all winding layers:

.. math:: n_i = {} ({i,}) i_{,||-1}(_e)

Parameters

Q : int Number of stator slots P : int Number of poles (even, ≥ 2) m : int Number of phases (default 3) layers : int | None 1 (single-layer) or 2 (double-layer). None → the best buildable, balanced candidate. w : int | None Coil span in slots. None → coil span that maximises the fundamental winding factor. theta_electrical : float Electrical time angle (radians, default 0).

Returns

np.ndarray, shape (Q,), dtype float64 Signed ampere-conductor value at each slot. Per-unit (peak = 1 A·turn).

import math
from emachines.winding.mmf import mmf_distribution, mmf_waveform, mmf_harmonics

# Examples
n = mmf_distribution(12, 10, layers=2)
assert n.shape == (12,)
assert abs(n.sum()) < 1e-10            # Ampère: ampere-conductors sum to zero around the bore

mmf_distribution: Example

from emachines.winding.mmf import mmf_distribution
import numpy as np

# 12s/10p double-layer FSCW at θ_e = 0  (phase A at positive peak)
n = mmf_distribution(12, 10, layers=2, theta_electrical=0.0)

print("12-slot / 10-pole double-layer FSCW, θ_e = 0°")
print(f"Slot conductors: {np.round(n, 4)}")
print(f"Sum (should be ≈ 0): {n.sum():.2e}")
print()
print("Interpretation: positive = net A·turns in forward direction,")
print("                negative = net A·turns in return direction.")
12-slot / 10-pole double-layer FSCW, θ_e = 0°
Slot conductors: [ 2.  -1.5  1.   0.  -1.   1.5 -2.   1.5 -1.  -0.   1.  -1.5]
Sum (should be ≈ 0): 0.00e+00

Interpretation: positive = net A·turns in forward direction,
                negative = net A·turns in return direction.

mmf_waveform: MMF Staircase

Theory

The MMF waveform is obtained by applying Ampere’s law around the stator bore. Integrating the ampere-conductor distribution n(θ) in the positive θ direction gives:

\[ F(\theta_i) = \sum_{j=0}^{i-1} n_j - \overline{F} \]

where \(\overline{F}\) is the spatial mean, subtracted to enforce zero net MMF around the closed path (no DC offset).

The result is a staircase waveform — constant between slots, stepping at each slot opening. In the limit of many slots (large Q) it approaches a sinusoid; for concentrated windings with few slots per phase it is highly non-sinusoidal.

Design insight: The ratio of fundamental amplitude to harmonic content directly determines torque quality. A near-sinusoidal MMF (many slots, distributed winding) gives low ripple; a square-wave MMF (concentrated winding) is rich in harmonics but simpler to manufacture.

References: Pyrhönen et al. (2014), §2.4, eq. (2.73); Müller, Vogt & Ponick (2008), §3.4.

mmf_waveform: Implementation


mmf_waveform

def mmf_waveform(
    Q:int, P:int, m:int=3, layers:int | None=None, w:int | None=None, theta_electrical:float=0.0
)->tuple[np.ndarray, np.ndarray]: # Mechanical angles in degrees, 0° … 360° inclusive.

Instantaneous MMF staircase waveform along the airgap.

Applies Ampere’s law around the stator bore: the MMF at mechanical angle θ equals the cumulative sum of ampere-conductors from slot 0 up to the slot preceding θ, with the DC offset removed.

.. math:: F(i) = {j=0}^{i-1} n_j -

The staircase is returned closed (first point repeated at 360°) for direct use in step-line plots.

Parameters

Q : int P : int m : int (default 3) layers : int | None 1 or 2. None → the best candidate. w : int | None theta_electrical : float Electrical time angle (radians, default 0)

Returns

angles : np.ndarray, shape (Q + 1,) Mechanical angles in degrees, 0° … 360° inclusive. F : np.ndarray, shape (Q + 1,) Per-unit MMF at each slot boundary (closed staircase).

# Examples
angles, F = mmf_waveform(12, 10, layers=2)
assert angles.shape == F.shape == (13,)   # closed staircase: 0° repeated at 360°
assert abs(F[:-1].mean()) < 1e-10         # zero mean over the Q slot boundaries (repeat excluded)

mmf_waveform: Example — Effect of Electrical Time Angle

from emachines.winding.mmf import mmf_waveform
import numpy as np

print("MMF waveform at three electrical time angles")
print("12-slot / 10-pole double-layer FSCW")
print()

for theta_deg in [0, 30, 90]:
    angles, F = mmf_waveform(12, 10, layers=2,
                              theta_electrical=np.radians(theta_deg))
    print(f"  θ_e = {theta_deg:3d}°  |  peak MMF = {np.max(np.abs(F[:-1])):.4f} pu")

print()
print("Observation: the peak MMF is the same at all time angles (rotating wave).")
MMF waveform at three electrical time angles
12-slot / 10-pole double-layer FSCW

  θ_e =   0°  |  peak MMF = 1.0000 pu
  θ_e =  30°  |  peak MMF = 0.8660 pu
  θ_e =  90°  |  peak MMF = 0.8660 pu

Observation: the peak MMF is the same at all time angles (rotating wave).

winding_factor_spectrum: Winding Factor vs. Harmonic Order

Theory

The winding factor for mechanical harmonic ν is the ratio of the actual phasor sum of conductor voltages to the arithmetic sum (i.e. the ideal case where all conductors are in one slot):

\[ k_{w\nu} = \frac{1}{m} \sum_{k=0}^{m-1} \frac{\left|\displaystyle\sum_{i,\,\text{lyr}} s_{i,\text{lyr}} \cdot e^{j\,\nu\,\frac{2\pi i}{Q}}\right|}{N_k} \]

where the inner sum runs over all conductors (across all layers) of phase k, \(s_{i,\text{lyr}} \in \{+1,-1\}\) is the conductor direction, and \(N_k\) is the total conductor count for phase k.

Mechanical vs. electrical harmonics: ν is the mechanical harmonic order — the number of complete cycles of the waveform around the full 360° mechanical circumference. The working harmonic (the one that produces torque with P poles) is at ν = p = P/2.

Design insight: Harmonics with high kw(ν) are efficiently produced. For a PMSM, harmonics other than ν = p are parasitic — they store reactive energy and cause rotor losses. A good winding has kw(p) ≈ 0.9–1.0 and kw(ν) ≈ 0 for all other significant ν.

References: Bianchi & Bolognani (2002); Müller, Vogt & Ponick (2008), eq. (3.65).

winding_factor_spectrum: Implementation

# winding_factor_spectrum is defined in emachines.winding.winding_factors
# and imported into this module via the setup cell above.
# It is re-exported from emachines.winding for convenience.
from emachines.winding.winding_factors import winding_factor_spectrum  # noqa: F401

winding_factor_spectrum: Example — Integer-slot vs. FSCW

from emachines.winding.mmf import winding_factor_spectrum
import numpy as np

configs = [
    dict(Q=24, P=4,  layers=2, label="24s/4p  integer-slot (q=2)"),
    dict(Q=12, P=10, layers=2, label="12s/10p FSCW (q=2/5)"),
    dict(Q=9,  P=8,  layers=2, label="9s/8p   FSCW (q=3/8)"),
]

print(f"{'Harmonic ν':>12}", end="")
for cfg in configs:
    print(f"  {cfg['label']:>28}", end="")
print()
print("-" * 95)

nu_max = 15
nu_arr = None
results = []
for cfg in configs:
    nu_arr, kw = winding_factor_spectrum(cfg["Q"], cfg["P"], layers=cfg["layers"], nu_max=nu_max)
    results.append((cfg, kw))

for i, nu_i in enumerate(nu_arr):
    print(f"  ν = {int(nu_i):>3}     ", end="")
    for cfg_j, kw_j in results:
        val = kw_j[i]
        marker = " ←working" if nu_i == cfg_j["P"] // 2 else ""
        print(f"  {'':>12}kw = {val:.4f}{marker}", end="")
    print()
  Harmonic ν    24s/4p  integer-slot (q=2)          12s/10p FSCW (q=2/5)          9s/8p   FSCW (q=3/8)
-----------------------------------------------------------------------------------------------
  ν =   1                   kw = 0.0000              kw = 0.0670              kw = 0.0607
  ν =   2                   kw = 0.9659 ←working              kw = 0.0000              kw = 0.1398
  ν =   3                   kw = 0.0000              kw = 0.5000              kw = 0.5774
  ν =   4                   kw = 0.0000              kw = 0.0000              kw = 0.9452 ←working
  ν =   5                   kw = 0.0000              kw = 0.9330 ←working              kw = 0.9452
  ν =   6                   kw = 0.7071              kw = 0.0000              kw = 0.5774
  ν =   7                   kw = 0.0000              kw = 0.9330              kw = 0.1398
  ν =   8                   kw = 0.0000              kw = 0.0000              kw = 0.0607
  ν =   9                   kw = 0.0000              kw = 0.5000              kw = 0.0000
  ν =  10                   kw = 0.2588              kw = 0.0000              kw = 0.0607
  ν =  11                   kw = 0.0000              kw = 0.0670              kw = 0.1398
  ν =  12                   kw = 0.0000              kw = 0.0000              kw = 0.5774
  ν =  13                   kw = 0.0000              kw = 0.0670              kw = 0.9452
  ν =  14                   kw = 0.2588              kw = 0.0000              kw = 0.9452
  ν =  15                   kw = 0.0000              kw = 0.5000              kw = 0.5774

mmf_harmonics: MMF Harmonic Amplitude Spectrum

Theory

The Fourier decomposition of the airgap MMF gives amplitude coefficients for each spatial harmonic ν. For a winding with winding factor kw(ν) and p pole pairs, the analytical result is:

\[ \hat{F}_\nu = \frac{k_{w\nu} \cdot p}{\nu} \]

The factor \(p/\nu\) arises because the MMF is the spatial integral of the conductor distribution: integrating \(\cos(\nu x)\) yields \(\sin(\nu x)/\nu\), and multiplying by p normalises the working harmonic (ν = p) to kw₁.

Three-phase cancellation: In a balanced m-phase winding, certain harmonics cancel completely. For m = 3, harmonics where ν is a non-working multiple of 3 vanish in the balanced sum. However, the simple rule “ν % m == 0 → cancel” fails when p itself is divisible by m (e.g. 9s/6p where p = 3). This implementation detects cancellation numerically by computing the complex m-phase phasor sum at each ν and checking whether both the forward- and backward-rotating components vanish.

Mode options: - "three_phase" — balanced m-phase MMF; zero-sequence harmonics cancelled (default, matches the website tool). - "single_phase" — single-phase MMF; all harmonics retained. - "winding_factor" — returns |kw(ν)| directly without the 1/ν weighting.

References: Pyrhönen et al. (2014), §2.4, eq. (2.98); Müller, Vogt & Ponick (2008), eq. (3.65).

mmf_harmonics: Implementation


mmf_harmonics

def mmf_harmonics(
    Q:int, P:int, m:int=3, layers:int | None=None, w:int | None=None,
    mode:str='three_phase', # ``"three_phase"``    — balanced m-phase MMF; zero-sequence harmonics
    #                        cancelled numerically (default).
    # ``"single_phase"``   — single-phase MMF; all harmonics retained.
    # ``"winding_factor"`` — returns |kw(ν)| with no 1/ν weighting.
    nu_max:int=40, normalize:bool=True, # ``True``  (default) — divide by the working-harmonic amplitude
    #                       so the working harmonic = 1.0.
    # ``False`` — return raw kw(ν)·p/ν values.
)->tuple[np.ndarray, np.ndarray]: # Mechanical harmonic orders 1 … nu_max.

MMF harmonic amplitude spectrum.

The amplitude of spatial harmonic ν in the airgap MMF:

.. math:: _=

For mode="three_phase" harmonics cancelled by the balanced m-phase current sum are identified numerically and zeroed out.

Parameters

Q : int P : int m : int Number of phases (default 3) layers : int | None 1 or 2. None → the best candidate. w : int | None mode : str "three_phase" — balanced m-phase MMF; zero-sequence harmonics cancelled numerically (default). "single_phase" — single-phase MMF; all harmonics retained. "winding_factor" — returns |kw(ν)| with no 1/ν weighting. nu_max : int Maximum harmonic order (default 40) normalize : bool True (default) — divide by the working-harmonic amplitude so the working harmonic = 1.0. False — return raw kw(ν)·p/ν values.

Returns

nu_arr : np.ndarray, shape (nu_max,), dtype int Mechanical harmonic orders 1 … nu_max. amp : np.ndarray, shape (nu_max,), dtype float64 Harmonic amplitudes.

References

Pyrhönen et al. (2014), §2.4, eq. (2.98). Müller, Vogt & Ponick (2008), eq. (3.65).

# Examples
nu, amp = mmf_harmonics(12, 10, layers=2, normalize=True)
assert math.isclose(amp[4], 1.0)          # working harmonic ν = 5 normalised to 1
nu, amp = mmf_harmonics(12, 10, layers=2, mode="single_phase", normalize=False)
assert amp[4] > 0

mmf_harmonics: Example — Single-layer vs. Double-layer

from emachines.winding.mmf import mmf_harmonics
import numpy as np

print("Three-phase MMF spectrum: 12s/10p FSCW")
print("Normalised to working harmonic (ν = 5)")
print()
print(f"{'ν':>4}  {'Single-layer':>14}  {'Double-layer':>14}")
print("-" * 38)

nu1, amp1 = mmf_harmonics(12, 10, layers=1, mode="three_phase", normalize=True)
nu2, amp2 = mmf_harmonics(12, 10, layers=2, mode="three_phase", normalize=True)

for i in range(min(20, len(nu1))):
    if amp1[i] > 1e-4 or amp2[i] > 1e-4:
        marker = " ← working" if nu1[i] == 5 else ""
        print(f"  {int(nu1[i]):>2}  {amp1[i]:>14.4f}  {amp2[i]:>14.4f}{marker}")

print()
print("Observation: double-layer significantly suppresses sub-harmonics.")
Three-phase MMF spectrum: 12s/10p FSCW
Normalised to working harmonic (ν = 5)

   ν    Single-layer    Double-layer
--------------------------------------
   1          1.3397          0.3590
   5          1.0000          1.0000 ← working
   7          0.7143          0.7143
  11          0.1218          0.0326
  13          0.1031          0.0276
  17          0.2941          0.2941
  19          0.2632          0.2632

Observation: double-layer significantly suppresses sub-harmonics.

mmf_harmonics: Comprehensive comparison — Integer-slot vs. FSCW

from emachines.winding.mmf import mmf_harmonics, winding_factor_spectrum
import numpy as np

configs = [
    dict(Q=24, P=4,  layers=2, label="24s/4p  integer-slot"),
    dict(Q=12, P=10, layers=2, label="12s/10p FSCW         "),
]

print("Three-phase MMF spectrum comparison (normalised, top harmonics only)")
print()

for cfg in configs:
    nu, amp = mmf_harmonics(cfg["Q"], cfg["P"], layers=cfg["layers"],
                             mode="three_phase", normalize=True)
    p = cfg["P"] // 2
    print(f"  {cfg['label']}  (working harmonic ν = {p})")
    significant = [(int(nu[i]), amp[i]) for i in range(len(nu)) if amp[i] > 0.01]
    significant.sort(key=lambda x: -x[1])
    for h, a in significant[:8]:
        marker = " ← working" if h == p else ""
        print(f"    ν = {h:>3}:  {a:.4f}{marker}")
    print()
Three-phase MMF spectrum comparison (normalised, top harmonics only)

  24s/4p  integer-slot  (working harmonic ν = 2)
    ν =   2:  1.0000 ← working
    ν =  22:  0.0909
    ν =  26:  0.0769
    ν =  10:  0.0536
    ν =  14:  0.0383
    ν =  34:  0.0158
    ν =  38:  0.0141

  12s/10p FSCW           (working harmonic ν = 5)
    ν =   5:  1.0000 ← working
    ν =   7:  0.7143
    ν =   1:  0.3590
    ν =  17:  0.2941
    ν =  19:  0.2632
    ν =  29:  0.1724
    ν =  31:  0.1613
    ν =  11:  0.0326

References

  1. Pyrhönen, J., Jokinen, T., & Hrabovcová, V. (2014). Design of Rotating Electrical Machines, 2nd ed. Wiley. §2.4, eq. (2.73), (2.98).
  2. Bianchi, N., & Bolognani, S. (2002). Design techniques for reducing cogging torque in surface-mounted PM motors. IEEE Transactions on Industry Applications, 38(5), 1259–1265. DOI: 10.1109/TIA.2002.802909
  3. Müller, G., Vogt, K., & Ponick, B. (2008). Berechnung elektrischer Maschinen. Wiley-VCH. §3.4–3.6, eq. (3.65).
  4. SWAT-EM open-source reference implementation: https://github.com/bayonet222/swat-em — accessed 2026-06-22.

Tests