开云体育

THD 0.000000%?


 

Why does THD give me zero when partial THD is 0.003792%?? What am I doing wrong?
Fourier components of ?v(out)
N-Period=60
DC component:-0.000986685
Harmonic ? ?Frequency ? ? Fourier ? ? Normalized ? ? Phase ? ? ?Normalized
?Number ? ? ? [Hz] ? ? ? Component ? ? Component ? ?[degree] ? ?Phase [deg]
? ? 1 ? ? ? ?2.000e+04 ? ? 1.005e+01 ? ? 1.000e+00 ? ? ? 94.00?° ? ? ? ?0.00?°
? ? 2 ? ? ? ?4.000e+04 ? ? 3.651e-04 ? ? 3.633e-05 ? ? ? 96.11?° ? ? ? ?2.11?°
? ? 3 ? ? ? ?6.000e+04 ? ? 9.642e-05 ? ? 9.596e-06 ? ? ? -0.69?° ? ? ?-94.69?°
? ? 4 ? ? ? ?8.000e+04 ? ? 3.907e-05 ? ? 3.888e-06 ? ? ?-99.48?° ? ? -193.48?°
? ? 5 ? ? ? ?1.000e+05 ? ? 1.996e-05 ? ? 1.986e-06 ? ? ?169.62?° ? ? ? 75.62?°
? ? 6 ? ? ? ?1.200e+05 ? ? 1.518e-05 ? ? 1.511e-06 ? ? ? 77.47?° ? ? ?-16.53?°
? ? 7 ? ? ? ?1.400e+05 ? ? 1.444e-05 ? ? 1.437e-06 ? ? ?-43.42?° ? ? -137.42?°
? ? 8 ? ? ? ?1.600e+05 ? ? 6.600e-06 ? ? 6.568e-07 ? ? -102.82?° ? ? -196.82?°
? ? 9 ? ? ? ?1.800e+05 ? ? 1.347e-05 ? ? 1.341e-06 ? ? -120.04?° ? ? -214.04?°
Partial Harmonic Distortion: 0.003792%
Total Harmonic Distortion: ? 0.000000%


 

开云体育

Please upload your .asc file, with associated models and symbols, to the Files->Temp- folder.
Without it, we need a crystal ball.

Le 03/02/2025 à 03:58, rlim701 via groups.io a écrit?:

Why does THD give me zero when partial THD is 0.003792%?? What am I doing wrong?
Fourier components of ?v(out)
N-Period=60
DC component:-0.000986685
Harmonic ? ?Frequency ? ? Fourier ? ? Normalized ? ? Phase ? ? ?Normalized
?Number ? ? ? [Hz] ? ? ? Component ? ? Component ? ?[degree] ? ?Phase [deg]
? ? 1 ? ? ? ?2.000e+04 ? ? 1.005e+01 ? ? 1.000e+00 ? ? ? 94.00?° ? ? ? ?0.00?°
? ? 2 ? ? ? ?4.000e+04 ? ? 3.651e-04 ? ? 3.633e-05 ? ? ? 96.11?° ? ? ? ?2.11?°
? ? 3 ? ? ? ?6.000e+04 ? ? 9.642e-05 ? ? 9.596e-06 ? ? ? -0.69?° ? ? ?-94.69?°
? ? 4 ? ? ? ?8.000e+04 ? ? 3.907e-05 ? ? 3.888e-06 ? ? ?-99.48?° ? ? -193.48?°
? ? 5 ? ? ? ?1.000e+05 ? ? 1.996e-05 ? ? 1.986e-06 ? ? ?169.62?° ? ? ? 75.62?°
? ? 6 ? ? ? ?1.200e+05 ? ? 1.518e-05 ? ? 1.511e-06 ? ? ? 77.47?° ? ? ?-16.53?°
? ? 7 ? ? ? ?1.400e+05 ? ? 1.444e-05 ? ? 1.437e-06 ? ? ?-43.42?° ? ? -137.42?°
? ? 8 ? ? ? ?1.600e+05 ? ? 6.600e-06 ? ? 6.568e-07 ? ? -102.82?° ? ? -196.82?°
? ? 9 ? ? ? ?1.800e+05 ? ? 1.347e-05 ? ? 1.341e-06 ? ? -120.04?° ? ? -214.04?°
Partial Harmonic Distortion: 0.003792%
Total Harmonic Distortion: ? 0.000000%


 

开云体育

