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_0\) and \(y = B/B_s\), a symmetric loop with its tip at \(x_m\) has two branches (Takács, 2001):
\[\text{ascending:}\quad y = \tanh(x - a_0) + b, \qquad \text{descending:}\quad y = \tanh(x + a_0) - b\]
\(a_0\) 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_s\) [T], \(h_0\) [A/m] and \(a_0\) [–].
The loop area follows from integrating descending minus ascending branch over \([-x_m, x_m]\). In physical units the energy per cycle is \(W = B_s h_0 A\) [J/m³].
The inverses are valid on the whole loop: on the ascending branch \(y - b\) runs from \(-\tanh(x_m + a_0)\) to \(\tanh(x_m - a_0)\), 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_m(x_m)\) 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_m < B_s\) has exactly one loop.
\(B_s\) and \(h_0\) are fitted scales, not physical constants: \(B_s\) is not the saturation polarisation \(J_s\).
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.
# 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.5x_m, a0 =2.5, 0.8b =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 tipassert 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-valuedprint(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³
For a sinusoidal supply the flux density is known, \(B(t) = \hat B \sin\omega 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_c\) is then \(i(t) = H(t)\, l_c / 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.
harmonic amplitudes of H (A/m), orders 1-7: [69.93 0. 10.57 0. 3.65 0. 1.75]
Fitting to Datasheet Data
A datasheet gives two things about each symmetric loop:
The tip, a point \((\hat H, \hat B)\) on the normal magnetisation curve.
The area, the static hysteresis energy per cycle. From the Bertotti separation \(p_h = k_h f \hat B^{2}\) [W/kg] (fit_bertotti, default exponent 2), the energy per cycle is \(W_h = k_h \hat B^{2} \rho\) [J/m³] with \(\rho\) the density.
fit_takacs finds \(B_s\), \(h_0\) and \(a_0\) 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.
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”.
# 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-9and 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_\text{Takács}(B) + c_{cl}\,\dot B + c_{exc}\,\operatorname{sign}(\dot B)\,|\dot B|^{1/2}\]
At the loop tip \(\dot B = 0\), so the tip does not move; the loop widens where \(B\) crosses zero.
Coefficients from fit_bertotti. Integrating \(H\,dB\) over one sinusoidal cycle and equating with \(p_e = k_e (f\hat B)^2\) and \(p_a = k_a (f\hat B)^{1.5}\) [W/kg]:
with \(\rho\) the density [kg/m³]. Nothing new is fitted. For sinusoidal \(B\), the dynamic loop area therefore equals the Bertotti total loss per cycle, \(\rho\,p(f, \hat B)/f\), whenever the static Takács loop matches the hysteresis term.
The fitted \(k_e\) usually differs from the physical \(\sigma d^2/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_{cl}\) 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 \(\sigma = 2\cdot10^6\) S/m and \(\mu_r\) between 1000 and 5000, \(\delta\) 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:
hysteresis
dynamic
\(H(t)\)
Loss per cycle
True
True
Takács loop + eddy/excess fields
static + eddy + excess
True
False
Takács loop
static hysteresis
False
True
normal curve + eddy/excess fields
eddy + excess
False
False
normal curve (single-valued B–H)
none
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; \(\dot 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.
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.
# loop energy: closed form equals the numerical integral of descending minus ascending branchfor 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), xmassert np.isfinite(m.loop_energy(1e6* m.h0)) # no overflow far into saturation# inverse branches: B -> H -> B round trip on both branchesB_m =1.2B = 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 inputsfor 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 reversalslambda: fit_takacs([1, 2], [0.1, 0.2], [], [])]:try: bad()exceptValueError:passelse:raiseAssertionError("no ValueError")print("✓ Takács model tests passed")
✓ Takács model tests passed
# dynamic terms vanish without coefficients: same H(t) as the static modeldyn0 = 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 curveassert 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 termsH_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 rejectsB_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 curveH_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 Bi_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_sassert np.isclose(W_e, rho * k_e * (f_chk * B_hat) **2/ f_chk, rtol=1e-3), f_chkassert np.isclose(W_a, rho * k_a * (f_chk * B_hat) **1.5/ f_chk, rtol=1e-3), f_chkassert 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()exceptValueError:passelse:raiseAssertionError("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.