Test_PositionSwitch_GreaterOrEqual Icon
Test_PositionSwitch_GreaterOrEqual
Usage
PrimitiveComponents.Test_PositionSwitch_GreaterOrEqual()
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) \geq \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 During positive half-cycles of the sine wave, output follows the sine signal and
# during negative half-cycles, output remains at 0.This creates a “half-wave rectified”
# waveform at `switch_.switch_position`.
component Test_PositionSwitch_GreaterOrEqual
switch_ = PrimitiveComponents.Switches.PositionSwitch_GreaterOrEqual(threshold = 0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 580, "y1": 500, "x2": 680, "y2": 600, "rot": 0}
}
}
}
sine = BlockComponents.Sine(amplitude = 1, frequency = 1) {
"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_Greater_Than_equal_": {"stop": 10}},
"tests": {
"case1": {
"stop": 3,
"abstol": 0.00001,
"reltol": 0.00001,
"expect": {"signals": ["switch_.switch_position"]}
}
}
}
}
end
Flattened Source
component Test_PositionSwitch_GreaterOrEqual
switch_ = PrimitiveComponents.Switches.PositionSwitch_GreaterOrEqual(threshold = 0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 580, "y1": 500, "x2": 680, "y2": 600, "rot": 0}
}
}
}
sine = BlockComponents.Sine(amplitude = 1, frequency = 1) {
"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_Greater_Than_equal_": {"stop": 10}},
"tests": {
"case1": {
"stop": 3,
"abstol": 0.00001,
"reltol": 0.00001,
"expect": {"signals": ["switch_.switch_position"]}
}
}
}
}
endTest Cases
Test Case case1
pltRelated
- Examples
- Experiments
- Analyses