LIBRARY
Examples.TestDiscreteIntegrator ​
Test component that validates the DiscreteIntegrator block with backward Euler method.
Connects a Step source through a Sampler (driven by a PeriodicClock) to a DiscreteIntegrator (backward method). The discrete integral of a step should produce a discrete ramp. Verifies all three discretization methods by including forward and trapezoidal integrators in parallel.
Usage ​
DiscreteComponents.Examples.TestDiscreteIntegrator()
Behavior ​
Behavior of this component cannot be rendered because it includes path variables.
Source ​
dyad
"""
Test component that validates the DiscreteIntegrator block with backward Euler method.
Connects a Step source through a Sampler (driven by a PeriodicClock) to a DiscreteIntegrator (backward method).
The discrete integral of a step should produce a discrete ramp. Verifies all three
discretization methods by including forward and trapezoidal integrators in parallel.
"""
test component TestDiscreteIntegrator
step = BlockComponents.Sources.Step(start_time = 0.0, offset = 0.0, height = 1.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 450, "x2": 120, "y2": 550, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 200, "y1": 450, "x2": 300, "y2": 550, "rot": 0}
},
"tags": []
}
}
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 200, "y1": 800, "x2": 300, "y2": 900, "rot": 0}
},
"tags": []
}
}
backward = DiscreteComponents.DiscreteIntegrator(method = DiscretizationMethod.Backward()) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 300, "x2": 500, "y2": 400, "rot": 0}
},
"tags": []
}
}
forward = DiscreteComponents.DiscreteIntegrator(method = DiscretizationMethod.Forward()) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 450, "x2": 500, "y2": 550, "rot": 0}
},
"tags": []
}
}
trapezoidal = DiscreteComponents.DiscreteIntegrator(method = DiscretizationMethod.Trapezoidal()) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 610, "x2": 500, "y2": 710, "rot": 0}
},
"tags": []
}
}
terminator = BlockComponents.Routing.Terminator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 580, "y1": 300, "x2": 680, "y2": 400, "rot": 0}
},
"tags": []
}
}
terminator1 = BlockComponents.Routing.Terminator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 580, "y1": 450, "x2": 680, "y2": 550, "rot": 0}
},
"tags": []
}
}
terminator2 = BlockComponents.Routing.Terminator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 580, "y1": 610, "x2": 680, "y2": 710, "rot": 0}
},
"tags": []
}
}
relations
connect(step.y, sampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(sampler.y, backward.u, trapezoidal.u, forward.u, periodicclock.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 350, "y": 500}, {"x": 350, "y": 350}], "E": 2}],
"renderStyle": "standard"
}
}
connect(backward.y, terminator.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(forward.y, terminator1.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(trapezoidal.y, terminator2.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
"Dyad": {
"tests": {
"case1": {"stop": 1, "expect": {"signals": ["backward.y", "forward.y", "trapezoidal.y"]}}
},
"doc": {"behavior": false}
}
}
endFlattened Source
dyad
"""
Test component that validates the DiscreteIntegrator block with backward Euler method.
Connects a Step source through a Sampler (driven by a PeriodicClock) to a DiscreteIntegrator (backward method).
The discrete integral of a step should produce a discrete ramp. Verifies all three
discretization methods by including forward and trapezoidal integrators in parallel.
"""
test component TestDiscreteIntegrator
step = BlockComponents.Sources.Step(start_time = 0.0, offset = 0.0, height = 1.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 450, "x2": 120, "y2": 550, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 200, "y1": 450, "x2": 300, "y2": 550, "rot": 0}
},
"tags": []
}
}
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 200, "y1": 800, "x2": 300, "y2": 900, "rot": 0}
},
"tags": []
}
}
backward = DiscreteComponents.DiscreteIntegrator(method = DiscretizationMethod.Backward()) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 300, "x2": 500, "y2": 400, "rot": 0}
},
"tags": []
}
}
forward = DiscreteComponents.DiscreteIntegrator(method = DiscretizationMethod.Forward()) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 450, "x2": 500, "y2": 550, "rot": 0}
},
"tags": []
}
}
trapezoidal = DiscreteComponents.DiscreteIntegrator(method = DiscretizationMethod.Trapezoidal()) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 610, "x2": 500, "y2": 710, "rot": 0}
},
"tags": []
}
}
terminator = BlockComponents.Routing.Terminator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 580, "y1": 300, "x2": 680, "y2": 400, "rot": 0}
},
"tags": []
}
}
terminator1 = BlockComponents.Routing.Terminator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 580, "y1": 450, "x2": 680, "y2": 550, "rot": 0}
},
"tags": []
}
}
terminator2 = BlockComponents.Routing.Terminator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 580, "y1": 610, "x2": 680, "y2": 710, "rot": 0}
},
"tags": []
}
}
relations
connect(step.y, sampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(sampler.y, backward.u, trapezoidal.u, forward.u, periodicclock.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 350, "y": 500}, {"x": 350, "y": 350}], "E": 2}],
"renderStyle": "standard"
}
}
connect(backward.y, terminator.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(forward.y, terminator1.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(trapezoidal.y, terminator2.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
"Dyad": {
"tests": {
"case1": {"stop": 1, "expect": {"signals": ["backward.y", "forward.y", "trapezoidal.y"]}}
},
"doc": {"behavior": false}
}
}
endTest Cases ​
Test Case case1 ​
julia
pltjulia
pltjulia
pltRelated ​
Examples
Experiments
Analyses
Tests