TestPeriodicClock Icon
Examples.TestPeriodicClock
Test component that validates the PeriodicClock component.
This component specifically tests the "provoker" / output formulation of the periodic clock. If it works correctly, this component should instantiate and run without error, sampling once per dt seconds.
Usage
DiscreteComponents.Examples.TestPeriodicClock()
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
dt | – | 0.1 |
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( sine_{+}y(t), samplevalue_{+}u(t) \right) \\ \mathrm{connect}\left( samplevalue_{+}y(t), periodicclockprovoker_{+}y(t) \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{samplevalue.y}\left( t \right) = Sample(ModelingToolkit.InferredClock.var"typeof(InferredClock)"(ModelingToolkit.InferredClock.var"##Storage#InferredDiscrete"(0)))\left( \mathtt{samplevalue.u}\left( t \right) \right) \\ \frac{\mathrm{d} \mathtt{periodicclockprovoker.dummy.dummy}\left( t \right)}{\mathrm{d}t} = 0 \\ \end{array} \right] \end{equation} \]
Source
"""
Test component that validates the PeriodicClock component.
This component specifically tests the "provoker" / output formulation of the periodic clock.
If it works correctly, this component should instantiate and run without error, sampling once per `dt` seconds.
"""
test component TestPeriodicClock
sine = BlockComponents.Sine(frequency = 1, amplitude = 1.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
},
"tags": []
}
}
samplevalue = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 180, "y1": 140, "x2": 280, "y2": 240, "rot": 0}
},
"tags": []
}
}
periodicclockprovoker = DiscreteComponents.PeriodicClock(dt = dt) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 410, "y1": 50, "x2": 510, "y2": 150, "rot": 0}
},
"tags": []
}
}
structural dt::Real = 0.1
relations
connect(samplevalue.u, sine.y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(periodicclockprovoker.y, samplevalue.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 350, "y": 100}, {"x": 350, "y": 190}], "E": 2}],
"renderStyle": "standard"
}
}
metadata {
"Dyad": {
"tests": {"case1": {"stop": 10, "expect": {"signals": ["sine.y", "unitdifference.y"]}}}
}
}
end
Flattened Source
"""
Test component that validates the PeriodicClock component.
This component specifically tests the "provoker" / output formulation of the periodic clock.
If it works correctly, this component should instantiate and run without error, sampling once per `dt` seconds.
"""
test component TestPeriodicClock
sine = BlockComponents.Sine(frequency = 1, amplitude = 1.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
},
"tags": []
}
}
samplevalue = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 180, "y1": 140, "x2": 280, "y2": 240, "rot": 0}
},
"tags": []
}
}
periodicclockprovoker = DiscreteComponents.PeriodicClock(dt = dt) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 410, "y1": 50, "x2": 510, "y2": 150, "rot": 0}
},
"tags": []
}
}
structural dt::Real = 0.1
relations
connect(samplevalue.u, sine.y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(periodicclockprovoker.y, samplevalue.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 350, "y": 100}, {"x": 350, "y": 190}], "E": 2}],
"renderStyle": "standard"
}
}
metadata {
"Dyad": {
"tests": {"case1": {"stop": 10, "expect": {"signals": ["sine.y", "unitdifference.y"]}}}
}
}
endTest Cases
Test Case case1
pltpltRelated
- Examples
- Experiments
- Analyses
- Tests