开云体育

Non-converging oscillation problem of inverse Jiles-Atherton model in LTspice


 

Hi all,

I’m implementing an inverse Jiles-Atherton model in LTspice, mainly based on this paper:

The simulation stops around a quarter cycle. It seems to get stuck when "dH/dt" approaches zero — likely because of? "delta", which is the sign of "dH/dt"

I’ve tried replacing the "delta" with a smooth "tanh" function, but the oscillation and convergence issue still remains.

Any suggestions on how to solve this problem?? I've posted my schematic here: /g/LTspice/files/Temp/invJAmodel_dynamictest.zip

Thanks!


 

Hi.
I managed to make a Jiles-Atherton model in LTspice. I also made a model taking into account the non-magnetic gap, and also derived H and B. I posted models on this forum. I also made the Jiles-Atherton model in Qspice.


 

Thanks for your efforts! I’ve seen the JA model you shared earlier—it’s excellent!

However, the circuit I’m working on is the "inverse JA model", where B is the input and H is the output, unlike the usual forward case. I previously implemented the forward model (usual JA model) myself and it worked well without major convergence issues. But this time, the inverse version performs poorly in LTspice, and I’m not sure why. Have you encountered similar convergence problems before?

Additionally, I also tested the inverse model in MATLAB in advance, and it behaved correctly there. But, since MATLAB updates variables sequentially accroding to my codes, while LTspice seems uses matrix-based solving, I wonder if it might be affecting the results. Do you have any suggestions?


 

Try to implement the delay not using LC, but using RC. I replaced the voltage sources with an equivalent in the form of a controlled current source and an Rpar and Cpar connected to it. TAU=Rpar*Cpar~50nsec. ?But this is the case if the received voltage is not applied anywhere, but is used only in mathematical terms.


 

Thank you very much for your suggestion — you solved a problem that had troubled me for weeks. The convergence is indeed much better now. However, there are still some aspects of the model that puzzle me.

When my input B is a 50?Hz sine wave, the simulation only converges when the delay "tau" is set to 300?ns. If I reduce tau to 200?ns or smaller, the simulation still gets stuck at some point. Moreover, when I try to increase the frequency of B, tau = 300?ns no longer works. This behavior seems to make the model not very robust across different conditions.

Do you have any insights into what might be causing this?

(The new one is here: /g/LTspice/files/Temp/invJAmodel_2.asc)

Again, thank you so much for taking the time to help!


 

Hi.
I found that LTspice does not want to read the voltage in the delta node correctly! The result is huge, unreal values of H and M.


 

On Tue, Apr 22, 2025 at 08:03 AM, Александр Бордодынов wrote:
I found that LTspice does not want to read the voltage in the delta node correctly!
That looks like it might be a language translation problem.
?
I can't see a reason why LTspice would be unable to correctly read the voltage on any node.? But maybe that node's voltage was created (driven) wrongly, such that its voltage is incorrect?? That is a different problem than inability to read that voltage.
?
I saw small oscillations here and there on various node voltages in this simulation.? I did not study it so I don't know what is supposed to happen.? That is just an observation.? I wonder if different simulation settings (plotwinsize, *tol tolerances, solver, timestep control) might be needed here?
?
Andy
?
?


 

Thanks for the suggestion — increasing rtol? is truly helpful.

This model seems to struggle when dH/dt is near zero, causing oscillations in all conditional terms. Sometimes it converges, sometimes it doesn't.

Three ways to improve it:

  1. Increase delay time (tau): Helps stability, but too large tau introduces more phase shift between B and H,which increases B-H loop area. At an input frequency of f = 50 Hz, using tau?= 300 ns still gives acceptable results, but if the frequency increases, tau must be reduced accordingly.

  2. Reduce max timestep: Slower simulation, but improves convergence near dH/dt ≈ 0. Dropping it from 1e-6 to 1e-7 helped. It seems that better numerical resolution earlier in the simulation helps the solver predict the behavior more accurately at those critical points.

  3. Increase rtol: Improves convergence but may distort waveforms. But combining this with a smaller timestep can balance accuracy. rtol = 0.005 worked better than the default rtol=0.001.

At this point, I haven’t found a way to eliminate the oscillations, but I can improve both convergence and accuracy by balancing the three strategies above. I’ll continue experimenting to see whether it's possible to reduce the oscillation by improving the inverse Jiles-Atherton algorithm itself.


 

Also, I was surprised to find that this model doesn’t seem to run in LTspice 24.1.5, even though it works fine with the same settings in version 24.0.7.


 

On Tue, Apr 22, 2025 at 11:31 PM, <limengfan81@...> wrote:
Also, I was surprised to find that this model doesn’t seem to run in LTspice 24.1.5, even though it works fine with the same settings in version 24.0.7.
It helps to say why it does not run, or what happens when it does run.
?
There were major program changes between LTspice 24.0.x and 24.1.x.? It was like a change in the major revision number.? Many things that ran OK previously stopped working when version 24.1.x was introduced.? Any major change like that can have problems.? Telling the folks at Analog Devices why it stops running (or perhaps, it runs but why it does not produce the same output), it might help them restore the functionality that was lost.
?
Andy
?


 

?
It helps to say why it does not run, or what happens when it does run.
?
There were major program changes between LTspice 24.0.x and 24.1.x.? It was like a change in the major revision number.? Many things that ran OK previously stopped working when version 24.1.x was introduced.? Any major change like that can have problems.? Telling the folks at Analog Devices why it stops running (or perhaps, it runs but why it does not produce the same output), it might help them restore the functionality that was lost.
?
Andy
?
Thanks for your suggestion. I will report this issue to them.


 

Hi.
I made an addition to your scheme. This is the calculation of dH/dT by a separate, controlled current source with RC. The resulting value is used to calculate delta. I made a netlist and used it to calculate Qspice. I had to replace the parameter k with k0, because in Qspice k is the Boltzmann constant. At tau=10ns, the counting time was 2.2 seconds. And everything was fine.


 

See file invJAmodel_AB.asc in TEMP folder.


 

开云体育

On 23/04/2025 09:55, Александр Бордодынов via groups.io wrote:
I had to replace the parameter k with k0, because in Qspice k is the Boltzmann constant. At tau=10ns, the counting time was 2.2 seconds. And everything was fine.
k is also defined as Boltzmann's constant in LTspice.

--
Regards,
Tony


 

开云体育

On 23/04/2025 11:00, Tony Casey via groups.io wrote:
On 23/04/2025 09:55, Александр Бордодынов via groups.io wrote:
I had to replace the parameter k with k0, because in Qspice k is the Boltzmann constant. At tau=10ns, the counting time was 2.2 seconds. And everything was fine.
k is also defined as Boltzmann's constant in LTspice.
I should clarify that:

k is pre-defined in LTspice, but only in the waveform viewer, not as a design parameter. Of the defined "constants" (e, pi, k and q) mentioned in the Help, only pi can be used as a design constant.

--
Regards,
Tony


 

开云体育

Maybe even a bit more explanation is necessary. To use the others in a simulation, it is necessary to include a directive, such as '.param k = 1.3806503e-23'. I hope that's right.

On 2025-04-23 10:13, Tony Casey via groups.io wrote:
On 23/04/2025 11:00, Tony Casey via groups.io wrote:
On 23/04/2025 09:55, Александр Бордодынов via groups.io wrote:
I had to replace the parameter k with k0, because in Qspice k is the Boltzmann constant. At tau=10ns, the counting time was 2.2 seconds. And everything was fine.
k is also defined as Boltzmann's constant in LTspice.
I should clarify that:

k is pre-defined in LTspice, but only in the waveform viewer, not as a design parameter. Of the defined "constants" (e, pi, k and q) mentioned in the Help, only pi can be used as a design constant.

--
Regards,
Tony
--
Best wishes John Woodgate RAYLEIGH Essex OOO-Own Opinions Only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


 

开云体育

That's correct.

I'm still left wondering why only pi is defined for analysis. Of course, for "e", it's shorter to define it:

.param e exp(1)

--
Regards,
Tony

On 23/04/2025 11:24, John Woodgate via groups.io wrote:

Maybe even a bit more explanation is necessary. To use the others in a simulation, it is necessary to include a directive, such as '.param k = 1.3806503e-23'. I hope that's right.


 

On Wed, Apr 23, 2025 at 12:55 AM, Александр Бордодынов wrote:
Hi.
I made an addition to your scheme. This is the calculation of dH/dT by a separate, controlled current source with RC. The resulting value is used to calculate delta. I made a netlist and used it to calculate Qspice. I had to replace the parameter k with k0, because in Qspice k is the Boltzmann constant. At tau=10ns, the counting time was 2.2 seconds. And everything was fine.
Thanks!
It looks like the trtol setting played a crucial role—it successfully reduced the oscillations. The reason behind the oscillation of sgn(dHdt) was likely that the tolerance for the derivative was set too tight, causing LTspice to over-focus on the exact value of dHdt. This led to repeated attempts, and during these attempts, the sign kept switching frequently.


 

"pi", "e", "k", ... are short identifiers. The user may want to use these names for node
names/labels or in expressions (K for gain or coupling factor, Pi for input power, e for
error...). This can be hard to find, especially in deeply nested subcircuits or when forgetting
that there is no case-sensitivity, or when brackets are optional.

-marcel


 

开云体育

On 25/04/2025 11:10, mhx via groups.io wrote:
"pi", "e", "k", ...  are short identifiers. The user may want to use these names for node 
names/labels or in expressions (K for gain or coupling factor, Pi for input power, e for
error...). This can be hard to find, especially in deeply nested subcircuits or when forgetting
that there is no case-sensitivity, or when brackets are optional.
You can use anything you like for net names containing any printable Latin character, except these: (? )? {? } ? '? *? = ,? :? ;? and space. My curiosity showed that even many non-Latin characters and "graphics" like ? and ? are accepted, although these are often not printed properly in the waveform window, which is more limited. You never knew your schematics could be so interesting!

If you try to redefine pi (perhaps being unaware it is already defined), it will succeed. Personally, I think that should generate at least a warning. OTOH, "temp" is also predefined and can be overridden legitimately.

--
Regards,
Tony