Skip to content
LIBRARY
Sources.Tests.Position.md

Sources.Tests.Position

Test of the Position source component with all ReferenceType enum variants, matching MSL ModelicaTest.Rotational.TestBearingConversion and TranslationalComponents pattern.

Three Position instances are driven by a common Sine reference (amplitude=0.1, frequency=1 Hz) and each drives an Inertia (J=1) with support grounded to Fixed:

  • pos_filtered: default Filtered mode (f_crit=50 Hz, af=1.3617, bf=0.6180)

  • pos_exact: Exact mode — spline angle equals input directly

  • pos_filtered_low: Filtered mode with low critical frequency (f_crit=5 Hz) to show visible filtering

Usage

RotationalComponents.Sources.Tests.Position()

Behavior

[connect(sine+y,posfiltered+phi_ref)connect(posfiltered+spline,inertiafiltered+spline_a)connect(posfiltered+support,fixed+spline)connect(sine+y,posexact+phi_ref)connect(posexact+spline,inertiaexact+spline_a)connect(posexact+support,fixed+spline)connect(sine+y,posfiltered_low+phi_ref)connect(posfiltered_low+spline,inertiafiltered_low+spline_a)connect(posfiltered_low+support,fixed+spline)sine.y(t)=sine.offset+sine.amplitudeifelse(tsine.starttime,sin(sine.phase+6.283185307179586sine.frequency(sine.starttime+t)),sin(sine.phase))posfiltered.support.phi(t)=posfiltered.phi_support(t)posfiltered.support.tau(t)=posfiltered.spline.tau(t)posfiltered.phi(t)=posfiltered.spline.phi(t)posfiltered.phi_support(t)posfiltered.w(t)=dposfiltered.phi(t)dtposfiltered.a(t)=dposfiltered.w(t)dtposfiltered.a(t)=314.1592653589793(posfiltered.a_fposfiltered.w(t)+100.0(posfiltered.phi(t)+posfiltered.phi_ref(t))π)posfiltered.b_finertiafiltered.phi(t)=inertiafiltered.spline_a.phi(t)inertiafiltered.phi(t)=inertiafiltered.spline_b.phi(t)dinertiafiltered.phi(t)dt=inertiafiltered.w(t)dinertiafiltered.w(t)dt=inertiafiltered.a(t)inertiafiltered.Jinertiafiltered.a(t)=inertiafiltered.spline_b.tau(t)+inertiafiltered.spline_a.tau(t)posexact.support.phi(t)=posexact.phi_support(t)posexact.support.tau(t)=posexact.spline.tau(t)posexact.phi(t)=posexact.phi_support(t)+posexact.spline.phi(t)posexact.phi(t)=posexact.phi_ref(t)posexact.w(t)=0posexact.a(t)=0inertiaexact.phi(t)=inertiaexact.spline_a.phi(t)inertiaexact.phi(t)=inertiaexact.spline_b.phi(t)dinertiaexact.phi(t)dt=inertiaexact.w(t)dinertiaexact.w(t)dt=inertiaexact.a(t)inertiaexact.Jinertiaexact.a(t)=inertiaexact.spline_a.tau(t)+inertiaexact.spline_b.tau(t)posfiltered_low.support.phi(t)=posfiltered_low.phi_support(t)posfiltered_low.support.tau(t)=posfiltered_low.spline.tau(t)posfiltered_low.phi(t)=posfiltered_low.spline.phi(t)posfiltered_low.phi_support(t)posfiltered_low.w(t)=dposfiltered_low.phi(t)dtposfiltered_low.a(t)=dposfiltered_low.w(t)dtposfiltered_low.a(t)=31.41592653589793(posfiltered_low.a_fposfiltered_low.w(t)+10.0π(posfiltered_low.phi_ref(t)posfiltered_low.phi(t)))posfiltered_low.b_finertiafiltered_low.phi(t)=inertiafiltered_low.spline_a.phi(t)inertiafiltered_low.phi(t)=inertiafiltered_low.spline_b.phi(t)dinertiafiltered_low.phi(t)dt=inertiafiltered_low.w(t)dinertiafiltered_low.w(t)dt=inertiafiltered_low.a(t)inertiafiltered_low.Jinertiafiltered_low.a(t)=inertiafiltered_low.spline_a.tau(t)+inertiafiltered_low.spline_b.tau(t)fixed.spline.phi(t)=fixed.phi0]

Source

