---
title: "Magnetics lab: inductors, transformers and skin effect"
heading: Sizing an inductor by the core geometry constant, completing its turns, gap and wire, finding a transformer's loss-optimal flux density numerically, and estimating AC resistance from the skin depth
eyebrow: S11 · Lesson 27 · Magnetics lab
xp: 60
---

::: hook
Lessons 24 to 26 designed magnetics by hand, one constraint at a time. Design tools chain the same steps into code that can sweep through a catalog of cores in seconds: required Kg, then turns, gap, wire and loss for each candidate, then the transformer's flux density that balances core and copper loss, then a check that the wire isn't so thick that skin effect undoes the copper loss estimate. In this lab you'll write that chain and check it against the lessons' worked examples.
:::

::: play
- The curves are a transformer's core loss $kB_\text{ac}^\beta$, copper loss $c/B_\text{ac}^2$ and their total, for k = 20, c = 0.0004 and the Steinmetz exponent β on the slider.
- The total has a broad minimum where the copper loss is β/2 times the core loss: 0.094 T for β = 2.7.
- Because the minimum is flat, flux density can be chosen a little below it to leave margin for hot cores without much penalty.
:::

```sim plot
view: graph
x: B = 0.03..0.25
y: P = 0..0.3
slider: b = 2.2..3 = 2.7
plot: 20*B^b | label: core loss, W
plot: 0.0004/B^2 | label: copper loss, W
plot: 20*B^b + 0.0004/B^2 | dashed | label: total
```

::: predict
## An inductor's RMS current doubles while its peak stays the same. What happens to the required $K_g$?

- [ ] It doubles
- [x] It quadruples
- [ ] It stays the same
- [ ] It halves

::: reveal
$K_g \ge \rho L^2I_\text{max}^2I_\text{rms}^2/(B_\text{max}^2P_{cu}K_u)$ goes as the RMS current squared: four times. The turns and gap, set by the peak current, don't change, but the window must hold four times the copper cross-section for the same loss, or the loss quadruples in the same core.
:::
:::

::: nameit
## What the lab computes

- **Required core constant** (SI units, ρ = 1.724 × 10⁻⁸ Ω·m for copper):
$$K_g \ge \frac{\rho L^2I_\text{max}^2I_\text{rms}^2}{B_\text{max}^2P_{cu}K_u}$$
and a core's own $K_g = A_c^2W_A/\text{MLT}$, usually quoted in cm⁵ (1 m⁵ = 10¹⁰ cm⁵).
- **Completing the design** on a chosen core: $N = \lceil LI_\text{max}/(B_\text{max}A_c)\rceil$, gap $g = \mu_0LI_\text{max}^2/(B_\text{max}^2A_c)$, wire area $A_w = K_uW_A/N$, resistance $\rho N\,\text{MLT}/A_w$ and copper loss $I_\text{rms}^2R$.
- **Transformer optimum**: minimize $kB_\text{ac}^\beta + c/B_\text{ac}^2$; at the minimum, copper loss is β/2 times core loss.
- **Skin depth** $\delta = \sqrt{\rho/(\pi f\mu_0)}$, 0.209 mm at 100 kHz. A round wire of diameter d has $R_{ac}/R_{dc} \approx 1$ for $d \le 2\delta$, and about $d/4\delta + 1/4$ for $d \gg \delta$.
:::

::: check
kind: python

## Write `kg_required(L, Ipk, Irms, Bmax, Pcu, Ku)` returning cm⁵ (SI inputs), and `core_kg(Ac, WA, MLT)` from centimeter dimensions, returning cm⁵.

```python starter
def kg_required(L, Ipk, Irms, Bmax, Pcu, Ku):
    return 0.0

def core_kg(Ac, WA, MLT):
    return 0.0
```

```python solution
def kg_required(L, Ipk, Irms, Bmax, Pcu, Ku):
    rho = 1.724e-8
    return rho * L ** 2 * Ipk ** 2 * Irms ** 2 / (Bmax ** 2 * Pcu * Ku) * 1e10

def core_kg(Ac, WA, MLT):
    return Ac ** 2 * WA / MLT
```

```python tests
k = kg_required(47e-6, 8.5, 8, 0.25, 1, 0.5)
assert abs(k - 0.0563) < 0.0005, "Lesson 25's inductor: 0.056 cm⁵."
assert abs(kg_required(47e-6, 8.5, 16, 0.25, 1, 0.5) / k - 4) < 1e-9, "Doubling the RMS current quadruples it."
assert abs(core_kg(1, 1.5, 5) - 0.3) < 1e-12, "The chosen core: 0.3 cm⁵."
```

::: right
Right. A catalog sorted by $K_g$ turns core selection into a lookup.
:::
:::

::: check
kind: python

## Write `design(L, Ipk, Irms, Bmax, Ku, Ac_cm2, WA_cm2, MLT_cm)`: return (N, gap in mm, wire area in mm², resistance in mΩ, copper loss in W), with N rounded up.

