% MotionGenesis file: BabybootWithKaneLagrange.txt % Problem: Analysis of 3D chaotic double pendulum. % Copyright (c) 2009 Motion Genesis LLC. All rights reserved. %---------------------------------------------------------------- SetDigits( 5 ) % Number of digits displayed for numbers %---------------------------------------------------------------- NewtonianFrame N RigidBody A % Upper rod RigidBody B % Lower plate %---------------------------------------------------------------- Variable qA'' % Pendulum angle and its time-derivatives Variable qB'' % Plate angle and its time-derivative Constant LA = 7.5 cm % Distance from pivot to A's mass center Constant LB = 20 cm % Distance from pivot to B's mass center Constant g = 9.81 m/s^2 % Earth's gravitational acceleration. A.SetMassInertia( mA = 10 grams, IAx = 50 g*cm^2, IAy, IAz ) B.SetMassInertia( mB = 100 grams, IBx = 2500 g*cm^2, IBy = 500 g*cm^2, IBz = 2000 g*cm^2 ) %---------------------------------------------------------------- % Rotational and translational kinematics. A.RotateX( N, qA ) B.RotateZ( A, qB ) Acm.Translate( No, -LA*Az> ) Bcm.Translate( No, -LB*Az> ) %----------------------------------------------------------- % Add relevant forces. System.AddForceGravity( -g*Nz> ) %---------------------------------------------------------------- % D'Alembert's equations of motion (MG road-maps). Dynamics[1] = Dot( Ax>, System(A,B).GetDynamics(No) ) Dynamics[2] = Dot( Bz>, B.GetDynamics(Bcm) ) %----------------------------------------------------------- % Kane's equations of motion (uses generalized speeds). SetGeneralizedSpeed( qA', qB' ) Dynamics := System.GetDynamicsKane() %----------------------------------------------------------- % Kinetic and potential energy. KE = System.GetKineticEnergy() PE = System.GetForceGravityPotentialEnergy( -g*Nz>, No ) Energy = KE + PE %----------------------------------------------------------- % Lagranges's equations of motion (uses generalized coordinates). SetGeneralizedCoordinates( qA, qB ) Dynamics := System.GetDynamicsLagrange( SystemPotential = PE ) Solve( Dynamics = 0, qA'', qB'' ) %----------------------------------------------------------- % Integration parameters and initial values. Input tFinal = 10 sec, tStep = 0.02 sec, absError = 1.0E-07, relError = 1.0E-07 Input qA = 90 deg, qA' = 0.0 rad/sec, qB = 1.0 deg, qB' = 0.0 rad/sec %----------------------------------------------------------- % List output quantities and solve ODEs. OutputPlot t sec, qA deg, qB deg, Energy N*m ODE() Babyboot %------------------------------------------------------------ % Record input together with responses Save BabybootWithKaneLagrange.html Quit