DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
Hysteresis.h File Reference

Jiles-Atherton magnetic hysteresis with an implicit NR solver. More...

#include "DspMath.h"
#include <algorithm>
#include <cmath>
Include dependency graph for Hysteresis.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::Hysteresis< T >
 Per-channel Jiles-Atherton hysteresis processor (field in, M out). More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Jiles-Atherton magnetic hysteresis with an implicit NR solver.

The physical core shared by tape and transformer modelling: magnetization M responds to the applied field H with saturation, memory (remanence) and rate-dependent loop losses, following the Jiles-Atherton model (Jiles & Atherton 1986; audio-rate treatment after Chowdhury, DAFx-19):

M_an(Q) = Ms * L(Q), L(x) = coth(x) - 1/x, Q = (H + alpha*M) / a

phi1 = (1-c) * dltM * (M_an - M) / [ (1-c)*dlt*k - alpha*(M_an - M) ] with dlt = sign(dH/dt), dltM the reversal gate

dM/dt = [ phi1 + c*(Ms/a)*L'(Q) ] / [ 1 - c*alpha*(Ms/a)*L'(Q) ] * dH/dt

The gate dltM zeroes the irreversible term whenever magnetization would move unphysically against the drive direction at reversal points.

Integration is trapezoidal (matching the WDF/bilinear convention used throughout the framework) solved per sample with a Newton-Raphson iteration on M_n, seeded by an explicit Euler predictor – converges in 1-3 iterations at audio rates. All internal state is double regardless of T: the model mixes quantities spanning ~9 orders of magnitude.

Verified by the test suite on first principles: odd symmetry of the B-H loop, monotone loop area vs the loss parameter k, remanence after field removal, and loop collapse as the reversible fraction c -> 1.

Mono processor: hold one instance per channel (the framework pattern for stateful per-channel cores, like Hilbert). Threading is owner-managed: the consuming effect calls setParameters()/processSample() from its own audio thread (the framework's dirty-flag pattern), so no atomics live here.

Dependencies: DspMath.h.

Definition in file Hysteresis.h.