dyad
"""
Test of the Position source component with all ReferenceType enum variants,
matching MSL ModelicaTest.Rotational.TestBearingConversion and TranslationalComponents pattern.

Three Position instances are driven by a common Sine reference (amplitude=0.1, frequency=1 Hz)
and each drives an Inertia (J=1) with support grounded to Fixed:

- pos_filtered: default Filtered mode (f_crit=50 Hz, af=1.3617, bf=0.6180)
- pos_exact: Exact mode — spline angle equals input directly
- pos_filtered_low: Filtered mode with low critical frequency (f_crit=5 Hz) to show visible filtering
"""
test component Position
  "Sine reference angle signal (amplitude=0.1, frequency=1 Hz)"
  sine = BlockComponents.Sources.Sine(amplitude = 0.1, frequency = 1.0)
  "Position source — Filtered with default Bessel filter (f_crit=50 Hz)"
  pos_filtered = RotationalComponents.Sources.Position()
  "Inertia driven by filtered position source"
  inertia_filtered = RotationalComponents.Components.Inertia(J = 1)
  "Position source — Exact (spline tracks input directly)"
  pos_exact = RotationalComponents.Sources.Position(ref_type = RotationalComponents.Sources.ReferenceType.Exact())
  "Inertia driven by exact position source"
  inertia_exact = RotationalComponents.Components.Inertia(J = 1)
  "Position source — Filtered with low critical frequency (f_crit=5 Hz)"
  pos_filtered_low = RotationalComponents.Sources.Position(ref_type = RotationalComponents.Sources.ReferenceType.Filtered(f_crit = 5.0))
  "Inertia driven by low-f_crit filtered position source"
  inertia_filtered_low = RotationalComponents.Components.Inertia(J = 1)
  "Fixed ground for all supports"
  fixed = RotationalComponents.Components.Fixed()
relations
  connect(sine.y, pos_filtered.phi_ref)
  connect(pos_filtered.spline, inertia_filtered.spline_a)
  connect(pos_filtered.support, fixed.spline)
  initial pos_filtered.w = 0
  connect(sine.y, pos_exact.phi_ref)
  connect(pos_exact.spline, inertia_exact.spline_a)
  connect(pos_exact.support, fixed.spline)
  connect(sine.y, pos_filtered_low.phi_ref)
  connect(pos_filtered_low.spline, inertia_filtered_low.spline_a)
  connect(pos_filtered_low.support, fixed.spline)
  initial pos_filtered_low.w = 0
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1.1,
        "atol": {
          "inertia_filtered.phi": 0.001,
          "inertia_exact.phi": 0.001,
          "inertia_filtered_low.phi": 0.001
        },
        "expect": {
          "initial": {
            "inertia_exact.phi": 0,
            "inertia_filtered.phi": 0,
            "inertia_filtered_low.phi": 0
          },
          "signals": ["inertia_filtered.phi", "inertia_exact.phi", "inertia_filtered_low.phi"]
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Test of the Position source component with all ReferenceType enum variants,
matching MSL ModelicaTest.Rotational.TestBearingConversion and TranslationalComponents pattern.

Three Position instances are driven by a common Sine reference (amplitude=0.1, frequency=1 Hz)
and each drives an Inertia (J=1) with support grounded to Fixed:

- pos_filtered: default Filtered mode (f_crit=50 Hz, af=1.3617, bf=0.6180)
- pos_exact: Exact mode — spline angle equals input directly
- pos_filtered_low: Filtered mode with low critical frequency (f_crit=5 Hz) to show visible filtering
"""
test component Position
  "Sine reference angle signal (amplitude=0.1, frequency=1 Hz)"
  sine = BlockComponents.Sources.Sine(amplitude = 0.1, frequency = 1.0)
  "Position source — Filtered with default Bessel filter (f_crit=50 Hz)"
  pos_filtered = RotationalComponents.Sources.Position()
  "Inertia driven by filtered position source"
  inertia_filtered = RotationalComponents.Components.Inertia(J = 1)
  "Position source — Exact (spline tracks input directly)"
  pos_exact = RotationalComponents.Sources.Position(ref_type = RotationalComponents.Sources.ReferenceType.Exact())
  "Inertia driven by exact position source"
  inertia_exact = RotationalComponents.Components.Inertia(J = 1)
  "Position source — Filtered with low critical frequency (f_crit=5 Hz)"
  pos_filtered_low = RotationalComponents.Sources.Position(ref_type = RotationalComponents.Sources.ReferenceType.Filtered(f_crit = 5.0))
  "Inertia driven by low-f_crit filtered position source"
  inertia_filtered_low = RotationalComponents.Components.Inertia(J = 1)
  "Fixed ground for all supports"
  fixed = RotationalComponents.Components.Fixed()
relations
  connect(sine.y, pos_filtered.phi_ref)
  connect(pos_filtered.spline, inertia_filtered.spline_a)
  connect(pos_filtered.support, fixed.spline)
  initial pos_filtered.w = 0
  connect(sine.y, pos_exact.phi_ref)
  connect(pos_exact.spline, inertia_exact.spline_a)
  connect(pos_exact.support, fixed.spline)
  connect(sine.y, pos_filtered_low.phi_ref)
  connect(pos_filtered_low.spline, inertia_filtered_low.spline_a)
  connect(pos_filtered_low.support, fixed.spline)
  initial pos_filtered_low.w = 0
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1.1,
        "atol": {
          "inertia_filtered.phi": 0.001,
          "inertia_exact.phi": 0.001,
          "inertia_filtered_low.phi": 0.001
        },
        "expect": {
          "initial": {
            "inertia_exact.phi": 0,
            "inertia_filtered.phi": 0,
            "inertia_filtered_low.phi": 0
          },
          "signals": ["inertia_filtered.phi", "inertia_exact.phi", "inertia_filtered_low.phi"]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt