% MotionGenesis file: MGMetronomePendulumEulerLagrangeKane.txt % Problem: Equation of motion for two-particle metronome. % Copyright (c) 2017 Motion Genesis LLC. All rights reserved. %-------------------------------------------------------------------- NewtonianFrame N % Earth with point No at metronome pivot. RigidFrame B % Metronome rod. Particle Q1, Q2 % Particles fixed at distal ends of B. %-------------------------------------------------------------------- Variable theta'' % Metronome angle and 1st/2nd derivative. Constant L = 0.2 m % Distance between point No and Q1. Constant h = 0.1456 m % Distance between point No and Q2. Constant g = 9.8 m/s^2 % Earth's gravitational acceleration. Constant k = 2 N*m/rad % Torsional spring constant. Q1.SetMass( m1 = 0.1 kg ) Q2.SetMass( m2 = 0.02 kg ) %-------------------------------------------------------------------- % Rotational and translational kinematics. B.RotateNegativeZ( N, theta ) Q1.Translate( No, -L*By> ) Q2.Translate( No, h*By> ) %-------------------------------------------------------------------- % Relevant forces and torques. System.AddForceGravity( -g*Ny> ) B.AddTorque( k*theta*Bz> ) %-------------------------------------------------------------------- % Euler's equation of motion (angular momentum principle about No). Euler = Dot( System.GetDynamics(No), -Bz> ) Factor( Euler, theta'', g ) %-------------------------------------------------------------------- % Conservation of mechanical energy. KineticEnergy = System.GetKineticEnergy() PotentialEnergyGravity = System.GetForceGravityPotentialEnergy( -g*Ny>, No ) PotentialEnergySpring = 1/2 * k * theta^2 PotentialEnergy = PotentialEnergyGravity + PotentialEnergySpring MechanicalEnergy = KineticEnergy + PotentialEnergy %-------------------------------------------------------------------- % Lagrange's equation of motion. SetGeneralizedCoordinate( theta ) Lagrange = System.GetDynamicsLagrange( SystemPotential = PotentialEnergy ) Factor( Lagrange, theta'', g ) %-------------------------------------------------------------------- % Kane's equation of motion. SetGeneralizedSpeed( theta' ) Kane = System.GetDynamicsKane() Factor( Kane, theta'', g ) %-------------------------------------------------------------------- % Save input and program responses. Save MGMetronomePendulumEulerLagrangeKane.html Quit