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.
- Host: GitHub
- URL: https://github.com/pietras333/n-mass-points-pendulum-simulator
- Owner: pietras333
- License: mit
- Created: 2025-10-30T16:44:44.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-10-30T17:05:13.000Z (7 months ago)
- Last Synced: 2025-10-30T18:34:25.270Z (7 months ago)
- Topics: langrangian, mathematics, pendulum-simulation, physics-simulation, rk4-algorithm, science, unity3d
- Language: C#
- Homepage:
- Size: 83 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.

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

- **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