% MotionGenesis file: MGSwingingSpring2DPendulumFma.txt % Problem: 2D Pendulum on a swinging spring (coupled nonlinear beat phenomenon). % Copyright (c) 2009 Motion Genesis LLC. All rights reserved. %-------------------------------------------------------------------- NewtonianFrame N % Earth. Particle Q % Particle at end of spring. RigidFrame B % Vector basis with By> directed from Q to No. %-------------------------------------------------------------------- Variable y'' % Spring stretch (from natural length) Variable q'' % Pendulum angle Constant g = 9.8 m/s^2 % Earth's gravitational acceleration Constant k = 100 N/m % Linear spring constant Constant Ln = 0.3 m % Natural length of spring Q.SetMass( m = 1 kg ) %-------------------------------------------------------------------- % Rotational and translational kinematics. B.RotateZ( N, q ) Q.Translate( No, -(Ln+y)*By> ) %-------------------------------------------------------------------- % Add gravity and spring forces to Q. Q.AddForce( -m*g*Ny> + k*y*By> ) %-------------------------------------------------------------------- % Equations of motion via F = m*a. Dynamics[1] = Dot( Bx>, Q.GetDynamics() ) Dynamics[2] = Dot( -By>, Q.GetDynamics() ) Solve( Dynamics, q'', y'' ) %-------------------------------------------------------------------- % Integration parameters and initial values. Input tFinal = 16 sec, tStep = 0.01 sec, absError = 1.0E-07 Input q = 1.0 deg, q'=0 deg/sec, y = 0.2 m, y' = 0 m/s %-------------------------------------------------------------------- % List output quantities and solve ODEs. Output t sec, q deg, y m ODE() MGSwingingSpring2DPendulumFma %-------------------------------------------------------------------- Save MGSwingingSpring2DPendulumFma.html Quit