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:

Read our final report for a more formal/comprehensive explanation of the process!

Download the code!

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.

We have to be able to transform between each frame of reference, so by doing some trigonometry, we find that the rotation matrices are:

and

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!

-Sophie

Neha Mohanta

What was the software that you used for simulation?

Sophie

If you’re still curious about the answer 2 years later, it was Matlab!

Brad

Would you happen to know how to solve for the equations of motion for the same n type problem using the Lagrangian Method instead?

Brad

To clarify, instead of the newtonian method you used?

Sophie

Hey Brad,

I don’t know off the top of my head what the solution will be. However, I have a couple of gut feeling directions towards a solution?

We mainly solved the problem by solving for a triple pendulum, then realizing that all other extensions to the problem to N-case would be variations of that pendulum. Page 2-3 of our final report sort of discuss this approach when we were searching for patterns to generalize. Let me know if that helps at all. I don’t think I’ve ever learned about legrangians, so it could be a fun weekend problem for me… :9

(Also the grammar on that report is terrible, we were pretty sleep deprived while writing it.)

Brad

Hi Sophie. Thanks for responding, I really appreciate it. Our problem is a little different than yours. In ours, we are assuming mass less rods, with a point mass on the ends of each one between the different segments of the pendulum. Would you be able to help me find a generalized form of the Kinetic Energy of the system, and to the extent, the Lagrangian of the system?