checkTHD function

Requirements.ChecksInFixedWindow_withFFT.Internal.checkTHD  · source

Icon of checkTHD

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:

  1. findBaseFrequency determines the real base frequency f_base2, its amplitude A_base2 and its index index_base2 in A_buf.
  2. The icon curves f_base2_line and fA_plot are computed with A_max_plot = max(A_buf) as top of the plot.
  3. calculateTHD computes the total harmonic distortion THD from harmonics 2 .. n_harmonics.
  4. scaledDistance = THDmax - THD; property is Violated if scaledDistance < 0, otherwise Satisfied if periods_ok and Undecided if not.

See WithinRelativeDomain for why this is one function rather than several equations in a when-clause.

Inputs

NameTypeDescription
A_buf[…] inputRealAmplitudes
f_resolution inputSI.FrequencyFrequency resolution of A_buf
f_base inputSI.FrequencyNominal base frequency
searchInterval inputRealin [%] of f_base
n_harmonics inputIntegerNumber of harmonics to take into account
THDmax inputRealTotal harmonic distortion limit
f_max_plot inputSI.FrequencyFrequency of the last element of A_buf
periods_ok inputBoolean= true, if all FFTs so far covered the required period

Outputs

NameTypeDescription
f_base2 outputSI.FrequencyReal base frequency
A_base2 outputRealAmplitude at the real base frequency
index_base2 outputIntegerIndex of f_base2 in A_buf
A_max_plot outputRealAmplitude at the top of the icon plot (= max(A_buf))
f_base2_line[…] outputRealVertical line at f_base2 in icon coordinates
fA_plot[…] outputRealAmplitude spectrum in icon coordinates
THD outputRealTotal harmonic distortion
scaledDistance outputReal= THDmax - THD
property outputPropertyResult of the check