LTspice .four command inconsistent results

If I do reruns with identical circuit and parameters I get variable results like .035% to .022%. I am using gear iteration, and tightened reltol, abstol, vntol, pivtol, which improved results to where I am now stuck. Doing a 200 ms sym with the last 100 ms computing the Fourier transform. Signal is 300 mV and 1 kHz. Anything else I can do or is this just what to expect. For what it’s worth, I am simulating a pp tube power amp.
 
I used both options statements below. They each helped a great deal. not sure which ones on the first line were most important. Strangely, not only did repeatably improve (not perfect) the THD also got much better. Now I get numbers like .0047 to .0052% for the same circuit. the simulation time did not increase significantly.

.options reltol=1e-5 PIVREL=1e-6 NUMDGT=7 VNTOL=1e-8
.options plotwinsize=0 maxstep=.005

Thanks for the help steveu!
 
The maxstep parameter is what's making the difference. The .four command runs an FFT on the last period within the transient results. You need to ensure that you get a reasonable number of data points within that period. I usually use 8192 points, so I set maxstep to 1/(f_max*8192) or 122.07 ns if I'm interested in 1 kHz.

You also need to make sure that the circuit has settled fully before you run the FFT. So maybe run the simulation for 10 full periods and run the FFT on the last period.

Tom
 
Last edited:
I use max step = {1/f/1024} which is about maxstep~= 0.000001 for f=1k and
maxstep ~= 0.0000001 for 10KHz
0.005 is 5 whole cycles at 1KHz
Others have suggested that the max step should be 1/8K of the cycle time {1/f/8192} but I found that I still got 0% THD with 1/1k {1/f/1024}. Eight times as many steps will be 8 times slower to simulate.
Normally there is little point simulating 100 cycles, it just takes longer to simulate. You could argue that you are waiting for DC to settle. The help notes say:
"The Fourier analysis is performed over the period from the final time, Tend, to one period before Tend unless an integer Nperiods is given after Nharmonics. If Nperiods is given as -1, the Fourier analysis is performed over the entire simulation data range."
 
Last edited: