1
\$\begingroup\$

I would like to better understand how LTspice works with the variable inductor defined by using the flux through it. I have some troubles to understand why according to the above post the formula of the flux as to be integrated... It is said that it is internally integrated? What does it mean? Does it mean that LTspice is observing dI and not i(t)?

How to model an inductor using a behavioural voltage source in LTspice (to get time-dependent inductors)?

Here is the formula according to the Faraday's Law and the relation between the voltage and the variation of current across an inductance:

$$d(Flux) = \frac{L}{N}dI$$

If we time integrate the above equation, we obtain:

$$Flux(t) = \frac{L}{N}i(t)$$

And that is the relation that we have to enter into LTspice. So in this case we have to integrate if we have a relation in function of dI.

According to me, I think that by observing the current $$i_{L}(t)$$ LTspice tries to adjust the coefficient $$\frac{L}{N}$$ in order to maintain the above relation equal.

So suppose I want to modelize an inductance. I know how the permeability change according to the excitation field H: $$µ(H) = µ(H=0)*f(H)$$ where f is a function which I know

Then, $$B = uH$$

If I consider that the magnetic field is homogenous over the all surface of the inductance S, I can say that $$Flux = B/S$$

Then If I do the same approximation about H around a wire but on a curve l: $$H = NI/l$$

I can say that: $$Flux = \frac{NI}{lS}*[µ(H=0)*f(\frac{NI}{l})]$$

In this case we do not have to integrate the relation for having the flux. Isn't it? What do you think?

Thank you and have a nice day!

\$\endgroup\$
4
  • \$\begingroup\$ May I ask why you are wanting to do this Jess? \$\endgroup\$ – Andy aka Dec 21 '20 at 10:06
  • \$\begingroup\$ For simulating an inductance on LTspice. You think that it is probably negligeable regarding the rest of the circuit ? Whatever the circuit, I want to understand ! :) \$\endgroup\$ – Jess Dec 21 '20 at 10:19
  • \$\begingroup\$ @Jess Have you checked the other link from the one in your post? In short, x is a keyword for the current through the inductor, and since its formula is a derivative, making that derivative act like a normal function is through integration. It's also in the help, under LTspice > Circuit Elements > L. Inductor? \$\endgroup\$ – a concerned citizen Dec 22 '20 at 16:41
  • \$\begingroup\$ @aconcernedcitizen I checked the link but I did not really understand, x is equal to the derivative of the current dI, so LTspice is measuring the derivative of the current and not just the current. So in order to make my formula "understable" for LTspice i need to integrate the formula in function of I and then LTspice will derivate it for having the formula in function of the current I ? \$\endgroup\$ – Jess Dec 23 '20 at 7:29
3
\$\begingroup\$

The behavioural inductor accepts expressions that are time-dependent. There is a keyword, x, signifying the current through the inductor, which is nothing but a shortcut for I(L1) (assuming some L1). For behavioural capacitors, x is the voltage across them, and in both cases the behavioural expressions are solved is by applying a partial derivative w.r.t. each variable (from LTspice > Circuit Elements > C. Capacitor):

LTspice will compile this expression and symbolically differentiate it with respect to all the variables, finding the partial derivative's that correspond to capacitances.

This means that, in order for a behavioural expression to reflect the desired change, it needs to be integrated, first.

So, for example, if the inductance needs to vary according to the mathematical expression

$$f(x)=-2x^3+3x^2+1$$

(with x being time), then the behavioural expression needs to be integrated first, resulting in

$$g(x)=-\dfrac12x^4+x^3+x$$

To test this, apply a unity current ramp (which results in the derivative of the current as 1) and read the voltage across the inductor (overlapping voltages have been shifted by a small amount):

test

La has the raw equation as its behavioural expression, and V(a) shows a parabola identical to what B2 shows, V(c2), which means the interpreted result is

$$h(x)=-6x^2+6x=\dfrac{\text{d}}{\text{d}x}f(x)$$

