Skip to content
LIBRARY
PlanarMechanics.SpringDamper.md

PlanarMechanics.SpringDamper

Linear 2D translational spring-damper with independent x, y, and phi stiffness and damping.

Combines spring and damping forces along world x and y axes with a rotational spring-damper acting on the relative angle between frames.

This component extends from PartialTwoFrames This component extends from MultibodyComponents.Renderable

Usage

MultibodyComponents.PlanarMechanics.SpringDamper(render=true, color=[0, 0.0, 1, 1], specular_coefficient=0.7, c_x=1, c_y=1, c_phi=1e5, d_x=1, d_y=1, d_phi=1, s_relx0=0, s_rely0=0, phi_rel0=0, radius=0.1, num_windings=6, N=200, end_ratio=0.1, z_position=0)

Parameters:

NameDescriptionUnitsDefault value
rendertrue
color[0, 0, 1, 1]
specular_coefficient0.7
c_xSpring constant in x dirN/m1
c_ySpring constant in y dirN/m1
c_phiSpring constant in phi dirN.m/rad100000
d_xDamping constant in x dir1
d_yDamping constant in y dir1
d_phiDamping constant in phi dir1
s_relx0Unstretched spring lengthm0
s_rely0Unstretched spring lengthm0
phi_rel0Unstretched spring anglerad0
radiusRadius of spring coil when rendered0.1
num_windingsNumber of spring coil windings6
NNumber of points used to render each winding200
end_ratioFraction of total length used for the tapered ends0.1
z_positionz-position of the spring in animations0

Connectors

  • frame_a - Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.

All variables are resolved in the planar world frame. (Frame2D)

  • frame_b - Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.

All variables are resolved in the planar world frame. (Frame2D)

Variables

NameDescriptionUnits
s_relxRelative x positionm
s_relyRelative y positionm
phi_relRelative anglerad
v_relxRelative velocity in x directionm/s
v_relyRelative velocity in y directionm/s
w_relRelative angular velocityrad/s
f_xForce in x directionN
f_yForce in y directionN
tauTorqueN.m

Behavior

Dict{MIME{Symbol("text/plain")}, String} with 1 entry: MIME type text/plain => "Error displaying result"

Source

dyad
"""
Linear 2D translational spring-damper with independent x, y, and phi stiffness and damping.

Combines spring and damping forces along world x and y axes with a rotational
spring-damper acting on the relative angle between frames.
"""
component SpringDamper
  extends PartialTwoFrames
  extends MultibodyComponents.Renderable(color = [0, 0.0, 1, 1])
  "Visualization shape for the spring-damper"
  shape = MultibodyComponents.SpringShape(render = render, color = color, num_windings = num_windings, N = N, end_ratio = end_ratio)
  "Spring constant in x dir"
  parameter c_x::TranslationalSpringConstant = 1
  "Spring constant in y dir"
  parameter c_y::TranslationalSpringConstant = 1
  "Spring constant in phi dir"
  parameter c_phi::RotationalSpringConstant = 1e5
  "Damping constant in x dir"
  parameter d_x::Real = 1
  "Damping constant in y dir"
  parameter d_y::Real = 1
  "Damping constant in phi dir"
  parameter d_phi::Real = 1
  "Unstretched spring length"
  parameter s_relx0::Length = 0
  "Unstretched spring length"
  parameter s_rely0::Length = 0
  "Unstretched spring angle"
  parameter phi_rel0::Angle = 0
  "Radius of spring coil when rendered"
  parameter radius::Real = 0.1
  "Number of spring coil windings"
  parameter num_windings::Real = 6
  "Number of points used to render each winding"
  parameter N::Integer = 200
  "Fraction of total length used for the tapered ends"
  parameter end_ratio::Real = 0.1
  "z-position of the spring in animations"
  parameter z_position::Real = 0
  "Relative x position"
  variable s_relx::Length
  "Relative y position"
  variable s_rely::Length
  "Relative angle"
  variable phi_rel::Angle
  "Relative velocity in x direction"
  variable v_relx::Velocity
  "Relative velocity in y direction"
  variable v_rely::Velocity
  "Relative angular velocity"
  variable w_rel::AngularVelocity
  "Force in x direction"
  variable f_x::Dyad.Force
  "Force in y direction"
  variable f_y::Dyad.Force
  "Torque"
  variable tau::Torque
