pendulum_runge4.py

Created by vnap0v

Created on June 24, 2025

2.77 KB

Damped, driven pendulum

This script calculates a solution to the ODE for a driven pendulum with damping.

I*d(dθ/dt)/dt + m*g*l*sin(θ) + b*dθ/dt = a*cos(Ω*t)

This second order non linear ODE has been to be modified to a system of two first order ODEs.

dω/dt = 1/I*( -g*m/l*sin(θ) - b*ω + a*cos(Ω*t) )
dθ/dt = ω

The script uses a 4th order Runge-Kutta method to calculate a solution of this system.

This solution is then plotted.

The libraries math, numpy and matplotlib are used.


During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.