27 Jul 2017

Double Pendulum

Simulating the double pendulum using RK4

Overview

A small video displaying the simulation may be seen here.

The double pendulum is a canonical classical mechanics problem to introduce the concept of chaos; the description will therefore be brief. First, find the equations of motion (EOM) using forces or the Lagrangian method; this describes the angles and angular velocities of the two masses. The derivation will not be done here as it is beyond the scope of this website, but it is a must-do mechanics problem to solve for undergraduates. The masses and pendula arm-lengths can be different which gives rise to interesting behavior, and the initial angles are chosen with a flat random number generator. The equations of motion need to be approximated, and in this case I used the Runge-Kutta method otherwise known as RK4. In order to proceed with the simulation, a time variable is needed to keep track of the evolution of the angles/angular velocities given some random initial condition. A simple tracer routine has been added to follow the position of the masses, and the alpha component decays as a function of position within the tracer C++ vector (I limit the number of traces to roughly 200-300 to avoid messy patterns). Note that with very little effort, the double pendulum simulation may be used as a spirograph generator. In this case, the RK4 method (and equations of motion) is discarded and one simply chooses angular velocities and arm-lengths.

Fig. 1 - The double pendulum simulation with rainbow (fading alpha) tracers on the second (first) mass.

-->