LIBRARY
PlanarMechanics.BodyShapePendulumTest
Pendulum with BodyShape: Fixed -> Revolute -> BodyShape.
A 1m BodyShape pendulum starting at rest, swinging under gravity. Translates the "Pendulum with body shape" test from test_PlanarMechanics.jl.
Usage
MultibodyComponents.PlanarMechanics.BodyShapePendulumTest()
Behavior
julia
using MultibodyComponents #hide
using ModelingToolkit #hide
@named sys = MultibodyComponents.PlanarMechanics.BodyShapePendulumTest() #hide
full_equations(sys) #hide<< @example-block not executed in draft mode >>Source
dyad
"""
Pendulum with BodyShape: Fixed -> Revolute -> BodyShape.
A 1m BodyShape pendulum starting at rest, swinging under gravity.
Translates the "Pendulum with body shape" test from test_PlanarMechanics.jl.
"""
test component BodyShapePendulumTest
world = World() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 220, "y2": 220, "rot": 0}
},
"tags": []
}
}
revolute = Revolute() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 280, "y1": 20, "x2": 480, "y2": 220, "rot": 0}
},
"tags": []
}
}
rod = BodyShape(r = [1.0, 0.0], m = 1.0, I = 0.1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 540, "y1": 20, "x2": 740, "y2": 220, "rot": 0}
},
"tags": []
}
}
relations
initial revolute.phi = 0.0
initial revolute.w = 0.0
connect(world.frame_b, revolute.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(revolute.frame_b, rod.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {"Dyad": {"tests": {"case1": {"stop": 3}}}}
endFlattened Source
dyad
"""
Pendulum with BodyShape: Fixed -> Revolute -> BodyShape.
A 1m BodyShape pendulum starting at rest, swinging under gravity.
Translates the "Pendulum with body shape" test from test_PlanarMechanics.jl.
"""
test component BodyShapePendulumTest
world = World() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 220, "y2": 220, "rot": 0}
},
"tags": []
}
}
revolute = Revolute() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 280, "y1": 20, "x2": 480, "y2": 220, "rot": 0}
},
"tags": []
}
}
rod = BodyShape(r = [1.0, 0.0], m = 1.0, I = 0.1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 540, "y1": 20, "x2": 740, "y2": 220, "rot": 0}
},
"tags": []
}
}
relations
initial revolute.phi = 0.0
initial revolute.w = 0.0
connect(world.frame_b, revolute.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(revolute.frame_b, rod.frame_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {"Dyad": {"tests": {"case1": {"stop": 3}}}}
endTest Cases
julia
using MultibodyComponents
using DyadInterface: TransientAnalysis, rebuild_sol, ODEAlg
using ModelingToolkit: toggle_namespacing, get_initial_conditions, @named
using CSV, DataFrames, Plots
snapshotsdir = joinpath(dirname(dirname(pathof(MultibodyComponents))), "test", "snapshots")<< @setup-block not executed in draft mode >>Test Case case1
julia
@named model_case1 = MultibodyComponents.PlanarMechanics.BodyShapePendulumTest()
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 = 3e+0, abstol=1e-6, reltol=1e-6)
sol_case1 = rebuild_sol(result_case1)<< @setup-block not executed in draft mode >>