Skip to content
SpringDamper.md

SpringDamper

Models a linear translational spring and a linear translational damper connected in parallel.

This component describes the behavior of an ideal translational spring and an ideal translational viscous damper that are arranged in parallel. The total force f generated by the component is the sum of the force from the spring f_c and the force from the damper f_d. The relative displacement across the component is s_rel and the relative velocity is v_rel. The spring force is determined by Hooke's Law:

fc=c(srelinitial_stretch)

where c is the spring constant and initial_stretch is the value of s_rel at which the spring is relaxed (exerts no force). The initial_stretch remains constant during the simulation. The damper force is proportional to the relative velocity:

fd=dvrel

where d is the damping constant. The total force exerted by the component is:

f=fc+fd

Power dissipated by the damper is calculated as:

lossPower=fdvrel

The component typically inherits s_rel, v_rel, and f from a base class like PartialCompliantWithRelativeStates.

This component extends from PartialCompliantWithRelativeStates

Usage

SpringDamper(c, d)

Parameters:

NameDescriptionUnitsDefault value
cSpring constant defining the stiffness of the spring elementN/m
dDamping constant defining the viscous friction of the damper elementN.s/m

Connectors

Variables

NameDescriptionUnits
s_relRelative displacement between flange_b and flange_a (flange_b.s - flange_a.s).m
v_relRelative velocity between flange_b and flange_a, defined as der(s_rel).m/s
fInternal force exerted by the compliant element between the flanges.N
initial_stretchRelative displacement at which the spring is in its relaxed (zero force) state; remains constant after initializationm
lossPowerPower dissipated by the damper element due to viscous frictionW
f_cForce exerted by the spring elementN
f_dForce exerted by the damper elementN

Behavior

s_rel(t)=flange_b.s(t)flange_a.s(t)v_rel(t)=ds_rel(t)dtflange_b.f(t)=f(t)flange_a.f(t)=f(t)f_c(t)=c(initial_stretch(t)+s_rel(t))dinitial_stretch(t)dt=0f_d(t)=dv_rel(t)f(t)=f_c(t)+f_d(t)lossPower(t)=v_rel(t)f_d(t)

Source

dyad
# Models a linear translational spring and a linear translational damper connected in parallel.
#
# This component describes the behavior of an ideal translational spring and an ideal translational viscous damper
# that are arranged in parallel. The total force `f` generated by the component is the sum of the force from the
# spring `f_c` and the force from the damper `f_d`. The relative displacement across the component is `s_rel`
# and the relative velocity is `v_rel`.
# The spring force is determined by Hooke's Law:
# ```math
# f_c = c \cdot (s_{rel} - initial\_stretch)
#
# ```
# where `c` is the spring constant and `initial_stretch` is the value of `s_rel` at which the spring is relaxed (exerts no force).
# The `initial_stretch` remains constant during the simulation.
# The damper force is proportional to the relative velocity:
# ```math
# f_d = d \cdot v_{rel}
# ```
# where `d` is the damping constant.
# The total force exerted by the component is:
# ```math
# f = f_c + f_d
# ```
# Power dissipated by the damper is calculated as:
# ```math
# lossPower = f_d \cdot v_{rel}
# ```
# The component typically inherits `s_rel`, `v_rel`, and `f` from a base class like `PartialCompliantWithRelativeStates`.
component SpringDamper
  extends PartialCompliantWithRelativeStates
  # Spring constant defining the stiffness of the spring element
  parameter c::TranslationalSpringConstant
  # Damping constant defining the viscous friction of the damper element
  parameter d::TranslationalDampingConstant
  # Relative displacement at which the spring is in its relaxed (zero force) state; remains constant after initialization
  variable initial_stretch::Length(guess=0)
  # Power dissipated by the damper element due to viscous friction
  variable lossPower::Power
  # Force exerted by the spring element
  variable f_c::Dyad.Force
  # Force exerted by the damper element
  variable f_d::Dyad.Force
relations
  f_c = c*(s_rel-initial_stretch)
  der(initial_stretch) = 0
  f_d = d*v_rel
  f = f_c+f_d
  lossPower = f_d*v_rel
metadata {
  "Dyad": {"icons": {"default": "dyad://TranslationalComponents/SpringDamper.svg"}}
}
end
Flattened Source
dyad
# Models a linear translational spring and a linear translational damper connected in parallel.
#
# This component describes the behavior of an ideal translational spring and an ideal translational viscous damper
# that are arranged in parallel. The total force `f` generated by the component is the sum of the force from the
# spring `f_c` and the force from the damper `f_d`. The relative displacement across the component is `s_rel`
# and the relative velocity is `v_rel`.
# The spring force is determined by Hooke's Law:
# ```math
# f_c = c \cdot (s_{rel} - initial\_stretch)
#
# ```
# where `c` is the spring constant and `initial_stretch` is the value of `s_rel` at which the spring is relaxed (exerts no force).
# The `initial_stretch` remains constant during the simulation.
# The damper force is proportional to the relative velocity:
# ```math
# f_d = d \cdot v_{rel}
# ```
# where `d` is the damping constant.
# The total force exerted by the component is:
# ```math
# f = f_c + f_d
# ```
# Power dissipated by the damper is calculated as:
# ```math
# lossPower = f_d \cdot v_{rel}
# ```
# The component typically inherits `s_rel`, `v_rel`, and `f` from a base class like `PartialCompliantWithRelativeStates`.
component SpringDamper
  # Port for the first mechanical translational flange.
  flange_a = Flange() [{"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}]
  # Port for the second mechanical translational flange.
  flange_b = Flange() [{"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}]
  # Relative displacement between flange_b and flange_a (flange_b.s - flange_a.s).
  variable s_rel::Distance
  # Relative velocity between flange_b and flange_a, defined as der(s_rel).
  variable v_rel::Velocity
  # Internal force exerted by the compliant element between the flanges.
  variable f::Dyad.Force
  # Spring constant defining the stiffness of the spring element
  parameter c::TranslationalSpringConstant
  # Damping constant defining the viscous friction of the damper element
  parameter d::TranslationalDampingConstant
  # Relative displacement at which the spring is in its relaxed (zero force) state; remains constant after initialization
  variable initial_stretch::Length(guess=0)
  # Power dissipated by the damper element due to viscous friction
  variable lossPower::Power
  # Force exerted by the spring element
  variable f_c::Dyad.Force
  # Force exerted by the damper element
  variable f_d::Dyad.Force
relations
  s_rel = flange_b.s-flange_a.s
  v_rel = der(s_rel)
  flange_b.f = f
  flange_a.f = -f
  f_c = c*(s_rel-initial_stretch)
  der(initial_stretch) = 0
  f_d = d*v_rel
  f = f_c+f_d
  lossPower = f_d*v_rel
metadata {
  "Dyad": {"icons": {"default": "dyad://TranslationalComponents/SpringDamper.svg"}}
}
end


Test Cases

This is setup code, that must be run before each test case.

julia
using TranslationalComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(TranslationalComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/TranslationalComponents/khJb7/test/snapshots"
  • Examples

  • Experiments

  • Analyses