An open API service indexing awesome lists of open source software.

https://github.com/pietras333/n-mass-points-pendulum-simulator

A scientific and visual exploration of multi‑pendulum dynamics, inspired by research on chaotic motion of coupled pendulums.
https://github.com/pietras333/n-mass-points-pendulum-simulator

langrangian mathematics pendulum-simulation physics-simulation rk4-algorithm science unity3d

Last synced: 7 months ago
JSON representation

A scientific and visual exploration of multi‑pendulum dynamics, inspired by research on chaotic motion of coupled pendulums.

Awesome Lists containing this project

README

          

# 🌀 N‑Mass Points Pendulum Simulator

A **scientific and visual exploration** of multi‑pendulum dynamics, inspired by research on chaotic motion of coupled pendulums. This simulator models pendulums with **3 or more masses**, solves their motion using rigorous physics, and provides a **real‑time visualizer** with velocity‑based trails.
image

https://github.com/user-attachments/assets/b223f54b-6794-428a-9f7e-16db154b0dfc

---

## 🔬 Research Basis

This project is grounded in scientific research and builds on key references:

- **D. Assêncio**, *“Double pendulum: Hamiltonian formulation”* ([Link](https://dassencio.org/33))
Derivation of double pendulum equations from Hamiltonian/Lagrangian mechanics.

- **J. Jiménez‑López & V.J. García‑Garrido**, *“Chaos and Regularity in the Double Pendulum with Lagrangian Descriptors”* ([arxiv](https://arxiv.org/html/2403.07000v1?utm_source=chatgpt.com))
Quantification of chaos using Lagrangian descriptors.

- **B. Yesilyurt**, *“Equations of Motion Formulation of a Pendulum Containing N-point Masses”* ([arxiv](https://arxiv.org/pdf/1910.12610?utm_source=chatgpt.com))
General formulation for **n‑mass pendulums**, providing the framework used for simulations with 3 or more masses.

Key points from these works implemented:

- Equations of motion derived from **Lagrangian / Hamiltonian mechanics**.
- **Double pendulum (n = 2)**: classical coupled nonlinear ODEs.
- **Multi-mass pendulums (n ≥ 3)**: generalized via mass matrix and coupling terms (see `PendulumSolver.cs`).
- **Runge‑Kutta 4th order (RK4)** integration with configurable sub-steps for stability and accuracy.
- Sensitivity to initial conditions and emergence of chaotic dynamics naturally appear in simulations.

---

## 🧮 Mathematics Behind It

image

- **Double pendulum (n = 2)**:

- **General n‑mass pendulum (n ≥ 3)**:

- **Integration**: RK4 with `subSteps` per frame:

- **Chaos and energy**: Following Jiménez‑López & García‑Garrido, chaos fraction depends on energy, mass ratios, and length ratios.

---

## 🎮 Features

- ✅ Supports **3 or more pendulum masses**
- ✅ Real-time visualization with **velocity-based trail colors**
- ✅ Custom shader for smooth, colorful trails
- ✅ Adjustable **rod width**, **mass radius**, **trail length**, and **velocity gradient**
- ✅ Sensitive dynamics, allowing chaos and regularity studies

---

## ⚙️ Usage

1. Open the project in **Unity**.
2. Add `PendulumSolver` and `PendulumFullRenderer` to an empty GameObject.
3. Configure mass points (`Mass`, `AttachedRodLength`, `InitialAngleDegrees`, `AngularVelocity`).
4. Adjust `subSteps` in `PendulumSolver` for numerical stability.
5. Customize visual parameters in `PendulumFullRenderer` (trail length, gradient, rod width, mass radius).
6. Press **Play** to simulate and visualize pendulum motion.

---

## 🎨 Visualization

- Trails colored by instantaneous angular velocity.
- Rods connecting masses with configurable colors and widths.
- Mass points rendered as spheres, with color indicating speed.
- Z-offsets per mass ensure distinct trails for multiple pendulums.

---

## 📚 References

- Assêncio, D., *Double pendulum: Hamiltonian formulation*, https://dassencio.org/33
- Jiménez‑López, J. & García‑Garrido, V.J., *Chaos and Regularity in the Double Pendulum with Lagrangian Descriptors*, arXiv:2403.07000
- Yesilyurt, B., *Equations of Motion Formulation of a Pendulum Containing N-point Masses*, arXiv:1910.12610