Test_PositionalSwitch_NotEqual Icon
Test_PositionalSwitch_NotEqual
Usage
PrimitiveComponents.Test_PositionalSwitch_NotEqual()
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( a_{+}y(t), switch_{1_{+}input\_primary(t)} \right) \\ \mathrm{connect}\left( step_{+}y(t), switch_{1_{+}switch\_primary(t)} \right) \\ \mathrm{connect}\left( b_{+}y(t), switch_{1_{+}input\_secondary(t)} \right) \\ \mathtt{switch\_1.switch\_position}\left( t \right) = ifelse\left( \left| - \mathtt{switch\_1.threshold} + \mathtt{switch\_1.switch\_primary}\left( t \right)\right| > \mathtt{switch\_1.tolerance}, \mathtt{switch\_1.input\_primary}\left( t \right), \mathtt{switch\_1.input\_secondary}\left( t \right) \right) \\ \mathtt{a.y}\left( t \right) = \mathtt{a.k} \\ \mathtt{b.y}\left( t \right) = \mathtt{b.k} \\ \mathtt{step.y}\left( t \right) = ifelse\left( t \geq \mathtt{step.start\_time}, \mathtt{step.height} + \mathtt{step.offset}, \mathtt{step.offset} \right) \\ \end{array} \right] \end{equation} \]
Source
# This test demonstrates the behavior of the `Switch_not_equal` component.
#
# The component switches between two constant inputs (`a` and `b`) based on whether
# the control signal (`step.y`) is not equal to the specified threshold.
# Here for t < 5: step.y = 10.00001 (within tolerance → considered equal) → output = b.y = 2
# and For t ≥ 5: step.y = 10.00011 (not equal beyond tolerance) → output = a.y = 1
component Test_PositionalSwitch_NotEqual
switch_1 = PrimitiveComponents.Switches.PositionalSwitch_NotEqual(threshold = 10, tolerance = 0.0001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 460, "y1": 190, "x2": 560, "y2": 290, "rot": 0}
}
}
}
a = BlockComponents.Constant(k = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 80, "y1": 10, "x2": 180, "y2": 110, "rot": 0}
}
}
}
b = BlockComponents.Constant(k = 2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 80, "y1": 370, "x2": 180, "y2": 470, "rot": 0}
}
}
}
step = BlockComponents.Step(start_time = 5, offset = 10.00001, height = 0.0001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 80, "y1": 190, "x2": 180, "y2": 290, "rot": 0}
}
}
}
relations
connect(a.y, switch_1.input_primary) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 319, "y": 60}, {"x": 319, "y": 203}], "E": 2}]}
}
connect(switch_1.switch_primary, step.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(switch_1.input_secondary, b.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 319, "y": 277}, {"x": 319, "y": 420}], "E": 2}]}
}
metadata {
"Dyad": {
"experiments": {"Test_Switch_not_equal_": {"stop": 10}},
"tests": {
"case1": {
"stop": 10,
"abstol": 0.00001,
"reltol": 0.00001,
"expect": {"signals": ["switch_1.switch_position"]}
}
}
}
}
end
Flattened Source
component Test_PositionalSwitch_NotEqual
switch_1 = PrimitiveComponents.Switches.PositionalSwitch_NotEqual(threshold = 10, tolerance = 0.0001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 460, "y1": 190, "x2": 560, "y2": 290, "rot": 0}
}
}
}
a = BlockComponents.Constant(k = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 80, "y1": 10, "x2": 180, "y2": 110, "rot": 0}
}
}
}
b = BlockComponents.Constant(k = 2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 80, "y1": 370, "x2": 180, "y2": 470, "rot": 0}
}
}
}
step = BlockComponents.Step(start_time = 5, offset = 10.00001, height = 0.0001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 80, "y1": 190, "x2": 180, "y2": 290, "rot": 0}
}
}
}
relations
connect(a.y, switch_1.input_primary) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 319, "y": 60}, {"x": 319, "y": 203}], "E": 2}]}
}
connect(switch_1.switch_primary, step.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(switch_1.input_secondary, b.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 319, "y": 277}, {"x": 319, "y": 420}], "E": 2}]}
}
metadata {
"Dyad": {
"experiments": {"Test_Switch_not_equal_": {"stop": 10}},
"tests": {
"case1": {
"stop": 10,
"abstol": 0.00001,
"reltol": 0.00001,
"expect": {"signals": ["switch_1.switch_position"]}
}
}
}
}
endTest Cases
Test Case case1
pltRelated
- Examples
- Experiments
- Analyses