Skip to content
Spring.md

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:

τ=c(phirelphirel0)

This component extends from PartialCompliant

Usage

Spring(c, phi_rel0=0.0)

Parameters:

NameDescriptionUnitsDefault value
cSpring constantN.m/rad
phi_rel0Unstretched spring anglerad0

Connectors

Variables

NameDescriptionUnits
phi_relRelative rotation angle between spline_b and spline_arad
tauTorque transmitted between the splinesN.m

Behavior

phi_rel(t)=spline_b.phi(t)spline_a.phi(t)spline_b.tau(t)=tau(t)spline_a.tau(t)=tau(t)tau(t)=c(phi_rel0+phi_rel(t))

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"