Simple Pendulum Simulator

JJ Ben-Joseph headshot JJ Ben-Joseph

KE
PE

Enter parameters and press Play.

Isochron Keeper Mini‑Game

1. Real‑World Phenomenon

The swing of a small weight suspended from a string has fascinated scientists for centuries. Galileo reportedly timed a chandelier's swings with his pulse, noticing the period stayed constant despite the amplitude shrinking. This observation foreshadowed the development of precise pendulum clocks that regulated timekeeping for hundreds of years. A simple pendulum consists of a point mass m attached to a massless rod or string of length L, free to swing under gravity. In practice the bob has finite size and the string adds mass, but the idealized model captures the essential physics when the amplitude is modest. The motion arises from the interplay between gravitational torque seeking to restore the bob to vertical and inertial effects that carry it through the equilibrium point. As the bob rises, gravitational potential energy increases while kinetic energy dwindles, only to reverse as it descends. The oscillation continues until friction or air resistance dissipates energy. Pendula appear in metronomes, seismometers, playground swings, and even in the Foucault experiment that demonstrates Earth's rotation. Understanding their dynamics illustrates broader principles of harmonic motion, energy conservation, and damping.

2. Variables and Assumptions

The simulator treats the pendulum as a rigid rod of length L with a point mass m at its end, oscillating in a vertical plane under uniform gravitational field g. The angular displacement from vertical is θ (positive clockwise). We allow an initial angle θ and angular velocity zero. Linear viscous damping proportional to angular velocity is included with coefficient γ (units 1s). Air drag and pivot friction are often approximately proportional to speed for small velocities, justifying this term. The string is assumed massless and inextensible; motions remain planar; g is constant. Energies derive from potential U=mgL1-cosθ and kinetic T=12mL2θ̇2. All quantities use SI units: meters, kilograms, seconds, and radians internally (degrees accepted for input).

3. Governing Equations

Applying torque balance about the pivot yields Iθ̈+γθ̇+mgLsinθ=0 where the moment of inertia for a point mass is I=mL2. Dividing by I gives the familiar nonlinear equation θ̈+γθ̇+gLsinθ=0. For small angles where sinθθ, the solution reduces to simple harmonic motion with period T=2πLg. However, when the amplitude exceeds about 15°, the linear approximation fails and the true period lengthens. Damping introduces exponential decay of amplitude, transforming pure sinusoidal motion into spiraling trajectories in phase space.

4. Numerical Scheme

To display realistic motion for any amplitude and damping, the simulator integrates the full nonlinear equation using a fourth‑order Runge–Kutta (RK4) scheme. Define the state vector (θ,ω), where ω=θ̇. The derivatives are dt=ω and dt=-γω-gLsinθ. Given time step Δt, the RK4 update computes intermediate slopes k_1 through k_4 and advances both θ and ω. RK4 offers excellent accuracy for smooth systems and preserves energy better than explicit Euler. Nevertheless, a finite step introduces numerical drift, especially for very small damping. The interface clamps Δt between 0.0005 and 0.05 s. Smaller values increase computational load but maintain fidelity; larger values may overshoot, causing energy to grow or decay artificially. The animation's frame loop accumulates simulated time separately from wall clock time, ensuring consistent physics even if the browser stutters. Energy at each step derives from the formulas above, permitting an overlay of kinetic and potential partitions.

5. Worked Example

Consider a 1 m pendulum with a 1 kg bob released from 20° in Earth's gravity without damping. The analytic small‑angle period would be 2π19.812.01 s. Running the simulator with γ=0 and Δt=0.01 s shows a full period of about 2.07 s, slightly longer because 20° is beyond the small‑angle regime. The energy bars swap as the bob moves: at the lowest point potential energy nearly vanishes while kinetic energy peaks at 0.38 J; at the extremes kinetic energy vanishes and potential reaches the same maximum, confirming energy conservation. Introducing damping γ=0.1 causes the amplitude to decay; after 20 s the bob barely moves. Exporting the CSV yields columns of time, angle, angular velocity, and energies. Plotting the energy sum reveals a tiny drift under 0.1% over 100 s, validating the numerical scheme.

6. Comparison Table

The table compares the baseline example with two variations. Each row lists the period measured from simulation and the total mechanical energy at the start.

L (m) θ₀ (deg) γ (1/s) Simulated Period (s) Initial Energy (J)
1.0 20 0 2.07 0.38
1.0 45 0 2.34 0.96
0.5 20 0.05 1.44 0.19

Increasing the amplitude to 45° lengthens the period by over 10%, while halving the length and adding slight damping shortens the period dramatically and reduces stored energy. These comparisons highlight how length and amplitude shape pendulum behavior beyond textbook approximations.

7. How to Read the Animation

The canvas depicts the pivot at the top center with a thin rod and orange bob. As time advances, the bob swings according to the integrated angle. The bar chart beneath uses blue stripes for kinetic energy and orange stripes for potential energy, relying on patterns rather than color alone. The summary below the bars states the current time, angle, and energies, and the hidden text summary mirrors these numbers for screen readers. Keyboard users can focus the canvas and press the space bar to toggle play and pause. Tooltips on each input display units to reinforce dimensional consistency. The CSV button downloads time‑stamped samples, enabling external plotting or error analysis.

8. Limitations

The model assumes a point mass and ignores string mass, air drag proportional to higher powers of velocity, and pivot friction that may be non‑linear. Large amplitudes approaching 180° would require careful treatment of the string going slack, an effect excluded here. Numerical integration, while robust, introduces small energy errors that grow over long simulations, especially with coarse time steps or zero damping. The energy bars consider only translational motion; rotational kinetic energy of extended bobs would slightly modify formulas. Additionally, the damping term assumes velocity-proportional drag, whereas turbulent air resistance scales with velocity squared.

9. Possible Extensions

Future refinements could include a driving torque to explore resonance and chaos, a phase‑space plot overlay showing θ versus ω, and unit toggles for inches or degrees Fahrenheit for outreach to broader audiences. Coupling two pendula via a spring would demonstrate mode splitting. Incorporating a constraint for a moving pivot would simulate playground swings being pumped. All these extensions remain compatible with the RK4 framework established here.

10. References and Related Tools

Embed this calculator

Copy and paste the HTML below to add the Interactive Simple Pendulum Simulator with Energy Bars to your website.