> 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-variable-tuned.md).

# Second-Order Filter (Variable-Tuned)

## Description

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

The **Second-Order Filter (Variable-Tuned)** block, located in the **OPAL-RT SPS Software/Control/Filters** library, implements second-order variable-tuned filter. Depending on the **Filter type** selected in the block menu, the Second-Order Filter block implements the following transfer function. The Fn input determines the filter natural frequency $$f\_n=\omega\_n/(2\pi)$$ of the filter.

Lowpass filter:

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

Highpass filter:

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

Bandpass filter:

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

Bandstop (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}

## Parameters

<table data-header-hidden><thead><tr><th width="249.22216796875"></th><th></th></tr></thead><tbody><tr><td><strong>Filter type</strong></td><td>Specify the type of filter: Lowpass, Highpass, Bandpass, or Bandstop (Notch) (default).</td></tr><tr><td><strong>Initial natural frequency fn (Hz)</strong></td><td>The initial natural frequency of the filter, in hertz. This value must be a scalar or a vector. Default is 120.</td></tr><tr><td><strong>Damping ratio Zeta (Q = 1/(2*Zeta))</strong></td><td><p>Specify the damping ratio of the filter. The damping ratio is typically a value between 0 and 1. Default is 0.707. 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></td><td>Specify the sample time of the block, in seconds. Set to 0 to implement a continuous block. Default is 0.</td></tr><tr><td><strong>Initialize filter states</strong></td><td><p>When this check box is selected, filter states are initialized according to the <strong>AC initial input</strong> and <strong>DC initial input</strong> parameters.</p><p>Default is selected.</p></td></tr><tr><td><strong>AC initial input: [ Mag, Phase (degrees), Freq (Hz) ]</strong></td><td><p>Specify the magnitude of the initial AC component of the input signal, its phase, in degrees, and its frequency, in hertz. Default is [0, 0, 60].</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>The <strong>AC initial input</strong> parameter is visible only when the <strong>Initialize filter states</strong> parameter is selected.</p></td></tr><tr><td><strong>DC initial input</strong></td><td><p>Specify the value of the 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. Default is 0.</p><p>The <strong>DC initial input</strong> parameter is visible only when the <strong>Initialize filter states</strong> parameter is selected.</p></td></tr></tbody></table>

## Inputs and Outputs

The inputs accept vectorized signals of N values, thus implementing N filters. This capability is particularly useful for designing controllers in three-phase systems (N = 3).

## Characteristics

<table data-header-hidden><thead><tr><th width="250.11114501953125"></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>

## Examples

The power\_SecondOrderFilterTuned example shows various uses of the Second-Order Filter (Variable-Tuned) block with 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-variable-tuned.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.
