## Introduction

The first part of my Double Pendulum project introduced an application which shows the motion of a double pendulum in *position space* depending on different initial parameters. The long term behaviour was visualized in a Poincaré map.

For this second part I have added 3D views to visualize the motion also in *phase space* and the ability to load Poincaré maps for different energies.

## Background

As being said in the first article, the double pendulum has four degrees of freedom: the angles and angular velocities of the two pendulum bobs (Θ1, Θ2, ω1 and ω2). To solve the equations of motion, it is more convenient to switch to generalized coordinates, which are in this case angles and angular momentums (Q1, Q2, L1 and L2).

When the pendulum moves, it travels along a path in the four dimensional phase space made up of Q1, Q2, L1 and L2: the phase space trajectory. If the motion is periodic, the trajectory is a closed curve, because the motion is repeated at some point in time. For quasiperiodic motions the trajectory is not closed anymore but forms regular structures and for chaotic motions the trajectory is completely irregular like a tangle of spaghetti.

Due to our limited 3D nature, we cannot look at the motion of the pendulum in a 4D space. But we can do the same trick that architects are using when they create 2D drawings of the 3D buildings they are planning: instead of a single 3D view they create several 2D views, which show the building from the top, from the front and from a side. In each of these views, the third dimension is simply ignored.

In our case we can create four 3D views to show the 4D trajectory from different *sides*. The possible sections are: (Q1, Q2, L1), (Q1, Q2, L2), (L1, L2, Q1) and (L1, L2, Q2).

## Using the code

If you unzip the demo project, there will be a *Data* folder, which contains the Poincaré points for thousands of simulations at different energies. For each energy there is a separate subfolder. If you build the code on your own, you'll have to move that folder to the *bin* directory of the VS solution.

## Using the application

On startup the application reads the subdirectories of the *Data* folder and shows them in a list at the right side of the main window. By selecting one of them, the Poincaré points of all simulations to the corresponding energy are loaded and the Poincaré map is recreated.

You can now start a new simulation by doing a right mouse button click at some point in the map. Stop the simulation by right clicking again or using the Start/Stop button in the 2D view.

If you want to zoom into the map, just drag the mouse to the bottom right with the left button pressed. Dragging to the top left will zoom out. Dragging a short distance will zoom one level back, whereas a long distance will show the complete map again.

The 3D view shows the pendulum itself or one the four phase space sections. Switch between them with the buttons at the top. The trajectories in phase space are recreated each time you switch the view. So the simulation needs to be running to see something here.

## Example Trajectories

At very low energy the motion of the pendulum is dominated by two periodic states: an inphase and an antiphase movement. Every movement which is not strictly periodic belongs to one of these states and is quasiperiodic. This is the Poincaré map for the energy of 0.1:

The white spot in the upper region represents the inphase movement, whereas the yellow one in the lower region represents the antiphase movement. If you have read my first article about the pendulum, you might recall that the phase space trajectory of a simple pendulum at low energy is simply a circle. Therefore it isn't surprising that the double pendulum is showing something similar simple for the inphase motion:

And also the trajectory for the antiphase motion is very simple:

So what about quasiperiodic motions? If we start a simulation near the inphase resonance point and let the pendulum move for a few oscillations, the trajectory looks like this:

As you might have thought, the trajectory is not getting repeated, but it will also not move far away from the periodic path, thus forming a nice pattern around that periodic curve. If we now move the initial point further away from the inphase resonance, let's say somewhere inbetween the inphase and antiphase attractors, the pattern expands to this beautiful ring:

If the energy gets higher, new periodic motions appear, as you can see in the this Poincaré map for the energy of 0.3:

Starting a simulation at the center of the magenta attractors to the left or to the right will lead to this trajectory:

The path is still closed but more complex than it was for the single resonance points before. In general there is a correlation between the number of resonance points in the Poincaré diagram and the complexity of the trajectories. The next picture shows the trajectory of the triple resonance at the energy of 2.2:

And here is a periodic motion with 5 points in the Poincaré map at the energy of 1:

You surely agree that these trajectories for periodic and quasiperiodic movements look great and it really makes fun to look at them in real time for different energies. But for sure one picture is missing. Chaos! This is how it looks like at the energy of 3.8:

## That's it!

This second part of the DoublePendulum article added Poincaré map data for more than 5000 simulations and the ability to look at the movement of the pendulum in sections of the phase space. Hope you enjoy it!

## Acknowledgement

For the 3D parts of the application I am using my own small WFTools3D library which I needed to enhance by a new model for the trajectories. I had no idea how to implement such a tube, but eventually found the Helix Toolkit project, which has a cool `MeshBuilder`

class (among other cool stuff), which does the job. To keep my own library further on small, I just took the relevant lines of code and adapted them for my purpose.

## History

26-May-2016: Initial upload