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

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) {
    "Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 605, "y2": 705}}}
  }
  "Position source — Filtered with default Bessel filter (f_crit=50 Hz)"
  pos_filtered = RotationalComponents.Sources.Position() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 605, "y2": 705}}}
  }
  "Inertia driven by filtered position source"
  inertia_filtered = RotationalComponents.Components.Inertia(J = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 605, "y2": 705}}}
  }
  "Position source — Exact (spline tracks input directly)"
  pos_exact = RotationalComponents.Sources.Position(ref_type = RotationalComponents.Sources.ReferenceType.Exact()) {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 195, "y2": 295}}}
  }
  "Inertia driven by exact position source"
  inertia_exact = RotationalComponents.Components.Inertia(J = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 195, "y2": 295}}}
  }
  "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)) {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 400, "y2": 500}}}
  }
  "Inertia driven by low-f_crit filtered position source"
  inertia_filtered_low = RotationalComponents.Components.Inertia(J = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 400, "y2": 500}}}
  }
  "Fixed ground for all supports"
  fixed = RotationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 290, "x2": 390, "y1": 60, "y2": 160}}}
  }
relations
  connect(sine.y, pos_filtered.phi_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(pos_filtered.spline, inertia_filtered.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(pos_filtered.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 205, "y": 760},
            {"x": 270, "y": 760},
            {"x": 270, "y": 20},
            {"x": 340, "y": 20}
          ],
          "E": 2
        }
      ],
      "path": {}
    }
  }
  initial pos_filtered.w = 0
  connect(sine.y, pos_exact.phi_ref) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 140, "y": 245}], "E": 2}],
      "junctions": [{"x": 140, "y": 655}],
      "path": {}
    }
  }
  connect(pos_exact.spline, inertia_exact.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(pos_exact.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 205, "y": 350}], "E": -1},
        {"S": -1, "M": [{"x": 270, "y": 20}, {"x": 340, "y": 20}], "E": 2}
      ],
      "junctions": [{"x": 270, "y": 350}],
      "path": {}
    }
  }
  connect(sine.y, pos_filtered_low.phi_ref) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 655}], "E": -1}, {"S": -1, "M": [], "E": 2}],
      "junctions": [{"x": 140, "y": 450}],
      "path": {}
    }
  }
  connect(pos_filtered_low.spline, inertia_filtered_low.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(pos_filtered_low.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 205, "y": 555}], "E": -1},
        {"S": -1, "M": [{"x": 270, "y": 20}, {"x": 340, "y": 20}], "E": 2}
      ],
      "junctions": [{"x": 270, "y": 555}],
      "path": {}
    }
  }
  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) {
    "Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 605, "y2": 705}}}
  }
  "Position source — Filtered with default Bessel filter (f_crit=50 Hz)"
  pos_filtered = RotationalComponents.Sources.Position() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 605, "y2": 705}}}
  }
  "Inertia driven by filtered position source"
  inertia_filtered = RotationalComponents.Components.Inertia(J = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 605, "y2": 705}}}
  }
  "Position source — Exact (spline tracks input directly)"
  pos_exact = RotationalComponents.Sources.Position(ref_type = RotationalComponents.Sources.ReferenceType.Exact()) {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 195, "y2": 295}}}
  }
  "Inertia driven by exact position source"
  inertia_exact = RotationalComponents.Components.Inertia(J = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 195, "y2": 295}}}
  }
  "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)) {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 400, "y2": 500}}}
  }
  "Inertia driven by low-f_crit filtered position source"
  inertia_filtered_low = RotationalComponents.Components.Inertia(J = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 400, "y2": 500}}}
  }
  "Fixed ground for all supports"
  fixed = RotationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 290, "x2": 390, "y1": 60, "y2": 160}}}
  }
relations
  connect(sine.y, pos_filtered.phi_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(pos_filtered.spline, inertia_filtered.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(pos_filtered.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 205, "y": 760},
            {"x": 270, "y": 760},
            {"x": 270, "y": 20},
            {"x": 340, "y": 20}
          ],
          "E": 2
        }
      ],
      "path": {}
    }
  }
  initial pos_filtered.w = 0
  connect(sine.y, pos_exact.phi_ref) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 140, "y": 245}], "E": 2}],
      "junctions": [{"x": 140, "y": 655}],
      "path": {}
    }
  }
  connect(pos_exact.spline, inertia_exact.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(pos_exact.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 205, "y": 350}], "E": -1},
        {"S": -1, "M": [{"x": 270, "y": 20}, {"x": 340, "y": 20}], "E": 2}
      ],
      "junctions": [{"x": 270, "y": 350}],
      "path": {}
    }
  }
  connect(sine.y, pos_filtered_low.phi_ref) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 655}], "E": -1}, {"S": -1, "M": [], "E": 2}],
      "junctions": [{"x": 140, "y": 450}],
      "path": {}
    }
  }
  connect(pos_filtered_low.spline, inertia_filtered_low.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(pos_filtered_low.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 205, "y": 555}], "E": -1},
        {"S": -1, "M": [{"x": 270, "y": 20}, {"x": 340, "y": 20}], "E": 2}
      ],
      "junctions": [{"x": 270, "y": 555}],
      "path": {}
    }
  }
  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