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
4-element Vector{Symbolics.Equation}:
connect(sine.y(t), samplevalue.u(t))
connect(samplevalue.y(t), periodicclockprovoker.y(t))
sine₊y(t) ~ ifelse(sine₊continuous, ifelse(t >= sine₊start_time, sin(sine₊phase + 6.283185307179586sine₊frequency*(-sine₊shift_time + t)), sin(sine₊phase + 6.283185307179586sine₊frequency*(-sine₊shift_time + sine₊start_time)))*sine₊amplitude, ifelse(t >= sine₊start_time, sin(sine₊phase + 6.283185307179586sine₊frequency*(-sine₊shift_time + t))*sine₊amplitude, 0.0)) + sine₊offset
samplevalue₊y(t) ~ Sample(InferredClock.InferredDiscrete(0))(samplevalue₊u(t))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.Sources.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 parameter 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": ["samplevalue.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.Sources.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 parameter 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": ["samplevalue.y"]}}}}
}
endTest Cases
Test Case case1
pltRelated
- Examples
- Experiments
- Analyses
- Tests