TestAcausalFIRFilter TestAcausalFIRFilter Icon

Examples.TestAcausalFIRFilter

Usage

PrimitiveComponents.Examples.TestAcausalFIRFilter()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( f_{+}flange_{b}, m_{+}flange_{a} \right) \\ \mathrm{connect}\left( hld_{+}y(t), f_{+}f(t) \right) \\ \mathrm{connect}\left( fix_{+}flange, f_{+}flange_{a} \right) \\ \mathrm{connect}\left( fir_{+}y(t), hld_{+}u(t) \right) \\ \mathrm{connect}\left( sin_{+}y(t), fir_{+}u(t) \right) \\ \mathrm{connect}\left( prescribeinitialposition_{+}flange, m_{+}flange_{b} \right) \\ \mathrm{connect}\left( prescribeinitialvelocity_{+}flange, m_{+}flange_{b} \right) \\ \mathtt{fir.y}\left( t \right) = \mathtt{fir.c1} \mathtt{fir.u}\left( t \right) + \mathtt{fir.c2} Shift(t, -1)\left( \mathtt{fir.u}\left( t \right) \right) \\ \frac{\mathrm{d} \mathtt{fir.l}\left( t \right)}{\mathrm{d}t} = 0 \\ \mathtt{sin.y}\left( t \right) = \mathtt{sin.offset} + \mathtt{sin.amplitude} ifelse\left( t \geq \mathtt{sin.start\_time}, \sin\left( \mathtt{sin.phase} + 6.2832 \mathtt{sin.frequency} \left( - \mathtt{sin.start\_time} + t \right) \right), \sin\left( \mathtt{sin.phase} \right) \right) \\ \mathtt{hld.y}\left( t \right) = ModelingToolkit.Hold()\left( \mathtt{hld.u}\left( t \right) \right) \\ \mathtt{f.flange\_a.f}\left( t \right) = \mathtt{f.f}\left( t \right) \\ \mathtt{f.flange\_b.f}\left( t \right) = - \mathtt{f.f}\left( t \right) \\ \mathtt{m.flange\_a.s}\left( t \right) = - \frac{1}{2} \mathtt{m.L} + \mathtt{m.s}\left( t \right) \\ \mathtt{m.flange\_b.s}\left( t \right) = \frac{1}{2} \mathtt{m.L} + \mathtt{m.s}\left( t \right) \\ \mathtt{m.v}\left( t \right) = \frac{\mathrm{d} \mathtt{m.s}\left( t \right)}{\mathrm{d}t} \\ \mathtt{m.a}\left( t \right) = \frac{\mathrm{d} \mathtt{m.v}\left( t \right)}{\mathrm{d}t} \\ \left( \mathtt{m.a}\left( t \right) + \mathtt{m.g} \sin\left( \mathtt{m.theta} \right) \right) \mathtt{m.m} = \mathtt{m.flange\_b.f}\left( t \right) + \mathtt{m.flange\_a.f}\left( t \right) \\ \mathtt{fix.flange.s}\left( t \right) = \mathtt{fix.s0} \\ \mathtt{prescribeinitialposition.flange.f}\left( t \right) = 0 \\ \frac{\mathrm{d} \mathtt{prescribeinitialvelocity.flange.s}\left( t \right)}{\mathrm{d}t} = \mathtt{prescribeinitialvelocity.v}\left( t \right) \\ \mathtt{prescribeinitialvelocity.flange.f}\left( t \right) = 0 \\ \end{array} \right] \end{equation} \]

Source

component TestAcausalFIRFilter
  fir = PrimitiveComponents.DiscretePrimitives.FIRFilter(dt = 0.01, n = 2, coeffs = [10, -10]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 140, "x2": 260, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  sin = BlockComponents.Sine(start_time = 1, offset = 0, amplitude = 10, frequency = 0.5, phase = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 140, "x2": 100, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  hld = PrimitiveComponents.DiscretePrimitives.ZeroOrderHold(initial_condition = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 340, "y1": 140, "x2": 440, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  f = TranslationalComponents.Force() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": 330, "x2": 520, "y2": 430, "rot": 0}
      }
    }
  }
  m = TranslationalComponents.Mass(m = 10, L = 0, g = -9.80665, theta = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 640, "y1": 330, "x2": 740, "y2": 430, "rot": 0}
      }
    }
  }
  fix = TranslationalComponents.Fixed(s0 = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 420, "x2": 360, "y2": 520, "rot": 0}
      }
    }
  }
  prescribeinitialposition = TranslationalComponents.PrescribeInitialPosition(s0 = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 870, "y1": 80, "x2": 970, "y2": 180, "rot": 0}
      },
      "tags": []
    }
  }
  prescribeinitialvelocity = TranslationalComponents.PrescribeInitialVelocity(v0 = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 870, "y1": 200, "x2": 970, "y2": 300, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(f.flange_b, m.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(f.f, hld.y) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 470, "y": 305}, {"x": 540, "y": 305}, {"x": 540, "y": 190}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(fix.flange, f.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 310, "y": 380}], "E": 2}]}}
  connect(fir.y, hld.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(sin.y, fir.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(prescribeinitialposition.flange, m.flange_b) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 805, "y": 130}, {"x": 805, "y": 380}], "E": 2}]
    }
  }
  connect(prescribeinitialvelocity.flange, m.flange_b) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 805, "y": 250}, {"x": 805, "y": 380}], "E": 2}]
    }
  }
end
Flattened Source
component TestAcausalFIRFilter
  fir = PrimitiveComponents.DiscretePrimitives.FIRFilter(dt = 0.01, n = 2, coeffs = [10, -10]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 140, "x2": 260, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  sin = BlockComponents.Sine(start_time = 1, offset = 0, amplitude = 10, frequency = 0.5, phase = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 140, "x2": 100, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  hld = PrimitiveComponents.DiscretePrimitives.ZeroOrderHold(initial_condition = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 340, "y1": 140, "x2": 440, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  f = TranslationalComponents.Force() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": 330, "x2": 520, "y2": 430, "rot": 0}
      }
    }
  }
  m = TranslationalComponents.Mass(m = 10, L = 0, g = -9.80665, theta = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 640, "y1": 330, "x2": 740, "y2": 430, "rot": 0}
      }
    }
  }
  fix = TranslationalComponents.Fixed(s0 = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 420, "x2": 360, "y2": 520, "rot": 0}
      }
    }
  }
  prescribeinitialposition = TranslationalComponents.PrescribeInitialPosition(s0 = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 870, "y1": 80, "x2": 970, "y2": 180, "rot": 0}
      },
      "tags": []
    }
  }
  prescribeinitialvelocity = TranslationalComponents.PrescribeInitialVelocity(v0 = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 870, "y1": 200, "x2": 970, "y2": 300, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(f.flange_b, m.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(f.f, hld.y) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 470, "y": 305}, {"x": 540, "y": 305}, {"x": 540, "y": 190}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(fix.flange, f.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 310, "y": 380}], "E": 2}]}}
  connect(fir.y, hld.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(sin.y, fir.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(prescribeinitialposition.flange, m.flange_b) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 805, "y": 130}, {"x": 805, "y": 380}], "E": 2}]
    }
  }
  connect(prescribeinitialvelocity.flange, m.flange_b) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 805, "y": 250}, {"x": 805, "y": 380}], "E": 2}]
    }
  }
metadata {}
end


Test Cases

No test cases defined.

  • Examples
  • Experiments
  • Analyses