Skip to content
LIBRARY
PlanarMechanics.RelativeForceTest.md

PlanarMechanics.RelativeForceTest

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

Topology: Fixed → Revolute → FixedTranslation → Body A RelativeForce applies a sinusoidal force between the fixed frame and the body, resolved in frame_a (default). A Damper stabilizes the revolute joint.

Translated from PlanarMechanicsTest.Sources.RelativeForce.

Usage

MultibodyComponents.PlanarMechanics.RelativeForceTest()

Behavior

[connect(revolute+frameb,rod+framea)connect(body+framea,rod+frameb,relforce+frame_b)connect(zeroy+y,relforce+force_y)connect(zerotau+y,relforce+torque)connect(sinex+y,relforce+force_x)connect(fixed+frameb,revolute+framea)connect(fixed+frameb,relforce+frame_a)world.frameb.x(t)=0world.frameb.y(t)=0world.frameb.phi(t)=0connect(frameb,framevis+frame_a)world.framevis.phi(t)=world.framevis.frame_a.phi(t)world.framevis.x_shape.r(t)=arrayliteral([3],world.framevis.frame_a.x(t),world.framevis.frame_a.y(t),world.framevis.z_position)world.framevis.x_shape.R(t)=arrayliteral([33],cos(world.framevis.phi(t)),sin(world.framevis.phi(t)),0,sin(world.framevis.phi(t)),cos(world.framevis.phi(t)),0,0,0,1)world.framevis.x_shape.r_shape(t)=[000]world.framevis.x_shape.length_direction(t)=[100]world.framevis.x_shape.width_direction(t)=[001]world.framevis.x_shape.length(t)=world.framevis.axis_lengthworld.framevis.x_shape.width(t)=2world.framevis.axis_radiusworld.framevis.x_shape.height(t)=2world.framevis.axis_radiusworld.framevis.y_shape.r(t)=arrayliteral([3],world.framevis.frame_a.x(t),world.framevis.frame_a.y(t),world.framevis.z_position)world.framevis.y_shape.R(t)=arrayliteral([33],cos(world.framevis.phi(t)),sin(world.framevis.phi(t)),0,sin(world.framevis.phi(t)),cos(world.framevis.phi(t)),0,0,0,1)world.framevis.y_shape.r_shape(t)=[000]world.framevis.y_shape.length_direction(t)=[010]world.framevis.y_shape.width_direction(t)=[001]world.framevis.y_shape.length(t)=world.framevis.axis_lengthworld.framevis.y_shape.width(t)=2world.framevis.axis_radiusworld.framevis.y_shape.height(t)=2world.framevis.axis_radiusworld.framevis.z_shape.r(t)=arrayliteral([3],world.framevis.frame_a.x(t),world.framevis.frame_a.y(t),world.framevis.z_position)world.framevis.z_shape.R(t)=arrayliteral([33],cos(world.framevis.phi(t)),sin(world.framevis.phi(t)),0,sin(world.framevis.phi(t)),cos(world.framevis.phi(t)),0,0,0,1)world.framevis.z_shape.r_shape(t)=[000]world.framevis.z_shape.length_direction(t)=[001]world.framevis.z_shape.width_direction(t)=[100]world.framevis.z_shape.length(t)=world.framevis.axis_lengthworld.framevis.z_shape.width(t)=2world.framevis.axis_radiusworld.framevis.z_shape.height(t)=2world.framevis.axis_radiusrevolute.w(t)=drevolute.phi(t)dtrevolute.alpha(t)=drevolute.w(t)dtrevolute.framea.x(t)=revolute.frameb.x(t)revolute.framea.y(t)=revolute.frameb.y(t)revolute.framea.phi(t)+revolute.phi(t)=revolute.frameb.phi(t)revolute.frameb.fx(t)+revolute.framea.fx(t)=0revolute.framea.fy(t)+revolute.frameb.fy(t)=0revolute.frameb.tau(t)+revolute.framea.tau(t)=0revolute.framea.tau(t)=revolute.tau(t)revolute.flangea.phi(t)=revolute.phi(t)revolute.flangea.tau(t)=revolute.tau(t)revolute.shape.r(t)=arrayliteral([3],revolute.framea.x(t),revolute.framea.y(t),revolute.zposition)revolute.shape.R(t)=arrayliteral([33],cos(revolute.framea.phi(t)),sin(revolute.framea.phi(t)),0,sin(revolute.framea.phi(t)),cos(revolute.framea.phi(t)),0,0,0,1)revolute.shape.rshape(t)=arrayliteral([3],0,0,12revolute.cylinderlength)revolute.shape.lengthdirection(t)=[001]revolute.shape.widthdirection(t)=[100]revolute.shape.length(t)=revolute.cylinderlengthrevolute.shape.width(t)=2revolute.radiusrevolute.shape.height(t)=2revolute.radiusrod.phi(t)=rod.framea.phi(t)rod.w(t)=drod.phi(t)dtrod.r0(t)=arrayliteral([22],cos(rod.phi(t)),sin(rod.phi(t)),sin(rod.phi(t)),cos(rod.phi(t)))rod.rrod.r0(t)=arrayliteral([2],rod.framea.x(t)+rod.frameb.x(t),rod.frameb.y(t)rod.framea.y(t))rod.framea.phi(t)=rod.frameb.phi(t)rod.framea.fx(t)+rod.frameb.fx(t)=0rod.frameb.fy(t)+rod.framea.fy(t)=0rod.framea.tau(t)+rod.frameb.tau(t)+rod.r01(t)rod.frameb.fy(t)rod.r02(t)rod.frameb.fx(t)=0rod.shape.r(t)=arrayliteral([3],rod.framea.x(t),rod.framea.y(t),rod.zposition)rod.shape.R(t)=arrayliteral([33],1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)rod.shape.rshape(t)=[000]rod.shape.lengthdirection(t)=arrayliteral([3],rod.r01(t)rod.l,rod.r02(t)rod.l,0)rod.shape.widthdirection(t)=[001]rod.shape.length(t)=rod.lrod.shape.width(t)=2rod.radiusrod.shape.height(t)=2rod.radiusbody.r(t)=arrayliteral([2],body.framea.x(t),body.framea.y(t))body.v(t)=dbody.r(t)dtbody.phi(t)=body.framea.phi(t)body.w(t)=dbody.phi(t)dtbody.a(t)=dbody.v(t)dtbody.alpha(t)=dbody.w(t)dtbody.f(t)=arrayliteral([2],body.framea.fx(t),body.framea.fy(t))body.f(t)+arrayliteral([2],body.mgn2d1,body.mgn2d2)=body.mbody.a(t)body.Ibody.alpha(t)=body.framea.tau(t)body.shape.r(t)=arrayliteral([3],body.framea.x(t),body.framea.y(t),body.zposition)body.shape.R(t)=arrayliteral([33],cos(body.phi(t)),sin(body.phi(t)),0,sin(body.phi(t)),cos(body.phi(t)),0,0,0,1)body.shape.rshape(t)=[000]body.shape.lengthdirection(t)=[001]body.shape.widthdirection(t)=[100]body.shape.length(t)=2body.radiusbody.shape.width(t)=2body.radiusbody.shape.height(t)=2body.radiusrelforce.frame_b.fx(t)+relforce.force_x(t)cos(relforce.phi(t))relforce.force_y(t)sin(relforce.phi(t))=0relforce.frame_b.fy(t)+relforce.force_x(t)sin(relforce.phi(t))+cos(relforce.phi(t))relforce.force_y(t)=0relforce.torque(t)+relforce.frame_b.tau(t)=0relforce.frame_b.fx(t)+relforce.frame_a.fx(t)=0relforce.frame_a.fy(t)+relforce.frame_b.fy(t)=0relforce.frame_b.tau(t)+relforce.frame_a.tau(t)=0relforce.force_arrow.r(t)=arrayliteral([3],relforce.frame_b.x(t),relforce.frame_b.y(t),relforce.z_position)relforce.force_arrow.R(t)=arrayliteral([33],cos(relforce.phi(t)),sin(relforce.phi(t)),0,sin(relforce.phi(t)),cos(relforce.phi(t)),0,0,0,1)relforce.force_arrow.r_shape(t)=[000]relforce.force_arrow.length_direction(t)=arrayliteral([3],relforce.force_x(t),relforce.force_y(t),0)relforce.force_arrow.width_direction(t)=[001]relforce.force_arrow.length(t)=relforce.scale(relforce.force_x(t))2+(relforce.force_y(t))2relforce.force_arrow.width(t)=relforce.arrow_diameterrelforce.force_arrow.height(t)=relforce.arrow_diameterrelforce.phi(t)=relforce.frame_a.phi(t)sinex.y(t)=sinex.offset+sinex.amplitudeifelse(tsinex.start_time,sin(sinex.phase+6.283185307179586sinex.frequency(sinex.start_time+t)),sin(sinex.phase))zeroy.y(t)=zeroy.kzerotau.y(t)=zerotau.karrayliteral([2],fixed.frameb.x(t),fixed.frameb.y(t))=fixed.rfixed.frameb.phi(t)=fixed.phi]

