# LTSpice resonant circuit simulation non-idealities

I just simulated the following circuit in ltspice XVII:

A parallel resonant circuit is tuned to 125KHz with varying capacitor sizes. Then a voltage divider is formed with a resistor.

These are my settings for the inductor, capacitor and in the Tool Panel. In my understanding, this should now simulate an ideal inductor without losses and the same for the capacitor.

Using ordinary AC-calculation, the voltage over the resonant circuit should be:

$$V_{res} = V1 * \frac{\frac{1}{\frac{1}{j \omega L} + j \omega C}}{R + \frac{1}{\frac{1}{j \omega L} + j \omega C}}$$ $$= V1 * \frac{1}{R*(j \omega C + \frac{1}{j \omega L}) + 1} = V1 * \frac{1}{j R*(\omega C - \frac{1}{\omega L}) + 1}$$ $$\Rightarrow V_{res} = V1 \quad \forall \quad \omega C = \frac{1}{\omega L} \Rightarrow L = \frac{1}{C \omega^2}$$

So at resonance, when $\omega C = 1/(\omega L)$ the resonant circuit poses an infinite resistance and $V_{res} = V1$.

However, LTSpice gives the following simulation results (where smaller C values yield larger amplitudes):

Now I'm wondering how this is calculated by LTSpice. Are there any non idealities that I didn't switch off? Or am I missing something in my calculation?

Any hints would be very appreciated, Thanks in advance.

• Besides that it might be useful to specify which ltspice version you use, you need to be aware of that any result you get is only an approximation, be it to the ideal or real behavior. Look in the "SPICE" settings tab, there is a lot of knobs to play around. (note that I haven't checked your calculations) – PlasmaHH Jul 12 '17 at 11:42
• You're right, I forgot to include the LTSpice Version. I edited it in the question. I'm using LTSpice XVII. – Felix S Jul 12 '17 at 11:46
• Could it be that you are just not giving enough time for the sinewave to stabilize at a peak of 1. Lowering C increases the Q and, for a high Q resonant filter you will need possibly hundreds of micro seconds to attain full output voltage (not so with low Q values). – Andy aka Jul 12 '17 at 11:51
• Another totally unrelated hint: you can specify '.tran 0 {50m+50u} 50m' as a more convenient way to set the transient timings – PlasmaHH Jul 12 '17 at 11:52
• In the SPICE settings, try setting Reltol to 0.00001 and try again, that should improve things. You should also add .opt numdgt=15 to force into internal doubles, and maybe lowering the max timestep helps too – PlasmaHH Jul 12 '17 at 11:55

Basically how any spice works is that for the next timestep it checks all involved complex formulas and matrices, and if they converge within the required number of iterations into values with error tolerances below those specified with the *tol options, then it will go on. If not, it will lower the timestep and try again, until it either reaches a limit and errors out, or the tolerance is met.
reltol is the paramter used to specify a certain accepted error relative to the next timestep. The error is estimated using a polynomial to "predict" the value at the next chosen timestep, then it is actually computed there, and the difference taken. If its too big, make the timestep smaller.
This also means that instead of those parameters, you can make the simulation more accurate by forcing a really small timestep like 1n but that makes things really really slow, the dynamic timestep feature is one of the things that make it much faster.
Together with trtol (which specifies a factor on overestimation of the actual error) these are the major knobs you want to play with to either make the simulation more accurate, or faster.
Additionally, ltspice internally uses floats, so sometimes .opt numdgt=7 (anything over 6) is needed to force it to use doubles instead, which may or may not make things more accurate.