**[EDIT Thu 1 Dec, 2022]**

In my studies I have developed models for more general cases of nonlinear systems with memory effects, more representative of real audio amplifiers. Won by curiosity, I have also investigated the trend of THD and IMD also for these cases, deriving a method to indirectly estimate the HD1 and then correct their values.

*THD and IMD calculation in dynamic nonlinear systems*

We broaden the previous study by addressing the more general case of dynamic nonlinear systems, in which memory effects occur. These systems are able to simulate both linear (the classic changes of magnitude and phase of frequency response) and nonlinear effects, that is, the appearance of new harmonics and related intermodulation products generated by the nonlinear interactions of the tones present in the source signal. In this respect they differ from static systems (without memory) in that in these the magnitudes of distortions are frequency-independent and can only take two predefined values in the phases. Dynamic systems remove both of these limitations. A ‘black-box’ model like that of Volterra-Hammerstein allows you to describe its behavior well when the nonlinear effects are small (< 1%), therefore close to the reality of good audio amplifiers.

Briefly, the system is modeled as the sum of input signal processing by *n* streams. Each one models the contributions of *i*-order distortion, and is composed of two cascading parts. The first is constituted by the application of a function (always a polynomial of degree *i*) to the signal that models the nonlinear part; the second part instead models the memory effects through a "classic" linear time-invariant (LTI) system. The diagram, limited for simplicity to the modeling of the 2nd and 3rd harmonic only, is as follows:

*Fig. 6 – Hammerstein-Volterra model, for 2nd and 3rd order distortions.*

The output *y*(*t*) relative to the input *x*(*t*) can be calculated using the following formula:

Where '*' represents the convolution operation and the h

*i*(*t*) functions represent the Kernel, with the following meaning:

- h1(
*t*): impulsive response of the system, dual of the classic frequency response H1(*f*) of the system.
- h2(
*t*), h3(*t*): impulsive responses respectively relating to the 2nd and 3rd order distortion associated with the relative harmonics.

To focus on the main aspects in the following simulations H1(*f*) is chosen so that it is unitary on all frequencies, while H2(*f*) and H3(f) (the transforms of h2(*t*) and h3(*t*)) are calculated so as to create the 2nd and 3rd harmonic distortions with the desired magnitude and phase values, constants over all bandwidth. This is due to real amplifiers with wide bandwidth and constant distortions in audio band (not unusual situation).

With these hypotheses we start by studying the behavior of 2nd order distortion when it varies its phase on a signal with a single tone. In static systems HD2 is -90 degrees compared to fundamental when positive and +90 degrees when negative. Since the 2nd order distortion is composed of DC+HD2, even if HD2 is out of phase, the DC will not undergo any change (it is a real value). So for the 2nd order we will only have a translation in time of the distortion curve, as reported in fig. 7 for some phase shift values.

*Fig. 7 – Source tone (first track) and 3rd order distortion component amplified for phase by steps of -90, -45, 0, 45 and 90 degrees (upper tracks from above).*

For the 3rd order distortion, more interesting things happen. We have seen that in static systems HD3 is 180 degrees compared to fundamental when positive (with expansive effect) and 0 degrees when negative (with compressive effect). Since the 3rd order distortion is composed of HD1+HD3, if HD3 is out of phase, HD1 will also be affected by the same phase shift (we assumed constant H3(*f*) in magnitude and phase). Since HD1 and HD3 have different frequencies, a phase shift of the same amount will cause a change in the waveform over time (to observe only a translation over time it is necessary that the phase shifts are in the same ratio of the frequencies of the tones, here 1:3). Figure 8 shows the waveform of the distortion when the HD3 phase assumes 180, 135, 90, 45, and 0 degrees. Of course these translations alter the resulting curve over time.

*Fig. 8 – Source tone (first track) and 3rd order distortion component amplified for phase by steps of 180, 135, 90, 45, and 0 degrees (upper tracks from above).*

The following curve shows the phase shift of HD1 compared to HD3 and the ratio between the magnitudes.

*Fig. 9 – HD1/HD3 magnitude and HD1 phase for a single tone, HD3 = -60dB, depending on its phase.*

The graph essentially tells us that when the HD3 phase changes, the HD1 contribution to the fundamental is constant in the magnitude but has a variable phase that depends linearly on it. This causes alterations to the fundamental harmonic that still remain small. To get an idea, the following figure shows the changes in module and phase of the fundamental when HD3 assumes a high value, -40dB (THD = 1%).

*Fig. 10 – Magnitude and phase variations of H1+HD1/HD1 for a single tone, HD3 = -40dB, depending on its phase.*