Source

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

Topology: Fixed → Revolute → FixedTranslation → Body
A RelativeForce applies a sinusoidal force between the fixed frame and the body,
resolved in frame_a (default).
A Damper stabilizes the revolute joint.

Translated from PlanarMechanicsTest.Sources.RelativeForce.
"""
test component RelativeForceTest
  world = World() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 840, "x2": 150, "y2": 940, "rot": 0}
      },
      "tags": []
    }
  }
  revolute = Revolute() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 280, "y1": 560, "x2": 380, "y2": 660, "rot": 0}
      },
      "tags": []
    }
  }
  rod = FixedTranslation(r = [0, -1]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 400, "y1": 560, "x2": 500, "y2": 660, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(m = 1, I = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 540, "y1": 560, "x2": 640, "y2": 660, "rot": 0}
      },
      "tags": []
    }
  }
  rel_force = RelativeForce(resolve_in_frame = MultibodyComponents.ResolveInFrame.FrameA(), scale = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 335, "x2": 255, "y2": 435, "rot": 0}
      },
      "tags": []
    }
  }
  sine_x = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 260, "x2": 120, "y2": 360, "rot": 0}
      },
      "tags": []
    }
  }
  zero_y = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  zero_tau = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 0, "x2": 120, "y2": 100, "rot": 0}
      },
      "tags": []
    }
  }
  fixed = MultibodyComponents.PlanarMechanics.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 30, "y1": 560, "x2": 130, "y2": 660, "rot": 0}
      },
      "tags": []
    }
  }
relations
  initial revolute.phi = 0
  initial revolute.w = 0
  connect(revolute.frame_b, rod.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(body.frame_a, rod.frame_b, rel_force.frame_b) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": 3, "M": [{"x": 520, "y": 385}], "E": -1}
      ],
      "junctions": [{"x": 520, "y": 610}],
      "renderStyle": "standard"
    }
  }
  connect(rel_force.force_y, zero_y.y) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 205, "y": 190}], "E": 2}]
    }
  }
  connect(zero_tau.y, rel_force.torque) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 241, "y": 50}], "E": 2}]
    }
  }
  connect(sine_x.y, rel_force.force_x) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 169, "y": 310}], "E": 2}]
    }
  }
  connect(fixed.frame_b, revolute.frame_a) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(fixed.frame_b, rel_force.frame_a) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 80, "y": 385}], "E": 2}]
    }
  }
metadata {"Dyad": {"tests": {"case1": {"stop": 3}}}}
end
Flattened Source
dyad
"""
Test for RelativeForce: a damped pendulum with an applied sinusoidal relative force.