relations
  s_relx = frame_b.x - frame_a.x
  s_rely = frame_b.y - frame_a.y
  phi_rel = frame_b.phi - frame_a.phi
  v_relx = der(s_relx)
  v_rely = der(s_rely)
  w_rel = der(phi_rel)
  tau = c_phi * (phi_rel - phi_rel0) + d_phi * w_rel
  frame_a.tau = -tau
  frame_b.tau = tau
  f_x = c_x * (s_relx - s_relx0) + d_x * v_relx
  f_y = c_y * (s_rely - s_rely0) + d_y * v_rely
  frame_a.fx = -f_x
  frame_b.fx = f_x
  frame_a.fy = -f_y
  frame_b.fy = f_y
  # set shape: spring runs from frame_a to frame_b
  shape.r = [frame_a.x, frame_a.y, z_position]
  shape.R = MultibodyComponents.RR(MultibodyComponents.nullrotation())
  shape.r_shape = [0, 0, 0]
  shape.length_direction = [s_relx, s_rely, 0]
  shape.width_direction = [0, 0, 1]
  shape.length = sqrt(s_relx ^ 2 + s_rely ^ 2)
  shape.width = radius
  shape.height = 0
metadata {"Dyad": {"icons": {"default": "dyad://MultibodyComponents/SpringDamper.svg"}}}
end
Flattened Source
dyad
"""
Linear 2D translational spring-damper with independent x, y, and phi stiffness and damping.

Combines spring and damping forces along world x and y axes with a rotational
spring-damper acting on the relative angle between frames.
"""
component SpringDamper
  frame_a = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 450, "x2": 150, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 450, "x2": 950, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 0.7
  "Visualization shape for the spring-damper"
  shape = MultibodyComponents.SpringShape(render = render, color = color, num_windings = num_windings, N = N, end_ratio = end_ratio)
  "Spring constant in x dir"
  parameter c_x::TranslationalSpringConstant = 1
  "Spring constant in y dir"
  parameter c_y::TranslationalSpringConstant = 1
  "Spring constant in phi dir"
  parameter c_phi::RotationalSpringConstant = 1e5
  "Damping constant in x dir"
  parameter d_x::Real = 1
  "Damping constant in y dir"
  parameter d_y::Real = 1
  "Damping constant in phi dir"
  parameter d_phi::Real = 1
  "Unstretched spring length"
  parameter s_relx0::Length = 0
  "Unstretched spring length"
  parameter s_rely0::Length = 0
  "Unstretched spring angle"
  parameter phi_rel0::Angle = 0
  "Radius of spring coil when rendered"
  parameter radius::Real = 0.1
  "Number of spring coil windings"
  parameter num_windings::Real = 6
  "Number of points used to render each winding"
  parameter N::Integer = 200
  "Fraction of total length used for the tapered ends"
  parameter end_ratio::Real = 0.1
  "z-position of the spring in animations"
  parameter z_position::Real = 0
  "Relative x position"
  variable s_relx::Length
  "Relative y position"
  variable s_rely::Length
  "Relative angle"
  variable phi_rel::Angle
  "Relative velocity in x direction"
  variable v_relx::Velocity
  "Relative velocity in y direction"
  variable v_rely::Velocity
  "Relative angular velocity"
  variable w_rel::AngularVelocity
  "Force in x direction"
  variable f_x::Dyad.Force
  "Force in y direction"
  variable f_y::Dyad.Force
  "Torque"
  variable tau::Torque
relations
  s_relx = frame_b.x - frame_a.x
  s_rely = frame_b.y - frame_a.y
  phi_rel = frame_b.phi - frame_a.phi
  v_relx = der(s_relx)
  v_rely = der(s_rely)
  w_rel = der(phi_rel)
  tau = c_phi * (phi_rel - phi_rel0) + d_phi * w_rel
  frame_a.tau = -tau
  frame_b.tau = tau
  f_x = c_x * (s_relx - s_relx0) + d_x * v_relx
  f_y = c_y * (s_rely - s_rely0) + d_y * v_rely
  frame_a.fx = -f_x
  frame_b.fx = f_x
  frame_a.fy = -f_y
  frame_b.fy = f_y
  # set shape: spring runs from frame_a to frame_b
  shape.r = [frame_a.x, frame_a.y, z_position]
  shape.R = MultibodyComponents.RR(MultibodyComponents.nullrotation())
  shape.r_shape = [0, 0, 0]
  shape.length_direction = [s_relx, s_rely, 0]
  shape.width_direction = [0, 0, 1]
  shape.length = sqrt(s_relx ^ 2 + s_rely ^ 2)
  shape.width = radius
  shape.height = 0
metadata {"Dyad": {"icons": {"default": "dyad://MultibodyComponents/SpringDamper.svg"}}}
end


Test Cases

No test cases defined.

  • Examples

  • Experiments

  • Analyses