Skip to content

A Python script demonstrating how a double-pendulum operates. Includes explanations and mathematical derivations.

License

Notifications You must be signed in to change notification settings

PolybitRockzz/double-pendulum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Double Pendulum Simulation

A Python script that simulates the motion of a double pendulum using physics.

Python Matplotlib SciPy

Overview

This script allows you to visualize the complex motion of a double pendulum system. By defining the initial conditions of the system, the script calculates and plots the motion of the pendulum.

Recorded GIF

Installation

To run this script, you need to have Python 3 installed. You can download Python 3 from the official website: https://www.python.org/downloads/

You also need to install the following packages:

  • Matplotlib
  • Scipy

You can install these packages using pip:

pip install matplotlib scipy

Finally, run the double_pendulum.py script.

Usage

The simulation starts with a double pendulum in a static position. The first mass is held in place while the second mass is released. The simulation then shows how the double pendulum moves over time based on the laws of physics.

Explanation

The double_pendulum.py script contains the Pendulum and Animator classes. The Pendulum class contains methods for calculating the position and movement of the double pendulum using polar coordinates. The Animator class contains methods for animating the movement of the double pendulum on a 2D plane.

Check out this website for reading the physics explanation for the double pendulum: https://physicspython.wordpress.com/2019/02/11/double-pendulum-pt-1/

Example

Here is an example of how to use the script:

import scipy as sp
from double_pendulum import Pendulum, Animator

pendulum = Pendulum(theta1=sp.pi, theta2=sp.pi - 0.01, dt=0.01)
animator = Animator(pendulum=pendulum, draw_trace=True)
animator.animate()

This will create a double pendulum with initial angles of π and π-0.01 radians and a time step of 0.01 seconds. The animation will include the trace of the second mass.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A Python script demonstrating how a double-pendulum operates. Includes explanations and mathematical derivations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages