Skip to content
LIBRARY
Nonlinear.Tests.DeadZone.md

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

BlockComponents.Nonlinear.Tests.DeadZone()

Behavior

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
Flattened 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


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt