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:
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:
where d
is the damping constant. The total force exerted by the component is:
Power dissipated by the damper is calculated as:
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:
Name | Description | Units | Default value |
---|---|---|---|
c | Spring constant defining the stiffness of the spring element | N/m | |
d | Damping constant defining the viscous friction of the damper element | N.s/m |
Connectors
Variables
Name | Description | Units |
---|---|---|
s_rel | Relative displacement between flange_b and flange_a (flange_b.s - flange_a.s). | m |
v_rel | Relative velocity between flange_b and flange_a, defined as der(s_rel). | m/s |
f | Internal force exerted by the compliant element between the flanges. | N |
initial_stretch | Relative displacement at which the spring is in its relaxed (zero force) state; remains constant after initialization | m |
lossPower | Power dissipated by the damper element due to viscous friction | W |
f_c | Force exerted by the spring element | N |
f_d | Force exerted by the damper element | N |
Behavior
Source
# 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
# 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.
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"
Related
Examples
Experiments
Analyses