LTspice .four thd results xxxx% (xxxx%)

Status
Not open for further replies.
Why two figures.
Is the first figure about the harmonics selected while the second is about all not selected ?
Is the first figure the rms value about the selected harmonics ( default is up to 9th harmonic )?
Is the second figure the rms value of all harmonics, not calculated this way but calculated as the rms value of the error signal ( distorted sine signal - perfect dine signal )?
Fiddling on a simulated audioamp, the second number can be higher then the first one, then by limiting the band the second can go to zero.
Another fiddling was to include more an more harmonics. I was expecting the first figure to converge at the second one, unfortunately I saw it going over the second one, can this be because of truncation errors from adding many very small figures.
I think these numbers should be considered with care.
The first one depends of the number of harmonics selected and goes wrong when too many.
The second one which can go about zillion gigahertz
is not realistic in actual système.
Well, how to deal with the numbers considering the actual bandwith of the amplifier.
 
The Help in the LTspice does not give the information.
It gives the syntax of the .four command, explain that it performs a fourrier anaysis but no détail about the thd figures.
I am quite sure the difference has to do with the number of selected harmonics.
Who knows the exact definitions in LTspice ?
 
The way PSPICE performs .FOUR analysis is documented. Maybe/probably LTSPICE does it the same way.

PSPICE fits interpolation polynomials to the transient analysis sampled data; partly for smoothing and partly to interpolate the non-uniform-sampling-interval used in transient analysis.

Then it calculates the best-fit Fourier coefficients of the first N harmonics where N is a user chosen value (default is N=9).

Then it normalizes all coefficients, dividing each of them by the coefficient of the fundamental, the "first harmonic".

Then it squares the normalized coefficients and adds up the squares of harmonics number 2 thru N, omitting the fundamental.

Then it takes the square root and reports this as THD (expressed as percent).

Notice that if you change the number N of harmonics printed, you change the summation and thus you change the reported THD.

These calculations are what LTSPICE reports as its first THD number, the one not in parentheses. You can verify this claim yourself, by slurping the normalized coefficients into Excel and having Excel do the squaring, summing, and square rooting. Voila they match! Do it again with a different number N of harmonics. Voila!

Here comes my total guess / speculation / rectal extraction: the SECOND number, the THD value within parentheses, is LTSPICE's estimate of what THD would be if you had asked for N=Infinity harmonics to be included in the summation. I'm guessing it calculates this a different way, by observing the delta between a perfect ideal sine wave, and the interpolation polynomial smoothed version of the transient analysis output. Like Billy Gibbons warns: I might be mistaken!
 
An example on a 20KHz output with no band limiting.
9 harmonic: thd 0.001745% (0.019%)
9h 0.0017 (0.019)
19h 0.043 (0.023)
29h 0.009 (0.024)
39h 0.012 (0.026)
49h 0.014 (0.025)

Indeed it has to do with the number of selected harmonics, what does they mean ?

With band limiting I can inprove the first figure and zero the second figure
However all this is a lot dependant of the number of selected harmonics.
And here the 49th harmonic of a 20Khz signal makes little sense for an output to a loud speaker.
 
Thanks Mark,

I think the first thd figure is exactly what you explain.
This takes care of the first thd figure.

About the second, I started on the same kind of guess.
RMS (signal - it's fondamental ) that should give the same as RMS( all harmonics ).
But......
Then, the second figure should always be larger than the first figure....How come the second is sometimes zero ? Zero seems in the the cases where, there are few harmonics from band limitation or fast decay.

Another trouble: Selecting more and more harmonics, the first figure should converge to the second. I tried that but got the first go higher than the second, I suspect calculation errors coming from adding too many near zeo values.
This leaves the second thd figure unexplained.

Marc
 
This passage from Larry Nagel's Ph.D. thesis, might be illustrative. He's the guy who wrote SPICE. You can download the whole thesis (here)

_
 

Attachments

  • thesis.png
    thesis.png
    59.7 KB · Views: 721
Hello everyone

There was a fairly long thread about this subject in the Yahoo LTspice group in September 2014 (I actually initiated the thread - my user name there is stephen.kingdom).

https://groups.yahoo.com/neo/groups/LTspice/conversations/topics/79180

It seems that the second figure in brackets is almost certainly the THD for all harmonics and quite possibly noise too, i.e. THD+N.

There are, however, instances where the second figure doesn't appear to make a lot of sense, including instances where it is actually higher than the first non-bracketed figure. However, one has to remember that LTspice, and in fact all SPICE programmes, work by sampling voltages using time steps that are sized dynamically according to need (i.e. there is no constant sampling rate), and that the programme is subject to rounding and other errors in its calculations due to the limitations of machine maths. These limitations, together with the possibility of noise being included in the calculation, may account for the slightly anomalous results sometimes obtained, especially at very low THD levels.

Unfortunately, in the absence of any communication from Mike Engelhardt to the community about the bracketed figure (as far as I am aware), we can do little more than speculate on how it is calculated. Personally, I ignore the bracketed figure and just work with the first figure, which is definitely the result of the .FOUR analysis specified on the schematic.

More generally, don't forget that you have control over the accuracy of simulations. A sinewave of 2V at 10kHz shows THD of 0.011490%(0.081598%), a noise floor (on the fft plot) of around -120dB and quantisation noise with a peak at around -68dB. Now add ".option plotwinsize=0 numdgt=7" and specify a max timestep of 1/(10**8). The THD now measures as 0.000000%(0.000304%), the noise floor is around -330dB and the quantisation noise is pushed out to much higher frequencies with peaks reduced in level to better than -280dB. This strikes me as an excellent result for a sampled sinewave; the penalty, of course, is increased simulation time.

Stephen
 
Thanks Stephen,
I could not ask on the LTspice forum because I don't have access to my account anymore....thanks to Yahoo.....
I am aware of time step, numdgt, plotwinsize, in order to get accurate results.
I'll recheck about those, and I think I will forget about the second thd figure, too.

Marc.
 
Status
Not open for further replies.