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

[connect(world+frameb,revolute+framea)connect(revolute+frameb,rod+framea)connect(rod+frameb,body+framea)connect(body+framea,force+frameb)connect(sinex+y,force+forcex)connect(zeroy+y,force+forcey)connect(zerotau+y,force+torque)connect(world+frameb,damper+framea)connect(body+framea,damper+frameb)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.radiusdamper.framea.x(t)+damper.r0x(t)=damper.frameb.x(t)damper.r0y(t)+damper.framea.y(t)=damper.frameb.y(t)ddamper.framea.x(t)dt+damper.vx(t)=ddamper.frameb.x(t)dtdamper.vy(t)+ddamper.framea.y(t)dt=ddamper.frameb.y(t)dtdamper.v(t)=damper.vy(t)damper.d0y(t)+damper.d0x(t)damper.vx(t)damper.f(t)=damper.ddamper.v(t)damper.d0x(t)=ifelse((damper.r0y(t))2+(damper.r0x(t))2<damper.ssmall,damper.r0x(t),damper.r0x(t)(damper.r0y(t))2+(damper.r0x(t))2)damper.d0y(t)=ifelse((damper.r0y(t))2+(damper.r0x(t))2<damper.ssmall,damper.r0y(t),damper.r0y(t)(damper.r0y(t))2+(damper.r0x(t))2)damper.framea.fx(t)=damper.f(t)damper.d0x(t)damper.framea.fy(t)=damper.d0y(t)damper.f(t)damper.framea.tau(t)=0damper.framea.fx(t)+damper.frameb.fx(t)=0damper.framea.fy(t)+damper.frameb.fy(t)=0damper.frameb.tau(t)+damper.framea.tau(t)=0force.frameb.fx(t)force.forcey(t)sin(force.phi(t))+cos(force.phi(t))force.forcex(t)=0force.frameb.fy(t)+force.forcey(t)cos(force.phi(t))+force.forcex(t)sin(force.phi(t))=0force.frameb.tau(t)+force.torque(t)=0force.forcearrow.r(t)=arrayliteral([3],force.frameb.x(t),force.frameb.y(t),force.zposition)force.forcearrow.R(t)=arrayliteral([33],cos(force.phi(t)),sin(force.phi(t)),0,sin(force.phi(t)),cos(force.phi(t)),0,0,0,1)force.forcearrow.r_shape(t)=[000]force.forcearrow.length_direction(t)=arrayliteral([3],force.forcex(t),force.forcey(t),0)force.forcearrow.width_direction(t)=[001]force.forcearrow.length(t)=force.scale(force.forcey(t))2+(force.forcex(t))2force.forcearrow.width(t)=force.arrowdiameterforce.forcearrow.height(t)=force.arrowdiameterforce.phi(t)=0sinex.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.k]

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() {
    "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
  initial revolute.phi = 0
  initial revolute.w = 0
  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() {
    "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
  initial revolute.phi = 0
  initial revolute.w = 0
  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