All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: To create a program that solve the following equation: and then create a simulation of the simple pendulum motion. Simple Pendulum: The simple pendulum is another mechanical system that moves in an oscillatory motion. It consists of a point mass ‘m’ suspended…
ANSHUL UPRETI
updated on 09 Jun 2021
Objective: To create a program that solve the following equation:
and then create a simulation of the simple pendulum motion.
Simple Pendulum:
The simple pendulum is another mechanical system that moves in an oscillatory motion. It consists of a point mass ‘m’ suspended by means of light inextensible string of length L from a fixed support. The motion occurs in a vertical plane and is driven by a gravitational force. The forces which are acting on the mass are shown in the figure. The tangential component of the gravitational force, mg sin θ, always acts towards the mean position θ = 0 opposite to the displacement, restoring force acting tangent to the arc.
The motion of the simple pendulum is expressed by the equation:
In the above equation,
g = gravity in m/s2,
L = length of the pendulum in m,
m = mass of the ball in kg,
b=damping coefficient.
The simulation video is represented as :
To solve the second order differential equation,we need to perform the following process:
we have the second order differential equation:
d2θdt2+bm.dθdt+gLsinθ=0
Let's assume,
θ=θ1
So,dθdt=dθ1dt
Now consider,
dθ1dt=θ2........................(1)
Differntiating on both sides:
d2θ1dt2=dθ2dt
Put these expressions in the above second order differential equation,
d2θ1dt2+bm.dθ1dt+gLsinθ1=0
dθ2dt+bm.θ2+gLsinθ1=0........................(2)
Based on these equations i.e, Eq 1 and 2,we have solution vector:
dθdt=[θ2dθ2dt=-bmθ2-gLsinθ1]
Now we have to make a python program to solve this equation and plot the results:
Given data:
L=1 metre,
m=1 kg,
b=0.05.
g=9.81 m/s2.
Program:
import math
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint
def model(theta,time,b,g,l,m):
theta1 = theta[0]
theta2 = theta[1]
dtheta1_dt = theta2
dtheta2_dt = -(b/m)*theta2 - (g/l)*math.sin(theta1)
dtheta_dt = [dtheta1_dt,dtheta2_dt]
return dtheta_dt
b = 0.05
g = 9.81
l = 1
m = 0.1
# initial condition
theta_0 = [0,3]
# time points
time = np.linspace(0,20,300)
# Solving ODE
theta = odeint(model,theta_0,time,args = (b,g,l,m))
Angular_displacement = []
Angular_velocity = []
for j in range(0,len(theta)):
displacement = theta[j,0]
Angular_displacement.append(displacement)
velocity = theta[j,1]
Angular_velocity.append(velocity)
#Creating a for loop to make arrays of angular displacement and velocity
# plotting the results
plt.figure(1)
plt.plot(time,theta[:,0],'b-',label = r'$frac{dtheta_1}{dt} = theta_2$')
plt.plot(time,theta[:,1],'r--',label = r'$frac{dtheta_2}{dt} = -frac{b}{m}theta_2 - frac{g}{l}sintheta_1$')
plt.xlabel('Time')
plt.ylabel('Plot')
plt.legend(loc = 'best')
plt.show()
# Simulating the simple pendulum
x0 = 0
y0 = 0
# creating a for loop to simulate the simple pendulum
ct = 1
for i in range(0,len(time)):
THETA = Angular_displacement[i]
x1 = l*math.sin(THETA)
y1 = -l*math.cos(THETA)
filename = 'pendulum%05d' % ct
ct = ct + 1
plt.figure(2)
plt.plot([-1,1],[0,0],color = 'r')
plt.plot([x0,x1],[y0,y1])
plt.plot(x1,y1,marker = 'o',markerfacecolor = 'g',markeredgecolor = 'k',markersize = 15)
plt.xlim([-2,3])
plt.ylim([-3,3])
plt.title('Animation of Simple pendulum motion',fontsize = 20,fontweight = 'bold')
plt.savefig(filename)
plt.clf()
Explanation of the codes:
Results:
Simulation video:
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Model Based Development of Adaptive Cruise Control feature using MATLAB/Simulink.
Aim: To develop a MBD model of Adaptive Cruise Control (ACC) feature as per the requirements using MATLAB/Simulink. General Overview: Adaptive Cruise Control: Adaptive Cruise Control Feature for passenger cars allows the host vehicle to adapt to the speed in line with the flow of traffic. Driving in heavy traffic…
24 Feb 2022 05:28 AM IST
Vehicle Direction Detection ADAS Project
General Overview: Identifying the direction of the vehicle is one of the important & diverse features in Autonomous driving & Advanced Driver Assistance Features. This particular sub-feature of identifying the direction of vehicle is basically identifying the direction the vehicle is taking based on the camera…
02 Feb 2022 08:28 AM IST
CHT Analysis on Exhaust port
Objective: To give a brief description about Conjugate Heat Transfer (CHT) Analysis. To simulate the flow and heat transfer to the solid on an exhaust port. To calculate the wall/surface heat transfer coefficient on the internal solid surface & show the velocity & temperature contours in appropriate areas.…
16 Nov 2021 05:11 PM IST
External flow simulation over an Ahmed body.
Objective: To explain about the Ahmed's body and importance. To explain the significance of the point of seperation. To run the simulation of flow over an Ahmed's body where inlet flow velocity is 25 m/s. To explain the reason for the negative pressure in the wake region. Ahmed's Body and its significance: …
22 Oct 2021 01:02 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.