Skip to content
LIBRARY
Sources.Tests.AllComponents.md

Sources.Tests.AllComponents

Tests Position, VelocitySource, AccelerationSource, and Torque2 components, matching the source-related subsystems from MSL ModelicaTest.Rotational.AllComponents.

Three subsystems from AllComponents are replicated here:

  1. Position (Filtered default, f_crit=50 Hz): Sine(f=1) → Position → Inertia(J=3)

  2. Velocity + Torque2 (Filtered default): Sine(f=1) → VelocitySource → Inertia(J=3) → Torque2(Sine f=1) → Inertia(J=3)

  3. Accelerate: Sine(f=1) → AccelerationSource → Inertia(J=3)

All supports are grounded to Fixed. Stop time = 0.9 s.

Usage

RotationalComponents.Sources.Tests.AllComponents()

Behavior

Source

dyad
"""
Tests Position, VelocitySource, AccelerationSource, and Torque2 components,
matching the source-related subsystems from MSL ModelicaTest.Rotational.AllComponents.

Three subsystems from AllComponents are replicated here:

1. Position (Filtered default, f_crit=50 Hz): Sine(f=1) → Position → Inertia(J=3)
2. Velocity + Torque2 (Filtered default): Sine(f=1) → VelocitySource → Inertia(J=3) → Torque2(Sine f=1) → Inertia(J=3)
3. Accelerate: Sine(f=1) → AccelerationSource → Inertia(J=3)

All supports are grounded to Fixed. Stop time = 0.9 s.
"""
test component AllComponents
  "Fixed ground for all supports"
  fixed = RotationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 225, "y2": 325}}}
  }
  "Sine reference for position source (f=1 Hz)"
  sine_pos = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {"Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 20, "y2": 120}}}}
  "Position source — default Filtered mode (f_crit=50 Hz)"
  position = RotationalComponents.Sources.Position() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 20, "y2": 120}}}
  }
  "Inertia driven by position source (MSL inertia9, J=3)"
  inertia_pos = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 20, "y2": 120}}}
  }
  "Sine reference for velocity source (f=1 Hz)"
  sine_velocity = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 670, "y2": 770}}}
  }
  "VelocitySource — default Filtered mode (f_crit=50 Hz)"
  velocity = RotationalComponents.Sources.VelocitySource() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 670, "y2": 770}}}
  }
  "Inertia driven by velocity source (MSL inertia10, J=3)"
  inertia_velocity = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 670, "y2": 770}}}
  }
  "Sine input for Torque2 (f=1 Hz)"
  sine_torque2 = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 280, "x2": 380, "y1": 345, "y2": 445}}}
  }
  "Torque2 — acts between velocity inertia and output inertia"
  torque2 = RotationalComponents.Sources.Torque2() {
    "Dyad": {"placement": {"diagram": {"x1": 415, "x2": 515, "y1": 670, "y2": 770}}}
  }
  "Inertia driven by Torque2 (MSL inertia13, J=3)"
  inertia13 = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 560, "x2": 660, "y1": 670, "y2": 770}}}
  }
  "Sine reference for accelerate source (f=1 Hz)"
  sine_acc = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 465, "y2": 565}}}
  }
  "AccelerationSource"
  accelerate = RotationalComponents.Sources.AccelerationSource() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 465, "y2": 565}}}
  }
  "Inertia driven by accelerate source (MSL inertia11, J=3)"
  inertia_acc = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 465, "y2": 565}}}
  }
