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

[connect(torquestep+spline,inertia+splinea)connect(torquestep+support,fixed+spline)fixed.spline.phi(t)=fixed.phi0torquestep.support.phi(t)=torquestep.phi_support(t)torquestep.support.tau(t)=torquestep.spline.tau(t)torquestep.phi(t)=torquestep.spline.phi(t)torquestep.phi_support(t)torquestep.tau(t)=torquestep.spline.tau(t)torquestep.tau(t)=torquestep.offsetTorque+ifelse(t<torquestep.startTime,0.0,torquestep.stepTorque)inertia.phi(t)=inertia.splinea.phi(t)inertia.phi(t)=inertia.splineb.phi(t)dinertia.phi(t)dt=inertia.w(t)dinertia.w(t)dt=inertia.a(t)inertia.Jinertia.a(t)=inertia.splinea.tau(t)+inertia.splineb.tau(t)]

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()
  "Torque step source (stepTorque=22, offsetTorque=11, startTime=1)"
  torque_step = RotationalComponents.Sources.TorqueStep(stepTorque = 22, offsetTorque = 11, startTime = 1)
  "Inertia (J=3)"
  inertia = RotationalComponents.Components.Inertia(J = 3)
relations
  initial inertia.phi = 0
  initial inertia.w = 0
  connect(torque_step.spline, inertia.spline_a)
  connect(torque_step.support, fixed.spline)
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()
  "Torque step source (stepTorque=22, offsetTorque=11, startTime=1)"
  torque_step = RotationalComponents.Sources.TorqueStep(stepTorque = 22, offsetTorque = 11, startTime = 1)
  "Inertia (J=3)"
  inertia = RotationalComponents.Components.Inertia(J = 3)
relations
  initial inertia.phi = 0
  initial inertia.w = 0
  connect(torque_step.spline, inertia.spline_a)
  connect(torque_step.support, fixed.spline)
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