TestRelay Icon
TestRelay
Usage
PrimitiveComponents.TestRelay()
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( source_{+}y(t), relay_{+}u(t) \right) \\ \mathtt{source.y}\left( t \right) = ifelse\left( \mathtt{source.start\_time} < t, ifelse\left( t < \mathtt{source.duration} + \mathtt{source.start\_time}, \mathtt{source.offset} + \frac{\mathtt{source.height} \left( - \mathtt{source.start\_time} + t \right)}{\mathtt{source.duration}}, \mathtt{source.height} + \mathtt{source.offset} \right), \mathtt{source.offset} \right) \\ \mathtt{relay.y}\left( t \right) = ifelse\left( \mathtt{relay.u}\left( t \right) \geq \mathtt{relay.switch\_on\_threshold}, \mathtt{relay.output\_when\_on}, ifelse\left( \mathtt{relay.u}\left( t \right) \leq \mathtt{relay.switch\_off\_threshold}, \mathtt{relay.output\_when\_off}, ifelse\left( \mathtt{relay.u}\left( t \right) > 0, \mathtt{relay.output\_when\_on}, \mathtt{relay.output\_when\_off} \right) \right) \right) \\ \end{array} \right] \end{equation} \]
Source
test component TestRelay
"Ramp input that sweeps through hysteresis band"
source = BlockComponents.Ramp(height = 4.0, duration = 4.0, offset = -2.0, start_time = 0.0) {}
"Relay component under test"
relay = PrimitiveComponents.Discontinuous.Relay(switch_on_threshold = 0.5, switch_off_threshold = -0.5, output_when_on = 10.0, output_when_off = 0.0) {}
relations
connect(source.y, relay.u) {}
metadata {
"Dyad": {
"experiments": {},
"tests": {
"case1": {
"stop": 10,
"abstol": 0.00001,
"reltol": 0.00001,
"expect": {"signals": ["relay.y"]}
}
},
"_links": {
"source": {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
},
"tags": []
}
},
"relay": {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 150, "y1": 20, "x2": 250, "y2": 120, "rot": 0}
},
"tags": []
}
},
"id3": {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
}
}
}
end
Flattened Source
test component TestRelay
"Ramp input that sweeps through hysteresis band"
source = BlockComponents.Ramp(height = 4.0, duration = 4.0, offset = -2.0, start_time = 0.0) {}
"Relay component under test"
relay = PrimitiveComponents.Discontinuous.Relay(switch_on_threshold = 0.5, switch_off_threshold = -0.5, output_when_on = 10.0, output_when_off = 0.0) {}
relations
connect(source.y, relay.u) {}
metadata {
"Dyad": {
"experiments": {},
"tests": {
"case1": {
"stop": 10,
"abstol": 0.00001,
"reltol": 0.00001,
"expect": {"signals": ["relay.y"]}
}
},
"_links": {
"source": {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
},
"tags": []
}
},
"relay": {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 150, "y1": 20, "x2": 250, "y2": 120, "rot": 0}
},
"tags": []
}
},
"id3": {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
}
}
}
endTest Cases
Test Case case1
plt