Skip to content
LIBRARY
PlanarMechanics.Damper.md

PlanarMechanics.Damper

Linear velocity-dependent damper.

Damping force acts along the line connecting the two frames. Uses ifelse to prevent zero-division when the distance between frames is very small.

This component extends from PartialTwoFrames

Usage

MultibodyComponents.PlanarMechanics.Damper(d=1, s_small=1e-10)

Parameters:

NameDescriptionUnitsDefault value
dDamping constant1
s_smallPrevent zero-division if distance between frame_a and frame_b is zerom1e-10

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
r0xRelative position x componentm
r0yRelative position y componentm
d0xDirection x component
d0yDirection y component
vxRelative velocity x componentm/s
vyRelative velocity y componentm/s
vRelative velocity magnitudem/s
fDamping forceN

Behavior

julia
using MultibodyComponents #hide
using ModelingToolkit #hide
@variables d #hide
@variables s_small #hide
@named sys = MultibodyComponents.PlanarMechanics.Damper(d=d, s_small=s_small) #hide
full_equations(sys) #hide
<< @example-block not executed in draft mode >>

Source

dyad
"""
Linear velocity-dependent damper.

Damping force acts along the line connecting the two frames. Uses `ifelse` to prevent
zero-division when the distance between frames is very small.
"""
component Damper
  extends PartialTwoFrames
  "Damping constant"
  parameter d::Real = 1
  "Prevent zero-division if distance between frame_a and frame_b is zero"
  parameter s_small::Length = 1e-10
  "Relative position x component"
  variable r0x::Length
  "Relative position y component"
  variable r0y::Length
  "Direction x component"
  variable d0x::Real
  "Direction y component"
  variable d0y::Real
  "Relative velocity x component"
  variable vx::Velocity
  "Relative velocity y component"
  variable vy::Velocity
  "Relative velocity magnitude"
  variable v::Velocity
  "Damping force"
  variable f::Dyad.Force
relations
  frame_a.x + r0x = frame_b.x
  frame_a.y + r0y = frame_b.y
  der(frame_a.x) + vx = der(frame_b.x)
  der(frame_a.y) + vy = der(frame_b.y)
  v = adjoint([vx, vy]) * [d0x, d0y]
  f = -d * v
  d0x = ifelse(sqrt(r0x ^ 2 + r0y ^ 2) < s_small, r0x, r0x / sqrt(r0x ^ 2 + r0y ^ 2))
  d0y = ifelse(sqrt(r0x ^ 2 + r0y ^ 2) < s_small, r0y, r0y / sqrt(r0x ^ 2 + r0y ^ 2))
  frame_a.fx = d0x * f
  frame_a.fy = d0y * f
  frame_a.tau = 0
  frame_a.fx + frame_b.fx = 0
  frame_a.fy + frame_b.fy = 0
  frame_a.tau + frame_b.tau = 0
metadata {"Dyad": {"icons": {"default": "dyad://MultibodyComponents/Damper.svg"}}}
end
Flattened Source
dyad
"""
Linear velocity-dependent damper.

Damping force acts along the line connecting the two frames. Uses `ifelse` to prevent
zero-division when the distance between frames is very small.
"""
component Damper
  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": []
    }
  }
  "Damping constant"
  parameter d::Real = 1
  "Prevent zero-division if distance between frame_a and frame_b is zero"
  parameter s_small::Length = 1e-10
  "Relative position x component"
  variable r0x::Length
  "Relative position y component"
  variable r0y::Length
  "Direction x component"
  variable d0x::Real
  "Direction y component"
  variable d0y::Real
  "Relative velocity x component"
  variable vx::Velocity
  "Relative velocity y component"
  variable vy::Velocity
  "Relative velocity magnitude"
  variable v::Velocity
  "Damping force"
  variable f::Dyad.Force
relations
  frame_a.x + r0x = frame_b.x
  frame_a.y + r0y = frame_b.y
  der(frame_a.x) + vx = der(frame_b.x)
  der(frame_a.y) + vy = der(frame_b.y)
  v = adjoint([vx, vy]) * [d0x, d0y]
  f = -d * v
  d0x = ifelse(sqrt(r0x ^ 2 + r0y ^ 2) < s_small, r0x, r0x / sqrt(r0x ^ 2 + r0y ^ 2))
  d0y = ifelse(sqrt(r0x ^ 2 + r0y ^ 2) < s_small, r0y, r0y / sqrt(r0x ^ 2 + r0y ^ 2))
  frame_a.fx = d0x * f
  frame_a.fy = d0y * f
  frame_a.tau = 0
  frame_a.fx + frame_b.fx = 0
  frame_a.fy + frame_b.fy = 0
  frame_a.tau + frame_b.tau = 0
metadata {"Dyad": {"icons": {"default": "dyad://MultibodyComponents/Damper.svg"}}}
end


Test Cases

No test cases defined.