# Modelling a transformer in LTspice

I wanted to model a transformer in LTspice. So I searched on internet how to do a transformer in LTspice. I found the following model with the coupled inductor:

But I didn't like this model. (I didn't say that it didn't work) but it is not helpful for understanding how a transformer works. It hides a lot of things. And without a huge knowledge (that I didn't have) of how a transformer works, I think it will lead to me to do errors.

So I decided to find an other model in LTspice. And I found the following from here: http://ltwiki.org/index.php?title=Transformers

Then I tried to understand how it works. I have written what I understand on the picture (at least what I think have understood). Nevertheless according to the model and what I understood there is some differences between the electrical model and the LTspice model. Here is the equivalent electrical model:

What I do not understand :

1. In the electrical model, the voltage across the magnetizing inductance is equal to Vp (primary voltage): $$VLmag = Vp$$ where as in the LTspice model, the voltage across what it seems to be the magnetizing inductance is equal to Vp/Np (Np is the primary number of turn): $$VLmag = \frac{Vp}{Np}$$
2. In the electrical model, the current through the magnetizing inductance is equal to (if I did not do a mistake): $$ILmag = Ip - \frac{NsIs}{Np}$$ where Ip is the primary current, Is is the secondary current, Ilmag is the current through the magnetizing inductance. In the Ltspice model, the current through the "magnetizing inductance" is equal to: $$ILmag = NpIp - NsIs$$

The two formula makes sense to me as when Ilmag is equal to 0 (ideal transformer) we get the current relation of an ideal transformer.

Nevertheless what I do not like is that Lmag from the Ltspice model and from the electrical model seem to be not equal. So if I measure the magnetizing inductance of a transformer I will not be able to simulate it without knowing the relation between the two models.

Thank you very much and have a nice day :D

--------------------------------------------------------------EDIT---------------------------------------------------------------

Here is what I finally have :

• The electrical model doesn't mention Vp (it mentions V1 and it mentions E1). You should use the exact same terminology as the circuit. – Andy aka Apr 21 '20 at 11:06
• Also, I didn't see the LTSpice model in the link. You need to be clear about this Jess. – Andy aka Apr 21 '20 at 11:13
• Both models are correct, but are abstracting away different things, and are best suited to different modelling scenarios. LT model doesn't mention number of turns for instance, and is ideal when k is set to 1. When k=1, X1 and X2 in the other model are zero, becoming finite when the LT model sets k less than 1. It's quite difficult to match all the parameters in the two models up, especially if you are new to transformers. – Neil_UK Apr 21 '20 at 11:19
• Andy, I m sorry... I will change it ! For the LTSpice model, I'm surprised that you do not find it ... Tell me if you didn't see it at this section : "Linear Transformer (linear magnetizing inductance - potentially unlimited energy storage)" – Jess Apr 21 '20 at 12:21
• Neil_UK thank you for your answer. I need to know what is the relation between the Lmag from the LTspice model and the Lmag from the equivalent electric circuit of a transformer as when a magnetizing inductance is measured in a real transformer it represents the one of the equivalent electric model. But I will continue to search :) – Jess Apr 21 '20 at 12:34

In the electrical schematic the magnetizing inductance is on the primary side, while in the LTspice schematic it's separated.

This is because the electrical schematic calculates it based on the number of turns, current, etc, essentially it's the value of the primary side, and then uses an ideal transformer which allows the primary side to be reflected on the secondary side, according to the ratio. This would be suited for the theory that you've shown.

In LTspice, the magnetizing inductance represents the unity inductance (N=1), and then the primary and secondary are determined through the help of an ideal transformer made of a VCVS and a CCCS, each (see the #4th picture in your ltwiki link). The turns are determined through the values of these sources. Thus, the value would have to be divided by the number of turns.

Here's a quick example:

Above is the LTspice version, below is the electrical version. See how the current through the LTspice magnetizing indictance (L1) needs to be divided by the number of turns of the primary to match the current through the electrical version (L2).

• Hi, thank you for your answer. I do not understand, in the LTspice model, the magnetizing inductance is equal to 10 mH, in the equivalent electrical model the magnetizing inductance is 1 H, so for having the same circuit you have to divid by 100 (Np²) the magnetizing inductance of the equivalent electrical model for having the inductance of the LTspice model and then for having the correct current divid by 10 (Np) again. So this is not the same circuit at all ... Or you wanted to say that inductance of the equivalent electrical model is equal to Np times the inductance of the LTspice model ! – Jess Apr 21 '20 at 13:22
• @Jess Yes, L2=10^2*L1, but also F1 has a value of 10, in fact, all the sources have un-squared values of the turns, which means the difference (or ratio) between the two currents will be linear, not squared. I think this is the beauty of it, it avoids possible numerical instablilities by avoiding the use of large numbers. If N=1000 => N^2=1e6, imagine the loss of precision. Still, look over the aswer from VerbalKint, it has a mix of the two methods, and works just as fine. One thing to remember: SPICE world need not be the real world as long as the results are true (or close enough). – a concerned citizen Apr 21 '20 at 14:09
• Thank you for your comment ! – Jess Apr 21 '20 at 14:37

I personally use a simple dc transformer constructed with a current-controlled current source ($$\F\$$ primitive) and a voltage-controlled voltage source ($$\E\$$ primitive). If I am not mistaken, this circuit was introduced by Larry Meares from Intusoft some years ago, circa 80's. See page 114 of this document published by Intusoft for more details. The dc transformer can be used in a variety of applications, including switching power supplies cycle-by-cycle simulations or average modeling. I prefer the version in which the leakage inductance clearly appears as it is easy to modify while a coupling coefficient needs extra computation to extract the leakage term. The below drawing shows the equivalent constructions between a coupling coefficient and the equivalent transformer.

The parameters window in the right-side of the drawing tells you how to calculate the leakage and magnetizing inductances from the coupling coefficients. After the simulation is run, the output voltages and input currents are rigorously identical.

• Thank you for this model and the document that you attached ! I will read this part later. Do you have comments to do about the model from LTwiki ? What I like with this model is that you can simulate the saturation of the core by using an "arbitrary inductor model". It will not take into account hysterisis but It will take into account saturation (i.e no infinite energy storage) But I actually do not implemented in the model above. Maybe later ;) – Jess Apr 21 '20 at 15:29
• Actually if you go through the PDF I linked, you can add saturation effects as well if needed. I usually do not take them into account as I first characterize my transformer and make sure I have comfortable design margin at the highest operating temp. That way I don't need to include these nonlinear effects which may significantly slow down simulation. – Verbal Kint Apr 21 '20 at 15:47
• It is a fairly simple model and it converges well. Good luck with your simulations! – Verbal Kint Apr 22 '20 at 8:50
• Yes, the 0-V source is a dummy source intended to measure the secondary current. F1 uses it to reflect the current to the primary scaled by the turns ratio. A source without voltage indication is 0 V by default. – Verbal Kint Apr 22 '20 at 9:51
• Your VM source should be reversed: the current sourced by E1 must enter the (+) pin. – Verbal Kint Apr 22 '20 at 9:53