---
url: /dyad/dev/stdlib/BlockComponents/components/Continuous.SecondOrder.md
description: >-
  Dyad Continuous.SecondOrder docs.  Second-order filter with configurable gain,
  bandwidth, and damping ratio.
---

# `Continuous.SecondOrder` {#Continuous.SecondOrder}

Second-order filter with configurable gain, bandwidth, and damping ratio.

A filter that implements a second-order transfer function with configurable gain k, bandwidth w, and relative damping d. The filter can be configured to achieve different response characteristics by adjusting the damping ratio: critically damped (d=1), under-damped (d<1), or over-damped (d>1). A damping value of d=1/√2 creates a Butterworth filter with maximally flat frequency response. The filter is characterized by the transfer function

$$Y(s)/U(s) = \frac{k \cdot w^2}{s^2 + 2d \cdot w \cdot s + w^2}$$

This component extends from [`BlockComponents.Interfaces.SISO`](../types/Interfaces.SISO.md)

## Usage {#Usage}

`BlockComponents.Continuous.SecondOrder(k=1.0, w=1.0, d=1.0)`

## Parameters: {#Parameters:}

| Name |                   Description | Units | Default value |
| ----:| -----------------------------:| -----:| -------------:|
|  `k` |                          Gain |     – |           1.0 |
|  `w` | Bandwidth (angular frequency) |     – |           1.0 |
|  `d` |              Relative damping |     – |           1.0 |

## Connectors {#Connectors}

* `u` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Variables {#Variables}

| Name |                            Description | Units |
| ----:| --------------------------------------:| -----:|
|  `x` |            State of SecondOrder filter |     – |
| `xd` | Derivative state of SecondOrder filter |     – |

## Behavior {#Behavior}

$$ \begin{align}
\frac{\mathrm{d}x\left( t \right)}{\mathrm{d}t} &= \mathtt{xd}\left( t \right) \\
\frac{\mathrm{d}\mathtt{xd}\left( t \right)}{\mathrm{d}t} &= \left(  - 2 ~ d ~ \mathtt{xd}\left( t \right) + \left(  - x\left( t \right) + k ~ u\left( t \right) \right) ~ w \right) ~ w \\
y\left( t \right) &= x\left( t \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
Second-order filter with configurable gain, bandwidth, and damping ratio.

A filter that implements a second-order transfer function with configurable gain k,
bandwidth w, and relative damping d. The filter can be configured to achieve different
response characteristics by adjusting the damping ratio: critically damped (d=1),
under-damped (d<1), or over-damped (d>1). A damping value of d=1/√2 creates a Butterworth
filter with maximally flat frequency response. The filter is characterized by the transfer
function

```math
Y(s)/U(s) = \frac{k \cdot w^2}{s^2 + 2d \cdot w \cdot s + w^2}
```
"""
component SecondOrder
  extends BlockComponents.Interfaces.SISO
  "State of SecondOrder filter"
  variable x::Real(stateSelect = StateSelect.Prefer)
  "Derivative state of SecondOrder filter"
  variable xd::Real(stateSelect = StateSelect.Prefer)
  "Gain"
  parameter k::Real = 1.0
  "Bandwidth (angular frequency)"
  parameter w::Real = 1.0
  "Relative damping"
  parameter d::Real = 1.0
relations
  der(x) = xd
  der(xd) = w * (w * (k * u - x) - 2 * d * xd)
  y = x
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/SecondOrder.svg"}
  }
}
end
````

````dyad
"""
Second-order filter with configurable gain, bandwidth, and damping ratio.

A filter that implements a second-order transfer function with configurable gain k,
bandwidth w, and relative damping d. The filter can be configured to achieve different
response characteristics by adjusting the damping ratio: critically damped (d=1),
under-damped (d<1), or over-damped (d>1). A damping value of d=1/√2 creates a Butterworth
filter with maximally flat frequency response. The filter is characterized by the transfer
function

```math
Y(s)/U(s) = \frac{k \cdot w^2}{s^2 + 2d \cdot w \cdot s + w^2}
```
"""
component SecondOrder
  "Input signal port"
  u = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0},
        "diagram": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      }
    }
  }
  "Output signal port"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "State of SecondOrder filter"
  variable x::Real(stateSelect = StateSelect.Prefer)
  "Derivative state of SecondOrder filter"
  variable xd::Real(stateSelect = StateSelect.Prefer)
  "Gain"
  parameter k::Real = 1.0
  "Bandwidth (angular frequency)"
  parameter w::Real = 1.0
  "Relative damping"
  parameter d::Real = 1.0
relations
  der(x) = xd
  der(xd) = w * (w * (k * u - x) - 2 * d * xd)
  y = x
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/SecondOrder.svg"}
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Constant`](Continuous.SecondOrder.md)

  * [`SecondOrder`](Continuous.SecondOrder.md)

  * [`SecondOrder`](Continuous.SecondOrder.md)
