For our Mechanical Dynamics final project, a friend and I decided to generalize the equations for compound pendulums to write a simulation program that could generate animations for n-link compound pendulums with user specified lengths, masses, angular displacement and velocities. We originally wanted to write a full blown physics engine, but quickly realized that two weeks was not enough time to do something of that scale, haha.
First things first, a demonstration! The following is an simulation of a 5 link compound pendulum:
These were the parameters entered in the GUI.
Our program also automatically generates energy and position/velocity/acceleration graphs.
Now, how did we manage to do such a cool thing?
In order to simulate a compound pendulum, we first had to fully understand the equations behind a simple pendulum. In a simple pendulum, we ignore the mass moments of inertia and only worry about gravity and tension. Take a look at my post about the equations of motion of simple pendulums for a more detailed explanation.
To move from a simple pendulum to a compound pendulum, we first have to recognize that the core difference between the two is that we must worry about the mass moments of inertia in a compound pendulum. We are no longer treating the pendulum as a mass attached to a string, but as a rectangular bar.
And ecetera for any future links to this pendulum.
We know we can describe the angular momentum of each pendulum as:
Where theta is the respective theta from 0 for each pendulum. There is only rotation about the third axis, the one that’s jutting out of the page. (We can verify this via the right hand rule.)
The inertial tensor for a rectangular bar it’s center of mass is:
Where m is the mass and L is the length of the bar.
Now, using the same method as in finding equations for a simple pendulum, we do the same by finding all the accelerations and forces to solve for the for each link. For simple pendulums, the reaction force (tension) was always aligned with along the length of the string. However, in a compound pendulum, the reaction forces aren’t always aligned so we must solve for them as well. This means, for each link the pendulum, there are three unknowns that must be solved. These are where are the reaction forces in the two orthogonal directions of the attached reference frame. The idea is illustrated below:
Since there are three unknowns per link, we’ll need three equations multiplied by however many links we have. We can get the two of the three by following the same method as with simple pendulums, by collecting the accelerations and forces and solving . The last equation we find by using the equation:
(i.e, the sum of the moments is equal to the derivative of the angular momentum)
A moment is equal to the force crossed by the distance over which it’s exerted:
As a quick example, this is how that calculation would work for the last link of our pendulum where the only moment would be as a result of the reaction force connecting it to the previous pendulum (B):
Working through all this math, we observe a pattern that every pendulum on the link is basically the same and because each has a reaction force on each end, and a theta relative to the vertical 0. The pendulums are connected by the reaction forces, as one can see in the free body diagram above, where R2 is on the bottom end of pendulum 1 and the top end of pendulum 2.
We generalized this to three equations:
Which we then used as our basis for our N-case pendulum program.
All in all, this was a super fun project. I never thought that pendulums could be so exciting, but being able to tie this all back into a coding project was pretty awesome!