Electronic – LTspice – Simulation of a variable inductance

inductanceinductorltspice

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!

Best Answer

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.