WOLFRAM SYSTEM MODELER

TotalHarmonicDistortion

Output the total harmonic distortion (THD)

Diagram

Wolfram Language

In[1]:=
SystemModel["Modelica.Blocks.Math.TotalHarmonicDistortion"]
Out[1]:=

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

This block determines the total harmonic distortion (THD) over the given period 1/f. Consider that the input u consists of harmonic RMS components U1, U2, U3, etc. The total RMS component is then determined by:

The calculation of the total harmonic distortion is based on the parameter useFirstHarmonic. The default value useFirstHarmonic = true represents the standard THD calculation used in electrical engineering. The non-default value useFirstHarmonic = false calculates the THD typically used for the assessment of audio signals.

If useFirstHarmonic = true, the total higher harmonic content (harmonic order numbers > 1) refers to the RMS value of the fundamental wave:

If useFirstHarmonic = false, the total higher harmonic content (harmonic order numbers > 1) refers to the total RMS:

In case of a zero input signal or within the first period of calculation, the boolean output signal valid becomes false to indicate that the calculation result is not valid. Valid calculations are indicated by valid = true.

Parameters (2)

f

Value:

Type: Frequency (Hz)

Description: Base frequency

useFirstHarmonic

Value: true

Type: Boolean

Description: THD with respect to first harmonic, if true; otherwise with respect to total RMS

Connectors (3)

u

Type: RealInput

Description: Connector of Real input signal

y

Type: RealOutput

Description: Connector of Real output signal

valid

Type: BooleanOutput

Description: True, if output y is valid

Components (9)

harmonic

Type: Harmonic

Description: Calculate harmonic over period 1/f

rootMeanSquare

Type: RootMeanSquare

Description: Calculate root mean square over period 1/f

greaterThreshold

Type: GreaterThreshold

Description: Output y is true, if input u is greater than threshold

division

Type: Division

Description: Output first input divided by second input

limiter

Type: Limiter

Description: Limit the range of a signal

pythagoras

Type: Pythagoras

Description: Determine the hypotenuse or leg of a right triangle

andValid

Type: And

Description: Logical 'and': y = u1 and u2

booleanExpression

Type: BooleanExpression

Description: Set output signal to a time varying Boolean expression

switch1

Type: Switch

Description: Switch between two Real signals

Used in Examples (1)

TotalHarmonicDistortion

Modelica.Blocks.Examples

Calculation of total harmonic distortion of voltage