Spring
Ideal linear rotational spring.
This component models an ideal linear rotational spring. The torque tau
generated by the spring is proportional to the difference between the relative angle of rotation phi_rel
across its flanges and its unstretched angle phi_rel0
. The constant of proportionality is the spring constant c
. The relationship is defined by Hooke's law for rotational systems:
This component extends from PartialCompliant
Usage
Spring(c, phi_rel0=0.0)
Parameters:
Name | Description | Units | Default value |
---|---|---|---|
c | Spring constant | N.m/rad | |
phi_rel0 | Unstretched spring angle | rad | 0 |
Connectors
Variables
Name | Description | Units |
---|---|---|
phi_rel | Relative rotation angle between spline_b and spline_a | rad |
tau | Torque transmitted between the splines | N.m |
Behavior
Source
dyad
# Ideal linear rotational spring.
#
# This component models an ideal linear rotational spring.
# The torque `tau` generated by the spring is proportional to the
# difference between the relative angle of rotation `phi_rel`
# across its flanges and its unstretched angle `phi_rel0`.
# The constant of proportionality is the spring constant `c`.
# The relationship is defined by Hooke's law for rotational systems:
# ```math
# \tau = c (\\phi_{rel} - \\phi_{rel0})
# ```
component Spring
extends PartialCompliant
# Spring constant
parameter c::RotationalSpringConstant
# Unstretched spring angle
parameter phi_rel0::Angle = 0.0
relations
tau = c*(phi_rel-phi_rel0)
metadata {"Dyad": {"icons": {"default": "dyad://RotationalComponents/Spring.svg"}}}
end
Flattened Source
dyad
# Ideal linear rotational spring.
#
# This component models an ideal linear rotational spring.
# The torque `tau` generated by the spring is proportional to the
# difference between the relative angle of rotation `phi_rel`
# across its flanges and its unstretched angle `phi_rel0`.
# The constant of proportionality is the spring constant `c`.
# The relationship is defined by Hooke's law for rotational systems:
# ```math
# \tau = c (\\phi_{rel} - \\phi_{rel0})
# ```
component Spring
# First rotational spline interface
spline_a = Spline() [{"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}]
# Second rotational spline interface
spline_b = Spline() [{"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}]
# Relative rotation angle between spline_b and spline_a
variable phi_rel::Angle
# Torque transmitted between the splines
variable tau::Torque
# Spring constant
parameter c::RotationalSpringConstant
# Unstretched spring angle
parameter phi_rel0::Angle = 0.0
relations
phi_rel = spline_b.phi-spline_a.phi
spline_b.tau = tau
spline_a.tau = -tau
tau = c*(phi_rel-phi_rel0)
metadata {"Dyad": {"icons": {"default": "dyad://RotationalComponents/Spring.svg"}}}
end
Test Cases
This is setup code, that must be run before each test case.
julia
using RotationalComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames
snapshotsdir = joinpath(dirname(dirname(pathof(RotationalComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/RotationalComponents/0VPxm/test/snapshots"
Related
Examples
Experiments
Analyses
Tests