# Hysteresis Models


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

## Executive Summary

**Purpose:** Model the static hysteresis loop of soft magnetic steel
from the data a steel datasheet provides.

**What it does:** Implements the Takács model in its basic form:
closed-form ascending and descending loop branches, their exact inverses
(H from B), remanence, coercivity and loop energy, and a fit of the
three parameters to datasheet data. `DynamicLoopModel` widens the static
loop for AC operation with Bertotti’s classical-eddy and excess fields,
using the coefficients of `fit_bertotti`.

### Why It Matters

A single-valued B–H curve gives the magnetising current but no
hysteresis. With a loop model, a voltage-driven device such as a
transformer gets its no-load current waveform (peaks, harmonics, the
in-phase loss component) analytically from B(t).

### Quick Start

**Inputs:** points on the normal magnetisation curve (loop tips) and the
static hysteresis energy per cycle at several peak flux densities (from
the Bertotti loss separation).

**Outputs:** `TakacsModel` with loops, H(t) for a given B(t), remanence,
coercivity and loop energy; `DynamicLoopModel` with H(t) and the energy
per cycle at a given frequency.

### Limits of the basic form

- The dynamic widening assumes uniform B through the sheet thickness (no
  skin effect): valid at mains frequency, not in the kHz range.
- Symmetric loops only: no DC bias and no minor loops inside a half
  cycle.
- The normal curve has a fixed tanh shape; a steel with a sharp knee and
  a slow approach to saturation may not fit well.

## How It Fits Into the Motor Design Workflow

**Lives in:** `emachines.magnetics`, next to the B–H models, so
transformers, solenoids and motors can share it.

**Upstream:** the static loop energy comes from the hysteresis term of
`fit_bertotti` (`emachines.magnetics.iron_loss`); the dynamic widening
uses its eddy and excess terms.

**Downstream:** the planned transformer module (no-load current
waveform).

## Theory: the Takács Model

In normalised units *x* = *H*/*h*<sub>0</sub> and
*y* = *B*/*B*<sub>*s*</sub>, a symmetric loop with its tip at
*x*<sub>*m*</sub> has two branches (Takács, 2001):

ascending:  *y* = tanh (*x* − *a*<sub>0</sub>) + *b*,   descending:  *y* = tanh (*x* + *a*<sub>0</sub>) − *b*

$$b = \tfrac{1}{2}\left\[\tanh(x_m + a_0) - \tanh(x_m - a_0)\right\]$$

*a*<sub>0</sub> shifts the branches apart and so creates the hysteresis;
*b* is not a free parameter, it closes the loop at its tip. The three
material parameters are *B*<sub>*s*</sub> \[T\], *h*<sub>0</sub> \[A/m\]
and *a*<sub>0</sub> \[–\].

Everything else follows in closed form:

<table>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr>
<th>Quantity</th>
<th>Normalised form</th>
</tr>
</thead>
<tbody>
<tr>
<td>Loop tip (normal magnetisation curve)</td>
<td><span class="math inline">$y_m = \tfrac{1}{2}\left[\tanh(x_m + a_0)
+ \tanh(x_m - a_0)\right]$</span></td>
</tr>
<tr>
<td>Remanence (descending branch at <span
class="math inline"><em>x</em> = 0</span>)</td>
<td><span
class="math inline"><em>y</em><sub><em>r</em></sub> = tanh (<em>a</em><sub>0</sub>) − <em>b</em></span></td>
</tr>
<tr>
<td>Coercivity (ascending branch at <span
class="math inline"><em>y</em> = 0</span>)</td>
<td><span
class="math inline"><em>x</em><sub><em>c</em></sub> = <em>a</em><sub>0</sub> − artanh (<em>b</em>)</span></td>
</tr>
<tr>
<td>Loop area</td>
<td><span class="math inline">$A = 2\ln\dfrac{\cosh(x_m +
a_0)}{\cosh(x_m - a_0)} - 2x_m\left[\tanh(x_m + a_0) - \tanh(x_m -
a_0)\right]$</span></td>
</tr>
<tr>
<td>Inverse, rising <span class="math inline"><em>B</em></span></td>
<td><span
class="math inline"><em>x</em> = artanh (<em>y</em> − <em>b</em>) + <em>a</em><sub>0</sub></span></td>
</tr>
<tr>
<td>Inverse, falling <span class="math inline"><em>B</em></span></td>
<td><span
class="math inline"><em>x</em> = artanh (<em>y</em> + <em>b</em>) − <em>a</em><sub>0</sub></span></td>
</tr>
</tbody>
</table>

