> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/analysis/thd.md).

# THD

## Description

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-e18990133d5d7cd74989719c3fd63973c6fe933d%2FTHD_block.png?alt=media" alt=""><figcaption></figcaption></figure>

The **THD** block, located in the **OPAL-RT SPS Software/Sensors and Measurements** library, computes the total harmonic distortion (THD) of a periodic distorted signal. The signal can be a measured voltage or current.

The THD is defined as the root mean square (RMS) value of the total harmonics of the signal, divided by the RMS value of its fundamental signal. For example, for currents, the THD is defined as

$$
\text{total harmonic distortion (THD)} = \frac{I\_{H}}{I\_{F}} \\\[8pt]

# I\_{H}

\sqrt{I\_{2}^{2} + I\_{3}^{2} + \cdots + I\_{n}^{2}}
\quad\text{(RMS value of the harmonic n)}
\\\[8pt]

I\_{F} : \text{RMS value of the fundamental current} \\\[8pt]
$$

The THD has a null value for a pure sinusoidal voltage or current.

## Characteristics

<table data-header-hidden><thead><tr><th width="249.77783203125"></th><th></th></tr></thead><tbody><tr><td><strong>Sample Time</strong></td><td>Specified in the <strong>Sample Time</strong> parameter Continuous if <strong>Sample Time</strong> = 0</td></tr><tr><td><strong>Scalar Expansion</strong></td><td>Yes, of the parameters</td></tr><tr><td><strong>Dimensionalized</strong></td><td>Yes</td></tr></tbody></table>

## Parameters

To edit block parameters interactively, use the Property Inspector. From the Simulink<sup>®</sup> Toolstrip, on the **Simulation** tab, in the **Prepare** gallery, select **Property Inspector**.

<table data-header-hidden><thead><tr><th width="250.11114501953125"></th><th></th></tr></thead><tbody><tr><td><strong>Fundamental frequency of input signal (Hz)</strong> — Frequency of fundamental signal<br><code>60</code> (default) | scalar</td><td>Frequency, in hertz, of the fundamental signal.</td></tr><tr><td><strong>Sample time</strong> — Block sample time<br><code>0</code> (default) | nonnegative scalar</td><td>Sample time of the block, in seconds. Set to 0 to implement a continuous block.</td></tr></tbody></table>

## Examples

The power\_RMS\_THD model uses a THD block to compute the THD of a 60 Hz signal with second harmonic and a DC bias.

The model sample time is parameterized by the Ts variable set to a default value of 50e-6 s.

Set Ts to 0 in the command window to simulate the model in continuous mode.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/analysis/thd.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
