Skip to content
LIBRARY
Sources.Tests.Torque2.md

Sources.Tests.Torque2

Test for Torque2: two inertias driven by a torque acting between them, matching the MSL test topology.

SpeedSource (sine, f=1 Hz) → inertia_a (J=3) → Torque2 → inertia_b (J=3) ↑ sine (f=1 Hz)

inertia_b is free on its outer flange. With tau = sin(2πt), and the flow sign convention at the connection (connect sums flow to zero), inertia_b sees +tau:

  • J_b * a_b = +tau → a_b = sin(2πt)/3

  • w_b(t) = (1 - cos(2πt))/(6π)

  • At t=1.0: w_b = 0

  • phi_b(t) = t/(6π) - sin(2πt)/(12π²)

  • At t=1.0: phi_b ≈ 1/(6π) ≈ 0.05305

Usage

RotationalComponents.Sources.Tests.Torque2()

Behavior

[connect(speedsine+y,speed+wref)connect(speed+support,fixed+spline)connect(speed+spline,inertiaa+spline_a)connect(inertiaa+spline_b,torque2+splinea)connect(torque2+splineb,inertiab+spline_a)connect(torquesine+y,torque2+tau)fixed.spline.phi(t)=fixed.phi0speedsine.y(t)=speedsine.offset+speedsine.amplitudeifelse(tspeedsine.start_time,sin(speedsine.phase+6.283185307179586speedsine.frequency(speedsine.start_time+t)),sin(speedsine.phase))speed.support.phi(t)=speed.phisupport(t)speed.support.tau(t)=speed.spline.tau(t)speed.phi(t)=speed.spline.phi(t)speed.phisupport(t)speed.w(t)=dspeed.phi(t)dtspeed.w(t)=speed.wref(t)speed.a(t)=0inertiaa.phi(t)=inertiaa.spline_a.phi(t)inertiaa.phi(t)=inertiaa.spline_b.phi(t)dinertiaa.phi(t)dt=inertiaa.w(t)dinertiaa.w(t)dt=inertiaa.a(t)inertiaa.Jinertiaa.a(t)=inertiaa.spline_b.tau(t)+inertiaa.spline_a.tau(t)torque2.splinea.tau(t)=torque2.tau(t)torque2.splineb.tau(t)=torque2.tau(t)torquesine.y(t)=torquesine.offset+torquesine.amplitudeifelse(ttorquesine.start_time,sin(torquesine.phase+6.283185307179586(ttorquesine.start_time)torquesine.frequency),sin(torquesine.phase))inertiab.phi(t)=inertiab.spline_a.phi(t)inertiab.phi(t)=inertiab.spline_b.phi(t)dinertiab.phi(t)dt=inertiab.w(t)dinertiab.w(t)dt=inertiab.a(t)inertiab.Jinertiab.a(t)=inertiab.spline_a.tau(t)+inertiab.spline_b.tau(t)]

Source

dyad
"""
Test for Torque2: two inertias driven by a torque acting between them, matching the MSL test topology.

SpeedSource (sine, f=1 Hz) → inertia_a (J=3) → Torque2 → inertia_b (J=3)

                                              sine (f=1 Hz)

inertia_b is free on its outer flange. With tau = sin(2πt), and the flow sign
convention at the connection (connect sums flow to zero), inertia_b sees +tau:
  - J_b * a_b = +tau → a_b = sin(2πt)/3
  - w_b(t) = (1 - cos(2πt))/(6π)
  - At t=1.0: w_b = 0
  - phi_b(t) = t/(6π) - sin(2πt)/(12π²)
  - At t=1.0: phi_b ≈ 1/(6π) ≈ 0.05305
"""
test component Torque2
  "Fixed support for speed source"
  fixed = RotationalComponents.Components.Fixed()
  "Sine signal for speed reference (amplitude=1, f=1 Hz)"
  speed_sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1)
  "Speed source prescribing inertia_a velocity (Exact mode)"
  speed = RotationalComponents.Sources.SpeedSource(ref_type = RotationalComponents.Sources.ReferenceType.Exact())
  "First inertia (J=3), speed-driven side"
  inertia_a = RotationalComponents.Components.Inertia(J = 3)
  "Torque2 under test"
  torque2 = RotationalComponents.Sources.Torque2()
  "Sine signal for torque input (amplitude=1, f=1 Hz)"
  torque_sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1)
  "Second inertia (J=3), free side"
  inertia_b = RotationalComponents.Components.Inertia(J = 3)
