Test_Switch_GreaterThan Test_Switch_GreaterThan Icon

Test_Switch_GreaterThan

Usage

PrimitiveComponents.Test_Switch_GreaterThan()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( sine_{+}y(t), switch_{_{+}input\_primary(t)} \right) \\ \mathrm{connect}\left( constant1_{+}y(t), switch_{_{+}input\_secondary(t)} \right) \\ \mathrm{connect}\left( sine_{+}y(t), switch_{_{+}switch\_primary(t)} \right) \\ \mathtt{switch\_.switch\_position}\left( t \right) = ifelse\left( \mathtt{switch\_.switch\_primary}\left( t \right) > \mathtt{switch\_.threshold}, \mathtt{switch\_.input\_primary}\left( t \right), \mathtt{switch\_.input\_secondary}\left( t \right) \right) \\ \mathtt{sine.y}\left( t \right) = \mathtt{sine.offset} + \mathtt{sine.amplitude} ifelse\left( t \geq \mathtt{sine.start\_time}, \sin\left( \mathtt{sine.phase} + 6.2832 \mathtt{sine.frequency} \left( - \mathtt{sine.start\_time} + t \right) \right), \sin\left( \mathtt{sine.phase} \right) \right) \\ \mathtt{constant1.y}\left( t \right) = \mathtt{constant1.k} \\ \end{array} \right] \end{equation} \]

Source

# This test demonstrates the behavior of the `Switch_Greater_Than_equal` component.
#
# The test connects a sine wave signal (`sine.y`) as both the `switch_primary` and `input_primary`,
# and a constant signal (`constant1.y`) with value 0 as the `input_secondary`.
# Since Threshold = 0, the switch output behaves as:
#   - When sine.y > 0 → output = sine.y  (passes through the sine wave)
#   - When sine.y < 0 → output = 0  
#
# Now Only the peaks of the sine wave above the threshold (1.0) appear at the output.
# The lower portion of the sine wave (below or equal to 1.0) is clipped to zero.
# This creates a **clipped positive waveform**, where only higher values of the sine wave pass through.
component Test_Switch_GreaterThan
  switch_ = PrimitiveComponents.Switches.PositionSwitch_Greater(threshold = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 580, "y1": 500, "x2": 680, "y2": 600, "rot": 0}
      }
    }
  }
  sine = BlockComponents.Sine(amplitude = 2, frequency = 0.2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 300, "x2": 320, "y2": 400, "rot": 0}
      }
    }
  }
  constant1 = BlockComponents.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 210, "y1": 650, "x2": 310, "y2": 750, "rot": 0}
      }
    }
  }
relations
  connect(switch_.input_primary, sine.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 449, "y": 513}, {"x": 449, "y": 350}], "E": 2}]}
  }
  connect(constant1.y, switch_.input_secondary) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 444, "y": 700}, {"x": 444, "y": 582}], "E": 2}]}
  }
  connect(switch_.switch_primary, sine.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 449, "y": 550}, {"x": 449, "y": 350}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_Switch_GreaterThan_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 3,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["switch_.switch_position"]}
      }
    }
  }
}
end
Flattened Source
component Test_Switch_GreaterThan
  switch_ = PrimitiveComponents.Switches.PositionSwitch_Greater(threshold = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 580, "y1": 500, "x2": 680, "y2": 600, "rot": 0}
      }
    }
  }
  sine = BlockComponents.Sine(amplitude = 2, frequency = 0.2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 300, "x2": 320, "y2": 400, "rot": 0}
      }
    }
  }
  constant1 = BlockComponents.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 210, "y1": 650, "x2": 310, "y2": 750, "rot": 0}
      }
    }
  }
relations
  connect(switch_.input_primary, sine.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 449, "y": 513}, {"x": 449, "y": 350}], "E": 2}]}
  }
  connect(constant1.y, switch_.input_secondary) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 444, "y": 700}, {"x": 444, "y": 582}], "E": 2}]}
  }
  connect(switch_.switch_primary, sine.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 449, "y": 550}, {"x": 449, "y": 350}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_Switch_GreaterThan_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 3,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["switch_.switch_position"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output
  • Examples
  • Experiments
  • Analyses