Skip to content
Inertia.md

Inertia

A 1D-rotational component with inertia, subject to torques from two splines.

This component represents a rigid body with a moment of inertia J that can rotate in one dimension. It connects to other components via two rotational splines, spline_a and spline_b (inherited from PartialTwoSplines). The absolute rotation angle of the inertia is phi, its angular velocity is w, and its angular acceleration is a. The core dynamic behavior is defined by Newton's second law for rotation:

J \\cdot a = \text{spline\\_a}.\\tau + \text{spline\\_b}.\\tau

The kinematic relationships defining angular velocity and acceleration are:

w=dphidta=dwdt

Both splines are rigidly attached to the inertia, meaning phi = spline_a.phi and phi = spline_b.phi.

This component extends from PartialTwoSplines

Usage

Inertia(J)

Parameters:

NameDescriptionUnitsDefault value
JMoment of inertia of the rotating bodykg.m2

Connectors

Variables

NameDescriptionUnits
phiAbsolute rotation angle of the inertiarad
wAbsolute angular velocity of the inertiarad/s
aAbsolute angular acceleration of the inertiarad/s2

Behavior

phi(t)=spline_a.phi(t)phi(t)=spline_b.phi(t)dphi(t)dt=w(t)dw(t)dt=a(t)Ja(t)=spline_b.tau(t)+spline_a.tau(t)

Source

dyad
# A 1D-rotational component with inertia, subject to torques from two splines.
#
# This component represents a rigid body with a moment of inertia `J` that can rotate in one dimension.
# It connects to other components via two rotational splines, `spline_a` and `spline_b` (inherited from `PartialTwoSplines`).
# The absolute rotation angle of the inertia is `phi`, its angular velocity is `w`,
# and its angular acceleration is `a`.
# The core dynamic behavior is defined by Newton's second law for rotation:
# ```math
# J \\cdot a = \text{spline\\_a}.\\tau + \text{spline\\_b}.\\tau
# ```
# The kinematic relationships defining angular velocity and acceleration are:
# ```math
# w = \frac{d\\phi}{dt}
# ```
# ```math
# a = \frac{dw}{dt}
# ```
# Both splines are rigidly attached to the inertia, meaning `phi = spline_a.phi` and `phi = spline_b.phi`.
component Inertia
  extends PartialTwoSplines
  # Moment of inertia of the rotating body
  parameter J::MomentOfInertia
  # Absolute rotation angle of the inertia
  variable phi::Angle
  # Absolute angular velocity of the inertia
  variable w::AngularVelocity
  # Absolute angular acceleration of the inertia
  variable a::AngularAcceleration
relations
  phi = spline_a.phi
  phi = spline_b.phi
  D(phi) = w
  D(w) = a
  J*a = spline_a.tau+spline_b.tau
metadata {"Dyad": {"icons": {"default": "dyad://RotationalComponents/Inertia.svg"}}}
end
Flattened Source
dyad
# A 1D-rotational component with inertia, subject to torques from two splines.
#
# This component represents a rigid body with a moment of inertia `J` that can rotate in one dimension.
# It connects to other components via two rotational splines, `spline_a` and `spline_b` (inherited from `PartialTwoSplines`).
# The absolute rotation angle of the inertia is `phi`, its angular velocity is `w`,
# and its angular acceleration is `a`.
# The core dynamic behavior is defined by Newton's second law for rotation:
# ```math
# J \\cdot a = \text{spline\\_a}.\\tau + \text{spline\\_b}.\\tau
# ```
# The kinematic relationships defining angular velocity and acceleration are:
# ```math
# w = \frac{d\\phi}{dt}
# ```
# ```math
# a = \frac{dw}{dt}
# ```
# Both splines are rigidly attached to the inertia, meaning `phi = spline_a.phi` and `phi = spline_b.phi`.
component Inertia
  # First spline
  spline_a = Spline() [{"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}]
  # Second spline
  spline_b = Spline() [{"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}]
  # Moment of inertia of the rotating body
  parameter J::MomentOfInertia
  # Absolute rotation angle of the inertia
  variable phi::Angle
  # Absolute angular velocity of the inertia
  variable w::AngularVelocity
  # Absolute angular acceleration of the inertia
  variable a::AngularAcceleration
relations
  phi = spline_a.phi
  phi = spline_b.phi
  D(phi) = w
  D(w) = a
  J*a = spline_a.tau+spline_b.tau
metadata {"Dyad": {"icons": {"default": "dyad://RotationalComponents/Inertia.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"