Lb has \$g(x)\$ as its behvioural expression, which means the voltage across it, V(b), is the same as the one supplied by B1, V(c). And, since the example implied the usage of time as the variable x, Lb2 shows that the voltage across it, V(b2), reflects the integrated expression with time as the variable. If another quantity would have been needed instead of x, such as a voltage, or a current, or any other time-dependent expression, it would have to be integrated, first.

Caution is needed when dealing with expressions, since they are, usually, within a bounded interval. Exceeding the limits may have very unpleasant consequences, and I don't mean the kind that are visible (voltages going sky-high, or similar), but the kind that are insiduous and give apparent good results, yet wrong -- the best debugging sessions. In this case, x (and, thus, time) is assumed to vary between [0...1], which means that simulating with .tran 2 will show software fireworks, but for time≤1.5 the results will seem correct.

Be careful when handling the mathematical expressions in LTspice: -x**4 will not give you what you expect (see the paragraph below the boolean table in the help: LTspice > Circuit Elements > B.). You will need to write them in the two ways shown: with appropriate parenthesis, or with a multiplier in front of it (dummy or not).


I would have replied to your comment, but this information should be added here, better. While x does signify the current through the inductor, using I(La) as the current through La is not a good idea, because of the following quote from the help (LTspice > Circuit Elements > B., the 3rd point):

[...] it is assumed that the circuit element current is varying quasi-statically, that is, there is no instantaneous feedback between the current through the referenced device and the behavioral source output.

I(La) meets the above condition, so the proper, 40+ year old way to use the current through a device is to add a series, zero valued voltage source as a sensor, then use that current, in the same way a CCCS (F source) or CCVS (H source) would be used.

Now, LTspice considers inductors as voltage sources, so it is possible to avoid the use of a series voltage source as a current sensor (e.g. a CCCS would have the value La 1), but not in this case, because of the quote above. Therefore, using I(La) may (most probably will) result in an error -- best use x.

OTOH, if, for example, the inductance needs to vary according to some external voltage, then there is no need to use x, but the expression still needs to be integrated. If the voltage varies according to a known mathematical function, the behavioural expression for Flux= can be derived and written, explicitely, otherwise something along these lines should be used, where G1 and C1 act as a unity integrator:

test2

The same slight offset has been applied, like in the picture above, for the same reason. Note that, due to the internal derivative, there may be initial spikes of MV or similar, lasting some 1 ns, hence the 1 ms skipped time in .tran 0 1 1m. Otherwise the response is right.

\$\endgroup\$
9
  • \$\begingroup\$ Thank you for this answer ! I will take some times to understand it completely ;) \$\endgroup\$ – Jess Dec 23 '20 at 11:10
  • \$\begingroup\$ So I could replace x (if x is equal to time) by I(La) for example in the expression of the flux ? I will try to take example of your simulation to better understand ! Thank you very much for this example ! \$\endgroup\$ – Jess Dec 23 '20 at 15:25
  • \$\begingroup\$ @Jess I've updated my answer since it required a bit more to say than it would have fit in a comment. If you think there are foggy areas, feel free to ask; my English is known to make people ponder for hours, sometimes. \$\endgroup\$ – a concerned citizen Dec 23 '20 at 16:47
  • \$\begingroup\$ Thank you for this second update ! I really appreciate your support and I learn many things. About your english, there is no problem :) My english is not as good as that of you. If i conclude I understand that I cannot adjust the value of the inductance in function of the current according to the statement that you have mentionned if I used I(La) (supposing the inductance is named La) but the variable x is equal to the current through the inductance. But if I look the first answer (the one not edited) of my question you said that x was equal to "time". \$\endgroup\$ – Jess Dec 25 '20 at 18:24
  • \$\begingroup\$ And you prove it by applying the same formula across a behavioral voltage source and replacing "x" by "time". So I have some troubles to understand that "x" is equal to the "current". Suppose the current is null through the inductance in function of the time, I do not want to see my inductance varying as the time is passing while the current is null... There is something that I do not undersand :( BTW, Merry Christmas ;) \$\endgroup\$ – Jess Dec 25 '20 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.