Skip to content
LIBRARY
PlanarMechanics.WorldForceTest.md

PlanarMechanics.WorldForceTest

Test for WorldForceTorque: a damped pendulum with an applied sinusoidal force.

Topology: Fixed → Revolute → FixedTranslation → Body A WorldForceTorque applies a sinusoidal force in x-direction to the body. A Damper stabilizes the revolute joint.

Translated from PlanarMechanicsTest.Sources.WorldForce.

Usage

MultibodyComponents.PlanarMechanics.WorldForceTest()

Behavior

Source

dyad
"""
Test for WorldForceTorque: a damped pendulum with an applied sinusoidal force.

Topology: Fixed → Revolute → FixedTranslation → Body
A WorldForceTorque applies a sinusoidal force in x-direction to the body.
A Damper stabilizes the revolute joint.

Translated from PlanarMechanicsTest.Sources.WorldForce.
"""
test component WorldForceTest
  world = World() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  revolute = Revolute(phi(initial = 0), w(initial = 0)) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 295, "y1": 20, "x2": 395, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  rod = FixedTranslation(r = [0, -1]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 415, "y1": 20, "x2": 515, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(m = 1, I = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 295, "y1": 150, "x2": 395, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  damper = MultibodyComponents.PlanarMechanics.Damper(d = 1) {
    "Dyad": {
      "placement": {
        "diagram": {
          "iconName": "default",
          "x1": 167.5,
          "y1": 150,
          "x2": 267.5,
          "y2": 250,
          "rot": 0
        }
      },
      "tags": []
    }
  }
  force = WorldForceTorque(resolve_in_frame = MultibodyComponents.ResolveInFrame.World(), scale = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 165, "y1": 270, "x2": 265, "y2": 370, "rot": 0}
      },
      "tags": []
    }
  }
  sine_x = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 150, "x2": 120, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  zero_y = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 270, "x2": 120, "y2": 370, "rot": 0}
      },
      "tags": []
    }
  }
  zero_tau = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 390, "x2": 120, "y2": 490, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(world.frame_b, revolute.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(revolute.frame_b, rod.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(rod.frame_b, body.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 525, "y": 70}, {"x": 525, "y": 300}], "E": -1},
        {"S": -1, "M": [], "E": -2},
        {"S": -2, "M": [], "E": 2}
      ],
      "junctions": [{"x": 285, "y": 300}, {"x": 285, "y": 200}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, force.frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 285, "y": 200}, {"x": 285, "y": 320}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(sine_x.y, force.force_x) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 200}, {"x": 140, "y": 285}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(zero_y.y, force.force_y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(zero_tau.y, force.torque) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 440}, {"x": 140, "y": 353}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(world.frame_b, damper.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 150, "y": 200}], "E": 2}],
      "junctions": [{"x": 150, "y": 70}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, damper.frame_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {"Dyad": {"tests": {"case1": {"stop": 3}}}}
end
Flattened Source
dyad
"""
Test for WorldForceTorque: a damped pendulum with an applied sinusoidal force.

Topology: Fixed → Revolute → FixedTranslation → Body
A WorldForceTorque applies a sinusoidal force in x-direction to the body.
A Damper stabilizes the revolute joint.

Translated from PlanarMechanicsTest.Sources.WorldForce.
"""
test component WorldForceTest
  world = World() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  revolute = Revolute(phi(initial = 0), w(initial = 0)) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 295, "y1": 20, "x2": 395, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  rod = FixedTranslation(r = [0, -1]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 415, "y1": 20, "x2": 515, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(m = 1, I = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 295, "y1": 150, "x2": 395, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  damper = MultibodyComponents.PlanarMechanics.Damper(d = 1) {
    "Dyad": {
      "placement": {
        "diagram": {
          "iconName": "default",
          "x1": 167.5,
          "y1": 150,
          "x2": 267.5,
          "y2": 250,
          "rot": 0
        }
      },
      "tags": []
    }
  }
  force = WorldForceTorque(resolve_in_frame = MultibodyComponents.ResolveInFrame.World(), scale = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 165, "y1": 270, "x2": 265, "y2": 370, "rot": 0}
      },
      "tags": []
    }
  }
  sine_x = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 150, "x2": 120, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  zero_y = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 270, "x2": 120, "y2": 370, "rot": 0}
      },
      "tags": []
    }
  }
  zero_tau = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 390, "x2": 120, "y2": 490, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(world.frame_b, revolute.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(revolute.frame_b, rod.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(rod.frame_b, body.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 525, "y": 70}, {"x": 525, "y": 300}], "E": -1},
        {"S": -1, "M": [], "E": -2},
        {"S": -2, "M": [], "E": 2}
      ],
      "junctions": [{"x": 285, "y": 300}, {"x": 285, "y": 200}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, force.frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 285, "y": 200}, {"x": 285, "y": 320}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(sine_x.y, force.force_x) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 200}, {"x": 140, "y": 285}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(zero_y.y, force.force_y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(zero_tau.y, force.torque) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 440}, {"x": 140, "y": 353}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(world.frame_b, damper.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 150, "y": 200}], "E": 2}],
      "junctions": [{"x": 150, "y": 70}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, damper.frame_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {"Dyad": {"tests": {"case1": {"stop": 3}}}}
end


Test Cases

Test Case case1