Spring
Linear spring acting as line force between frame_a and frame_b.
A force f is exerted on the origin of frame_b and with opposite sign on the origin of frame_a along the line from the origin of frame_a to the origin of frame_b according to Hooke's law: f = c * (s - s_unstretched).
Optionally, the mass of the spring is taken into account by a point mass located on the line between frame_a and frame_b.
This component extends from PartialTwoFrames This component extends from Renderable
Usage
MultibodyComponents.Spring(render=true, color=world_default_spring_color(), specular_coefficient=1.5, c=1.0, s_unstretched=0, m=1.0, lengthfraction=0.5, radius=world_default_force_width(), num_windings=6, N=200, end_ratio=0.1)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
fixed_rotation_at_frame_a | – | false | |
fixed_rotation_at_frame_b | – | false | |
hasmass | – | false | |
render | – | true | |
color | – | world_defau...ing_color() | |
specular_coefficient | – | 1.5 | |
c | spring constant | N/m | 1.0 |
s_unstretched | unstretched length of spring | m | 0 |
m | mass | kg | 1.0 |
lengthfraction | Location of point mass with respect to frame_a as a fraction of the distance from frame_a to frame_b | – | 0.5 |
radius | Radius of spring coil when rendered | – | world_defau...rce_width() |
num_windings | Number of spring coil windings | – | 6 |
N | Number of points used to render each winding | – | 200 |
end_ratio | Fraction of total length used for the tapered ends | – | 0.1 |
Connectors
frame_a- Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or severalFrame
connectors that can be connected together (Frame3D)
frame_b- Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or severalFrame
connectors that can be connected together (Frame3D)
Variables
| Name | Description | Units |
|---|---|---|
r_rel_a | Position vector from origin of frame_a to origin of frame_b, resolved in frame_a | m |
e_a | Unit vector on the line connecting the origin of frame_a with the origin of frame_b resolved in frame_a (directed from frame_a to frame_b) | – |
f | Line force acting on frame_a and on frame_b (positive, if acting on frame_b and directed from frame_a to frame_b) | N |
length | Distance between the origin of frame_a and the origin of frame_b | m |
s | (Guarded) distance between the origin of frame_a and the origin of frame_b (>= s_small)) | m |
v | derivative of s | m/s |
r_rel_0 | Position vector from frame_a to frame_b resolved in world frame | m |
e_rel_0 | Unit vector in direction from frame_a to frame_b, resolved in world frame | – |
Behavior
Source
"""
Linear spring acting as line force between `frame_a` and `frame_b`.
A force `f` is exerted on the origin of `frame_b` and with opposite sign
on the origin of `frame_a` along the line from the origin of `frame_a` to
the origin of `frame_b` according to Hooke's law: `f = c * (s - s_unstretched)`.
Optionally, the mass of the spring is taken into account by a point mass
located on the line between `frame_a` and `frame_b`.
"""
component Spring
extends PartialTwoFrames
extends Renderable(color = world_default_spring_color())
lineforce = LineForceWithMass(final hasmass = hasmass, final fixed_rotation_at_frame_a = fixed_rotation_at_frame_a, final fixed_rotation_at_frame_b = fixed_rotation_at_frame_b) if !hasmass
spring1d = TranslationalComponents.Components.Spring(final c = c, final s_rel0 = s_unstretched)
# Visualization shape
spring_shape = SpringShape(render = render, color = color, num_windings = num_windings, N = N, end_ratio = end_ratio, r = frame_a.r_0, length_direction = r_rel_0, length = s, width = radius)
structural parameter fixed_rotation_at_frame_a::Boolean = false
structural parameter fixed_rotation_at_frame_b::Boolean = false
structural parameter hasmass::Boolean = false
"spring constant"
parameter c::TranslationalSpringConstant = 1.0
"unstretched length of spring"
parameter s_unstretched::Length = 0
"mass"
parameter m::Mass = 1.0 if hasmass
"Location of point mass with respect to frame_a as a fraction of the distance from frame_a to frame_b"
parameter lengthfraction::Real = 0.5 if hasmass
"Radius of spring coil when rendered"
parameter radius::Real = world_default_force_width()
"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
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_a"
variable r_rel_a::Position[3]
"Unit vector on the line connecting the origin of frame_a with the origin of frame_b resolved in frame_a (directed from frame_a to frame_b)"
variable e_a::Real[3]
"Line force acting on frame_a and on frame_b (positive, if acting on frame_b and directed from frame_a to frame_b)"
variable f::Dyad.Force
"Distance between the origin of frame_a and the origin of frame_b"
variable length::Length
"(Guarded) distance between the origin of frame_a and the origin of frame_b (>= s_small))"
variable s::Length
"derivative of s"
variable v::Velocity
"Position vector from frame_a to frame_b resolved in world frame"
variable r_rel_0::Position[3]
"Unit vector in direction from frame_a to frame_b, resolved in world frame"
variable e_rel_0::Real[3]
relations
der(s) = v
r_rel_a = resolve2(frame_a.R, r_rel_0)
e_a = r_rel_a / s
f = spring1d.f
length = lineforce.length
s = lineforce.s
r_rel_0 = lineforce.r_rel_0
e_rel_0 = lineforce.e_rel_0
connect(lineforce.frame_a, frame_a)
connect(lineforce.frame_b, frame_b)
connect(spring1d.flange_b, lineforce.flange_b)
connect(spring1d.flange_a, lineforce.flange_a)
metadata {
"Dyad": {
"icons": {"default": "dyad://MultibodyComponents/Spring.svg"},
"labels": [
{
"label": "$(instance)",
"x": 500,
"y": 280,
"rot": 0,
"attrs": {"font-size": "160"}
}
]
}
}
endFlattened Source
"""
Linear spring acting as line force between `frame_a` and `frame_b`.
A force `f` is exerted on the origin of `frame_b` and with opposite sign
on the origin of `frame_a` along the line from the origin of `frame_a` to
the origin of `frame_b` according to Hooke's law: `f = c * (s - s_unstretched)`.
Optionally, the mass of the spring is taken into account by a point mass
located on the line between `frame_a` and `frame_b`.
"""
component Spring
frame_a = Frame3D() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
},
"tags": []
}
}
frame_b = Frame3D() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "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 = 1.5
lineforce = LineForceWithMass(final hasmass = hasmass, final fixed_rotation_at_frame_a = fixed_rotation_at_frame_a, final fixed_rotation_at_frame_b = fixed_rotation_at_frame_b) if !hasmass
spring1d = TranslationalComponents.Components.Spring(final c = c, final s_rel0 = s_unstretched)
# Visualization shape
spring_shape = SpringShape(render = render, color = color, num_windings = num_windings, N = N, end_ratio = end_ratio, r = frame_a.r_0, length_direction = r_rel_0, length = s, width = radius)
structural parameter fixed_rotation_at_frame_a::Boolean = false
structural parameter fixed_rotation_at_frame_b::Boolean = false
structural parameter hasmass::Boolean = false
"spring constant"
parameter c::TranslationalSpringConstant = 1.0
"unstretched length of spring"
parameter s_unstretched::Length = 0
"mass"
parameter m::Mass = 1.0 if hasmass
"Location of point mass with respect to frame_a as a fraction of the distance from frame_a to frame_b"
parameter lengthfraction::Real = 0.5 if hasmass
"Radius of spring coil when rendered"
parameter radius::Real = world_default_force_width()
"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
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_a"
variable r_rel_a::Position[3]
"Unit vector on the line connecting the origin of frame_a with the origin of frame_b resolved in frame_a (directed from frame_a to frame_b)"
variable e_a::Real[3]
"Line force acting on frame_a and on frame_b (positive, if acting on frame_b and directed from frame_a to frame_b)"
variable f::Dyad.Force
"Distance between the origin of frame_a and the origin of frame_b"
variable length::Length
"(Guarded) distance between the origin of frame_a and the origin of frame_b (>= s_small))"
variable s::Length
"derivative of s"
variable v::Velocity
"Position vector from frame_a to frame_b resolved in world frame"
variable r_rel_0::Position[3]
"Unit vector in direction from frame_a to frame_b, resolved in world frame"
variable e_rel_0::Real[3]
relations
der(s) = v
r_rel_a = resolve2(frame_a.R, r_rel_0)
e_a = r_rel_a / s
f = spring1d.f
length = lineforce.length
s = lineforce.s
r_rel_0 = lineforce.r_rel_0
e_rel_0 = lineforce.e_rel_0
connect(lineforce.frame_a, frame_a)
connect(lineforce.frame_b, frame_b)
connect(spring1d.flange_b, lineforce.flange_b)
connect(spring1d.flange_a, lineforce.flange_a)
metadata {
"Dyad": {
"icons": {"default": "dyad://MultibodyComponents/Spring.svg"},
"labels": [
{
"label": "$(instance)",
"x": 500,
"y": 280,
"rot": 0,
"attrs": {"font-size": "160"}
}
]
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses