IntegratorFEwInitial IntegratorFEwInitial Icon

Examples.Integrator.IntegratorFEwInitial

Usage

DiscreteComponents.Examples.Integrator.IntegratorFEwInitial()

Parameters:

NameDescriptionUnitsDefault 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

NameDescriptionUnits
reset_value–

Behavior

36-element Vector{Symbolics.Equation}:
 reset_value(t) ~ NaN
 connect(ic(t), ic_sampler.u(t))
 connect(ic_sampler.y(t), clockpropagator.u(t))
 connect(reset(t), samplevalue.u(t))
 connect(samplevalue.y(t), clockpropagator1.u(t))
 connect(ic_sampler.y(t), clockpropagator2.y(t))
 connect(clockpropagator2.u(t), clockpropagator1.y(t))
 connect(y(t), unitdelay.u(t))
 connect(unitdelay.y(t), add.u1(t))
 connect(sampletimeblock.y(t), multiply.u2(t))
 ⋮
 unitdelay₊y(t) ~ Shift(t, -1)(unitdelay₊u(t))
 add₊y(t) ~ add₊k1*add₊u1(t) + add₊k2*add₊u2(t)
 multiply₊y(t) ~ multiply₊u1(t)*multiply₊u2(t)
 sampletimeblock₊y(t) ~ ModelingToolkitBase.SampleTime(ModelingToolkitBase.ShiftIndex(InferredClock.Inferred(Base.UUID("e87effad-7af0-4ef1-bb38-618e57692d1b")), 0), nothing)()
 resetvaluetracker₊resetvalue(t) ~ ifelse(DiscreteComponents.Examples.isnan_wrapper(Shift(t, -1)(resetvaluetracker₊resetvalue(t))), resetvaluetracker₊initialcondition(t), Shift(t, -1)(resetvaluetracker₊resetvalue(t)))
 switch1₊y(t) ~ ifelse(switch1₊signal(t), switch1₊u1(t), switch1₊u2(t))
 lastvalue₊y(t) ~ SynchToolkit.Latest()(lastvalue₊u(t), lastvalue₊init)
 lessthan₊y(t) ~ lessthan₊u1(t) < lessthan₊u2(t)
 constant1₊y(t) ~ constant1₊k

Source

component IntegratorFEwInitial@[output clk]
  u = RealInput() {
    "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": []
    }
  }
  ic_sampler = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 200, "x2": 220, "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": []
    }
  }
  clockpropagator = DiscreteComponents.ClockPropagator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": 310, "x2": 520, "y2": 410, "rot": 0}
      },
      "tags": []
    }
  }
  samplevalue = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 20, "x2": 220, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  clockpropagator1 = DiscreteComponents.ClockPropagator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": -80, "x2": 520, "y2": 20, "rot": 0}
      },
      "tags": []
    }
  }
  clockpropagator2 = DiscreteComponents.ClockPropagator@[clk = clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": 110, "x2": 520, "y2": 210, "rot": 0}
      },
      "tags": []
    }
  }
  unitdelay = DiscreteComponents.UnitDelay() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 300, "x2": 750, "y2": 400, "rot": 0}
      },
      "tags": []
    }
  }
  add = BlockComponents.Math.Add() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 670, "y1": 450, "x2": 770, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  multiply = BlockComponents.Math.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": []
    }
  }
  resetvaluetracker = DiscreteComponents.Examples.Integrator.ResetValueTracker() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 590, "y1": 200, "x2": 690, "y2": 300, "rot": 0}
      },
      "tags": []
    }
  }
  switch1 = DiscreteComponents.Examples.Integrator.Switch() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 870, "y1": 430, "x2": 970, "y2": 530, "rot": 0}
      },
      "tags": []
    }
  }
  lastvalue = DiscreteComponents.Latest() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 450, "x2": 220, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  periodicclockprovoker = DiscreteComponents.PeriodicClock(dt = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 600, "x2": 360, "y2": 700, "rot": 0}
      },
      "tags": []
    }
  }
  lessthan = DiscreteComponents.Examples.Integrator.LessThan() {
    "Dyad": {"placement": {"diagram": {"x1": 700, "y1": 40, "x2": 800, "y2": 140}}}
  }
  constant1 = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {"placement": {"diagram": {"x1": 570, "y1": 90, "x2": 630, "y2": 150}}}
  }
  structural parameter 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@(clk-1) = 0.0
  initial reset_value@(clk-1) = 0.0
  initial y@(clk-1) = 0.0
  connect(ic, ic_sampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(ic_sampler.y, clockpropagator.u) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 260, "y": 250}, {"x": 260, "y": 325}], "E": 2}]}
  }
  connect(reset, samplevalue.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(samplevalue.y, clockpropagator1.u) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 290, "y": 70}, {"x": 290, "y": -65}], "E": 2}]}
  }
  connect(ic_sampler.y, clockpropagator2.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 370.5, "y": 250}, {"x": 370.5, "y": 195}], "E": 2}]
    }
  }
  connect(clockpropagator2.u, clockpropagator1.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 390, "y": 125}, {"x": 390, "y": 5}], "E": 2}]}
  }
  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": 540, "y": 670}, {"x": 540, "y": 623}], "E": 2}]}
  }
  connect(multiply.y, add.u2) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 660, "y": 600}, {"x": 660, "y": 530}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(ic_sampler.y, resetvaluetracker.initialcondition) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  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": 570}], "E": 2}]}
  }
  connect(clockpropagator.y, lastvalue.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 330.5, "y": 395}, {"x": 330.5, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(resetvaluetracker.resetvalue, switch1.u1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 870, "y": 250}, {"x": 870, "y": 454}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(samplevalue.y, lessthan.u1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460.5, "y": 70}, {"x": 460.5, "y": 66}], "E": 2}]
    }
  }
  connect(constant1.y, lessthan.u2) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 673, "y": 120}, {"x": 673, "y": 117}], "E": 2}]}
  }
  connect(lessthan.y, switch1.signal) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 920, "y": 90}], "E": 2}]}}
  connect(switch1.y, y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 1050, "y": 480}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(add.y, switch1.u2) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 822.5, "y": 500}, {"x": 822.5, "y": 504}], "E": 2}]
    }
  }
end
Flattened Source
component IntegratorFEwInitial
  u = RealInput() {
    "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": []
    }
  }
  ic_sampler = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 200, "x2": 220, "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": []
    }
  }
  clockpropagator = DiscreteComponents.ClockPropagator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": 310, "x2": 520, "y2": 410, "rot": 0}
      },
      "tags": []
    }
  }
  samplevalue = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 20, "x2": 220, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  clockpropagator1 = DiscreteComponents.ClockPropagator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": -80, "x2": 520, "y2": 20, "rot": 0}
      },
      "tags": []
    }
  }
  clockpropagator2 = DiscreteComponents.ClockPropagator@[clk = clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": 110, "x2": 520, "y2": 210, "rot": 0}
      },
      "tags": []
    }
  }
  unitdelay = DiscreteComponents.UnitDelay() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 300, "x2": 750, "y2": 400, "rot": 0}
      },
      "tags": []
    }
  }
  add = BlockComponents.Math.Add() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 670, "y1": 450, "x2": 770, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  multiply = BlockComponents.Math.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": []
    }
  }
  resetvaluetracker = DiscreteComponents.Examples.Integrator.ResetValueTracker() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 590, "y1": 200, "x2": 690, "y2": 300, "rot": 0}
      },
      "tags": []
    }
  }
  switch1 = DiscreteComponents.Examples.Integrator.Switch() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 870, "y1": 430, "x2": 970, "y2": 530, "rot": 0}
      },
      "tags": []
    }
  }
  lastvalue = DiscreteComponents.Latest() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 450, "x2": 220, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  periodicclockprovoker = DiscreteComponents.PeriodicClock(dt = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 600, "x2": 360, "y2": 700, "rot": 0}
      },
      "tags": []
    }
  }
  lessthan = DiscreteComponents.Examples.Integrator.LessThan() {
    "Dyad": {"placement": {"diagram": {"x1": 700, "y1": 40, "x2": 800, "y2": 140}}}
  }
  constant1 = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {"placement": {"diagram": {"x1": 570, "y1": 90, "x2": 630, "y2": 150}}}
  }
  structural parameter 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@(clk-1) = 0.0
  initial reset_value@(clk-1) = 0.0
  initial y@(clk-1) = 0.0
  connect(ic, ic_sampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(ic_sampler.y, clockpropagator.u) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 260, "y": 250}, {"x": 260, "y": 325}], "E": 2}]}
  }
  connect(reset, samplevalue.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(samplevalue.y, clockpropagator1.u) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 290, "y": 70}, {"x": 290, "y": -65}], "E": 2}]}
  }
  connect(ic_sampler.y, clockpropagator2.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 370.5, "y": 250}, {"x": 370.5, "y": 195}], "E": 2}]
    }
  }
  connect(clockpropagator2.u, clockpropagator1.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 390, "y": 125}, {"x": 390, "y": 5}], "E": 2}]}
  }
  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": 540, "y": 670}, {"x": 540, "y": 623}], "E": 2}]}
  }
  connect(multiply.y, add.u2) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 660, "y": 600}, {"x": 660, "y": 530}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(ic_sampler.y, resetvaluetracker.initialcondition) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  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": 570}], "E": 2}]}
  }
  connect(clockpropagator.y, lastvalue.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 330.5, "y": 395}, {"x": 330.5, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(resetvaluetracker.resetvalue, switch1.u1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 870, "y": 250}, {"x": 870, "y": 454}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(samplevalue.y, lessthan.u1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460.5, "y": 70}, {"x": 460.5, "y": 66}], "E": 2}]
    }
  }
  connect(constant1.y, lessthan.u2) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 673, "y": 120}, {"x": 673, "y": 117}], "E": 2}]}
  }
  connect(lessthan.y, switch1.signal) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 920, "y": 90}], "E": 2}]}}
  connect(switch1.y, y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 1050, "y": 480}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(add.y, switch1.u2) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 822.5, "y": 500}, {"x": 822.5, "y": 504}], "E": 2}]
    }
  }
metadata {}
end


Test Cases

No test cases defined.

  • Examples
  • Experiments
  • Analyses