The loop area follows from integrating descending minus ascending branch
over \[−*x*<sub>*m*</sub>, *x*<sub>*m*</sub>\]. In physical units the
energy per cycle is *W* = *B*<sub>*s*</sub>*h*<sub>0</sub>*A* \[J/m³\].

The inverses are valid on the whole loop: on the ascending branch
*y* − *b* runs from −tanh (*x*<sub>*m*</sub> + *a*<sub>0</sub>) to
tanh (*x*<sub>*m*</sub> − *a*<sub>0</sub>), both inside (−1, 1), and
likewise for the descending branch. So for a voltage-driven device,
where *B*(*t*) is known, *H*(*t*) is explicit.

The tip curve *y*<sub>*m*</sub>(*x*<sub>*m*</sub>) rises monotonically
from 0 to 1 (its slope
$\tfrac12\[\operatorname{sech}^2(x_m + a_0) + \operatorname{sech}^2(x_m - a_0)\]$
is positive), so every 0 \< *B*<sub>*m*</sub> \< *B*<sub>*s*</sub> has
exactly one loop.

*B*<sub>*s*</sub> and *h*<sub>0</sub> are fitted scales, not physical
constants: *B*<sub>*s*</sub> is not the saturation polarisation
*J*<sub>*s*</sub>.

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

### TakacsModel

``` python
def TakacsModel(
    B_s:float, h0:float, a0:float
)->None:
```

*Takács hysteresis model, basic form: static, symmetric loops.*

Branches in normalised units x = H/h0, y = B/B_s, for a loop with tip at
x_m: ascending y = tanh(x - a0) + b, descending y = tanh(x + a0) - b,
with b = (tanh(x_m + a0) - tanh(x_m - a0)) / 2.

``` python
# Examples
# Illustrative parameters only — not fitted to any real steel.
m = TakacsModel(B_s=1.6, h0=50.0, a0=0.8)
H_m = 2.5 * m.h0                                     # x_m = 2.5
x_m, a0 = 2.5, 0.8
b = 0.5 * (np.tanh(x_m + a0) - np.tanh(x_m - a0))
assert np.isclose(m.tip_B(H_m), m.branch_B(H_m, H_m, rising=True))      # branches meet at the tip
assert np.isclose(m.tip_B(H_m), m.branch_B(H_m, H_m, rising=False))
assert np.isclose(m.remanence(H_m), 1.6 * (np.tanh(a0) - b))
assert np.isclose(m.branch_B(m.coercivity(H_m), H_m, rising=True), 0, atol=1e-12)
assert np.isclose(m.tip_H(m.tip_B(H_m)), H_m)
assert np.isclose(m.normal_H(-m.tip_B(H_m)), -H_m) and m.normal_H(0.0) == 0.0   # odd, single-valued
print(f"tip B = {m.tip_B(H_m):.4f} T, B_r = {m.remanence(H_m):.4f} T, "
      f"H_c = {m.coercivity(H_m):.2f} A/m, W = {m.loop_energy(H_m):.1f} J/m³")
```

    tip B = 1.5462 T, B_r = 1.0130 T, H_c = 38.45 A/m, W = 226.2 J/m³

``` python
fig, ax = plt.subplots(figsize=(7, 4.5))
for xm in [1.0, 1.5, 2.5, 5.0]:
    H, B = m.loop(xm * m.h0)
    ax.plot(H, B, lw=1.4, label=f"tip H = {xm * m.h0:.0f} A/m")
H_n = np.linspace(1, 5 * m.h0, 200)
ax.plot(H_n, m.tip_B(H_n), "k--", lw=1, label="normal curve (loop tips)")
ax.set_xlabel("H (A/m)"); ax.set_ylabel("B (T)")
ax.set_title("Takács loops, illustrative parameters")
ax.grid(True, alpha=0.4); ax.legend(fontsize=8)
plt.show()
```

![](07_hysteresis_files/figure-commonmark/cell-4-output-1.png)

## Field Waveform for a Given B(t)

For a sinusoidal supply the flux density is known,
*B*(*t*) = *B̂*sin *ω**t*, and the exact inverses give *H*(*t*) point by
point. The magnetising current of a winding with *N* turns on a core of
path length *l*<sub>*c*</sub> is then
*i*(*t*) = *H*(*t*) *l*<sub>*c*</sub>/*N*.

Because the loop is static, this is the current at very low frequency.
At 50 Hz eddy currents widen the loop: see *Dynamic Widening* below.

``` python
# Examples
theta = np.linspace(0, 2 * np.pi, 720, endpoint=False)
B_t = 1.3 * np.sin(theta)
H_t = m.field_waveform(B_t)
# H(t) retraces the loop: rising samples lie on the ascending branch
up = np.roll(B_t, -1) > np.roll(B_t, 1)
assert np.allclose(m.branch_B(H_t[up], H_t.max(), rising=True), B_t[up])
# half-wave symmetry: H(t + T/2) = -H(t), so only odd harmonics
assert np.allclose(H_t[360:], -H_t[:360])
c = np.fft.rfft(H_t) / len(H_t) * 2
print("harmonic amplitudes of H (A/m), orders 1-7:", np.round(np.abs(c[1:8]), 2))

fig, ax = plt.subplots(figsize=(7, 3.5))
ax.plot(np.degrees(theta), H_t, label="H(t)")
ax2 = ax.twinx(); ax2.plot(np.degrees(theta), B_t, "k:", label="B(t)")
ax.set_xlabel("ωt (deg)"); ax.set_ylabel("H (A/m)"); ax2.set_ylabel("B (T)")
ax.set_title("Field for sinusoidal B, illustrative parameters"); ax.grid(True, alpha=0.4)
plt.show()
```

    harmonic amplitudes of H (A/m), orders 1-7: [69.93  0.   10.57  0.    3.65  0.    1.75]

![](07_hysteresis_files/figure-commonmark/cell-5-output-2.png)

## Fitting to Datasheet Data

A datasheet gives two things about each symmetric loop:

1.  **The tip**, a point (*Ĥ*, *B̂*) on the normal magnetisation curve.
2.  **The area**, the static hysteresis energy per cycle. From the
    Bertotti separation
    *p*<sub>*h*</sub> = *k*<sub>*h*</sub>*f**B̂*<sup>2</sup> \[W/kg\]
    (`fit_bertotti`, default exponent 2), the energy per cycle is
    *W*<sub>*h*</sub> = *k*<sub>*h*</sub>*B̂*<sup>2</sup>*ρ* \[J/m³\]
    with *ρ* the density.

`fit_takacs` finds *B*<sub>*s*</sub>, *h*<sub>0</sub> and
*a*<sub>0</sub> by least squares on the relative errors of both. There
are more data points than parameters, so the residuals also show whether
the basic form suits the material. Remanence and coercivity are then
predictions of the fitted model; without a measured loop they cannot be
checked.

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

### fit_takacs

``` python
def fit_takacs(
    H_tip, B_tip, B_loop, W_loop
)->dict:
```

*Fit TakacsModel to loop tips and loop energies.*

Args: H_tip, B_tip: points on the normal magnetisation curve \[A/m\],
\[T\]. B_loop: peak flux densities \[T\] at which the loop energy is
known. W_loop: static hysteresis energy per cycle at B_loop \[J/m³\].

Returns: Dict with ‘B_s’, ‘h0’, ‘a0’, the fitted ‘takacs’ model, and the
relative rms errors ‘rel_rms_tip’ and ‘rel_rms_energy’; ‘model’ is
“Takács”.

``` python
# Examples
# Self-consistency check: data generated from a known model are fitted back.
# The data are synthetic, made by TakacsModel itself — not datasheet values.
true = TakacsModel(B_s=1.6, h0=50.0, a0=0.8)
H_tip = np.array([40, 60, 80, 120, 200, 400])
B_loop = np.array([0.5, 0.8, 1.0, 1.2, 1.4])
fit = fit_takacs(H_tip, true.tip_B(H_tip), B_loop, true.loop_energy(true.tip_H(B_loop)))
assert np.allclose([fit["B_s"], fit["h0"], fit["a0"]], [1.6, 50.0, 0.8], rtol=1e-6)
assert fit["rel_rms_tip"] < 1e-9 and fit["rel_rms_energy"] < 1e-9
```

## Dynamic Widening: Bertotti’s Field Separation

At AC the field needed to drive *B*(*t*) through a lamination is the
static hysteresis field plus two rate-dependent terms (Bertotti, 1988):

*H*(*t*) = *H*<sub>Takács</sub>(*B*) + *c*<sub>*c**l*</sub> *Ḃ* + *c*<sub>*e**x**c*</sub> sign (*Ḃ*) |*Ḃ*|<sup>1/2</sup>

<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr>
<th>Term</th>
<th>Origin</th>
<th>Loss</th>
</tr>
</thead>
<tbody>
<tr>
<td><span
class="math inline"><em>H</em><sub>Takács</sub>(<em>B</em>)</span></td>
<td>static domain-wall pinning</td>
<td><span class="math inline"><em>p</em><sub><em>h</em></sub></span>,
the static loop area</td>
</tr>
<tr>
<td><span
class="math inline"><em>c</em><sub><em>c</em><em>l</em></sub> <em>Ḃ</em></span></td>
<td>classical eddy currents; physically <span
class="math inline"><em>c</em><sub><em>c</em><em>l</em></sub> = <em>σ</em><em>d</em><sup>2</sup>/12</span></td>
<td><span
class="math inline"><em>p</em><sub><em>e</em></sub> ∝ <em>f</em><sup>2</sup><em>B̂</em><sup>2</sup></span></td>
</tr>
<tr>
<td><span
class="math inline"><em>c</em><sub><em>e</em><em>x</em><em>c</em></sub>sign (<em>Ḃ</em>)|<em>Ḃ</em>|<sup>1/2</sup></span></td>
<td>excess (domain-wall) eddy currents</td>
<td><span
class="math inline"><em>p</em><sub><em>a</em></sub> ∝ <em>f</em><sup>1.5</sup><em>B̂</em><sup>1.5</sup></span></td>
</tr>
</tbody>
</table>

At the loop tip *Ḃ* = 0, so the tip does not move; the loop widens where
*B* crosses zero.

**Coefficients from `fit_bertotti`.** Integrating *H* *d**B* over one
sinusoidal cycle and equating with
*p*<sub>*e*</sub> = *k*<sub>*e*</sub>(*f**B̂*)<sup>2</sup> and
*p*<sub>*a*</sub> = *k*<sub>*a*</sub>(*f**B̂*)<sup>1.5</sup> \[W/kg\]:

$$c\_{cl} = \frac{k_e\\\rho}{2\pi^2}, \qquad c\_{exc} = \frac{k_a\\\rho}{C\sqrt{2\pi}}, \qquad C = \int_0^{2\pi}|\cos\theta|^{1.5}\\d\theta = 3.4961$$

with *ρ* the density \[kg/m³\]. Nothing new is fitted. For sinusoidal
*B*, the dynamic loop area therefore equals the Bertotti total loss per
cycle, *ρ* *p*(*f*, *B̂*)/*f*, whenever the static Takács loop matches
the hysteresis term.

The fitted *k*<sub>*e*</sub> usually differs from the physical
*σ**d*<sup>2</sup>/12, because measured eddy loss is often larger than
the classical value and the fit shares the surplus between the eddy and
excess terms. `classical_eddy_coefficient(sigma, d)` gives the physical
value for comparison.

**Validity: no skin effect.** The *c*<sub>*c**l*</sub> term assumes
uniform *B* through the sheet, which needs the skin depth
$\delta = \sqrt{2/(\omega\mu\sigma)}$ to exceed the half-thickness
*d*/2. With *σ* = 2 ⋅ 10<sup>6</sup> S/m and *μ*<sub>*r*</sub> between
1000 and 5000, *δ* is 0.7–1.6 mm at 50 Hz but 0.16–0.36 mm at 1 kHz,
against *d*/2 = 0.175 mm for 0.35 mm sheet. So the model holds at mains
frequency and fails in the kHz range.

**Choosing the effects.** `field_waveform` and `cycle_energy` take two
switches, so the same model can be analysed with or without each effect:

<table>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th><code>hysteresis</code></th>
<th><code>dynamic</code></th>
<th><span class="math inline"><em>H</em>(<em>t</em>)</span></th>
<th>Loss per cycle</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>True</code></td>
<td><code>True</code></td>
<td>Takács loop + eddy/excess fields</td>
<td>static + eddy + excess</td>
</tr>
<tr>
<td><code>True</code></td>
<td><code>False</code></td>
<td>Takács loop</td>
<td>static hysteresis</td>
</tr>
<tr>
<td><code>False</code></td>
<td><code>True</code></td>
<td>normal curve + eddy/excess fields</td>
<td>eddy + excess</td>
</tr>
<tr>
<td><code>False</code></td>
<td><code>False</code></td>
<td>normal curve (single-valued B–H)</td>
<td>none</td>
</tr>
</tbody>
</table>

With `hysteresis=False` the static field comes from the normal
magnetisation curve of the same Takács model (`normal_H`), so all four
options share the same fitted data and the same loop tips. Turning
hysteresis off removes only the loop width. A single-valued curve also
accepts biased *B*(*t*) and minor reversals, which the loop branches
reject.

**Input.** *B*(*t*) is sampled at a fixed time step `dt` over one
period; *Ḃ* is the periodic central difference, accurate to second order
in `dt`. The basic Takács form still rejects minor reversals, so PWM
ripple is not covered.

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

