LIBRARY
Nonlinear.Tests.VariableLimiter
Test harness for the VariableLimiter block.
A sine (amplitude 2, frequency 1) is limited by two configurations, both driven by the same source:
vl_tv— time-varying upper limit:limit1is a ramp falling from 1.5 to 0.5 over one second,limit2is a constant -1. This exercises the "variable" aspect: the upper clamp boundary moves during the run, so the saturated output tracks the ramping limit rather than a fixed value.vl_const— constant symmetric limitslimit1 = +1,limit2 = -1(the MSL baseline). Output passes through while|u| <= 1and clamps to +/-1 outside.
limit1 >= limit2 holds at all times in both cases (the block asserts this).
Usage
BlockComponents.Nonlinear.Tests.VariableLimiter()
Behavior
Source
dyad
"""
Test harness for the VariableLimiter block.
A sine (amplitude 2, frequency 1) is limited by two configurations, both driven
by the same source:
- `vl_tv` — **time-varying** upper limit: `limit1` is a ramp falling from 1.5 to
0.5 over one second, `limit2` is a constant -1. This exercises the "variable"
aspect: the upper clamp boundary moves during the run, so the saturated output
tracks the ramping limit rather than a fixed value.
- `vl_const` — constant symmetric limits `limit1 = +1`, `limit2 = -1` (the MSL
baseline). Output passes through while `|u| <= 1` and clamps to +/-1 outside.
`limit1 >= limit2` holds at all times in both cases (the block asserts this).
"""
test component VariableLimiter
"Sine sweeping beyond the limits"
sine = BlockComponents.Sources.Sine(amplitude = 2, frequency = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 120, "x2": 120, "y2": 220, "rot": 0}
}
}
}
"Time-varying upper limit: 1.5 -> 0.5 over [0, 1]"
upperRamp = BlockComponents.Sources.Ramp(offset = 1.5, height = -1.0, duration = 1.0, start_time = 0.0) {"Dyad": {"placement": {"diagram": {"x1": 20, "y1": 0, "x2": 120, "y2": 100}}}}
"Constant lower limit for the time-varying case"
lowerConst = BlockComponents.Sources.Constant(k = -1.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 260, "x2": 120, "y2": 360, "rot": 0}
}
}
}
"VariableLimiter with a moving upper limit"
vl_tv = BlockComponents.Nonlinear.VariableLimiter() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 260, "y1": 120, "x2": 360, "y2": 220, "rot": 0}
}
}
}
"Constant upper limit (+1)"
upperConst = BlockComponents.Sources.Constant(k = 1.0) {
"Dyad": {"placement": {"diagram": {"x1": 10, "y1": 450, "x2": 110, "y2": 550}}}
}
"Constant lower limit (-1)"
lowerConst2 = BlockComponents.Sources.Constant(k = -1.0) {
"Dyad": {"placement": {"diagram": {"x1": 10, "y1": 680, "x2": 110, "y2": 780}}}
}
"VariableLimiter with constant symmetric limits (baseline)"
vl_const = BlockComponents.Nonlinear.VariableLimiter() {
"Dyad": {"placement": {"diagram": {"x1": 260, "y1": 580, "x2": 360, "y2": 680}}}
}
relations
connect(sine.y, vl_tv.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(upperRamp.y, vl_tv.limit1) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 50}, {"x": 230, "y": 140}], "E": 2}]}
}
connect(lowerConst.y, vl_tv.limit2) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 310}, {"x": 230, "y": 200}], "E": 2}]}
}
connect(sine.y, vl_const.u) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 200, "y": 170}, {"x": 200, "y": 630}], "E": 2}]}
}
connect(upperConst.y, vl_const.limit1) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 500}, {"x": 230, "y": 600}], "E": 2}]}
}
connect(lowerConst2.y, vl_const.limit2) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 110, "y": 620},
{"x": 110, "y": 730},
{"x": 215, "y": 730},
{"x": 215, "y": 660}
],
"E": 2
}
]
}
}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {
"case1": {
"stop": 1,
"expect": {"signals": ["sine.y", "upperRamp.y", "vl_tv.y", "vl_const.y"]}
}
}
}
}
endFlattened Source
dyad
"""
Test harness for the VariableLimiter block.
A sine (amplitude 2, frequency 1) is limited by two configurations, both driven
by the same source:
- `vl_tv` — **time-varying** upper limit: `limit1` is a ramp falling from 1.5 to
0.5 over one second, `limit2` is a constant -1. This exercises the "variable"
aspect: the upper clamp boundary moves during the run, so the saturated output
tracks the ramping limit rather than a fixed value.
- `vl_const` — constant symmetric limits `limit1 = +1`, `limit2 = -1` (the MSL
baseline). Output passes through while `|u| <= 1` and clamps to +/-1 outside.
`limit1 >= limit2` holds at all times in both cases (the block asserts this).
"""
test component VariableLimiter
"Sine sweeping beyond the limits"
sine = BlockComponents.Sources.Sine(amplitude = 2, frequency = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 120, "x2": 120, "y2": 220, "rot": 0}
}
}
}
"Time-varying upper limit: 1.5 -> 0.5 over [0, 1]"
upperRamp = BlockComponents.Sources.Ramp(offset = 1.5, height = -1.0, duration = 1.0, start_time = 0.0) {"Dyad": {"placement": {"diagram": {"x1": 20, "y1": 0, "x2": 120, "y2": 100}}}}
"Constant lower limit for the time-varying case"
lowerConst = BlockComponents.Sources.Constant(k = -1.0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 260, "x2": 120, "y2": 360, "rot": 0}
}
}
}
"VariableLimiter with a moving upper limit"
vl_tv = BlockComponents.Nonlinear.VariableLimiter() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 260, "y1": 120, "x2": 360, "y2": 220, "rot": 0}
}
}
}
"Constant upper limit (+1)"
upperConst = BlockComponents.Sources.Constant(k = 1.0) {
"Dyad": {"placement": {"diagram": {"x1": 10, "y1": 450, "x2": 110, "y2": 550}}}
}
"Constant lower limit (-1)"
lowerConst2 = BlockComponents.Sources.Constant(k = -1.0) {
"Dyad": {"placement": {"diagram": {"x1": 10, "y1": 680, "x2": 110, "y2": 780}}}
}
"VariableLimiter with constant symmetric limits (baseline)"
vl_const = BlockComponents.Nonlinear.VariableLimiter() {
"Dyad": {"placement": {"diagram": {"x1": 260, "y1": 580, "x2": 360, "y2": 680}}}
}
relations
connect(sine.y, vl_tv.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(upperRamp.y, vl_tv.limit1) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 50}, {"x": 230, "y": 140}], "E": 2}]}
}
connect(lowerConst.y, vl_tv.limit2) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 310}, {"x": 230, "y": 200}], "E": 2}]}
}
connect(sine.y, vl_const.u) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 200, "y": 170}, {"x": 200, "y": 630}], "E": 2}]}
}
connect(upperConst.y, vl_const.limit1) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 500}, {"x": 230, "y": 600}], "E": 2}]}
}
connect(lowerConst2.y, vl_const.limit2) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 110, "y": 620},
{"x": 110, "y": 730},
{"x": 215, "y": 730},
{"x": 215, "y": 660}
],
"E": 2
}
]
}
}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {
"case1": {
"stop": 1,
"expect": {"signals": ["sine.y", "upperRamp.y", "vl_tv.y", "vl_const.y"]}
}
}
}
}
endTest Cases
Test Case case1
julia
pltjulia
pltjulia
pltjulia
pltRelated
Examples
Experiments
Analyses
Tests