Skip to content
TwoInertiasWithDrivingTorque.md

TwoInertiasWithDrivingTorque

A mechanical system of two rotational inertias coupled by a spring and damper, driven by a sinusoidal torque.

This model represents a dynamic system where a primary rotational inertia (inertia1) is subjected to an external torque generated by a sinusoidal source. This first inertia is mechanically coupled to a second rotational inertia (inertia2) through a torsional spring and a torsional damper, which are arranged in parallel. The torque source is referenced to a fixed ground. Initial conditions for angular positions, and implicitly angular velocities through the initial acceleration constraint, define the starting state of the system.

Usage

TwoInertiasWithDrivingTorque()

Behavior

julia
using RotationalComponents #hide
using ModelingToolkit #hide
@named sys = TwoInertiasWithDrivingTorque() #hide
full_equations(sys) #hide
<< @example-block not executed in draft mode >>

Source

dyad
# A mechanical system of two rotational inertias coupled by a spring and damper, driven by a sinusoidal torque.
#
# This model represents a dynamic system where a primary rotational inertia
# (inertia1) is subjected to an external torque generated by a sinusoidal source.
# This first inertia is mechanically coupled to a second rotational inertia
# (inertia2) through a torsional spring and a torsional damper, which are arranged
# in parallel. The torque source is referenced to a fixed ground.
# Initial conditions for angular positions, and implicitly angular velocities
# through the initial acceleration constraint, define the starting state of the system.
test component TwoInertiasWithDrivingTorque
  # Represents a fixed mechanical ground or reference frame.
  fixed = Fixed()
  # Source that applies a torque to the system, driven by an external signal.
  torque = TorqueSource()
  # First rotational inertia with moment of inertia J=2 kg.m^2.
  inertia1 = Inertia(J=2)
  # Second rotational inertia with moment of inertia J=4 kg.m^2.
  inertia2 = Inertia(J=4)
  # Torsional spring connecting the two inertias, with spring constant c=1e4 N.m/rad.
  spring = Spring(c=1e4)
  # Torsional damper in parallel with the spring, with damping coefficient d=10 N.m.s/rad.
  damper = Damper(d=10)
  # Generates a sinusoidal signal for the driving torque, with amplitude=10 and frequency=5 Hz.
  sine = BlockComponents.Sine(amplitude=10, frequency=5)
relations
  initial inertia1.phi = 1
  initial inertia2.phi = 0.5
  initial inertia2.a = 0
  initial inertia2.w = 0
  connect(sine.y, torque.tau)
  connect(torque.support, fixed.spline)
  connect(torque.spline, inertia1.spline_a)
  connect(inertia1.spline_b, spring.spline_a, damper.spline_a)
  connect(spring.spline_b, damper.spline_b, inertia2.spline_a)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 1,
        "expect": {
          "initial": {"inertia1.phi": 1, "inertia2.phi": 0.5, "inertia1.w": -500, "inertia2.w ": 0}
        }
      }
    }
  }
}
end
Flattened Source
dyad
# A mechanical system of two rotational inertias coupled by a spring and damper, driven by a sinusoidal torque.
#
# This model represents a dynamic system where a primary rotational inertia
# (inertia1) is subjected to an external torque generated by a sinusoidal source.
# This first inertia is mechanically coupled to a second rotational inertia
# (inertia2) through a torsional spring and a torsional damper, which are arranged
# in parallel. The torque source is referenced to a fixed ground.
# Initial conditions for angular positions, and implicitly angular velocities
# through the initial acceleration constraint, define the starting state of the system.
test component TwoInertiasWithDrivingTorque
  # Represents a fixed mechanical ground or reference frame.
  fixed = Fixed()
  # Source that applies a torque to the system, driven by an external signal.
  torque = TorqueSource()
  # First rotational inertia with moment of inertia J=2 kg.m^2.
  inertia1 = Inertia(J=2)
  # Second rotational inertia with moment of inertia J=4 kg.m^2.
  inertia2 = Inertia(J=4)
  # Torsional spring connecting the two inertias, with spring constant c=1e4 N.m/rad.
  spring = Spring(c=1e4)
  # Torsional damper in parallel with the spring, with damping coefficient d=10 N.m.s/rad.
  damper = Damper(d=10)
  # Generates a sinusoidal signal for the driving torque, with amplitude=10 and frequency=5 Hz.
  sine = BlockComponents.Sine(amplitude=10, frequency=5)
relations
  initial inertia1.phi = 1
  initial inertia2.phi = 0.5
  initial inertia2.a = 0
  initial inertia2.w = 0
  connect(sine.y, torque.tau)
  connect(torque.support, fixed.spline)
  connect(torque.spline, inertia1.spline_a)
  connect(inertia1.spline_b, spring.spline_a, damper.spline_a)
  connect(spring.spline_b, damper.spline_b, inertia2.spline_a)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 1,
        "expect": {
          "initial": {"inertia1.phi": 1, "inertia2.phi": 0.5, "inertia1.w": -500, "inertia2.w ": 0}
        }
      }
    }
  }
}
end


Test Cases

julia
using RotationalComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(RotationalComponents))), "test", "snapshots")
<< @setup-block not executed in draft mode >>

Test Case case1

julia
@mtkbuild model_case1 = TwoInertiasWithDrivingTorque()
u0_case1 = []
prob_case1 = ODEProblem(model_case1, u0_case1, (0, 1))
sol_case1 = solve(prob_case1)
<< @setup-block not executed in draft mode >>