# FREQ function as LTspice equivalent

Hi folks.

Is there a “Qspice way” to model a complex impedance in frequency (so, only on AC simulation) like LTspice does with the `FREQ` function?

Example of netlist:

``````B1 out 0 V=V(in) FREQ(1,0,0,5,8,45,10,18,0)
V1 in 0 ac 1
.ac dec 100 1 10
.end
``````

The `FREQ` function is totally undocumented on LTspice Help file (and naively I thought also Qspice did in this way), but it’s simple to model complex impedances from large data (like this great tutorial teach me).
I’ve tried (also here naively) with `TABLE(x,a,b,...)` and `LAPLACE` on B sources, but I don’t know how to model arbitrary data with equation.

If someone could help increase my knowledge on Qspice I will really appreciate that!

Thanks in advance and best regards.

This is the method I can think of if you really need R+jX type of impedance expression for .ac analysis
The idea is to use Rs-Ls model for complex impedance Z = Rs+j2pifreq*Ls. User input R and X to calculate Rs and Ls (you will get negative Ls for negative X, in theory/simulation is ok). I add attribute Rpar=0 to Ls, to force Rpar to infinity to eliminate any error introduce in calculation at extreme frequency. This demo also use a table for X value.

I output the plot of re(Z) and im(Z). You better to change y-axis to linear (de-select log). As Waveform Viewer not support Cartesian plot yet, it just plot magnitude and angle. You have to use angle to determine it is +ve or -ve. For example, at 1MHz, im(Z) reads magnitude 10 and phase 180 degree, it represent im(Z) = -10.

1 Like

Post with picture cannot be edit, correct a typo.
@100Hz it read im(Z) magnitude 10 and phase 180 degree (not 1MHz), that represent im(Z)=-10
@1MHz, magnitude 10 and phase 0 degree, represent im(Z)=10
that what the table do to X

As always, thank you @KSKelvin !!

You can also use Laplace G-source to simulate complex impedance. This is same simulation as above but with Laplace G-source to model complex impedance. I put a text explanation in schematic for the derive of this method.

1 Like