relations
  initial inertia_a.phi = 0
  initial inertia_b.phi = 0
  initial inertia_b.w = 0
  connect(speed_sine.y, speed.w_ref)
  connect(speed.support, fixed.spline)
  connect(speed.spline, inertia_a.spline_a)
  connect(inertia_a.spline_b, torque2.spline_a)
  connect(torque2.spline_b, inertia_b.spline_a)
  connect(torque_sine.y, torque2.tau)
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "atol": {"inertia_b.phi": 0.001, "inertia_b.w": 0.001, "inertia_a.w": 0.001},
        "expect": {
          "initial": {"inertia_a.phi": 0, "inertia_b.phi": 0, "inertia_b.w": 0},
          "final": {"inertia_b.phi": 0.05305, "inertia_b.w": 0, "inertia_a.w": 0},
          "signals": ["inertia_b.phi", "inertia_b.w", "inertia_a.w", "inertia_a.phi"]
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Test for Torque2: two inertias driven by a torque acting between them, matching the MSL test topology.

SpeedSource (sine, f=1 Hz) → inertia_a (J=3) → Torque2 → inertia_b (J=3)

                                              sine (f=1 Hz)

inertia_b is free on its outer flange. With tau = sin(2πt), and the flow sign
convention at the connection (connect sums flow to zero), inertia_b sees +tau:
  - J_b * a_b = +tau → a_b = sin(2πt)/3
  - w_b(t) = (1 - cos(2πt))/(6π)
  - At t=1.0: w_b = 0
  - phi_b(t) = t/(6π) - sin(2πt)/(12π²)
  - At t=1.0: phi_b ≈ 1/(6π) ≈ 0.05305
"""
test component Torque2
  "Fixed support for speed source"
  fixed = RotationalComponents.Components.Fixed()
  "Sine signal for speed reference (amplitude=1, f=1 Hz)"
  speed_sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1)
  "Speed source prescribing inertia_a velocity (Exact mode)"
  speed = RotationalComponents.Sources.SpeedSource(ref_type = RotationalComponents.Sources.ReferenceType.Exact())
  "First inertia (J=3), speed-driven side"
  inertia_a = RotationalComponents.Components.Inertia(J = 3)
  "Torque2 under test"
  torque2 = RotationalComponents.Sources.Torque2()
  "Sine signal for torque input (amplitude=1, f=1 Hz)"
  torque_sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1)
  "Second inertia (J=3), free side"
  inertia_b = RotationalComponents.Components.Inertia(J = 3)
relations
  initial inertia_a.phi = 0
  initial inertia_b.phi = 0
  initial inertia_b.w = 0
  connect(speed_sine.y, speed.w_ref)
  connect(speed.support, fixed.spline)
  connect(speed.spline, inertia_a.spline_a)
  connect(inertia_a.spline_b, torque2.spline_a)
  connect(torque2.spline_b, inertia_b.spline_a)
  connect(torque_sine.y, torque2.tau)
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "atol": {"inertia_b.phi": 0.001, "inertia_b.w": 0.001, "inertia_a.w": 0.001},
        "expect": {
          "initial": {"inertia_a.phi": 0, "inertia_b.phi": 0, "inertia_b.w": 0},
          "final": {"inertia_b.phi": 0.05305, "inertia_b.w": 0, "inertia_a.w": 0},
          "signals": ["inertia_b.phi", "inertia_b.w", "inertia_a.w", "inertia_a.phi"]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt

julia
plt