checkTHD function
Requirements.ChecksInFixedWindow_withFFT.Internal.checkTHD
· source
MaxTotalHarmonicDistortion's whole evaluation in one call: base frequency, THD, check, icon curves
Extends Modelica.Icons.Function
Performs the complete evaluation of block MaxTotalHarmonicDistortion after an FFT has been computed, in one call:
- findBaseFrequency
determines the real base frequency
f_base2, its amplitudeA_base2and its indexindex_base2inA_buf. - The icon curves
f_base2_lineandfA_plotare computed withA_max_plot = max(A_buf)as top of the plot. - calculateTHD
computes the total harmonic distortion
THDfrom harmonics 2 ..n_harmonics. scaledDistance = THDmax - THD;propertyis Violated ifscaledDistance < 0, otherwise Satisfied ifperiods_okand Undecided if not.
See WithinRelativeDomain for why this is one function rather than several equations in a when-clause.
Inputs
| Name | Type | Description |
|---|---|---|
A_buf[…] input | Real | Amplitudes |
f_resolution input | SI.Frequency | Frequency resolution of A_buf |
f_base input | SI.Frequency | Nominal base frequency |
searchInterval input | Real | in [%] of f_base |
n_harmonics input | Integer | Number of harmonics to take into account |
THDmax input | Real | Total harmonic distortion limit |
f_max_plot input | SI.Frequency | Frequency of the last element of A_buf |
periods_ok input | Boolean | = true, if all FFTs so far covered the required period |
Outputs
| Name | Type | Description |
|---|---|---|
f_base2 output | SI.Frequency | Real base frequency |
A_base2 output | Real | Amplitude at the real base frequency |
index_base2 output | Integer | Index of f_base2 in A_buf |
A_max_plot output | Real | Amplitude at the top of the icon plot (= max(A_buf)) |
f_base2_line[…] output | Real | Vertical line at f_base2 in icon coordinates |
fA_plot[…] output | Real | Amplitude spectrum in icon coordinates |
THD output | Real | Total harmonic distortion |
scaledDistance output | Real | = THDmax - THD |
property output | Property | Result of the check |