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

julia
using MultibodyComponents #hide
using ModelingToolkit #hide
@named sys = MultibodyComponents.PlanarMechanics.examples.SpringAndDamperTest() #hide
full_equations(sys) #hide
<< @example-block not executed in draft mode >>

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