abdelrahman-26/double-pendulum-analysis
A Python simulation of the double pendulum system using Lagrangian mechanics to demonstrate chaotic behavior.
Double Pendulum Analysis
A Python simulation of the double pendulum system using Lagrangian mechanics to demonstrate chaotic behavior and analyze normal modes.
Overview
This repository contains a numerical investigation of the double pendulum. It explores two main regimes:
- Non-Linear (Chaotic): Solving the full Euler–Lagrange equations to visualize sensitivity to initial conditions.
- Linearized (Small Angle): Deriving the equations of motion for small angles to find normal-mode frequencies (eigenvalues) and verifying them using Fast Fourier Transforms (FFT).
Demo
Repository Structure
| File | Description |
|---|---|
notebooks/01_full_simulation.ipynb |
Derives the full non-linear EOMs using SymPy, solves them with scipy.integrate.solve_ivp, and animates the chaotic trajectory. |
notebooks/02_linearization_analysis.ipynb |
Linearizes the system around the stable equilibrium, calculates eigenvalues/eigenfrequencies, and compares analytical predictions with FFT results. |
The Physics
The system consists of two masses
Lagrangian Formulation
The Lagrangian
Linearization & Normal Modes
For small angles (
The normal-mode frequencies follow from:
Where:
-
$M$ is the mass matrix -
$K$ is the stiffness matrix from the linearized potential energy
Installation
-
Clone the repository:
git clone https://github.com/abdelrahman-26/double-pendulum-analysis.git
-
Install dependencies:
pip install numpy scipy matplotlib sympy jupyter
Usage
Launch Jupyter Notebook inside the repository folder:
jupyter notebook
Then open the notebooks in the notebooks/ directory:
-
Full simulation:
01_full_simulation.ipynb
Run all cells to see the animation of the chaotic system. -
Physics + FFT analysis:
02_linearization_analysis.ipynb
Walks through the small-angle approximation, eigenvalue calculation, and FFT analysis.
Key Libraries
- SymPy — symbolic derivation of Euler–Lagrange equations
- SciPy —
solve_ivpfor numerical integration. - NumPy — array operations, FFT
- Matplotlib — plotting and animation
License
Distributed under the MIT License. See LICENSE for details.
Acknowledgments
Derived from standard Lagrangian mechanics coursework.
Visualizations inspired by examples from the Python scientific computing community.
