All Projects → narimiran → Double_pendulum

narimiran / Double_pendulum

Licence: mit
Animations of random double pendulums

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Double pendulum

Pynamical
Pynamical is a Python package for modeling and visualizing discrete nonlinear dynamical systems, chaos, and fractals.
Stars: ✭ 458 (+527.4%)
Mutual labels:  numpy, matplotlib
Notes Python
中文 Python 笔记
Stars: ✭ 6,127 (+8293.15%)
Mutual labels:  numpy, matplotlib
Mexican Government Report
Text Mining on the 2019 Mexican Government Report, covering from extracting text from a PDF file to plotting the results.
Stars: ✭ 473 (+547.95%)
Mutual labels:  numpy, matplotlib
Python Notlarim
Python notes in Turkish.
Stars: ✭ 356 (+387.67%)
Mutual labels:  numpy, matplotlib
Abu
阿布量化交易系统(股票,期权,期货,比特币,机器学习) 基于python的开源量化交易,量化投资架构
Stars: ✭ 8,589 (+11665.75%)
Mutual labels:  numpy, matplotlib
Stats Maths With Python
General statistics, mathematical programming, and numerical/scientific computing scripts and notebooks in Python
Stars: ✭ 381 (+421.92%)
Mutual labels:  numpy, matplotlib
Youtube Report
📊 Generate a personal YouTube report from your Google Takeout data
Stars: ✭ 607 (+731.51%)
Mutual labels:  numpy, matplotlib
Ai Learn
人工智能学习路线图,整理近200个实战案例与项目,免费提供配套教材,零基础入门,就业实战!包括:Python,数学,机器学习,数据分析,深度学习,计算机视觉,自然语言处理,PyTorch tensorflow machine-learning,deep-learning data-analysis data-mining mathematics data-science artificial-intelligence python tensorflow tensorflow2 caffe keras pytorch algorithm numpy pandas matplotlib seaborn nlp cv等热门领域
Stars: ✭ 4,387 (+5909.59%)
Mutual labels:  numpy, matplotlib
Mlcourse.ai
Open Machine Learning Course
Stars: ✭ 7,963 (+10808.22%)
Mutual labels:  numpy, matplotlib
Machine Learning Alpine
Alpine Container for Machine Learning
Stars: ✭ 30 (-58.9%)
Mutual labels:  numpy, matplotlib
Thesemicolon
This repository contains Ipython notebooks and datasets for the data analytics youtube tutorials on The Semicolon.
Stars: ✭ 345 (+372.6%)
Mutual labels:  numpy, matplotlib
Accupy
Accurate sums and dot products for Python.
Stars: ✭ 65 (-10.96%)
Mutual labels:  numpy, numerical-methods
Python for data analysis 2nd chinese version
《利用Python进行数据分析·第2版》
Stars: ✭ 4,049 (+5446.58%)
Mutual labels:  numpy, matplotlib
Data Science Ipython Notebooks
Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, AWS, and various command lines.
Stars: ✭ 22,048 (+30102.74%)
Mutual labels:  numpy, matplotlib
Finger Detection And Tracking
Finger Detection and Tracking using OpenCV and Python
Stars: ✭ 317 (+334.25%)
Mutual labels:  numpy, matplotlib
Baby Names Analysis
Data ETL & Analysis on the dataset 'Baby Names from Social Security Card Applications - National Data'.
Stars: ✭ 557 (+663.01%)
Mutual labels:  numpy, matplotlib
Quantum-Computing-Collection-Of-Resources
A Well Maintained Repository On Quantum Computing Resources [Code+Theory] Updated Regularly During My Time At IBM, Qubit x Qubit And The Coding School's Introduction To Quantum Computing Course '21
Stars: ✭ 183 (+150.68%)
Mutual labels:  numpy, matplotlib
python3-docker-devenv
Docker Start Guide with Python Development Environment
Stars: ✭ 13 (-82.19%)
Mutual labels:  numpy, matplotlib
Pythondatasciencehandbook
The book was written and tested with Python 3.5, though other Python versions (including Python 2.7) should work in nearly all cases.
Stars: ✭ 31,995 (+43728.77%)
Mutual labels:  numpy, matplotlib
Machine Learning
notebooks with example for machine learning examples
Stars: ✭ 45 (-38.36%)
Mutual labels:  numpy, matplotlib

Double pendulum

The code behind @pendulum_bot Twitter bot which posts animations of a double pendulum released from a random position to swing for 30 seconds.

 

Basic usage

To create an animation of a random double pendulum:

>>> from simulation import create_random_example, simulate
>>> from animations import single_animation
>>> rand_ex = create_random_example()
>>> results = simulate(rand_ex)
>>> single_animation(results, rand_ex)

The animation is saved as .mp4 video in animations subdirectory.


To create an animation and post it on Twitter, a valid API key is needed, and should be stored in api_key.txt.

>>> from tweet_it import new_tweet
>>> new_tweet() # creates a new animation of random double pendulum
# or
>>> new_tweet('existing_file', 'My custom Twitter status')

To create double pendulum with the exact values for initial conditions:

>>> from pendulum import Pendulum, DoublePendulum
>>> p1 = Pendulum(m=2.7, x=2.5, y=3.7, u=0, v=0)
>>> p2 = Pendulum(m=3.1, x=0.2, y=6.3, u=0, v=0)
>>> dp = DoublePendulum(p1, p2)

To create multiple pendulums with slight perturbations of initial conditions to observe chaotic behaviour:

>>> from simulation import create_random_example, create_perturbations, simulate_multiple_examples
>>> from animations import multi_animation
>>> rand_ex = create_random_example()
>>> perturbed = create_perturbations(10, rand_ex, amount=1e-5)
>>> results = simulate_multiple_examples(perturbed)
>>> multi_animation(results, rand_ex)

 

Installation

git clone https://github.com/narimiran/double_pendulum.git
cd double_pendulum

Dependencies

  • Python 3
  • numpy (running simulations)
  • matplotlib (creating animations)
  • ffmpeg or avconv/libavtools (saving videos)
  • twython (posting Twitter updates)

 

FAQ

Q: Why do you use Cartesian coordinates? I prefer polar coordinates.

A: The initial task I was given was to implement double pendulum as DAE system in Cartesian coordinates. The idea for animations and Twitter bot came later, and Cartesian coordinates remained.

Q: Which Runge-Kutta methods can I use?

A: Any of these:

  • Forward Euler (Euler)
  • Explicit midpoint (ExplicitMidpoint)
  • Ralston's method (Ralston)
  • Kutta's 3rd order method (Kutta3)
  • the Runge-Kutta 4th order method (RK4)
  • Runge-Kutta-Fehlberg (RKF)
  • Cash-Karp (Cash-Karp)
  • Dormand-Prince method (DOPRI5)

Q: Why can't I use implicit Runge-Kutta methods?

A: Implicit methods require different solving method (solving a system of non-linear equations). This is not (yet) implemented.

Q: Is there any damping/friction?

There is no damping and no friction. The only force acting on the system is gravity.

Q: Couldn't all/some of this be done simpler?

A: Probably.

 

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].