### DynamicLoopModel

``` python
def DynamicLoopModel(
    static:TakacsModel, c_cl:float, c_exc:float
)->None:
```

*Static Takács loop widened by Bertotti’s classical-eddy and excess
fields.*

H(t) = H_static(B) + c_cl dB/dt + c_exc sign(dB/dt) |dB/dt|^0.5

Both effects are optional per call: `hysteresis=False` replaces the loop
by the single-valued normal curve of the same model, `dynamic=False`
drops the rate-dependent terms.

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

### classical_eddy_coefficient

``` python
def classical_eddy_coefficient(
    sigma:float, d:float
)->float:
```

*Physical classical-eddy coefficient c_cl = σ d² / 12 \[A·s/(m·T)\].*

Args: sigma: electrical conductivity of the steel \[S/m\] d: lamination
thickness \[m\]

``` python
# Examples
# Illustrative Bertotti coefficients and density — not fitted to any real steel.
k_e, k_a, rho = 5e-5, 5e-4, 7650.0
dyn = DynamicLoopModel.from_bertotti(m, k_e, k_a, rho)
assert np.isclose(dyn.c_cl, k_e * rho / (2 * np.pi ** 2))

f, B_hat, n = 50.0, 1.3, 2000
t = np.arange(n) / (n * f)
B_t = B_hat * np.sin(2 * np.pi * f * t)
W_dyn = dyn.cycle_energy(B_t, t[1])
W_static = m.loop_energy(m.tip_H(B_hat))
W_eddy_exc = rho * (k_e * (f * B_hat) ** 2 + k_a * (f * B_hat) ** 1.5) / f   # Bertotti p_e + p_a per cycle
assert np.isclose(W_dyn, W_static + W_eddy_exc, rtol=1e-3)   # loop area = static + Bertotti dynamic loss
print(f"per cycle at {f:.0f} Hz, {B_hat} T: static {W_static:.1f} + eddy/excess {W_eddy_exc:.1f} "
      f"= {W_static + W_eddy_exc:.1f} J/m³; dynamic loop area {W_dyn:.1f} J/m³")
# the four combinations of the two switches
W = {(h, d): dyn.cycle_energy(B_t, t[1], hysteresis=h, dynamic=d) for h in (True, False) for d in (True, False)}
assert np.isclose(W[True, False], W_static, rtol=1e-3)            # static loop only
assert np.isclose(W[False, True], W_eddy_exc, rtol=1e-3)          # eddy + excess only
assert abs(W[False, False]) < 1e-9 * W_static                     # single-valued curve: no loss
# physical check: σ d²/12 for 0.35 mm sheet, σ = 2e6 S/m (typical value, not a specific steel)
print(f"c_cl from k_e = {dyn.c_cl:.4f}, physical σd²/12 = {classical_eddy_coefficient(2e6, 0.35e-3):.4f} A·s/(m·T)")
```

    per cycle at 50 Hz, 1.3 T: static 141.0 + eddy/excess 72.4 = 213.4 J/m³; dynamic loop area 213.4 J/m³
    c_cl from k_e = 0.0194, physical σd²/12 = 0.0204 A·s/(m·T)

``` python
fig, ax = plt.subplots(figsize=(7, 4.5))
H_nc = m.normal_H(np.linspace(-B_hat, B_hat, 201))
ax.plot(H_nc, np.linspace(-B_hat, B_hat, 201), "k:", lw=1.2, label="normal curve (hysteresis off)")
for f_plot, style in [(0.0, "k--"), (50.0, "C0"), (200.0, "C3")]:
    if f_plot == 0:
        H, B = m.loop(m.tip_H(B_hat))
        ax.plot(H, B, style, lw=1.2, label="static (DC)")
        continue
    tt = np.arange(n) / (n * f_plot)
    Bt = B_hat * np.sin(2 * np.pi * f_plot * tt)
    Ht = dyn.field_waveform(Bt, tt[1])
    ax.plot(np.append(Ht, Ht[0]), np.append(Bt, Bt[0]), style, lw=1.4, label=f"{f_plot:.0f} Hz")
ax.set_xlabel("H (A/m)"); ax.set_ylabel("B (T)")
ax.set_title("Dynamic widening, illustrative coefficients")
ax.grid(True, alpha=0.4); ax.legend(fontsize=8)
plt.show()
```

![](07_hysteresis_files/figure-commonmark/cell-11-output-1.png)

## Tests

``` python
# loop energy: closed form equals the numerical integral of descending minus ascending branch
for xm in [0.5, 1.0, 2.5, 6.0]:
    H_m = xm * m.h0
    num = quad(lambda H: m.branch_B(H, H_m, False) - m.branch_B(H, H_m, True), -H_m, H_m)[0]
    assert np.isclose(m.loop_energy(H_m), num, rtol=1e-9), xm
assert np.isfinite(m.loop_energy(1e6 * m.h0))                  # no overflow far into saturation

# inverse branches: B -> H -> B round trip on both branches
B_m = 1.2
B = np.linspace(-B_m, B_m, 101)
H_tipB = m.tip_H(B_m)
for rising in (True, False):
    assert np.allclose(m.branch_B(m.branch_H(B, B_m, rising), H_tipB, rising), B)

# normal curve is monotonic and below B_s (range kept where tanh is still resolvable in float64)
H = np.linspace(1, 8 * m.h0, 500)
assert np.all(np.diff(m.tip_B(H)) > 0) and m.tip_B(H).max() < m.B_s

# invalid inputs
for bad in [lambda: TakacsModel(1.6, 50, 0), lambda: m.tip_H(1.6), lambda: m.tip_H(0),
            lambda: m.loop_energy(0), lambda: m.field_waveform(1.3 * np.sin(theta) + 0.2),
            lambda: m.field_waveform(np.sin(theta) + 0.3 * np.sin(3 * theta)),   # symmetric, but with minor reversals
            lambda: fit_takacs([1, 2], [0.1, 0.2], [], [])]:
    try:
        bad()
    except ValueError:
        pass
    else:
        raise AssertionError("no ValueError")
print("✓ Takács model tests passed")
```

    ✓ Takács model tests passed