Topology: Fixed → Revolute → FixedTranslation → Body
A RelativeForce applies a sinusoidal force between the fixed frame and the body,
resolved in frame_a (default).
A Damper stabilizes the revolute joint.

Translated from PlanarMechanicsTest.Sources.RelativeForce.
"""
test component RelativeForceTest
  world = World() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 840, "x2": 150, "y2": 940, "rot": 0}
      },
      "tags": []
    }
  }
  revolute = Revolute() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 280, "y1": 560, "x2": 380, "y2": 660, "rot": 0}
      },
      "tags": []
    }
  }
  rod = FixedTranslation(r = [0, -1]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 400, "y1": 560, "x2": 500, "y2": 660, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(m = 1, I = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 540, "y1": 560, "x2": 640, "y2": 660, "rot": 0}
      },
      "tags": []
    }
  }
  rel_force = RelativeForce(resolve_in_frame = MultibodyComponents.ResolveInFrame.FrameA(), scale = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 335, "x2": 255, "y2": 435, "rot": 0}
      },
      "tags": []
    }
  }
  sine_x = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 260, "x2": 120, "y2": 360, "rot": 0}
      },
      "tags": []
    }
  }
  zero_y = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  zero_tau = BlockComponents.Sources.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 0, "x2": 120, "y2": 100, "rot": 0}
      },
      "tags": []
    }
  }
  fixed = MultibodyComponents.PlanarMechanics.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 30, "y1": 560, "x2": 130, "y2": 660, "rot": 0}
      },
      "tags": []
    }
  }
relations
  initial revolute.phi = 0
  initial revolute.w = 0
  connect(revolute.frame_b, rod.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(body.frame_a, rod.frame_b, rel_force.frame_b) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": 3, "M": [{"x": 520, "y": 385}], "E": -1}
      ],
      "junctions": [{"x": 520, "y": 610}],
      "renderStyle": "standard"
    }
  }
  connect(rel_force.force_y, zero_y.y) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 205, "y": 190}], "E": 2}]
    }
  }
  connect(zero_tau.y, rel_force.torque) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 241, "y": 50}], "E": 2}]
    }
  }
  connect(sine_x.y, rel_force.force_x) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 169, "y": 310}], "E": 2}]
    }
  }
  connect(fixed.frame_b, revolute.frame_a) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(fixed.frame_b, rel_force.frame_a) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 80, "y": 385}], "E": 2}]
    }
  }
metadata {"Dyad": {"tests": {"case1": {"stop": 3}}}}
end


Test Cases

Test Case case1