This project explores the famously chaotic dynamics of a double pendulum system using a PyTorch ResNet to predict its motion.
The double pendulum consists of two pendulums, with one attached to the end of the other. The state of the system is fully described by 8 parameters: the masses (
Below is a schematic representation of the system taken from Wikipedia:
-
double_pendulum.py: Contains the highly accuratescipy.integrate.solve_ivp(DOP853) numerical solver to generate true physics trajectories and real-time animations of the chaotic motion. -
train_dynamics.py: The data generation and PyTorch training pipeline. We generate 100,000 continuous transitions and train a Deep Residual Network (ResNet) to predict the$\delta$ (change) in state for an infinitesimal timestep$dt$ . -
evaluate_dynamics.py: Evaluates the trained model against the physics solver using a completely unseen starting condition, generating a continuous autoregressive visual rollout to see exactly when the AI succumbs to the butterfly effect. -
architecture_diagram.md: A Mermaid graph breaking down the flow of tensors through the ResNet architecture.
-
Feature Normalization: Uses Standard Scalers to convert all
$(m_1, m_2, l_1, l_2, \theta_1, \theta_2, \omega_1, \omega_2)$ inputs into normalized zero-mean distributions. - Residual Blocks: Utilizes 3 concatenated residual blocks with Layer Normalization to smoothly learn complex topological mappings.
-
Delta-Prediction: Instead of predicting the absolute next state, the model correctly predicts the residual vector
$x_{t+dt} - x_t$ , drastically improving accuracy per timestep integration.