relations
  # Position subsystem
  initial position.w = 0
  initial inertia_velocity.phi = 0
  connect(sine_pos.y, position.phi_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(position.spline, inertia_pos.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(position.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 205, "y": 415}], "E": -1},
        {"S": -1, "M": [{"x": 270, "y": 170}, {"x": 335, "y": 170}], "E": 2}
      ],
      "junctions": [{"x": 270, "y": 415}],
      "path": {}
    }
  }
  # Velocity + Torque2 subsystem
  initial inertia13.phi = 0
  initial inertia13.w = 0
  connect(sine_velocity.y, velocity.w_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(velocity.spline, inertia_velocity.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(velocity.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 205, "y": 825},
            {"x": 270, "y": 825},
            {"x": 270, "y": 170},
            {"x": 335, "y": 170}
          ],
          "E": 2
        }
      ],
      "path": {}
    }
  }
  connect(inertia_velocity.spline_b, torque2.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(torque2.spline_b, inertia13.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(sine_torque2.y, torque2.tau) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 465, "y": 395}], "E": 2}], "path": {}}}
  # Accelerate subsystem
  initial accelerate.phi = 0
  initial accelerate.w = 0
  connect(sine_acc.y, accelerate.a_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(accelerate.spline, inertia_acc.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(accelerate.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 205, "y": 620}], "E": -1},
        {"S": -1, "M": [{"x": 270, "y": 170}, {"x": 335, "y": 170}], "E": 2}
      ],
      "junctions": [{"x": 270, "y": 620}],
      "path": {}
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 0.9,
        "expect": {
          "signals": [
            "position.phi",
            "position.w",
            "velocity.phi",
            "velocity.w",
            "accelerate.phi",
            "accelerate.w",
            "inertia13.phi",
            "inertia13.w"
          ]
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Tests Position, VelocitySource, AccelerationSource, and Torque2 components,
matching the source-related subsystems from MSL ModelicaTest.Rotational.AllComponents.

Three subsystems from AllComponents are replicated here:

1. Position (Filtered default, f_crit=50 Hz): Sine(f=1) → Position → Inertia(J=3)
2. Velocity + Torque2 (Filtered default): Sine(f=1) → VelocitySource → Inertia(J=3) → Torque2(Sine f=1) → Inertia(J=3)
3. Accelerate: Sine(f=1) → AccelerationSource → Inertia(J=3)

All supports are grounded to Fixed. Stop time = 0.9 s.
"""
test component AllComponents
  "Fixed ground for all supports"
  fixed = RotationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 225, "y2": 325}}}
  }
  "Sine reference for position source (f=1 Hz)"
  sine_pos = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {"Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 20, "y2": 120}}}}
  "Position source — default Filtered mode (f_crit=50 Hz)"
  position = RotationalComponents.Sources.Position() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 20, "y2": 120}}}
  }
  "Inertia driven by position source (MSL inertia9, J=3)"
  inertia_pos = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 20, "y2": 120}}}
  }
  "Sine reference for velocity source (f=1 Hz)"
  sine_velocity = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 670, "y2": 770}}}
  }
  "VelocitySource — default Filtered mode (f_crit=50 Hz)"
  velocity = RotationalComponents.Sources.VelocitySource() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 670, "y2": 770}}}
  }
  "Inertia driven by velocity source (MSL inertia10, J=3)"
  inertia_velocity = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 670, "y2": 770}}}
  }
  "Sine input for Torque2 (f=1 Hz)"
  sine_torque2 = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 280, "x2": 380, "y1": 345, "y2": 445}}}
  }
  "Torque2 — acts between velocity inertia and output inertia"
  torque2 = RotationalComponents.Sources.Torque2() {
    "Dyad": {"placement": {"diagram": {"x1": 415, "x2": 515, "y1": 670, "y2": 770}}}
  }
  "Inertia driven by Torque2 (MSL inertia13, J=3)"
  inertia13 = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 560, "x2": 660, "y1": 670, "y2": 770}}}
  }
  "Sine reference for accelerate source (f=1 Hz)"
  sine_acc = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 465, "y2": 565}}}
  }
  "AccelerationSource"
  accelerate = RotationalComponents.Sources.AccelerationSource() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 465, "y2": 565}}}
  }
  "Inertia driven by accelerate source (MSL inertia11, J=3)"
  inertia_acc = RotationalComponents.Components.Inertia(J = 3) {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 465, "y2": 565}}}
  }
relations
  # Position subsystem
  initial position.w = 0
  initial inertia_velocity.phi = 0
  connect(sine_pos.y, position.phi_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(position.spline, inertia_pos.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(position.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 205, "y": 415}], "E": -1},
        {"S": -1, "M": [{"x": 270, "y": 170}, {"x": 335, "y": 170}], "E": 2}
      ],
      "junctions": [{"x": 270, "y": 415}],
      "path": {}
    }
  }
  # Velocity + Torque2 subsystem
  initial inertia13.phi = 0
  initial inertia13.w = 0
  connect(sine_velocity.y, velocity.w_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(velocity.spline, inertia_velocity.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(velocity.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 205, "y": 825},
            {"x": 270, "y": 825},
            {"x": 270, "y": 170},
            {"x": 335, "y": 170}
          ],
          "E": 2
        }
      ],
      "path": {}
    }
  }
  connect(inertia_velocity.spline_b, torque2.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(torque2.spline_b, inertia13.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(sine_torque2.y, torque2.tau) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 465, "y": 395}], "E": 2}], "path": {}}}
  # Accelerate subsystem
  initial accelerate.phi = 0
  initial accelerate.w = 0
  connect(sine_acc.y, accelerate.a_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(accelerate.spline, inertia_acc.spline_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(accelerate.support, fixed.spline) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 205, "y": 620}], "E": -1},
        {"S": -1, "M": [{"x": 270, "y": 170}, {"x": 335, "y": 170}], "E": 2}
      ],
      "junctions": [{"x": 270, "y": 620}],
      "path": {}
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://RotationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 0.9,
        "expect": {
          "signals": [
            "position.phi",
            "position.w",
            "velocity.phi",
            "velocity.w",
            "accelerate.phi",
            "accelerate.w",
            "inertia13.phi",
            "inertia13.w"
          ]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt