HomeCVSimulations

Pendulum simulation

θ0r\theta_{0r}57°
θ0b\theta_{0b}11°
θ0g\theta_{0g}6°

How does it work?

In this model, we neglect the effect of air friction, so the pendulum's mass is only submitted to two forces: its weight, and the tension of the cord.

If we call θ\theta the angle between the pendulum and the vertical axis, it can be shown that the differential equation which governs the motion of a pendulum is

d2θdt2=glsin(θ)\frac{d^2 \theta}{dt^2} = - \frac{g}{l} \sin(\theta)

Hence, to make this simulation, at each step we compute:

  • θ(t)=glsin(θ(t))\theta''(t) = - \frac{g}{l} \sin (\theta(t))
  • θ(t+dt)θ(t)+dt×θ(t)\theta'(t+dt) \approx \theta'(t) + dt \times \theta''(t)
  • θ(t+dt)θ(t)+dt×θ(t+dt)\theta(t+dt) \approx \theta(t) + dt \times \theta'(t+dt)

Small angles case

When θ\theta is small, we can make the approximation d2θdt2glθ\frac{d^2\theta}{dt^2} \approx - \frac{g}{l} \theta

If we assume that the pendulum is released with zero angular velocity, the solution of this approximation is θ(t)=θ0cos(glt)\theta(t) = \theta_0 \cos (\sqrt{ \frac{g}{l} } t)

More generally, in this approximation the oscillation period is T=2πlgT = 2 \pi \sqrt{ \frac{l}{g}} : it does not depend on θ0\theta_0

You can see this here by launching the simulation with two different small angles : these two pendulums will swing in sync for a long time.