Git Product home page Git Product logo

zaman13 / double-pendulum-motion-animation Goto Github PK

View Code? Open in Web Editor NEW
36.0 1.0 16.0 1.7 MB

Animation of the motion a double-pendulum. Both Julia and Python versions of the code are given.

License: MIT License

Jupyter Notebook 57.16% Python 42.84%
animation julia python pendulum double-pendulum chaotic-dynamical-systems chaotic-motion differential-equations computational-physics numerical-methods

double-pendulum-motion-animation's Introduction

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/

double-pendulum-motion-animation's People

Contributors

zaman13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.