Skip to content
LIBRARY
Sources.Tests.TorqueStep.md

Sources.Tests.TorqueStep

Test for TorqueStep source, matching MSL ModelicaTest.Rotational.AllComponents topology.

TorqueStep applies offsetTorque=11 for t<1, then offsetTorque+stepTorque=33 for t≥1 to an inertia (J=3, initially at rest).

Phase 1 (0 ≤ t < 1): tau=11, a=11/3, w(t)=(11/3)t, phi(t)=(11/6)t² w(1) = 11/3 ≈ 3.667, phi(1) = 11/6 ≈ 1.833

Phase 2 (t ≥ 1): tau=33, a=11, w(t)=(11/3)+11(t-1), phi(t)=11/6+(11/3)(t-1)+(11/2)(t-1)² w(2) = 11/3+11 ≈ 14.667, phi(2) = 11/6+11/3+11/2 = 11/6+22/6+33/6 = 11

Usage

RotationalComponents.Sources.Tests.TorqueStep()

Behavior

Source

dyad
"""
Test for TorqueStep source, matching MSL ModelicaTest.Rotational.AllComponents topology.

TorqueStep applies offsetTorque=11 for t<1, then offsetTorque+stepTorque=33 for t≥1
to an inertia (J=3, initially at rest).

Phase 1 (0 ≤ t < 1): tau=11, a=11/3, w(t)=(11/3)t, phi(t)=(11/6)t²
  w(1) = 11/3 ≈ 3.667, phi(1) = 11/6 ≈ 1.833

Phase 2 (t ≥ 1): tau=33, a=11, w(t)=(11/3)+11(t-1), phi(t)=11/6+(11/3)(t-1)+(11/2)(t-1)²
  w(2) = 11/3+11 ≈ 14.667, phi(2) = 11/6+11/3+11/2 = 11/6+22/6+33/6 = 11 
"""
test component TorqueStep
  "Fixed ground for source support"
  fixed = RotationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 140, "x2": 240, "y1": 230, "y2": 330}}}
  }
  "Torque step source (stepTorque=22, offsetTorque=11, startTime=1)"
  torque_step = RotationalComponents.Sources.TorqueStep(stepTorque = 22, offsetTorque = 11, startTime = 1) {"Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 20, "y2": 120}}}}
  "Inertia (J=3)"
  inertia = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 150, "x2": 250, "y1": 20, "y2": 120}}}
  }
relations
  initial inertia.phi = 0
  initial inertia.w = 0
  connect(torque_step.spline, inertia.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(torque_step.support, fixed.spline) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 70, "y": 175}, {"x": 190, "y": 175}], "E": 2}],
      "path": {}
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 2,
        "atol": {"inertia.w": 0.01, "inertia.phi": 0.01},
        "expect": {
          "initial": {"inertia.phi": 0, "inertia.w": 0},
          "final": {"inertia.w": 14.667, "inertia.phi": 11},
          "signals": ["inertia.w", "inertia.phi", "torque_step.tau"]
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Test for TorqueStep source, matching MSL ModelicaTest.Rotational.AllComponents topology.

TorqueStep applies offsetTorque=11 for t<1, then offsetTorque+stepTorque=33 for t≥1
to an inertia (J=3, initially at rest).

Phase 1 (0 ≤ t < 1): tau=11, a=11/3, w(t)=(11/3)t, phi(t)=(11/6)t²
  w(1) = 11/3 ≈ 3.667, phi(1) = 11/6 ≈ 1.833

Phase 2 (t ≥ 1): tau=33, a=11, w(t)=(11/3)+11(t-1), phi(t)=11/6+(11/3)(t-1)+(11/2)(t-1)²
  w(2) = 11/3+11 ≈ 14.667, phi(2) = 11/6+11/3+11/2 = 11/6+22/6+33/6 = 11 
"""
test component TorqueStep
  "Fixed ground for source support"
  fixed = RotationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 140, "x2": 240, "y1": 230, "y2": 330}}}
  }
  "Torque step source (stepTorque=22, offsetTorque=11, startTime=1)"
  torque_step = RotationalComponents.Sources.TorqueStep(stepTorque = 22, offsetTorque = 11, startTime = 1) {"Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 20, "y2": 120}}}}
  "Inertia (J=3)"
  inertia = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 150, "x2": 250, "y1": 20, "y2": 120}}}
  }
relations
  initial inertia.phi = 0
  initial inertia.w = 0
  connect(torque_step.spline, inertia.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(torque_step.support, fixed.spline) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 70, "y": 175}, {"x": 190, "y": 175}], "E": 2}],
      "path": {}
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 2,
        "atol": {"inertia.w": 0.01, "inertia.phi": 0.01},
        "expect": {
          "initial": {"inertia.phi": 0, "inertia.w": 0},
          "final": {"inertia.w": 14.667, "inertia.phi": 11},
          "signals": ["inertia.w", "inertia.phi", "torque_step.tau"]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt