Skip to content
LIBRARY
PlanarMechanics.examples.SpringAndDamperTest.md

PlanarMechanics.examples.SpringAndDamperTest

This example shows how to use a spring and a damper separately. The motion is constrained by a prismatic joint. The spring passes a point of zero length.

Usage

MultibodyComponents.PlanarMechanics.examples.SpringAndDamperTest()

Behavior

[connect(world+frameb,damper+framea)connect(world+frameb,spring+framea)connect(world+frameb,prismatic+framea)connect(body+framea,spring+frameb)connect(body+framea,prismatic+frameb)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_radiusspring.srelx(t)=spring.frameb.x(t)spring.framea.x(t)spring.srely(t)=spring.frameb.y(t)spring.framea.y(t)spring.phirel(t)=spring.frameb.phi(t)spring.framea.phi(t)spring.fx(t)=spring.cx(spring.srelx0+spring.srelx(t))spring.fy(t)=spring.cy(spring.srely0+spring.srely(t))spring.framea.fx(t)=spring.fx(t)spring.frameb.fx(t)=spring.fx(t)spring.framea.fy(t)=spring.fy(t)spring.frameb.fy(t)=spring.fy(t)spring.framea.tau(t)=0spring.frameb.tau(t)=0spring.shape.r(t)=arrayliteral([3],spring.framea.x(t),spring.framea.y(t),spring.zposition)spring.shape.R(t)=arrayliteral([33],1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)spring.shape.rshape(t)=[000]spring.shape.lengthdirection(t)=arrayliteral([3],spring.srelx(t),spring.srely(t),0)spring.shape.widthdirection(t)=[001]spring.shape.length(t)=(spring.srelx(t))2+(spring.srely(t))2spring.shape.width(t)=spring.radiusspring.shape.height(t)=0damper.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)=0prismatic.e0(t)=arrayliteral([22],cos(prismatic.framea.phi(t)),sin(prismatic.framea.phi(t)),sin(prismatic.framea.phi(t)),cos(prismatic.framea.phi(t)))prismatic.rprismatic.rprismatic.r0(t)=prismatic.s(t)prismatic.e0(t)prismatic.v(t)=dprismatic.s(t)dtprismatic.a(t)=dprismatic.v(t)dtprismatic.r01(t)+prismatic.framea.x(t)=prismatic.frameb.x(t)prismatic.r02(t)+prismatic.framea.y(t)=prismatic.frameb.y(t)prismatic.framea.phi(t)=prismatic.frameb.phi(t)prismatic.framea.fx(t)+prismatic.frameb.fx(t)=0prismatic.framea.fy(t)+prismatic.frameb.fy(t)=0prismatic.frameb.tau(t)+prismatic.framea.tau(t)+prismatic.r01(t)prismatic.frameb.fy(t)prismatic.r02(t)prismatic.frameb.fx(t)=0prismatic.framea.fx(t)prismatic.e01(t)+prismatic.e02(t)prismatic.framea.fy(t)=prismatic.f(t)prismatic.f(t)=0prismatic.shape.r(t)=[000]prismatic.shape.R(t)=arrayliteral([33],1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)prismatic.shape.rshape(t)=arrayliteral([3],prismatic.framea.x(t),prismatic.framea.y(t),prismatic.zposition)prismatic.shape.lengthdirection(t)=arrayliteral([3],prismatic.e01(t),prismatic.e02(t),0)prismatic.shape.widthdirection(t)=[001]prismatic.shape.length(t)=prismatic.s(t)prismatic.shape.width(t)=prismatic.boxwidthprismatic.shape.height(t)=prismatic.boxheightbody.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.radius]

Source

dyad
"This example shows how to use a spring and a damper separately. The motion is constrained by a prismatic joint. The spring passes a point of zero length."
example component SpringAndDamperTest
  world = MultibodyComponents.PlanarMechanics.World() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 10, "x2": 560, "y2": 210, "rot": 0}
      },
      "tags": []
    }
  }
  spring = MultibodyComponents.PlanarMechanics.Spring(c_x = 1.0, c_y = 10.0, s_rely0 = -0.5, c_phi = 1e5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 280, "x2": 560, "y2": 480, "rot": 90}
      },
      "tags": []
    }
  }
  damper = MultibodyComponents.PlanarMechanics.Damper(d = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 280, "x2": 320, "y2": 480, "rot": 90}
      },
      "tags": []
    }
  }
  prismatic = MultibodyComponents.PlanarMechanics.Prismatic(r = [0.0, 1.0]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 610, "y1": 280, "x2": 810, "y2": 480, "rot": 90}
      },
      "tags": []
    }
  }
  body = MultibodyComponents.PlanarMechanics.Body(m = 0.5, I = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 630, "x2": 560, "y2": 830, "rot": 90}
      },
      "tags": []
    }
  }
relations
  initial prismatic.s = 0.0
  initial prismatic.v = 0.0
  connect(world.frame_b, damper.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 190}, {"x": 220, "y": 190}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(world.frame_b, spring.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(world.frame_b, prismatic.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 190}, {"x": 710, "y": 190}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, spring.frame_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(body.frame_a, prismatic.frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 565}, {"x": 710, "y": 565}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, damper.frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 565}, {"x": 220, "y": 565}], "E": 2}],
      "renderStyle": "standard"
    }
  }
end
Flattened Source
dyad
"This example shows how to use a spring and a damper separately. The motion is constrained by a prismatic joint. The spring passes a point of zero length."
example component SpringAndDamperTest
  world = MultibodyComponents.PlanarMechanics.World() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 10, "x2": 560, "y2": 210, "rot": 0}
      },
      "tags": []
    }
  }
  spring = MultibodyComponents.PlanarMechanics.Spring(c_x = 1.0, c_y = 10.0, s_rely0 = -0.5, c_phi = 1e5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 280, "x2": 560, "y2": 480, "rot": 90}
      },
      "tags": []
    }
  }
  damper = MultibodyComponents.PlanarMechanics.Damper(d = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 280, "x2": 320, "y2": 480, "rot": 90}
      },
      "tags": []
    }
  }
  prismatic = MultibodyComponents.PlanarMechanics.Prismatic(r = [0.0, 1.0]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 610, "y1": 280, "x2": 810, "y2": 480, "rot": 90}
      },
      "tags": []
    }
  }
  body = MultibodyComponents.PlanarMechanics.Body(m = 0.5, I = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 630, "x2": 560, "y2": 830, "rot": 90}
      },
      "tags": []
    }
  }
relations
  initial prismatic.s = 0.0
  initial prismatic.v = 0.0
  connect(world.frame_b, damper.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 190}, {"x": 220, "y": 190}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(world.frame_b, spring.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(world.frame_b, prismatic.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 190}, {"x": 710, "y": 190}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, spring.frame_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(body.frame_a, prismatic.frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 565}, {"x": 710, "y": 565}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, damper.frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 565}, {"x": 220, "y": 565}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {}
end


Test Cases

No test cases defined.

  • Examples

  • Experiments

  • Analyses