Which version of LTspice are you using? If it's 24.1.anything, it may be another bug to report.

On 2025-02-03 02:58, rlim701 via groups.io wrote:
Why does THD give me zero when partial THD is 0.003792%?? What am I doing wrong?
Fourier components of ?v(out)
N-Period=60
DC component:-0.000986685
Harmonic ? ?Frequency ? ? Fourier ? ? Normalized ? ? Phase ? ? ?Normalized
?Number ? ? ? [Hz] ? ? ? Component ? ? Component ? ?[degree] ? ?Phase [deg]
? ? 1 ? ? ? ?2.000e+04 ? ? 1.005e+01 ? ? 1.000e+00 ? ? ? 94.00?° ? ? ? ?0.00?°
? ? 2 ? ? ? ?4.000e+04 ? ? 3.651e-04 ? ? 3.633e-05 ? ? ? 96.11?° ? ? ? ?2.11?°
? ? 3 ? ? ? ?6.000e+04 ? ? 9.642e-05 ? ? 9.596e-06 ? ? ? -0.69?° ? ? ?-94.69?°
? ? 4 ? ? ? ?8.000e+04 ? ? 3.907e-05 ? ? 3.888e-06 ? ? ?-99.48?° ? ? -193.48?°
? ? 5 ? ? ? ?1.000e+05 ? ? 1.996e-05 ? ? 1.986e-06 ? ? ?169.62?° ? ? ? 75.62?°
? ? 6 ? ? ? ?1.200e+05 ? ? 1.518e-05 ? ? 1.511e-06 ? ? ? 77.47?° ? ? ?-16.53?°
? ? 7 ? ? ? ?1.400e+05 ? ? 1.444e-05 ? ? 1.437e-06 ? ? ?-43.42?° ? ? -137.42?°
? ? 8 ? ? ? ?1.600e+05 ? ? 6.600e-06 ? ? 6.568e-07 ? ? -102.82?° ? ? -196.82?°
? ? 9 ? ? ? ?1.800e+05 ? ? 1.347e-05 ? ? 1.341e-06 ? ? -120.04?° ? ? -214.04?°
Partial Harmonic Distortion: 0.003792%
Total Harmonic Distortion: ? 0.000000%
-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

Virus-free.


 

No need for sorcery here. Any experienced LTspice user can tell from these numbers that this is most likely a machine precision issue.
.four is a post-processing step. It works with the numbers stored in the .raw file as single precision by default. That's only 6.5 decimal digits.
Try again with
?
.options numdgt=16
?
If that doesn't work, get the crystal ball ready.
?
Best Regards,
Mathias
?
On Mon, Feb 3, 2025 at 09:04 AM, Jerry Lee Marcel wrote:

Please upload your .asc file, with associated models and symbols, to the Files->Temp- folder.
Without it, we need a crystal ball.

Le 03/02/2025 à 03:58, rlim701 via groups.io a écrit?:
Why does THD give me zero when partial THD is 0.003792%?? What am I doing wrong?
Fourier components of ?v(out)
N-Period=60
DC component:-0.000986685
Harmonic ? ?Frequency ? ? Fourier ? ? Normalized ? ? Phase ? ? ?Normalized
?Number ? ? ? [Hz] ? ? ? Component ? ? Component ? ?[degree] ? ?Phase [deg]
? ? 1 ? ? ? ?2.000e+04 ? ? 1.005e+01 ? ? 1.000e+00 ? ? ? 94.00?° ? ? ? ?0.00?°
? ? 2 ? ? ? ?4.000e+04 ? ? 3.651e-04 ? ? 3.633e-05 ? ? ? 96.11?° ? ? ? ?2.11?°
? ? 3 ? ? ? ?6.000e+04 ? ? 9.642e-05 ? ? 9.596e-06 ? ? ? -0.69?° ? ? ?-94.69?°
? ? 4 ? ? ? ?8.000e+04 ? ? 3.907e-05 ? ? 3.888e-06 ? ? ?-99.48?° ? ? -193.48?°
? ? 5 ? ? ? ?1.000e+05 ? ? 1.996e-05 ? ? 1.986e-06 ? ? ?169.62?° ? ? ? 75.62?°
? ? 6 ? ? ? ?1.200e+05 ? ? 1.518e-05 ? ? 1.511e-06 ? ? ? 77.47?° ? ? ?-16.53?°
? ? 7 ? ? ? ?1.400e+05 ? ? 1.444e-05 ? ? 1.437e-06 ? ? ?-43.42?° ? ? -137.42?°
? ? 8 ? ? ? ?1.600e+05 ? ? 6.600e-06 ? ? 6.568e-07 ? ? -102.82?° ? ? -196.82?°
? ? 9 ? ? ? ?1.800e+05 ? ? 1.347e-05 ? ? 1.341e-06 ? ? -120.04?° ? ? -214.04?°
Partial Harmonic Distortion: 0.003792%
Total Harmonic Distortion: ? 0.000000%


 

