> 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/filters/second-order-filter.md).

# Second Order Filter

## Description

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

The **Second Order Filter** block, located in the **OPAL-RT SPS Software/Control/Filters** library, implements second-order filter, based on the **Filter type** selected in the block menu, the Second-Order Filter block implements the following transfer function:

Low-pass filter:

$$
H(s) = \frac{\omega\_{n}^{2}}{s^{2} + 2 \zeta \omega\_{n} s + \omega\_{n}^{2}} \\\[8pt]
$$

High-pass filter:

$$
H(s) = \frac{s^{2}}{s^{2} + 2 \zeta \omega\_{n} s + \omega\_{n}^{2}} \\\[8pt]
$$

Band-pass filter:

$$
H(s) = \frac{2 \zeta \omega\_{n} s}{s^{2} + 2 \zeta \omega\_{n} s + \omega\_{n}^{2}} \\\[8pt]
$$

Band-stop (notch) filter:

$$
H(s) = \frac{s^{2} + \omega\_{n}^{2}}{s^{2} + 2 \zeta \omega\_{n} s + \omega\_{n}^{2}} \\\[8pt]
$$

where\
$$s$$:Laplace operator\
$$\omega\_{n}$$: natural frequency $$\omega\_{n} = 2\pi f\_{n}$$\
$$\zeta$$ : damping ratio}

The key characteristics of the Second-Order Filter block are:

* Input accepts a vectorized input of N signals, implementing N filters. This feature is particularly useful for designing controllers in three-phase systems (N = 3).
* Filter states can be initialized for specified DC and AC inputs.
* It enables you to compute and plot filter response.

## Characteristics

<table data-header-hidden><thead><tr><th width="250.22216796875">Direct Feedthrough</th><th></th></tr></thead><tbody><tr><td>Direct Feedthrough</td><td>Yes</td></tr><tr><td>Sample Time</td><td>Specified in the <strong>Sample Time</strong> parameter Continuous if <strong>Sample Time</strong> = 0</td></tr><tr><td>Scalar Expansion</td><td>Yes, of the parameters</td></tr><tr><td>States</td><td>Two states per filter</td></tr><tr><td>Dimensionalized</td><td>Yes</td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="249.888916015625"></th><th></th></tr></thead><tbody><tr><td><strong>Filter type</strong> — Type of filter<br>Bandpass (default) | Lowpass | Highpass | Bandstop (notch)</td><td>Specify the type of filter: Lowpass, Highpass, Bandpass (default), or Bandstop (notch).</td></tr><tr><td><strong>Natural frequency fn (Hz)</strong> — Natural frequency of filter<br>120 (default) | scalar | vector</td><td>Natural frequency of the filter, in hertz.</td></tr><tr><td><strong>Damping ratio Zeta (Q = 1/(2*Zeta))</strong> — Damping ratio of filter<br>0.707 (default) | scalar in the range [0, 1]</td><td><p>Damping ratio of the filter. The damping ratio is typically a value between 0 and 1.</p><p>The damping ratio is related to the filter quality factor Q:</p><p><span class="math">\\[8pt]Q=\frac{1}{2\zeta}\\[8pt]</span></p><p>For a bandpass or a bandstop filter, the 3 dB bandwidth is given by</p><p><span class="math">\\[8pt]BW=\frac{f_n}{Q}=2\zeta f_n\\[8pt]</span></p></td></tr><tr><td><strong>Sample time</strong> — Block sample time<br>0 (default) | nonnegative scalar</td><td>Sample time of the block, in seconds. Set to 0 to implement a continuous block.</td></tr><tr><td><strong>Initialize filter states</strong> — Option to initialize filter states<br>on (default) | off</td><td>Select this parameter to initialize the filter states according to the <strong>AC initial input</strong> and <strong>DC initial input</strong> parameters.</td></tr><tr><td><strong>AC initial input: [ Mag, Phase (degrees), Freq (Hz) ]</strong> — Magnitude, phase, and frequency of initial AC component<br>[0, 0, 60] (default) | vector of three elements | matrix of N-by-3 elements</td><td><p>Magnitude of the initial AC component of the input signal, its phase, in degrees, and its frequency, in hertz.</p><p>When the input is vectorized (N signals), specify an N-by-3 matrix, where each row of the matrix corresponds to a particular input.</p><p><strong>Dependencies</strong> To enable this parameter, select the <strong>Initialize filter states</strong> parameter.</p></td></tr><tr><td><strong>DC initial input</strong> — Initial DC component of input signal<br>0 (default) | vector of 1-by-N elements</td><td><p>Initial DC component of the input signal. When the input signal is vectorized, specify a 1-by-N vector, where each value corresponds to a particular input.</p><p>The <strong>DC initial input</strong> parameter is visible only when the <strong>Initialize filter states</strong> parameter is selected.</p><p><strong>Dependencies</strong> To enable this parameter, select the <strong>Initialize filter states</strong> parameter.</p></td></tr><tr><td><strong>Plot filter response</strong> — Option to plot filter response<br>off (default) | on</td><td>Select this parameter to plot the filter step response and its Bode diagram (magnitude and phase of transfer function as a function of frequency) in a figure.</td></tr><tr><td><strong>Frequency range (Hz): [Start, End, Inc.]</strong> — Frequency range for plotting filter Bode diagram<br>[0, 500, 1] (default) | vector of three elements</td><td><p>Frequency range for plotting the filter Bode diagram. Specify a vector containing the starting frequency, the end frequency, and the incremental frequency, in hertz.</p><p><strong>Dependencies</strong> To enable this parameter, select the <strong>Plot filter response</strong> parameter.</p></td></tr></tbody></table>

## Examples

The power\_SecondOrderFilter example shows the Second-Order Filter block using two **Filter type** parameter settings (Lowpass and Bandstop).

The model sample time is parameterized with variable Ts (default value Ts = 50e-6). To simulate continuous filters, specify Ts = 0 in the MATLAB® Command Window before starting the simulation.


---

# 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/filters/second-order-filter.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.
