Skip to content

Fully customizable/interactable pendulum simulation with 3 PDE methods and an ability to use none of them. Comes with a GUI; Is easily generalizable. PDE-s derived from MatLab.

Notifications You must be signed in to change notification settings

A1K28/multipendulum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Pendulum Project

This build supports both simple and complex/compound pendulum systems (assuming no friction at the pivot or air resistance). 5 formulas of equations of motion for the multi-simple pendulum are derived via MatLab. This project allows for a fully customizable/interactive pendulum simulation with 3 methods for PDE-s and an ability to use none of them, comes with a GUI, and is easily generalizable. This project is to simply show that it is possible to create a simulation of N number of pendulums at once given the computational resources.

Demo

Demonstration of the project:

Accession

To run this project, simply clone the repository, install the dependency and run the script:

pip install pygame
python py_pend_proj.py

Methods for Solving Partial Differential Equations (PDE-s)

The script currently contains 3 types of methods for solving PDE-s

  1. Euler's Method
  2. Runge-Kutta Method (II-order, I-derivative)
  3. Runge-Kutta Method (IV-order, I-derivative)

It is important to note that different methods of solving equations greatly affect the overall motion of the pendula system. Currently (at least in this project), the RK-IV-I method can be used for closest approximation - keeping in mind that the RK-IV-I is the slowest of the 4.

Runge-kutta-svg-1

The 4-th method simply implies not using any of the aforementioned methods to solve for velocity. Instead, we directly solve with respect to acceleration and change velocity FPS times per second, where FPS is a constant. Moreover, by the equations of motion it is implied that each pendulum has its own equation for the second order derivative of the angle with respect to time. since the length of the pendulum is constant, we can use polar coordinates and portray its position by a single variable - angle (fi), instead of 2 variables (x,y) on the cartesian plane. giving a single simple pendulum only 1 degree of freedom. which is great news.

The second order derivative of the angle with respect to time is acceleration. However our functions (Eqs of motion) do not have time as a variable, thus we let: dw0/dt=C ==> w0=C*t.

Final Notes

  1. Keep the gui OFF after messing around with the variables to put less pressure on the CPU and also to be able to interact with the system via mouse. That last feauture is simply there to avoid making easy mistakes.
  2. This sim is not meant to be used for a physics inspiration in a video game in any way whatsoever. As far as video games go, for that purpose, we can simplify things incredibly by using verlet integration (which is faster and easier to implement). E.g. we can simulate hundreds of pendula at once without having to worry for computational resources, although inaccurate.
  3. If you are keen on a Complex/Compound pendulum, you might find this video interesting.

I welcome any pull requests. contact: aleksandrekhorbaladze@gmail.com

About

Fully customizable/interactable pendulum simulation with 3 PDE methods and an ability to use none of them. Comes with a GUI; Is easily generalizable. PDE-s derived from MatLab.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published