开云体育

But surely that issue would not find a THD less than the partial THD up to the 9th harmonic?

On 2025-02-03 11:11, Mathias Born via groups.io wrote:
No need for sorcery here. Any experienced LTspice user can tell from these numbers that this is most likely a machine precision issue.
.four is a post-processing step. It works with the numbers stored in the .raw file as single precision by default. That's only 6.5 decimal digits.
Try again with
?
.options numdgt=16
?
If that doesn't work, get the crystal ball ready.
?
Best Regards,
Mathias
?
On Mon, Feb 3, 2025 at 09:04 AM, Jerry Lee Marcel wrote:

Please upload your .asc file, with associated models and symbols, to the Files->Temp- folder.
Without it, we need a crystal ball.

Le 03/02/2025 à 03:58, rlim701 via groups.io a écrit?:
Why does THD give me zero when partial THD is 0.003792%?? What am I doing wrong?
Fourier components of ?v(out)
N-Period=60
DC component:-0.000986685
Harmonic ? ?Frequency ? ? Fourier ? ? Normalized ? ? Phase ? ? ?Normalized
?Number ? ? ? [Hz] ? ? ? Component ? ? Component ? ?[degree] ? ?Phase [deg]
? ? 1 ? ? ? ?2.000e+04 ? ? 1.005e+01 ? ? 1.000e+00 ? ? ? 94.00?° ? ? ? ?0.00?°
? ? 2 ? ? ? ?4.000e+04 ? ? 3.651e-04 ? ? 3.633e-05 ? ? ? 96.11?° ? ? ? ?2.11?°
? ? 3 ? ? ? ?6.000e+04 ? ? 9.642e-05 ? ? 9.596e-06 ? ? ? -0.69?° ? ? ?-94.69?°
? ? 4 ? ? ? ?8.000e+04 ? ? 3.907e-05 ? ? 3.888e-06 ? ? ?-99.48?° ? ? -193.48?°
? ? 5 ? ? ? ?1.000e+05 ? ? 1.996e-05 ? ? 1.986e-06 ? ? ?169.62?° ? ? ? 75.62?°
? ? 6 ? ? ? ?1.200e+05 ? ? 1.518e-05 ? ? 1.511e-06 ? ? ? 77.47?° ? ? ?-16.53?°
? ? 7 ? ? ? ?1.400e+05 ? ? 1.444e-05 ? ? 1.437e-06 ? ? ?-43.42?° ? ? -137.42?°
? ? 8 ? ? ? ?1.600e+05 ? ? 6.600e-06 ? ? 6.568e-07 ? ? -102.82?° ? ? -196.82?°
? ? 9 ? ? ? ?1.800e+05 ? ? 1.347e-05 ? ? 1.341e-06 ? ? -120.04?° ? ? -214.04?°
Partial Harmonic Distortion: 0.003792%
Total Harmonic Distortion: ? 0.000000%
-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

Virus-free.


 

Don't underestimate the intricacies of floating point math:
?
?
Partial and harmonic distortion are calculated very differently. If the result is dominated by rounding errors, anything is possible.
?
Best Regards,
Mathias
?
On Mon, Feb 3, 2025 at 12:24 PM, John Woodgate wrote:

But surely that issue would not find a THD less than the partial THD up to the 9th harmonic?


 

开云体育

What could be simpler? ?

On 2025-02-03 12:12, Mathias Born via groups.io wrote:
Don't underestimate the intricacies of floating point math:
?
?
Partial and harmonic distortion are calculated very differently. If the result is dominated by rounding errors, anything is possible.
?
Best Regards,
Mathias
?
On Mon, Feb 3, 2025 at 12:24 PM, John Woodgate wrote:

But surely that issue would not find a THD less than the partial THD up to the 9th harmonic?

-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

Virus-free.


 

On Mon, Feb 3, 2025 at 06:24 AM, John Woodgate wrote:

