---
url: /dyad/stable/stdlib/BlockComponents/tests/Nonlinear.Tests.DeadZone.md
description: Dyad Nonlinear.Tests.DeadZone docs.  Test harness for the DeadZone block.
---

# `Nonlinear.Tests.DeadZone` {#Nonlinear.Tests.DeadZone}

Test harness for the DeadZone block.

A sine (amplitude 2, frequency 1) sweeps the input through and beyond both dead zones over one period, so the trajectory covers: inside-zone output = 0, positive excess (`u - uMax`), and negative excess (`u - uMin`).

Two instances are driven by the same source:

* `dz_sym` — symmetric default zone `uMax = 1`, `uMin = -1`. Peaks give `y = ±1` (excess of 1 beyond each limit); `y = 0` while `|u| <= 1`.

* `dz_asym` — asymmetric zone `uMax = 2`, `uMin = -0.5`. The input peak (+2) only touches the upper limit, so the positive side stays ~0, while the trough (-2) gives `y = -1.5`. Verifies the two limits act independently.

## Usage {#Usage}

`BlockComponents.Nonlinear.Tests.DeadZone()`

## Behavior {#Behavior}

$$ \begin{align}
0 &= \mathrm{connect}\left( sine\_{+}y, dz\_{sym\_{+}u} \right) \\
0 &= \mathrm{connect}\left( sine\_{+}y, dz\_{asym\_{+}u} \right) \\
\mathtt{sine.y}\left( t \right) &= ifelse\left( \mathtt{sine.continuous}, ifelse\left( t \geq \mathtt{sine.start_time}, \sin\left( \mathtt{sine.phase} + 6.2832 ~ \mathtt{sine.frequency} ~ \left(  - \mathtt{sine.shift_time} + t \right) \right), \sin\left( \mathtt{sine.phase} + 6.2832 ~ \mathtt{sine.frequency} ~ \left(  - \mathtt{sine.shift_time} + \mathtt{sine.start_time} \right) \right) \right) ~ \mathtt{sine.amplitude}, ifelse\left( t \geq \mathtt{sine.start_time}, \sin\left( \mathtt{sine.phase} + 6.2832 ~ \mathtt{sine.frequency} ~ \left(  - \mathtt{sine.shift_time} + t \right) \right) ~ \mathtt{sine.amplitude}, 0 \right) \right) + \mathtt{sine.offset} \\
\mathtt{dz_sym.y}\left( t \right) &= ifelse\left( \mathtt{dz_sym.uMax} < \mathtt{dz_sym.u}\left( t \right), \mathtt{dz_sym.u}\left( t \right) - \mathtt{dz_sym.uMax}, ifelse\left( \mathtt{dz_sym.u}\left( t \right) < \mathtt{dz_sym.uMin}, \mathtt{dz_sym.u}\left( t \right) - \mathtt{dz_sym.uMin}, 0 \right) \right) \\
\mathtt{dz_asym.y}\left( t \right) &= ifelse\left( \mathtt{dz_asym.uMax} < \mathtt{dz_asym.u}\left( t \right), \mathtt{dz_asym.u}\left( t \right) - \mathtt{dz_asym.uMax}, ifelse\left( \mathtt{dz_asym.u}\left( t \right) < \mathtt{dz_asym.uMin}, \mathtt{dz_asym.u}\left( t \right) - \mathtt{dz_asym.uMin}, 0 \right) \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Test harness for the DeadZone block.

A sine (amplitude 2, frequency 1) sweeps the input through and beyond both dead
zones over one period, so the trajectory covers: inside-zone output = 0,
positive excess (`u - uMax`), and negative excess (`u - uMin`).

Two instances are driven by the same source:
- `dz_sym` — symmetric default zone `uMax = 1`, `uMin = -1`. Peaks give
  `y = ±1` (excess of 1 beyond each limit); `y = 0` while `|u| <= 1`.
- `dz_asym` — asymmetric zone `uMax = 2`, `uMin = -0.5`. The input peak (+2)
  only touches the upper limit, so the positive side stays ~0, while the trough
  (-2) gives `y = -1.5`. Verifies the two limits act independently.
"""
test component DeadZone
  "Sine sweeping in and out of both dead zones"
  sine = BlockComponents.Sources.Sine(amplitude = 2, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 120, "x2": 120, "y2": 220, "rot": 0}
      }
    }
  }
  "Symmetric dead zone (uMax = 1, uMin = -1)"
  dz_sym = BlockComponents.Nonlinear.DeadZone() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 20, "x2": 320, "y2": 120, "rot": 0}
      }
    }
  }
  "Asymmetric dead zone (uMax = 2, uMin = -0.5)"
  dz_asym = BlockComponents.Nonlinear.DeadZone(uMax = 2, uMin = -0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 220, "x2": 320, "y2": 320, "rot": 0}
      }
    }
  }
relations
  connect(sine.y, dz_sym.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 170, "y": 170}, {"x": 170, "y": 70}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(sine.y, dz_asym.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 170, "y": 170}, {"x": 170, "y": 270}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["sine.y", "dz_sym.y", "dz_asym.y"]}}
    }
  }
}
end
```

```dyad
"""
Test harness for the DeadZone block.

A sine (amplitude 2, frequency 1) sweeps the input through and beyond both dead
zones over one period, so the trajectory covers: inside-zone output = 0,
positive excess (`u - uMax`), and negative excess (`u - uMin`).

Two instances are driven by the same source:
- `dz_sym` — symmetric default zone `uMax = 1`, `uMin = -1`. Peaks give
  `y = ±1` (excess of 1 beyond each limit); `y = 0` while `|u| <= 1`.
- `dz_asym` — asymmetric zone `uMax = 2`, `uMin = -0.5`. The input peak (+2)
  only touches the upper limit, so the positive side stays ~0, while the trough
  (-2) gives `y = -1.5`. Verifies the two limits act independently.
"""
test component DeadZone
  "Sine sweeping in and out of both dead zones"
  sine = BlockComponents.Sources.Sine(amplitude = 2, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 120, "x2": 120, "y2": 220, "rot": 0}
      }
    }
  }
  "Symmetric dead zone (uMax = 1, uMin = -1)"
  dz_sym = BlockComponents.Nonlinear.DeadZone() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 20, "x2": 320, "y2": 120, "rot": 0}
      }
    }
  }
  "Asymmetric dead zone (uMax = 2, uMin = -0.5)"
  dz_asym = BlockComponents.Nonlinear.DeadZone(uMax = 2, uMin = -0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 220, "x2": 320, "y2": 320, "rot": 0}
      }
    }
  }
relations
  connect(sine.y, dz_sym.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 170, "y": 170}, {"x": 170, "y": 70}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(sine.y, dz_asym.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 170, "y": 170}, {"x": 170, "y": 270}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["sine.y", "dz_sym.y", "dz_asym.y"]}}
    }
  }
}
end
```

## Test Cases {#Test-Cases}

### Test Case `case1` {#Test-Case-case1}

```julia
plt
```

![](brlnjmx.svg)

```julia
plt
```

![](pvcexah.svg)

```julia
plt
```

![](qmvtslw.svg)

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`DeadZone`](Nonlinear.Tests.DeadZone.md)

  * [`DeadZone`](Nonlinear.Tests.DeadZone.md)

  * [`Sine`](Nonlinear.Tests.DeadZone.md)
