Double Pendulum Simulator

Visualizations

Node Angles

Angular Velocity

ω₁
ω₂

ω₁: 0.00 rad/s

ω₂: 0.00 rad/s

System Energy (J)

KE 0.00

PE 0.00

Etotal 0.00

Avg E 0.00

ΔE 0.00 %

Avg & StDev % (last ~1s)

Energy Detail (J)

KE₁ 0.00

KE₂ 0.00

PE₁ 0.00

PE₂ 0.00

Forces on Bob 1 (N)

Fg,x 0.00

Fg,y 0.00

Fd,x 0.00

Fd,y 0.00

FB,x 0.00

FB,y 0.00

FW,x 0.00

FW,y 0.00

Forces on Bob 2 (N)

Fg,x 0.00

Fg,y 0.00

Fd,x 0.00

Fd,y 0.00

FB,x 0.00

FB,y 0.00

FW,x 0.00

FW,y 0.00

Angular Velocity History

Energy History

Chaos History

Simulation Canvas

Controls & Parameters

Simulation Control
Updates per second for physics calculations. Higher is more accurate but slower. (e.g., 120)
Frames per second for updating the canvas visuals. (e.g., 60)
Initial State (Defaults on Reset)
Default initial angle for Bob 1. Vertical down is 0. (e.g., 120)
Default initial angle for Bob 2. Vertical down is 0. (e.g., -30)
Calculated default X position of Bob 1
Calculated default Y position of Bob 1 (relative to pivot)
Calculated default X position of Bob 2
Calculated default Y position of Bob 2 (relative to pivot)
Current angle of Bob 1. Can be set by dragging when paused.
Current angle of Bob 2. Can be set by dragging when paused.
Pendulum Parameters
Length of the first rod. (e.g., 1.0)
Length of the second rod. (e.g., 1.0)
Mass of the first bob (at end of L1). (e.g., 1.0)
Mass of the second bob (at end of L2). (e.g., 1.0)
Acceleration due to gravity. (e.g., 9.81)
Frictional drag coefficient for Bob 1 (proportional to velocity). 0 = no damping. (e.g., 0.01)
Frictional drag coefficient for Bob 2. (e.g., 0.01)
Visualization Settings
Number of points in the trail of Bob 1. (e.g., 500)
Number of points in the trail of Bob 2. (e.g., 500)
Scene Forces (Optional)
Magnitude of a constant wind force applied to both bobs. (e.g., 0.5)
Direction of the wind force (0=right, 90=up). (e.g., 0)
Electric charge of Bob 1 (for Lorentz force). (e.g., 1.0)
Electric charge of Bob 2. (e.g., -1.0)
Strength of a uniform magnetic field perpendicular to the plane (z-axis). >0 is into page (⊗), <0 is out of page (⊙). (e.g., 0.5)
Applies uniform wind force and/or Lorentz force (simplified).
Data Recording & Export
Maximum duration of simulation data to record. Large values use more memory. (e.g., 60) Est. Size: 0.0 MB
Ready to record. Press Start.

Equations Used

Coordinates:

x_1 = L_1 \sin \theta_1 \\ y_1 = L_1 \cos \theta_1 \\ x_2 = x_1 + L_2 \sin \theta_2 = L_1 \sin \theta_1 + L_2 \sin \theta_2 \\ y_2 = y_1 + L_2 \cos \theta_2 = L_1 \cos \theta_1 + L_2 \cos \theta_2

Lagrangian ( $\mathcal{L} = T - V$ ):

T = \frac{1}{2} m_1 (L_1 \dot{\theta}_1)^2 + \frac{1}{2} m_2 \left[ (L_1 \dot{\theta}_1)^2 + (L_2 \dot{\theta}_2)^2 + 2 L_1 L_2 \dot{\theta}_1 \dot{\theta}_2 \cos(\theta_1 - \theta_2) \right] \\ V = -m_1 g L_1 \cos \theta_1 - m_2 g (L_1 \cos \theta_1 + L_2 \cos \theta_2)

Equations of Motion (from Euler-Lagrange $\frac{d}{dt} \frac{\partial \mathcal{L}}{\partial \dot{\theta}_i} - \frac{\partial \mathcal{L}}{\partial \theta_i} = Q_i$ ):

\begin{pmatrix} M_{11} & M_{12} \\ M_{21} & M_{22} \end{pmatrix} \begin{pmatrix} \ddot{\theta}_1 \\ \ddot{\theta}_2 \end{pmatrix} = \begin{pmatrix} F_1 \\ F_2 \end{pmatrix} + \begin{pmatrix} Q_{1,ext} \\ Q_{2,ext} \end{pmatrix} Where $M$ is the mass matrix, $F$ contains gravitational and centrifugal/Coriolis terms, and $Q_{ext}$ are external generalized forces (damping, wind, Lorentz). \ddot{\theta}_1 = \frac{-g(2m_1+m_2)\sin\theta_1 - m_2 g \sin(\theta_1-2\theta_2) - 2\sin(\theta_1-\theta_2)m_2(L_2\dot{\theta}_2^2 + L_1\dot{\theta}_1^2\cos(\theta_1-\theta_2))}{L_1(2m_1+m_2-m_2\cos(2\theta_1-2\theta_2))} + Q'_{1} \\ \ddot{\theta}_2 = \frac{2\sin(\theta_1-\theta_2)\left(L_1\dot{\theta}_1^2(m_1+m_2) + g(m_1+m_2)\cos\theta_1 + L_2\dot{\theta}_2^2 m_2 \cos(\theta_1-\theta_2)\right)}{L_2(2m_1+m_2-m_2\cos(2\theta_1-2\theta_2))} + Q'_{2} $Q'_{i}$ represents the effect of external torques after inverting the mass matrix.

External Forces (Cartesian Components & Generalized Torques $Q_i$):

\vec{F}_{g,j} = (0, -m_j g) \\ \vec{F}_{d,j} = -d_j \vec{v}_j \\ \vec{F}_{wind} = (F_W \cos \phi_W, F_W \sin \phi_W) \\ \vec{F}_{B,j} = q_j (\vec{v}_j \times \vec{B}) = q_j (v_{j,y} B_z, -v_{j,x} B_z) \\ Q_{i,ext} = \sum_{j=1,2} (\vec{r}_j \times (\vec{F}_{d,j} + \vec{F}_{wind} + \vec{F}_{B,j}))_z

Total Energy ( $E = T + V$ ):

E = \text{Kinetic Energy (T)} + \text{Potential Energy (V)}

Numerical Integration (4th Order Runge-Kutta):

\vec{y}_{n+1} = \vec{y}_n + \frac{h}{6}(\vec{k}_1 + 2\vec{k}_2 + 2\vec{k}_3 + \vec{k}_4) \quad \text{where} \quad \vec{y} = (\theta_1, \theta_2, \dot{\theta}_1, \dot{\theta}_2)

Energy Conservation: In an ideal system with no damping ($d_1=d_2=0$) and no external forces (wind/Lorentz forces = 0), the total mechanical energy $E = T + V$ should remain constant over time. This is because gravity is a conservative force. However, numerical integration methods like RK4 introduce small computational errors at each step, which can cause the calculated energy to drift slightly over long simulations. The "Energy Variation" metric reflects these numerical fluctuations or actual energy changes if non-conservative forces are active. For the default parameters ($L_1=L_2=1$, $m_1=m_2=1$, $g=9.80665$, $\theta_1=120^\circ$, $\theta_2=-30^\circ$, $\dot{\theta}_1=\dot{\theta}_2=0$), the initial total energy is approximately $1.314$ Joules.