OneSimulation docs Website Free books Plans on Gumroad

Docs › Build a first case in each physics package › Multibody dynamics

5.12 Multibody dynamics

onesim.physics.multibody

SimplePendulum advances angle and angular velocity. EulerTop evolves rotation about principal inertia axes. TorsionalDrivetrain uses shaft stiffness, damping and gear ratios. DrivenFourBar also has geometry and an assembly branch. LinearJointSystem adds algebraic constraints to inertial dynamics. For a linkage, check constraint residuals and initial configuration consistency as well as the trajectory. test_multibody_input_flexibility.py gives driven examples and tests physical inputs.

# Use run_lumped and scalar_series from the cooling chapter.
from onesim.physics.multibody import SimplePendulum

domain = LumpedDomain()
pendulum = SimplePendulum(domain=domain.system, length=0.5)
_, samples, time = run_lumped(
    domain, pendulum,
    ((pendulum.angle, 0.15), (pendulum.angular_velocity, 0.0)),
    (pendulum.angle, pendulum.energy), end=2.0, dt=0.005, interval=0.025,
)
theta = scalar_series(samples, pendulum.angle)
energy = scalar_series(samples, pendulum.energy)
np.testing.assert_allclose(energy, np.full_like(energy, energy[0]), atol=1e-8)

Plot angle and phase against time or convert the angle to a bob position for an animation. The small-angle period \(2\pi\sqrt{\ell/g}\) provides a reference for small initial angles. Use energy or torque balance for larger amplitudes.