> 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/total-harmonic-distortion.md).

# Total Harmonic Distortion

## Description

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

The **Total Harmonic Distortion** block, located in the **OPAL-RT SPS Software/powerlib\_extras/Measurements** library, measures the total harmonic distortion (THD) of a periodic distorted signal. The signal can be a measured voltage or current.

{% hint style="info" %}
The Measurements section of the Control and Measurements library contains the **THD block**. This is an improved version of the Total Harmonic Distortion block. The new block features a mechanism that eliminates duplicate continuous and discrete versions of the same block by basing the block configuration on the simulation mode. If your legacy models contain the Total Harmonic Distortion block, they continue to work. However, for best performance, use the THD block in your new models.
{% endhint %}

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) }= I\_H/I\_F
$$

where

$$
I\_H=\sqrt{I\_2^2 +I\_3^2+....I\_n^2}
$$

where

*I*<sub>*n*</sub> =RMS value of the harmonic *n*\
*I*<sub>*F*</sub>= RMS value of the fundamental current.

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

## Parameters

<table data-header-hidden><thead><tr><th width="250.33331298828125"></th><th></th></tr></thead><tbody><tr><td><strong>Fundamental frequency</strong></td><td>The frequency, in hertz, of the fundamental signal.</td></tr></tbody></table>

### Inputs and Outputs

<table data-header-hidden><thead><tr><th width="249.888916015625"></th><th></th></tr></thead><tbody><tr><td><strong>signal</strong></td><td>Connect this input to the voltage or current you want to measure the total harmonic distortion.</td></tr><tr><td><strong>THD</strong></td><td>The output returns the THD of the input signal.</td></tr></tbody></table>


---

# 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/total-harmonic-distortion.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.
