IntegratorFEwInitialSimpler Icon
Examples.IntegratorFEwInitialSimpler
Usage
DiscreteComponents.Examples.IntegratorFEwInitialSimpler()
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
dt | – | 0.1 |
Connectors
u- This connector represents a real signal as an input to a component (RealInput)ic- This connector represents a real signal as an input to a component (RealInput)reset- This connector represents a real signal as an input to a component (RealInput)y- This connector represents a real signal as an output from a component (RealOutput)
Variables
| Name | Description | Units |
|---|---|---|
reset_value | – |
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( y(t), unitdelay_{+}u(t) \right) \\ \mathrm{connect}\left( unitdelay_{+}y(t), add_{+}u1(t) \right) \\ \mathrm{connect}\left( sampletimeblock_{+}y(t), multiply_{+}u2(t) \right) \\ \mathrm{connect}\left( multiply_{+}y(t), add_{+}u2(t) \right) \\ \mathrm{connect}\left( lastvalue_{+}y(t), periodicclockprovoker_{+}y(t) \right) \\ \mathrm{connect}\left( u(t), lastvalue_{+}u(t) \right) \\ \mathrm{connect}\left( lastvalue_{+}y(t), multiply_{+}u1(t) \right) \\ \mathrm{connect}\left( add_{+}y(t), y(t) \right) \\ \mathrm{connect}\left( ic(t), sampler1_{+}u(t) \right) \\ \mathrm{connect}\left( lastvalue_{+}y(t), clockpropagator_{+}y(t) \right) \\ \mathrm{connect}\left( sampler1_{+}y(t), clockpropagator_{+}u(t) \right) \\ \mathrm{connect}\left( reset(t), sampler_{+}u(t) \right) \\ \mathrm{connect}\left( sampler_{+}y(t), clockpropagator1_{+}u(t) \right) \\ \mathrm{connect}\left( sampler1_{+}y(t), clockpropagator1_{+}y(t) \right) \\ \mathrm{connect}\left( constant1_{+}y(t), lessthan_{+}u2(t) \right) \\ \mathrm{connect}\left( sampler_{+}y(t), lessthan_{+}u1(t) \right) \\ \frac{\mathrm{d} \mathtt{dummy.dummy}\left( t \right)}{\mathrm{d}t} = 0 \\ \mathtt{unitdelay.y}\left( t \right) = Shift(t, -1)\left( \mathtt{unitdelay.u}\left( t \right) \right) \\ \frac{\mathrm{d} \mathtt{unitdelay.dummy.dummy}\left( t \right)}{\mathrm{d}t} = 0 \\ \mathtt{add.y}\left( t \right) = \mathtt{add.k1} \mathtt{add.u1}\left( t \right) + \mathtt{add.k2} \mathtt{add.u2}\left( t \right) \\ \mathtt{multiply.y}\left( t \right) = \mathtt{multiply.u2}\left( t \right) \mathtt{multiply.u1}\left( t \right) \\ \mathtt{sampletimeblock.y}\left( t \right) = ModelingToolkit.SampleTime \\ \mathtt{lastvalue.y}\left( t \right) = SynchToolkit.LastValue()\left( \mathtt{lastvalue.u}\left( t \right) \right) \\ \frac{\mathrm{d} \mathtt{periodicclockprovoker.dummy.dummy}\left( t \right)}{\mathrm{d}t} = 0 \\ \mathtt{sampler1.y}\left( t \right) = Sample(ModelingToolkit.InferredClock.var"typeof(InferredClock)"(ModelingToolkit.InferredClock.var"##Storage#InferredDiscrete"(0)))\left( \mathtt{sampler1.u}\left( t \right) \right) \\ \mathtt{clockpropagator.dummy}\left( t \right) = ifelse\left( \mathtt{clockpropagator.u}\left( t \right) < \mathtt{clockpropagator.y}\left( t \right), 0.1, 0.1 \right) \\ \mathtt{sampler.y}\left( t \right) = Sample(ModelingToolkit.InferredClock.var"typeof(InferredClock)"(ModelingToolkit.InferredClock.var"##Storage#InferredDiscrete"(0)))\left( \mathtt{sampler.u}\left( t \right) \right) \\ \mathtt{clockpropagator1.dummy}\left( t \right) = ifelse\left( \mathtt{clockpropagator1.u}\left( t \right) < \mathtt{clockpropagator1.y}\left( t \right), 0.1, 0.1 \right) \\ \mathtt{constant1.y}\left( t \right) = \mathtt{constant1.k} \\ \mathtt{lessthan.y}\left( t \right) = \mathtt{lessthan.u1}\left( t \right) < \mathtt{lessthan.u2}\left( t \right) \\ \end{array} \right] \end{equation} \]
Source
component IntegratorFEwInitialSimpler@[output clk, input inclk]
u = RealInput@[inclk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
},
"tags": []
}
}
ic = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 200, "x2": 50, "y2": 300, "rot": 0}
},
"tags": []
}
}
reset = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 20, "x2": 50, "y2": 120, "rot": 0}
},
"tags": []
}
}
y = RealOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 440, "x2": 1100, "y2": 540, "rot": 0}
},
"tags": []
}
}
dummy = DiscreteComponents.DummyDynamics() {
"Dyad": {
"placement": {
"diagram": {
"iconName": "default",
"x1": -250,
"y1": -210,
"x2": -150,
"y2": -110,
"rot": 0
}
},
"tags": []
}
}
unitdelay = DiscreteComponents.UnitDelay() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 850, "y1": 300, "x2": 750, "y2": 400, "rot": 0}
},
"tags": []
}
}
add = BlockComponents.Add() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 670, "y1": 450, "x2": 770, "y2": 550, "rot": 0}
},
"tags": []
}
}
multiply = BlockComponents.Product() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 550, "y1": 550, "x2": 650, "y2": 650, "rot": 0}
},
"tags": []
}
}
sampletimeblock = DiscreteComponents.SampleTimeSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 410, "y1": 620, "x2": 510, "y2": 720, "rot": 0}
},
"tags": []
}
}
lastvalue = DiscreteComponents.LastValue() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 120, "y1": 450, "x2": 220, "y2": 550, "rot": 0}
},
"tags": []
}
}
periodicclockprovoker = DiscreteComponents.PeriodicClock(dt = dt) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 260, "y1": 600, "x2": 360, "y2": 700, "rot": 0}
},
"tags": []
}
}
sampler1 = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 200, "x2": 260, "y2": 300, "rot": 0}
},
"tags": []
}
}
clockpropagator = DiscreteComponents.ClockPropagator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 330, "y1": 320, "x2": 430, "y2": 420, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 20, "x2": 260, "y2": 120, "rot": 0}
},
"tags": []
}
}
clockpropagator1 = DiscreteComponents.ClockPropagator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 330, "y1": 100, "x2": 430, "y2": 200, "rot": 0}
},
"tags": []
}
}
constant1 = BlockComponents.Constant() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 480, "y1": 190, "x2": 530, "y2": 240, "rot": 0}
},
"tags": []
}
}
lessthan = DiscreteComponents.Examples.LessThan() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 650, "y1": 130, "x2": 750, "y2": 230, "rot": 0}
},
"tags": []
}
}
structural dt::Real = 0.1
variable reset_value::Real = NaN
relations
"""
y@(clk) = ifelse(0.0 < reset, sample(reset_value, clk), y@(clk-1) + u(clk) * dt)
reset_value@(clk) = ifelse(
isnan_wrapper(sample(reset_value, clk)@(clk-1)),
ic@(clk),
reset_value@(clk-1)
)
"""
initial u@(inclk-1) = 0.0
initial reset_value@(clk-1) = 0.0
initial y@(clk-1) = 0.0
connect(unitdelay.u, y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 1050, "y": 350}], "E": 2}],
"renderStyle": "standard"
}
}
connect(unitdelay.y, add.u1) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 640, "y": 350}, {"x": 640, "y": 470}], "E": 2}],
"renderStyle": "standard"
}
}
connect(sampletimeblock.y, multiply.u2) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 543.5, "y": 670},
{"x": 543.5, "y": 660},
{"x": 540, "y": 660},
{"x": 540, "y": 623}
],
"E": 2
}
],
"renderStyle": "standard"
}
}
connect(multiply.y, add.u2) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 660, "y": 600}, {"x": 660, "y": 530}], "E": 2}],
"renderStyle": "standard"
}
}
connect(lastvalue.y, periodicclockprovoker.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 240, "y": 500}, {"x": 240, "y": 650}], "E": 2}],
"renderStyle": "standard"
}
}
connect(u, lastvalue.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(lastvalue.y, multiply.u1) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 431, "y": 500}, {"x": 431, "y": 575}], "E": 2}],
"renderStyle": "standard"
}
}
connect(add.y, y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 1050, "y": 500}], "E": 2}]
}
}
connect(ic, sampler1.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(lastvalue.y, clockpropagator.y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 275.5, "y": 500}, {"x": 275.5, "y": 405}], "E": 2}]
}
}
connect(sampler1.y, clockpropagator.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 295.5, "y": 250}, {"x": 295.5, "y": 335}], "E": 2}]
}
}
connect(reset, sampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(sampler.y, clockpropagator1.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 295.5, "y": 70}, {"x": 295.5, "y": 115}], "E": 2}]
}
}
connect(clockpropagator1.y, sampler1.y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 295.5, "y": 185}, {"x": 295.5, "y": 250}], "E": 2}]
}
}
connect(constant1.y, lessthan.u2) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 591.75, "y": 215}, {"x": 591.75, "y": 207}], "E": 2}]
}
}
connect(sampler.y, lessthan.u1) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 455.5, "y": 70}, {"x": 455.5, "y": 156}], "E": 2}]
}
}
end
Flattened Source
component IntegratorFEwInitialSimpler
u = RealInput@[inclk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
},
"tags": []
}
}
ic = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 200, "x2": 50, "y2": 300, "rot": 0}
},
"tags": []
}
}
reset = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 20, "x2": 50, "y2": 120, "rot": 0}
},
"tags": []
}
}
y = RealOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 440, "x2": 1100, "y2": 540, "rot": 0}
},
"tags": []
}
}
dummy = DiscreteComponents.DummyDynamics() {
"Dyad": {
"placement": {
"diagram": {
"iconName": "default",
"x1": -250,
"y1": -210,
"x2": -150,
"y2": -110,
"rot": 0
}
},
"tags": []
}
}
unitdelay = DiscreteComponents.UnitDelay() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 850, "y1": 300, "x2": 750, "y2": 400, "rot": 0}
},
"tags": []
}
}
add = BlockComponents.Add() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 670, "y1": 450, "x2": 770, "y2": 550, "rot": 0}
},
"tags": []
}
}
multiply = BlockComponents.Product() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 550, "y1": 550, "x2": 650, "y2": 650, "rot": 0}
},
"tags": []
}
}
sampletimeblock = DiscreteComponents.SampleTimeSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 410, "y1": 620, "x2": 510, "y2": 720, "rot": 0}
},
"tags": []
}
}
lastvalue = DiscreteComponents.LastValue() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 120, "y1": 450, "x2": 220, "y2": 550, "rot": 0}
},
"tags": []
}
}
periodicclockprovoker = DiscreteComponents.PeriodicClock(dt = dt) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 260, "y1": 600, "x2": 360, "y2": 700, "rot": 0}
},
"tags": []
}
}
sampler1 = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 200, "x2": 260, "y2": 300, "rot": 0}
},
"tags": []
}
}
clockpropagator = DiscreteComponents.ClockPropagator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 330, "y1": 320, "x2": 430, "y2": 420, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 20, "x2": 260, "y2": 120, "rot": 0}
},
"tags": []
}
}
clockpropagator1 = DiscreteComponents.ClockPropagator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 330, "y1": 100, "x2": 430, "y2": 200, "rot": 0}
},
"tags": []
}
}
constant1 = BlockComponents.Constant() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 480, "y1": 190, "x2": 530, "y2": 240, "rot": 0}
},
"tags": []
}
}
lessthan = DiscreteComponents.Examples.LessThan() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 650, "y1": 130, "x2": 750, "y2": 230, "rot": 0}
},
"tags": []
}
}
structural dt::Real = 0.1
variable reset_value::Real = NaN
relations
"""
y@(clk) = ifelse(0.0 < reset, sample(reset_value, clk), y@(clk-1) + u(clk) * dt)
reset_value@(clk) = ifelse(
isnan_wrapper(sample(reset_value, clk)@(clk-1)),
ic@(clk),
reset_value@(clk-1)
)
"""
initial u@(inclk-1) = 0.0
initial reset_value@(clk-1) = 0.0
initial y@(clk-1) = 0.0
connect(unitdelay.u, y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 1050, "y": 350}], "E": 2}],
"renderStyle": "standard"
}
}
connect(unitdelay.y, add.u1) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 640, "y": 350}, {"x": 640, "y": 470}], "E": 2}],
"renderStyle": "standard"
}
}
connect(sampletimeblock.y, multiply.u2) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 543.5, "y": 670},
{"x": 543.5, "y": 660},
{"x": 540, "y": 660},
{"x": 540, "y": 623}
],
"E": 2
}
],
"renderStyle": "standard"
}
}
connect(multiply.y, add.u2) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 660, "y": 600}, {"x": 660, "y": 530}], "E": 2}],
"renderStyle": "standard"
}
}
connect(lastvalue.y, periodicclockprovoker.y) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 240, "y": 500}, {"x": 240, "y": 650}], "E": 2}],
"renderStyle": "standard"
}
}
connect(u, lastvalue.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(lastvalue.y, multiply.u1) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 431, "y": 500}, {"x": 431, "y": 575}], "E": 2}],
"renderStyle": "standard"
}
}
connect(add.y, y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 1050, "y": 500}], "E": 2}]
}
}
connect(ic, sampler1.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(lastvalue.y, clockpropagator.y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 275.5, "y": 500}, {"x": 275.5, "y": 405}], "E": 2}]
}
}
connect(sampler1.y, clockpropagator.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 295.5, "y": 250}, {"x": 295.5, "y": 335}], "E": 2}]
}
}
connect(reset, sampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(sampler.y, clockpropagator1.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 295.5, "y": 70}, {"x": 295.5, "y": 115}], "E": 2}]
}
}
connect(clockpropagator1.y, sampler1.y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 295.5, "y": 185}, {"x": 295.5, "y": 250}], "E": 2}]
}
}
connect(constant1.y, lessthan.u2) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 591.75, "y": 215}, {"x": 591.75, "y": 207}], "E": 2}]
}
}
connect(sampler.y, lessthan.u1) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 455.5, "y": 70}, {"x": 455.5, "y": 156}], "E": 2}]
}
}
metadata {}
endTest Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses
- Tests