Simulates a multi-body-pendulum
Project description
Multi body pendulum
Simulation software for multi-body pendulums using Runge-Kutta 4, and with vizualization of the pendulum:
and the energy:
My notes/derivation of the governing system of equations for this system can be found here.
Installation
pip install multibodypendulum
Quick start
A quick usecase to simulate a 5 pendulum system could look like this
import multibodypendulum as mbp
n = 5
dt = 0.001
g = 9.82
model = mbp.MultiBodyPendulum(n, dt,g=g)
theta0 = 0.5*math.pi*torch.ones(n)
dtheta0 = 0.0*torch.ones(n)
nsteps = 100
times, thetas, dthetas = model.simulate(nsteps,theta0,dtheta0)
model.plot_energy()
model.animate_pendulum()
Limitations
The code has some limitations:
- The simulation assumes pendulums of mass 1 kg, and length between pendulums of 1 m. These assumptions significantly speeds up the simulation and was all I needed for my usecase.
Contribution
- The simulation uses pytorch, but could easily be ported to numpy, which would make it easier to use for a lot of people. I haven't done this since I primarily use pytorch so it doesn't matter to me, but if others need it, it could be a nice contribution project.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file multibodypendulum-0.2.4.tar.gz
.
File metadata
- Download URL: multibodypendulum-0.2.4.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.13 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1908559d952d6b21985ee3fe5b3393947748304f9533a78d068e6dabf583a6f |
|
MD5 | 1f62daf5c5ed0de1200bc2ebeb410509 |
|
BLAKE2b-256 | 60c59c284d7946355a390786fac4cc8091c93181a1f4f2c350f4319af409a028 |
File details
Details for the file multibodypendulum-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: multibodypendulum-0.2.4-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.13 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b156ea828affdc0c43e8828c7be8f55331795c1251a5b4443349da2337f109fc |
|
MD5 | 64e1cdc56d616350eacf4e876167157b |
|
BLAKE2b-256 | 06cdcdf187afb9ec8f1494f06b22fcdee537aefc55d7715b931639b26f4197f2 |