logo

Double Pendulum as a Dynamical System 📂Dynamics

Double Pendulum as a Dynamical System

Model

alt text

In a plane, a pendulum with another pendulum attached to its end is called a double pendulum1.

ϕ¨=[1μcos2(ψϕ)]1[μg1sinψcos(ψϕ)+μϕ˙2sin(ψϕ)cos(ψϕ)g1sinϕ+μλψ˙sin(ψϕ)]ψ¨=[1μcos2(ψϕ)]1[g2sinϕcos(ψϕ)μψ˙2sin(ψϕ)cos(ψϕ)g2sinψλϕ˙sin(ψϕ)] \begin{align*} \ddot{\phi} =& \left[ 1 - \mu \cos^{2} \left( \psi - \phi \right) \right]^{-1} \left[ \mu g_{1} \sin \psi \cos \left( \psi - \phi \right) \right. \\ & \left. + \mu \dot{\phi}^{2} \sin \left( \psi - \phi \right) \cos \left( \psi - \phi \right) - g_{1} \sin \phi + {\frac{ \mu }{ \lambda }} \dot{\psi} \sin \left( \psi - \phi \right) \right] \\ \ddot{\psi} =& \left[ 1 - \mu \cos^{2} \left( \psi - \phi \right) \right]^{-1} \left[ g_{2} \sin \phi \cos \left( \psi - \phi \right) \right. \\ & \left. - \mu \dot{\psi}^{2} \sin \left( \psi - \phi \right) \cos \left( \psi - \phi \right) - g_{2} \sin \psi - \lambda \dot{\phi} \sin \left( \psi - \phi \right) \right] \end{align*}

Variables

  • ϕ(t)\phi (t): The angle between the origin and the first pendulum at tt time.
  • ψ(t)\psi (t): The angle between the first and second pendulums at tt time.

Parameters

  • g9.80665g \approx 9.80665: The gravitational acceleration.
  • l1l_{1}: The distance between the origin and the first pendulum.
  • l2l_{2}: The distance between the first and second pendulums.
  • m1m_{1}: The mass of the first pendulum.
  • m2m_{2}: The mass of the second pendulum.

λ\lambda, g1g_{1}, g2g_{2}, and μ\mu are defined as follows: λ=l1/l2g1=g/l1g2=g/l2μ=m2/M \begin{align*} \lambda =& l_{1} / l_{2} \\ g_{1} =& g / l_{1} \\ g_{2} =& g / l_{2} \\ \mu =& m_{2} / M \end{align*}

Let the position of the first pendulum be (x1,y1)\left( x_{1}, y_{1} \right) and the position of the second pendulum be (x1,y1)\left( x_{1}, y_{1} \right), then the following holds true: x1=+l1sinϕy1=l1cosϕx2=+l1sinϕ+l2sinψy2=l1cosϕl2cosψ \begin{align*} x_{1} =& + l_{1} \sin \phi \\ y_{1} =& - l_{1} \cos \phi \\ x_{2} =& + l_{1} \sin \phi + l_{2} \sin \psi \\ y_{2} =& - l_{1} \cos \phi - l_{2} \cos \psi \end{align*} Through this equation, the position of the pendulum can be accurately calculated from the angles.

Explanation

Chaos

Some of the fundamental systems in dynamics that demonstrate chaos include the logistic map for systems defined by maps and the Lorenz attractor for dynamical systems defined by differential equations. However, these systems require considerable time to understand their intuitive motivation. In contrast, the double pendulum inherently conveys why it is chaotic without much explanation.

Code

Trajectory

The following Julia code solves and visualizes the double pendulum equations using RK4.

using Plots, DataFrames

h = 1e-3
function RK4(f, y)
    V1 = f(y)
    V2 = f(y + h*V1/2)
    V3 = f(y + h*V2/2)
    V4 = f(y + h*V3)
    return y + h/6*(V1 + 2V2 + 2V3 + V4)
end

g = 9.80665
l1 = 2
l2 = 1
m1 = 1
m2 = 1
λ = l1 / l2
μ = m2 / (m1 + m2)
g1 = g / l1
g2 = g / l2
function f(pppp)
    ϕ, ψ, Φ, Ψ = pppp
    ϕ̇ = Φ
    ψ̇ = Ψ
    Φ̇ = (μ*g1*sin(ψ)*cos(ψ-ϕ) + μ*(Φ^2)*sin(ψ-ϕ)*cos(ψ-ϕ) - g1*sin(ϕ) + (μ/λ)*(Ψ^2)*sin(ψ-ϕ)) / (1-μ*(cos(ψ-ϕ)^2))
    Ψ̇ = (g2*sin(ϕ)*cos(ψ-ϕ) - μ*(Ψ^2)*sin(ψ-ϕ)*cos(ψ-ϕ) - g2*sin(ψ) - λ*(Φ^2)*sin(ψ-ϕ)) / (1-μ*(cos(ψ-ϕ)^2))
    return [ϕ̇ , ψ̇ , Φ̇ , Ψ̇ ]
end

x_ = [[1.0,1,2,2]]
for t in 0:h:50
    push!(x_, RK4(f, x_[end]))
end
_x_ = stack(x_, dims = 1)
ϕ = _x_[:, 1]
ψ = _x_[:, 2]

x1 = +l1*sin.(ϕ)
y1 = -l1*cos.(ϕ)
x2 = +l1*sin.(ϕ) + l2*sin.(ψ)
y2 = -l1*cos.(ϕ) - l2*cos.(ψ)

df = DataFrame(; ϕ, ψ, x1, x2, y1, y2)

p0 = plot(size = [600, 600], xlims = [-3, 3], ylims = [-4, 2], legend = :none)
@time a1 = @animate for k = 1:20:nrow(df)
    p1 = plot(p0, df.x2[1:10:k], df.y2[1:10:k], color = :black, alpha = (1:10:k)./2k)
    p2 = plot(p1, [0, df.x1[k]], [0, df.y1[k]], lw = 2)
    p3 = plot(p2, [df.x1[k], df.x2[k]], [df.y1[k], df.y2[k]], lw = 2)
end
mp4(a1, "double_pendulum.mp4", fps = 60)

  1. Korsch. (2008). Chaos: A Program Collection for the PC: p91~92. ↩︎