But surely that issue would not find a THD less than the partial THD up to the 9th harmonic?

Those two results are calculated quite differently.? That's why it can be less.
?
The Partial THD calculation that includes only the first N harmonics does it by first calculating the component at each harmonic, then adding them up, RMS-wise.
?
The Total THD calculation ignores the harmonics that could be calculated at each harmonic.? Instead, it compares the level of the calculated fundamental against the level of the whole signal.? Because of limited accuracy/resolution, if the calculated fundamental's amplitude happens to be equal to or greater than the RMS voltage or current of the raw signal, then it has to conclude that it must have zero harmonic content.? Think of it as meaning "less than I can determine".? When the numbers are this close, when the contribution of the harmonics is so small, then it becomes limited by numerical resolution.
?
Andy
?


 

开云体育

Thanks, Andy. I can understand why that was done a long time ago, when calculation speeds and memory capacity were far less than now. But it's obviously dangerous in principle to use two different algorithms, and that has now surfaced. I have used .FOUR to evaluate over 40 harmonics in a 'noiseless' simulation, with no speed or memory issues. I can see a problem if LTspice is asked, in error, to calculate THD over a bandwidth which includes noise at a level greater than -10dB relative to the nearest (in frequency) harmonic, but that condition could be caught and flagged.

On 2025-02-03 17:42, Andy I via groups.io wrote:
On Mon, Feb 3, 2025 at 06:24 AM, John Woodgate wrote:

But surely that issue would not find a THD less than the partial THD up to the 9th harmonic?

Those two results are calculated quite differently.? That's why it can be less.
?
The Partial THD calculation that includes only the first N harmonics does it by first calculating the component at each harmonic, then adding them up, RMS-wise.
?
The Total THD calculation ignores the harmonics that could be calculated at each harmonic.? Instead, it compares the level of the calculated fundamental against the level of the whole signal.? Because of limited accuracy/resolution, if the calculated fundamental's amplitude happens to be equal to or greater than the RMS voltage or current of the raw signal, then it has to conclude that it must have zero harmonic content.? Think of it as meaning "less than I can determine".? When the numbers are this close, when the contribution of the harmonics is so small, then it becomes limited by numerical resolution.
?
Andy
?
-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying


 

On Mon, Feb 3, 2025 at 01:06 PM, John Woodgate wrote:

Thanks, Andy. I can understand why that was done a long time ago, when calculation speeds and memory capacity were far less than now. But it's obviously dangerous in principle to use two different algorithms, and that has now surfaced. I have used .FOUR to evaluate over 40 harmonics in a 'noiseless' simulation, with no speed or memory issues. I can see a problem if LTspice is asked, in error, to calculate THD over a bandwidth which includes noise at a level greater than -10dB relative to the nearest (in frequency) harmonic, but that condition could be caught and flagged.

Most .TRAN simulations have no noise whatsoever, so that should rarely be a problem.? But there is math 'noise' to contend with.
?
Personally, I would not have called it 'dangerous' that it calculates the two (T)HD numbers differently; but that may be because I know and understand that the methods are different.? In some respects it is not that different than knowing that a smaller timestep almost always helps accuracy, even when all the frequencies are so low that such a small timestep "should" not be necessary.? We who have used LTspice for a while realize that this is not always the case.
?
Andy
?


 

开云体育

I meant math noise, but of course simulated electronic noise would have a similar effect.

On 2025-02-03 19:56, Andy I via groups.io wrote:
On Mon, Feb 3, 2025 at 01:06 PM, John Woodgate wrote:

Thanks, Andy. I can understand why that was done a long time ago, when calculation speeds and memory capacity were far less than now. But it's obviously dangerous in principle to use two different algorithms, and that has now surfaced. I have used .FOUR to evaluate over 40 harmonics in a 'noiseless' simulation, with no speed or memory issues. I can see a problem if LTspice is asked, in error, to calculate THD over a bandwidth which includes noise at a level greater than -10dB relative to the nearest (in frequency) harmonic, but that condition could be caught and flagged.

Most .TRAN simulations have no noise whatsoever, so that should rarely be a problem.? But there is math 'noise' to contend with.
?
Personally, I would not have called it 'dangerous' that it calculates the two (T)HD numbers differently; but that may be because I know and understand that the methods are different.? In some respects it is not that different than knowing that a smaller timestep almost always helps accuracy, even when all the frequencies are so low that such a small timestep "should" not be necessary.? We who have used LTspice for a while realize that this is not always the case.
?
Andy
?
-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

