Add Jiles-Atherton B-H hysteresis to inductor#344
Open
esaruoho wants to merge 1 commit intopfalstad:v3-devfrom
Open
Add Jiles-Atherton B-H hysteresis to inductor#344esaruoho wants to merge 1 commit intopfalstad:v3-devfrom
esaruoho wants to merge 1 commit intopfalstad:v3-devfrom
Conversation
Extends the saturable core model (PR pfalstad#308) with a full B-H hysteresis loop using a normalized Jiles-Atherton formulation. Inductor tracks irreversible magnetization Mirr and total M as internal state, advanced once per timestep in startIteration(). Companion resistance is recomputed from the incremental slope dm/dh, floored and capped for convergence. User-facing parameters on InductorElm: - Coercive Current (A) -- 0 disables hysteresis (default) - Hysteresis Reversibility (0-1) -- JA c parameter, default 0.1 Shape and interdomain coupling (JA a, alpha) use fixed internal defaults tuned so initial small-signal inductance equals L0. Degradation path: - coerciveCurrent=0, saturationCurrent>0 -> PR pfalstad#308 saturation - coerciveCurrent=0, saturationCurrent=0 -> linear inductor (unchanged) Backwards-compatible dump: new tokens appended at end, wrapped in the existing try/catch block. XML attrs ich/hrev only emitted when hysteresis active. Transformer hysteresis is intentionally deferred to a follow-up PR to keep this change focused. Includes war/circuits/hysteresis-loop.txt as a minimal demo. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
coerciveCurrent = 0degrades to Add saturable core model for inductors and transformers #308 saturation;saturationCurrent = 0as well degrades to the original linear inductor.Why
Critics have pointed to "linear-biased, can't do real B-H hysteresis cleanly" as a gap. #308 closed half the gap (single-valued saturation). This closes the other half — history-dependent magnetization, which is what you need to see real hysteresis loops, coercivity-driven demagnetization, and realistic flyback/Joule-Thief core loss.
How it works
Internal dimensionless Jiles-Atherton state:
h = I / Ic(normalized field)Man(he) = coth(he/a) - a/he(Langevin, Ms = 1)he = h + alpha*mdMirr/dh = (Man - Mirr) / (delta - alpha*(Man - Mirr))withdelta = sign(dh)andknormalized to 1m = Mirr + c*(Man - Mirr)Fixed internal constants
a = 1/3,alpha = 1e-3are tuned so the virgin small-signal inductance equals the user-specifiedL0. The user only exposes:0disables hysteresis (default)c, default 0.1State is advanced once per timestep in
startIteration()(not per Newton iteration), following the capacitor-charge pattern — Newton sees a linearized inductor per step. Companion resistance is derived from the incremental slopedm/dh, with a[0.01, 3.0]floor/cap and a|denom| >= 1e-3clamp on the JA denominator to avoid singularities at loop tips.Backwards compatibility
try/catchblock. Old circuit files load unchanged.ichandhrevattributes are only emitted when hysteresis is active. Old XML files round-trip unchanged.Inductor.setup()callers (RelayCoilElm, RelayElm, DCMotorElm) use the 3-arg overload which is preserved; the 6-arg overload is new.Files changed
Inductor.java— JA state,advanceHysteresis(), extendedstartIteration()/stamp()/nonLinear()/resetTo(), new 6-argsetup()InductorElm.java— two newEditInfoslots, dump/undump tail tokens, XML attrs, info-panel additionswar/circuits/hysteresis-loop.txt— minimal demo (AC source, inductor, 1-ohm sense)Scope
In: InductorElm B-H hysteresis, 2 UI params, backwards-compat dump, demo circuit.
Deferred (future PRs):
TransformerElmhysteresis (coupled-state bookkeeping warrants its own review)MsHappy to simplify the model (fewer params, different formulation) if you prefer a lighter touch — JA is the SPICE-standard but the framework here can host a simpler Tellinen-style
atan()model just as easily.Test plan
Ic = 0, Isat = 0-> identical behavior to current inductorIc = 0, Isat > 0-> identical to Add saturable core model for inductors and transformers #3082*IcMto 0 (virgin curve on next excitation)Ic = 0)