ParticlePendulumKane.html  (MotionGenesis input/output).
   (1) % MotionGenesis file: ParticlePendulumKane.txt
   (2) % Problem: Particle pendulum with air resistance.  
   (3) % Copyright (c) 2009 Motion Genesis LLC.  All rights reserved.
   (4) %------------------------------------------------------------
   (5) NewtonianFrame N            % Earth
   (6) RigidFrame     B            % Massless cable.
   (7) Particle       Q            % Particle at end of cable.
   (8) %------------------------------------------------------------
   (9) Q.SetMass( m = 100 kg )
   (10) Constant  g = 9.8 m/s^2     % Earth's gravitational acceleration
   (11) Constant  L = 50 m          % Cable length 
   (12) Constant  bAir = 2.0 N*s/m  % Air-resistance constant
   (13) Variable  theta''           % Pendulum swing angle
   (14) %------------------------------------------------------------
   (15) %       Rotation and translation kinematics.
   (16) B.RotateZ( N, theta )
-> (17) B_N = [cos(theta), sin(theta), 0;  -sin(theta), cos(theta), 0;  0, 0, 1]
-> (18) w_B_N> = theta'*Bz>
-> (19) alf_B_N> = theta''*Bz>

   (20) Q.Translate( No,  -L*By> )
-> (21) p_No_Q> = -L*By>
-> (22) v_Q_N> = L*theta'*Bx>
-> (23) a_Q_N> = L*theta''*Bx> + L*theta'^2*By>

   (24) %------------------------------------------------------------
   (25) %       Contact and distance forces on Q.
   (26) %       Note: Constraint forces such as tension do not appear in Kane's equations.
   (27) Q.AddForce( -m*g*Ny> - bAir*Q.GetVelocity(N) )
-> (28) Force_Q> = -bAir*L*theta'*Bx> - m*g*Ny>

   (29) %------------------------------------------------------------
   (30) %       Form equations of motion with  Kane's method.
   (31) SetGeneralizedSpeed( theta' )
   (32) Dynamics = System.GetDynamicsKane() 
-> (33) Dynamics = [L*(m*g*sin(theta)+bAir*L*theta'+m*L*theta'')]

   (34) Solve( Dynamics,  theta'' )
-> (35) theta'' = -(m*g*sin(theta)+bAir*L*theta')/(m*L)

   (36) %------------------------------------------------------------
   (37) %       Initial values and numerical integration parameters.
   (38) Input   theta = 60 deg,  theta' = 0 deg/sec
   (39) Input   tFinal = 120 sec,  tStep = 0.1 sec
   (40) %------------------------------------------------------------
   (41) %       List output quantities and solve ODEs.
   (42) Output  t sec,  theta degrees
   (43) ODE() ParticlePendulumKane

   (44) %------------------------------------------------------------
Saved by Motion Genesis LLC.   Portions copyright (c) 2009-2017 Motion Genesis LLC. Rights reserved. Only for use with MotionGenesis.