The trend is of a sinusoidal type. We observe that:

- When the phase changes, the fundamental will undergo amplitude changes of ±0.25dB while; by performing some calculations, the phase changes determine a group delay in low frequency that can reach an excursion of ±0.2ms (not very far from what is believed to be the threshold of hearing); for HD3 = -60dB (THD = 0.1%) these values are reduced by 10 times.
- The frequency of the tone is irrelevant, as we have assumed that the phase of distortion is independent of it. If this is not true we will also have HD1 variable with the frequency and therefore, in the presence of complex signals each of the component tones will be altered in magnitude and phase of different values (even if low, as described in the previous point), despite the level of the 3rd harmonic is constant throughout the audio band.

What is described results in saying that the phase changes introduced by dynamic systems in 2nd and 3rd order distortions do not cause appreciable changes in the value of THD. It follows that we can go back to what has already been studied in the case of static systems, where the ‘error’ in the calculation of the THD, due to not considering HD1, depends only on the ratio of the level of distortions of 2nd and 3rd order. The values to be applied can be found in the graph in fig. 2, calculating the difference between the True-THD and THD curve (up to about 10dB, when the 3rd harmonic is predominant).

For classic intermodulation tests (IMD) with two-tone tests the situation gets complicated, but not too much. The ‘luck’ is due to the fact that the two tones used in the tests generate distinct intermodulation products for 2nd and 3rd order of distortion, as shown in the figures below for the SMPTE and CCIF tests.

*Fig. 11 – Simulation of the SMPTE test (two tones at 60Hz and 7KHz in a ratio of 4:1), with HD2 = HD3 = -40dB.*
*Fig. 12 – CCIF test simulation (two tones at 19KHz and 20KHz in 1:1 ratio), with HD2 = HD3 = -40dB.*

There is no overlap between the harmonics created by the two orders of distortion: each set is in its own and therefore a possible change in the phases of distortions does not cause alterations in the level of any harmonic. As a result, the IMD test will also be independent of the 2nd and 3rd order distortion phases. Here too, this does not imply that these do not have impacts on the resulting curve in time.

The summary of the above is shown in Figure 13, which shows the extent of the corrections to be applied to THD and IMD for the SMPTE and CCIF tests as a function of the ratio of the distortion level between 3rd and 2nd harmonic, considering the entire spectrum. The distortion values are calculated on the signal in the time domain (for Parseval's theorem, the result is equivalent to the classical one calculated in the frequency domain), still by the simulator of fig. 6. We remind that the extent of the correction does not depend on the absolute level of distortions.

*Fig. 13 – THD and IMD test correction according to HD3/HD2 ratio.*

Therefore, even in the more general case of dynamic nonlinear systems, the contributions of 3rd order distortion to the fundamental (HD1) remain, resulting in variable errors in THD or IMD if taken as a measure of the extent of the overall distortions introduced by the non-linearities of a system. These errors are negligible (below 1dB) as long as HD3 is at least 15dB lower than HD2.

Strictly speaking, to complete the picture we should also include higher-order distortions in the analysis. In this more general case the models tell us that the order of distortion *i*-th is composed of the harmonics of order *i*, *i* – 2, *i* – 4, and so on. Thus, the harmonics of the highest orders will ‘interfer’ with those relating to the lowest orders. The classic measurements of THD and IMD already measure all this by referring to harmonics, again with the exception of the HD1 component, which is affected by all odd order distortions. The model described in fig. 6, extended to the highest orders, makes it possible to trace the magnitude of HD1, and thus the corrections to be made to THD and IMD for any value of the phase shift. Unfortunately, the results cannot be summarized in simple graphs, given the number of variables in play: the same calculations as the simulator must be performed. To get an idea of the complexity and extent of the quantities involved, the following graphs illustrate what happens to HD1 (similar to the graph in fig. 9) in the presence of distortions of even the 4th and 5th order as the phase of HD3 varies and HD5/HD3 ratio (HD2 and HD4 do not affect graphics). The first graph shows the HD1 module, where the 0dB reference is compared to the situation where the 4th and 5th order are not present; the second reports HD1 phase.

*Fig. 14 – Amplitude impacts on HD1 per HD3 phase and HD5/HD3 ratio.*
*Fig. 15 – HD1 phase per HD3 phase and HD5/HD3 ratio.*

It is evident that the trend is not exactly monothonic and with no small oscillations. Fortunately, in most real amplifiers under normal working conditions the harmonics of the 2nd and 3rd harmonic distortions are predominant over the others (20dB or more), so the contribution of the higher harmonics cause negligible impacts to the graph of fig. 13.