Consider a mass m attached to a spring of spring constant k swinging in a vertical plane as shown in Figure 1. The equations of motion can be derived easily by writing the Lagrangian and then writing the Lagrange equations of motion.
Where l is equilibrium length of the pendulum, m is mass of the bob attached to spring. Let l+r(t) be the length of the spring, and θ(t) be the angle of the spring w.r.t vertical.
Figure 1: Spring Pendulum
2. Lagrange’s Equations of motion for Spring Pendulum
The kinetic and potential energies of the mass are given as follows
Where x is the stretch in the spring beyond its equilibrium. Therefore the Lagrangian is given is
The equations of motion for spring pendulum are as follows:
Where ωr and ωθ are the springs frequency along its length and pendulums frequency of oscillation respectively and are given by
3. Numerical Integration of System of Equations
The system of equations (2.5) and (2.6) can be time integrated to know the trajectory/ position of the spring pendulum using methods like Euler method, Runge-Kutta method etc,. Runge-Kutta method is better and more accurate. To apply these techniques the system of equations are transferred to first order differential equations as follows:
To solve the above first order differential equations initial values are required i.e. are required.
4. Code of SpringPendulum
A code is written in MATLAB for spring pendulum. Systems of equations are solved using ODE45 of the MATLAB. Animation of the spring pendulum motion is plotted. Phase plane plots of the spring motion and pendulum motion are plotted in the same animation plot. The following are the values used in the code and can be changed accordingly.
Mass of the bob, M = 2 N