Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 3.75 KB

File metadata and controls

57 lines (37 loc) · 3.75 KB

Double-Pendulum-Motion-Animation

alt text alt text alt text alt text

alt text Animation of the chaotic motion a double-pendulum using Julia and Python. The julia version is implemented in a Jupyter notebook environment whereas the python version is a conventional script. Double pendulums of arbitrary lengths, masses, initial positions, and the initial velocities can be simulated using this code. Both versions of the code allow the animation to be saved in either mp4 or gif format.

Julia version alt text

The code can save the animation as a gif file. It can also playback the video in Jupyter notebook environment. The animation is recorded at equal time steps to preserve relative velocity of the pendulums in the video.

Python version alt text

The animation is done using FuncAnimation() of matplotlib. The code can save the animation as a mp4 file. The python script was tested in spyder environment. Plotting in external window should be enabled to view the animation.

Package requirements for Julia version

  1. Plots
  2. Differential Equations
  3. Direckx

Package requirements for Python version

  1. numpy
  2. scipy.integrate (odeint)
  3. pylab, matplotlib (animation)
  4. imagemagick (to save animation as a gif file)

Use

The mass and length of the pendulums, gravitational acceleration constant, the initial conditions and the simulaiton duration are defined at the beginning of the code. Different cases can be simulated by changing these parameters.

Sample output

Double pendulum system animation. The left animation is from the julia code with m1 = m2 = 1kg, L1 = L2 = 1m, initial conditions: θ1 = 5π/8, θ2 = 5π/9, ω1 = 0, ω2 = 0. The right animation is from the python code with m1 = 2kg, m2 = 1kg, L1 =1.4m, L2 = 1m, initial conditions: θ1 = 5π/11, θ2 = 5π/9, ω1 = 0, ω2 = 0.

Here, θ1 and θ2 are the initial angular positions, and, ω1 and ω2 are initial angular velocities in SI units.

alt text alt text

References

  1. http://sophia.dtp.fmph.uniba.sk/~kovacik/doublePendulum.pdf
  2. http://www.phys.lsu.edu/faculty/gonzalez/Teaching/Phys7221/DoublePendulum.pdf
  3. http://louistiao.me/posts/notebooks/save-matplotlib-animations-as-gifs/