Transient Simulation of a Simple Pendulum Motion Using PYTHON


1. To simulate the Transient Behaviour of a Pendulum by Solving Second Order Differential        Equation

2. Obtain Plots for Angular Displacement and Angular Velocity vs Time.


Consider a simple pendulum system. A ball of mass m connected to a mass-less string of length L. The ball is made to swing to and fro. Due to action of gravity and air resistance the ball stops swinging at some particular point of time. The way a pendulum moves simply depends on newtons second law, F = ma. The second order linear non-homogenous equation is given below.


Here, L = length of the pendulum in m 

g = gravitational acceleration in m/sec^2 

m = mass of the ball in kg

b = damping coefficient

What we will do next is try creating an array so that we can pass our initial conditions value and compute the equation. Below given is an image showing how a second order derivative could be converted into first order derivative. 

Value of Constant parametres:

L = 1 m

m = 0.1 kg

b = 0.02

g = 9.81 m/sec^2

Initial Conditions:

We will simulate the motion between 0-10 sec, for initial conditions we will take angular displacement = 0 rad and initial angular velocity =3rad/sec^2 at time t = 0


import math
import matplotlib.pyplot as plt
import numpy as np 
from scipy.integrate import odeint

def pendulum_eq(theta, t, b, g, l, m): 
	dtheta1_dt = theta2
	dtheta2_dt = (-b/m)*theta2-(g/l)*math.sin(theta1)
	return dtheta_dt 

theta_0 = [0,2] #initial conditions
t = np.linspace(0,10,150)
points = len(t)
L= np.arange(0,points,1)
theta = odeint(pendulum_eq,theta_0,t, args=(b,g,l,m) )
plt.title('Displacement and Angular velocity vs time ')
# Animation
theta1 = theta[:,1]
x = l*np.sin(theta1)
y = -l*np.cos(theta1)
for points in L:
	plt.xlabel( 'X cordinates')
	plt.ylabel('Y cordinates')
	plt.title('Transient Pendulum Simulation')
	file_no = points
	file_no = format(file_no,"01")
	filename = "{}.png".format(file_no)

Projects by Saikat Paul

OBJECTIVE: 1. Simulating Conjugate Heat Transfer Flow through a solid pipe and post process using            CONVERGE Studio 2. Perform Grid dependancy Test and study the effect of Supercycling Stage Interval. INTRODUCTION: Conjugate he Read more

OBJECTIVE: 1. To simulate a 2D shock flow on a plate, post process the results using converge CFD and        analyse the fluid property variations using paraview 2. To study the effect of SGS parameter on shock location INTRODUCTION: A shock is Read more

OBJECTIVE:  1) To build a otto cycle simulator with engine kinematics using python. 2) Plotting the PV diagram as well as calculating efficiency of the otto cycle. INTRODUCTION: We are all familiar with air standard cycles which are used to describe the functio Read more

OBJECTIVE: i.) To minimize a objective function with respect to variables in the presence of constraints. ii.) Understanding application of minimizing cost functions for industrial or economic use. INTRODUCTION: Mathematical optimization is the process of optimizing Read more

OBJECTIVE:  To Simulate The  Forward Kinematics of a 2D Robotic Arm Using Python and Sublime.  INTRODUCTION: Why Python for Robotics ? Python is a very widely used language in the field of robotics because it can be implemented very easilly. Python pr Read more

OBJECTIVE: 1.) To compute the drag force experienced by a cyclist using python and sublime.  2.) Developing code to plot (velocity vs drag force) and (drag-coefficient vs drag Force). INTRODUCTION: The force generated on the frontal area of a bicycle due to air Read more

OBJECTIVE:  1.) To perform a steady state simulation of fluid flowing over a throttle body and post process the results. 2.) Generate fine mesh using embedded grid system, plot Graphs for pressure, velocity, mass flow rate and total cell count . INTRODUCTION: I Read more

OBJECTIVE : Use the icoFOAM solver to simulate the flow through a backward facing step for diferent mesh grades and compare the results obtained in each meshes. INTRODUCTION: openFoam provides few tutorials for their users to better understand how the solver works. Read more

OBJECTIVE: To understand the significance of interpolation schemes and fux limiters in Finite Volume Method.  INTERPOLATION SCHEMES AND IT\'S SIGNIFICANCE: A finite volume method discretization is based upon an integral form of PDE equation. The PDE is written s Read more


The End