LIBRARY
Examples.FirstGrounded
First example: simple drive train with grounded elements.
The drive train consists of a motor inertia which is driven by a sine-wave motor torque. Via a gearbox the rotational energy is transmitted to a load inertia. Elasticity in the gearbox is modeled by a spring element. A linear damper is used to model the damping in the gearbox bearing.
In Dyad, support flanges are always present. Both torque source and ideal gear supports are connected to the fixed reference, equivalent to the MSL variant with useSupport=false (internally grounded).
Corresponds to Modelica.Mechanics.Rotational.Examples.FirstGrounded. StopTime=1.0, Interval=0.001.
Usage
RotationalComponents.Examples.FirstGrounded()
Behavior
julia
using RotationalComponents #hide
using ModelingToolkit #hide
@named sys = RotationalComponents.Examples.FirstGrounded() #hide
full_equations(sys) #hide<< @example-block not executed in draft mode >>Source
dyad
"""
First example: simple drive train with grounded elements.
The drive train consists of a motor inertia which is driven by a sine-wave
motor torque. Via a gearbox the rotational energy is transmitted to a load
inertia. Elasticity in the gearbox is modeled by a spring element. A linear
damper is used to model the damping in the gearbox bearing.
In Dyad, support flanges are always present. Both torque source and ideal gear
supports are connected to the fixed reference, equivalent to the MSL variant
with useSupport=false (internally grounded).
Corresponds to Modelica.Mechanics.Rotational.Examples.FirstGrounded.
StopTime=1.0, Interval=0.001.
"""
example component FirstGrounded
"Fixed mechanical ground."
fixed = RotationalComponents.Components.Fixed() {}
"Torque source driven by external sine signal."
torque = RotationalComponents.Sources.TorqueSource() {}
"Motor inertia, J=0.1 kg.m^2."
inertia1 = RotationalComponents.Components.Inertia(J = 0.1) {}
"Ideal gear with ratio=10."
ideal_gear = RotationalComponents.Components.IdealGear(ratio = 10) {}
"Intermediate inertia after gearbox, J=2 kg.m^2."
inertia2 = RotationalComponents.Components.Inertia(J = 2) {}
"Torsional spring in gearbox, c=1e4 N.m/rad."
spring = RotationalComponents.Components.Spring(c = 1e4) {}
"Load inertia, J=2 kg.m^2."
inertia3 = RotationalComponents.Components.Inertia(J = 2) {}
"Bearing damper, d=10 N.m.s/rad."
damper = RotationalComponents.Components.Damper(d = 10) {}
"Sine torque signal, amplitude=10 N.m, frequency=5 Hz."
sine = BlockComponents.Sources.Sine(amplitude = 10, frequency = 5) {}
relations
initial inertia2.phi = 0
initial inertia2.w = 0
initial spring.phi_rel = 0
initial inertia3.w = 0
connect(sine.y, torque.tau)
connect(torque.spline, inertia1.spline_a)
connect(torque.support, fixed.spline)
connect(inertia1.spline_b, ideal_gear.spline_a)
connect(ideal_gear.spline_b, inertia2.spline_a)
connect(ideal_gear.support, fixed.spline)
connect(inertia2.spline_b, spring.spline_a, damper.spline_a)
connect(spring.spline_b, inertia3.spline_a)
connect(damper.spline_b, fixed.spline)
metadata {
"Dyad": {
"icons": {"default": "dyad://RotationalComponents/Example.svg"},
"tests": {
"case1": {
"stop": 1,
"expect": {"initial": {"inertia2.phi": 0, "inertia2.w": 0, "inertia3.w": 0}}
}
}
}
}
endFlattened Source
dyad
"""
First example: simple drive train with grounded elements.
The drive train consists of a motor inertia which is driven by a sine-wave
motor torque. Via a gearbox the rotational energy is transmitted to a load
inertia. Elasticity in the gearbox is modeled by a spring element. A linear
damper is used to model the damping in the gearbox bearing.
In Dyad, support flanges are always present. Both torque source and ideal gear
supports are connected to the fixed reference, equivalent to the MSL variant
with useSupport=false (internally grounded).
Corresponds to Modelica.Mechanics.Rotational.Examples.FirstGrounded.
StopTime=1.0, Interval=0.001.
"""
example component FirstGrounded
"Fixed mechanical ground."
fixed = RotationalComponents.Components.Fixed() {}
"Torque source driven by external sine signal."
torque = RotationalComponents.Sources.TorqueSource() {}
"Motor inertia, J=0.1 kg.m^2."
inertia1 = RotationalComponents.Components.Inertia(J = 0.1) {}
"Ideal gear with ratio=10."
ideal_gear = RotationalComponents.Components.IdealGear(ratio = 10) {}
"Intermediate inertia after gearbox, J=2 kg.m^2."
inertia2 = RotationalComponents.Components.Inertia(J = 2) {}
"Torsional spring in gearbox, c=1e4 N.m/rad."
spring = RotationalComponents.Components.Spring(c = 1e4) {}
"Load inertia, J=2 kg.m^2."
inertia3 = RotationalComponents.Components.Inertia(J = 2) {}
"Bearing damper, d=10 N.m.s/rad."
damper = RotationalComponents.Components.Damper(d = 10) {}
"Sine torque signal, amplitude=10 N.m, frequency=5 Hz."
sine = BlockComponents.Sources.Sine(amplitude = 10, frequency = 5) {}
relations
initial inertia2.phi = 0
initial inertia2.w = 0
initial spring.phi_rel = 0
initial inertia3.w = 0
connect(sine.y, torque.tau)
connect(torque.spline, inertia1.spline_a)
connect(torque.support, fixed.spline)
connect(inertia1.spline_b, ideal_gear.spline_a)
connect(ideal_gear.spline_b, inertia2.spline_a)
connect(ideal_gear.support, fixed.spline)
connect(inertia2.spline_b, spring.spline_a, damper.spline_a)
connect(spring.spline_b, inertia3.spline_a)
connect(damper.spline_b, fixed.spline)
metadata {
"Dyad": {
"icons": {"default": "dyad://RotationalComponents/Example.svg"},
"tests": {
"case1": {
"stop": 1,
"expect": {"initial": {"inertia2.phi": 0, "inertia2.w": 0, "inertia3.w": 0}}
}
}
}
}
endTest Cases
julia
using RotationalComponents
using DyadInterface: TransientAnalysis, rebuild_sol, ODEAlg
using ModelingToolkit: toggle_namespacing, get_initial_conditions, @named
using CSV, DataFrames, Plots
snapshotsdir = joinpath(dirname(dirname(pathof(RotationalComponents))), "test", "snapshots")<< @setup-block not executed in draft mode >>Test Case case1
julia
@named model_case1 = RotationalComponents.Examples.FirstGrounded()
model_case1 = toggle_namespacing(model_case1, false)
model_case1 = toggle_namespacing(model_case1, true)
result_case1 = TransientAnalysis(; model = model_case1, alg = ODEAlg.Auto(), start = 0e+0, stop = 1e+0, abstol=1e-6, reltol=1e-6)
sol_case1 = rebuild_sol(result_case1)<< @setup-block not executed in draft mode >>Related
Examples
Experiments
Analyses