Click here to Skip to main content
15,867,686 members
Articles / Desktop Programming / WPF

DoublePendulum Part II: The Phase Space Trajectories of a Double Pendulum

Rate me:
Please Sign up or sign in to vote.
5.00/5 (10 votes)
26 May 2016GPL35 min read 23.4K   420   11   9
A WPF 3D simulation to visualize the phase space trajectories of a double pendulum

Image 1

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:

Image 2

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:

Image 3

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

Image 4

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:

Image 5

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:

Image 6

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

Image 7

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

Image 8

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:

Image 9

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

Image 10

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:

Image 11

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

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
Germany Germany
I started programming in Basic, Pascal, Fortran and C in the late 1980s during my last semesters at the University of Bonn, Germany, where I studied Physics. As a professional software engineer I moved on to C++ and C# in the field of scientific data acquisition, data analysis and - my favourite - data visualization.

From the very start of my life as developer I have been a fan of graphics, especially 3D graphics. I have been working with OpenGL, XNA and WPF 3D. Planning to start with SharpDX in the near future.

Besides programming I love making music (guitar and violin), doing sports (rock climbing and volleyball) and spending time with my beloved family.

Comments and Discussions

 
GeneralMy vote of 5 Pin
sbarnes14-Jan-21 3:00
sbarnes14-Jan-21 3:00 
GeneralMy vote of 5 Pin
Degryse Kris3-Jun-16 3:21
Degryse Kris3-Jun-16 3:21 
PraiseAwesome Pin
David197630-May-16 12:16
David197630-May-16 12:16 
Imho, one of the best articles on wpf, simulation and math\physics
GeneralRe: Awesome Pin
Wolfgang Foerster2-Jun-16 20:58
professionalWolfgang Foerster2-Jun-16 20:58 
QuestionDouble pendulum Pin
jhog30-May-16 6:13
jhog30-May-16 6:13 
AnswerRe: Double pendulum Pin
Wolfgang Foerster2-Jun-16 21:21
professionalWolfgang Foerster2-Jun-16 21:21 
GeneralRe: mp4 upload Pin
jhog3-Jun-16 8:51
jhog3-Jun-16 8:51 
GeneralRe: mp4 upload Pin
Wolfgang Foerster3-Jun-16 10:50
professionalWolfgang Foerster3-Jun-16 10:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.