```python starter
def design(L, Ipk, Irms, Bmax, Ku, Ac_cm2, WA_cm2, MLT_cm):
    return 1, 0.0, 0.0, 0.0, 0.0
```

```python solution
import math

def design(L, Ipk, Irms, Bmax, Ku, Ac_cm2, WA_cm2, MLT_cm):
    Ac = Ac_cm2 * 1e-4
    WA = WA_cm2 * 1e-4
    MLT = MLT_cm * 1e-2
    N = math.ceil(L * Ipk / (Bmax * Ac) - 1e-9)
    g = 4 * math.pi * 1e-7 * L * Ipk ** 2 / (Bmax ** 2 * Ac)
    Aw = Ku * WA / N
    R = 1.724e-8 * N * MLT / Aw
    return N, g * 1e3, Aw * 1e6, R * 1e3, Irms ** 2 * R
```

```python tests
N, g, Aw, R, P = design(47e-6, 8.5, 8, 0.25, 0.5, 1, 1.5, 5)
assert N == 16, "16 turns."
assert abs(g - 0.683) < 0.005 and abs(Aw - 4.69) < 0.01, "0.68 mm gap, 4.69 mm² wire."
assert abs(R - 2.94) < 0.01 and abs(P - 0.188) < 0.002, "2.94 mΩ and 0.19 W."
```

::: right
Right. The loss comes out well under the 1 W budget because the chosen core's $K_g$ is five times the minimum.
:::
:::

::: check
kind: python

## Write `transformer_optimum(k, beta, c)`: the flux density minimizing $kB^\beta + c/B^2$ by golden-section search between 0.001 and 1 T, returning (B, core loss, copper loss).

```python starter
def transformer_optimum(k, beta, c):
    return 0.1, 0.0, 0.0
```

```python solution
import math

def transformer_optimum(k, beta, c):
    f = lambda B: k * B ** beta + c / B ** 2
    lo, hi = 0.001, 1.0
    g = (math.sqrt(5) - 1) / 2
    for _ in range(200):
        x1 = hi - g * (hi - lo)
        x2 = lo + g * (hi - lo)
        if f(x1) < f(x2):
            hi = x2
        else:
            lo = x1
    B = (lo + hi) / 2
    return B, k * B ** beta, c / B ** 2
```

```python tests
B, Pfe, Pcu = transformer_optimum(20, 2.7, 0.0004)
assert abs(B - 0.0938) < 0.0005, "Lesson 26's example: 0.094 T."
assert abs(Pcu / Pfe - 1.35) < 1e-6, "At the optimum, copper loss is β/2 times core loss."
assert abs(B - (2 * 0.0004 / (2.7 * 20)) ** (1 / 4.7)) < 1e-9, "It matches the closed form."
```

::: right
Right. The numerical search and the derivative condition agree; the search also works when the loss models aren't simple powers.
:::
:::

::: check
kind: python

## Write `skin_depth_mm(f)` for copper and `rac_ratio(d_mm, f)`: 1 when d ≤ 2δ, otherwise $d/4\delta + 1/4$.

```python starter
def skin_depth_mm(f):
    return 1.0

def rac_ratio(d_mm, f):
    return 1.0
```

```python solution
import math

def skin_depth_mm(f):
    return math.sqrt(1.724e-8 / (math.pi * f * 4 * math.pi * 1e-7)) * 1e3

def rac_ratio(d_mm, f):
    d = skin_depth_mm(f)
    return 1.0 if d_mm <= 2 * d else d_mm / (4 * d) + 0.25
```

```python tests
assert abs(skin_depth_mm(100e3) - 0.209) < 0.001, "0.209 mm at 100 kHz."
assert abs(skin_depth_mm(60) - 8.53) < 0.01, "8.5 mm at 60 Hz."
assert rac_ratio(0.4, 100e3) == 1.0, "Thin wire: no penalty."
assert abs(rac_ratio(2.0, 100e3) - (2.0 / (4 * 0.209) + 0.25)) < 0.01, "A 2 mm wire at 100 kHz: over 2.6 times its DC resistance."
```

::: right
Right. That's why high-frequency windings use litz wire or foil: many strands thinner than the skin depth share the current.
:::
:::

::: explain
## Why does a transformer's total loss have a minimum at an intermediate flux density?

::: model
For a given core and window, raising the peak AC flux density lets the winding use fewer turns, because each turn links more flux for the same volt-seconds. Fewer turns mean thicker wire in the same window and much less copper loss, which falls as the inverse square of the flux density. But core loss rises steeply with flux density, typically to the power 2.6 to 2.8. One loss falls while the other rises, so their sum has a minimum where the copper loss is about β/2 times the core loss, and because the minimum is broad, designers can choose a slightly lower flux density for thermal margin without much penalty.
:::
:::