Virus-free.


 

Alright, guys.? I uploaded heng-24v.asc and heng-models.txt.? I have a 'throw_cycles' parameter that throws away cycles before doing .four.? If I set that to 100, I see THD=0.002% but when I set that to >1000, reported THD is always 0.000000%.? Setting numdgt to 16 did not make a difference.
Thanks in advance,
Richard


 

Richard,
?
You forgot to upload the symbol file LG_single.asy.? We can't see your whole schematic, nor run the simulation, without it.? If you forgot the symbol, you might have forgotten its model too.
?
It makes perfect sense that throwing away more cycles (waiting for things to stabilize) results in lower distortion.
?
It also makes sense that there is a point at which you just can't make the calculations any better.
?
Which version of LTspice are you using?? There are known bugs with NUMDGT in the latest version, 24.1.1 - which is turning out to be a major disaster, by the way.
?
Andy
?


 

Richard,
?
I don't know if this makes any difference (since I can't try your simulation).? I am only suggesting it as something to try.? Your simulation saves data for 61 cycles, then it asks the .FOUR to calculate harmonics over exactly 61 cycles.? But what if round-off causes the simulated interval to be ever slightly smaller than 61 cycles?? Can you save data for 61 cycles, then set the .FOUR's Ncycles to 60?
?
Andy
?


 

Just uploaded LG_single.asc.? It did not make any difference whether I am using version 24.0.12 or 24.1.1.? Andy, I think I see where you are going.? Still trying to digest your post.....


 

开云体育

Are you sure you uploaded the right schematic? LG_single.asc doesn't even have an analysis directive. It just looks like a loop probe, which designed to be used in .AC analyses, anyway.

--
Regards,
Tony


On 03/02/2025 21:57, rlim701 via groups.io wrote:

Just uploaded LG_single.asc.? It did not make any difference whether I am using version 24.0.12 or 24.1.1.? Andy, I think I see where you are going.? Still trying to digest your post.....


 

开云体育

Sorry, I missed that it is supposed to be used with another schematic.

For future reference, it is best to upload all required files packaged in a zip, not separately. that makes it easier and more convenient for sharing.

--
Regards,
Tony




On 03/02/2025 23:07, Tony Casey wrote:

Are you sure you uploaded the right schematic? LG_single.asc doesn't even have an analysis directive. It just looks like a loop probe, which designed to be used in .AC analyses, anyway.


 

开云体育

Is there a good reason why you are performing the the .FOUR over 61 cycles? You don't get a more accurate answer using more cycles. Unless you have some time-varying perturbation going on, why not use .FOUR with its default setting, which is 1 cycle? Try that and see if it fixes your issue.

--
Regards,
Tony


On 03/02/2025 21:14, rlim701 via groups.io wrote:

Alright, guys.? I uploaded heng-24v.asc and heng-models.txt.? I have a 'throw_cycles' parameter that throws away cycles before doing .four.? If I set that to 100, I see THD=0.002% but when I set that to >1000, reported THD is always 0.000000%.? Setting numdgt to 16 did not make a difference.


 

On Mon, Feb 3, 2025 at 03:57 PM, <rlim701@...> wrote:
Just uploaded LG_single.asc.
That's good -- but it does not fully help.? Your main schematic (heng-24v.asc) wants to load the symbol named "LG_single".? That symbol is a file named "LG_single.asy", which is still on your computer only.? None of the rest of the world can try your simulation because none of the rest of us has that symbol file.
?
Maybe you don't want us to try your simulation, and that is sort of OK if it's true.? But wouldn't it help to give us all the parts so that we can try it?? Sometimes, someone else may discover something that a single pair of eyes doesn't find.
?
As it appears, that symbol file represents the lower-level hierarchical block in the schematic "LG_single.asc".? So we now have THAT file.? But we are still missing the symbol that represents that lower schematic on your main schematic.? Without it, there's a hole in your schematic and some missing current paths, causing the distortion to exceed 1%.
?
Andy
?


 

Sorry.? Just uploaded LG_single.asy.? If missing, it could be shorted out in the schematic.? Anyway, I think Andy is correct in that I was asking .FOUR to perform exactly 61 cycles and I suspect the end time was perhaps one point short of 61 cycles.? when I added 1us to the end time, I was able to get a THD that is non-zero.
Thanks everyone!
?
Richard