``` python
# dynamic terms vanish without coefficients: same H(t) as the static model
dyn0 = DynamicLoopModel(m, 0.0, 0.0)
assert np.allclose(dyn0.field_waveform(B_t, t[1]), m.field_waveform(B_t))
# switches: dynamic=False gives the static loop, hysteresis=False the normal curve
assert np.allclose(dyn.field_waveform(B_t, t[1], dynamic=False), m.field_waveform(B_t))
assert np.allclose(dyn.field_waveform(B_t, t[1], hysteresis=False, dynamic=False), m.normal_H(B_t))
# hysteresis off and dynamic on: the field is the normal curve plus the same dynamic terms
H_dyn_only = dyn.field_waveform(B_t, t[1], hysteresis=False) - m.normal_H(B_t)
assert np.allclose(H_dyn_only, dyn.field_waveform(B_t, t[1]) - m.field_waveform(B_t))
# a single-valued curve accepts biased B(t) and minor reversals, which the loop rejects
B_bias = 0.5 + 0.6 * np.sin(2 * np.pi * f * t)
assert np.all(np.isfinite(dyn.field_waveform(B_bias, t[1], hysteresis=False)))
# normal curve is the odd inverse of the tip curve
H_chk = np.array([30.0, 80.0, 200.0])
assert np.allclose(m.normal_H(m.tip_B(H_chk)), H_chk) and np.allclose(m.normal_H(-m.tip_B(H_chk)), -H_chk)
# the tip does not move: dB/dt = 0 at the peak of B
i_pk = np.argmax(B_t)
assert np.isclose(dyn.field_waveform(B_t, t[1])[i_pk], m.field_waveform(B_t)[i_pk], rtol=1e-3)
# cycle energy of each term alone matches its Bertotti loss (eddy ∝ f², excess ∝ f^1.5)
for f_chk in (50.0, 400.0):
    tt = np.arange(n) / (n * f_chk)
    Bt = B_hat * np.sin(2 * np.pi * f_chk * tt)
    W_s = m.loop_energy(m.tip_H(B_hat))
    W_e = DynamicLoopModel.from_bertotti(m, k_e, 0.0, rho).cycle_energy(Bt, tt[1]) - W_s
    W_a = DynamicLoopModel.from_bertotti(m, 0.0, k_a, rho).cycle_energy(Bt, tt[1]) - W_s
    assert np.isclose(W_e, rho * k_e * (f_chk * B_hat) ** 2 / f_chk, rtol=1e-3), f_chk
    assert np.isclose(W_a, rho * k_a * (f_chk * B_hat) ** 1.5 / f_chk, rtol=1e-3), f_chk
assert np.isclose(classical_eddy_coefficient(2e6, 0.35e-3), 2e6 * 0.35e-3 ** 2 / 12)
for bad in [lambda: DynamicLoopModel(m, -1.0, 0.0), lambda: dyn.field_waveform(B_t, 0.0),
            lambda: DynamicLoopModel.from_bertotti(m, k_e, k_a, 0.0), lambda: classical_eddy_coefficient(0, 1e-3)]:
    try:
        bad()
    except ValueError:
        pass
    else:
        raise AssertionError("no ValueError")
print("✓ Dynamic widening tests passed")
```

    ✓ Dynamic widening tests passed

## References

- Takács, J. (2001). A phenomenological mathematical model of
  hysteresis. *COMPEL*, 20(4), 1002–1015.
- Takács, J. (2003). *Mathematics of Hysteretic Phenomena: The T(x)
  Model for the Description of Hysteresis*. Wiley-VCH.
- Bertotti, G. (1988). General properties of power losses in soft
  ferromagnetic materials. *IEEE Transactions on Magnetics*, 24(1),
  621–630 — loss and field separation.
- Bertotti, G. (1998). *Hysteresis in Magnetism*. Academic Press — loss
  separation used for the loop energy.
