# LTSpice divergence between AC analysis and transient analysis for low frequency gain

A simulation is done in LTSpice (version 4.23k)

There is an inverter: Fig.1: schematic

1mV small-signal input.

AC analysis is run. Low frequency gain (Vout/Vin) is 20.69 dB (10.82 times).

Transient analysis (for the same schematic) is run. The amplitude of the small-signal component of Vout is 47.89 mV. It means low frequency gain is 47.89. Fig.2 Results of simulations

It means, for the DC gain, AC analysis produced 11x, while transient analysis produced 48x. Nearly five time difference!!!

1) Can you explain the divergence?

2) After this, can we rely on LTSpice AC analysis?

• The link to the LTSpice model: yadi.sk/d/p1a-6GlyrjLFn Thanks a lot, folks! – Sergei Gorbikov May 15 '16 at 21:05
• Have you run a dc sweep to check that 2.5 V bias is actually the exact midpoint of the transition in the dc transfer function? – The Photon May 15 '16 at 23:03
• As ThePhoton says ... an inverter is an amplifier, and if you choose the operating point correctly you can get very large gains, but this is very dependant upon the operating point. If you provide feedback to the input from the output so the amplifier self-biases, you will see more uniform results. Use a high value resistor if you want to do this. – placeholder May 16 '16 at 0:42
• @The Photon: yes, I did. It is the midpoint. As Adam Haun mentioned below, he also verified this. – Sergei Gorbikov May 16 '16 at 12:42
• @Sergej, at the moment I cannot explain the discrepancy. But I can assure you that the problem will be NOT caused by the simulator. In 99.9% of all similar problems it is the user who makes errors, false assumptions or inappropriate interpretations of the results. For the same operating point, TRAN as well as AC analyses will give the same results if (a) the TRAN amplitudes are small enough and (b) the operating frequency is low enough not to cause unwanted (additional) effects. – LvW May 16 '16 at 16:22

After playing with this for a while, I think this is due to differences in the way the transient and AC analyses are calculated. I got similar results with different AC voltages, load resistances, and different MOSFET models from MOSIS. I also tried putting the AC and DC voltages in series and removing Rbig and Cbig in case those were causing trouble. I verified that 2.5V is the correct DC bias for your models.

I found poor agreement between the transient gain, AC analysis gain, and DC sweep gain at the midpoint. Agreement was much better (though not great) with a DC bias of 2.6V, which has a gain of around 3.

Here's my reproduction of the difference with the MOSIS models. The gains were 59 for DC, 38 for transient, and 23 for AC. Note the linear vertical scale on the AC analysis plot.     As to which is more correct, it seems to depend on the circumstances. Quoting from a SPICE tutorial:

The small-signal (AC) analysis is performed around the operating point calculated using the OP analysis and it is exactly the same as the manual small-signal analysis. Since the circuit is linearized for this analysis, any distortion, saturation or intermodulation that would occur in the real circuit is not considered by the analysis. The operating point is calculated automatically even if the OP analysis is not specified.

From the next page:

Transient analysis solves the complete nonlinear algebraic-differential equations of a circuit. Effects such as nonlinear distortion, intermodulation, saturation, clipping and oscillations (unstable behaviour) can be modeled with this analysis. Equations are numerically solved by default using the operating point as the initial condition.

And here's a quote from The Designer's Guide to SPICE and Spectre:

AC analysis computes the small-signal behavior of a circuit by first linearizing the circuit about a DC operating point. Since the AC analyses operate on a linear time-invariant representation, the results computed by the AC analyses cannot exhibit the effects normally associated with nonlinear and time-varying circuits: distortion and frequency translation. However, the AC analyses do provide a wealth of information about the linearized circuit and so are invaluable in certain applications. They are also, on the whole, much less tempermental than DC or transient analysis. The AC analyses are not subject to the convergence problems of DC, and the accuracy problems of transient. If the AC analyses are inaccurate, it is almost always because the component models are incorrect.

UPDATE: Based on Placeholder's comments, I tried a 10nV stimulus to see if there was any improvement. The theory behind this would be that a smaller stimulus might avoid recomputation of the operating point during transient analysis, which would bring the results in line with the linearized AC analysis. I changed Rbig to 10MΩ and Cbig to 10mF when I did these; I forget why. Unfortunately, the results are similar, despite obvious quantization problems. The transient gain is ~50 and the AC gain is ~10.  UPDATE 2: Sergei got a response from Mike Engelhardt, the author of LTSpice:

You'll find most SPICE programs have trouble with level 3 AC linearization (which is what AC is reported on). I've fixed most of the problems but some remain. It's one of the reasons that level 3 was obsoleted 25 years ago. Level 3 is no longer used in IC design.

UPDATE 3: Mike sent a follow-up message:

BTW, you can add that I'll look to see if I can improve the issue with level 3 in your case, and I do appreciate your test vector, but you should realized that absolutely every time I see a level 3 question like this, there is never any hardware involved. LTspice is about current circuit design, not digging through obsolete model files.

• You're missing the the part about how the transient analyst actually accomplishes the modelling of nonlinear effects etc. The sparse matrix formed at the start of a transient analysis will be very similar to the one formed as part of the AC analysis. During transient analysis the small signal analysis proceeds until such time as it is determined that the OP has shifted significantly (which is parameter of simulation) as which point a new OP is calculated, a new small signal analysis is performed and new matrix is determined. This is how SPICE can time step through and model properly. Cont'd – placeholder May 16 '16 at 4:22
• Continuation. IF you then use a transient analysis with very small excitation signals, you may not actually shift the OP enough to cause this re-compute cycle. If that is the case, then the AC results will be the very similar to the Transient results. So I conclude by saying that it is possible that is it just the difference between AC and .Tran one cannot rule out that it may just be due to differing OP. I say this because the excitation is very small here. Of course the Posting author can get the tool to dump out the calculated operating points for comparison. – placeholder May 16 '16 at 4:27
• Dear Adam. Thank you so much for the modelling you’ve done and the well-structured answer with links. You reconfirmed the discrepancy! In summary: 1) Results of AC and transient analyses should correspond to one another. So, we have detected the inaccuracy in LTSpice numerical algorithms that lead to such a large discrepancy. From practical standpoint, such a large difference is unacceptable, imho. 2) I’ll email the bug to Linear Technology and will respond here if they reply. Cont'd. – Sergei Gorbikov May 16 '16 at 13:42
• 3) Intuitively, I feel that the key is the wrong operating point used for AC analysis. Note that near the midpoint the derivative of gain with respect to DC voltage is high (that is, the gain is very sensitive to OP). If we take an OP shifted from the 2.5 V midpoint (e.g. 2.3 V for DC input), then the discrepancy is smaller (1.5x/1.4x for AC and transient respectively). Unfortunately I don’t have a tool to unload the OP point used in AC, as placeholder suggested (I also tried to google it w/o success). Cont'd. – Sergei Gorbikov May 16 '16 at 13:42
• Adam, I’ll mark your answer as a solution to the question by tomorrow unless no one responds further. Dear Placeholder, thank you very very much for your hints re operating point. PS: I was very frustrated yesterday, when noticed that my favorite simulator produced crap. However, after you’ve helped me with this, I feel well better (: – Sergei Gorbikov May 16 '16 at 13:42