All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
1. AIM:- Write a programme for solving second order differential equation for a pendulum and also transient behaviour of a pendulum . 2.Governing Equation : 3.OBJECTIVE OF PROJECT: To To study how the time period of a simple changes when its amplitude (θ ) is changed. 4.BODY:- import…
GAURAV
updated on 28 Jun 2020
1. AIM:- Write a programme for solving second order differential equation for a pendulum and also transient behaviour of a pendulum .
2.Governing Equation :
3.OBJECTIVE OF PROJECT: To To study how the time period of a simple changes when its amplitude (θ ) is changed.
4.BODY:-
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import math
#function that return dz/dt
def model (theta,t,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=1
#initial conddition
theta_0 = [math.pi/2,0]
#time points
t = np.linspace(0,10,150)
#solve ODE
theta = odeint(model,theta_0,t,args = (b,g,l,m))
#plot results
plt.plot(t,theta[:,0],'b-',label=r'$\frac{d\theta_1}{dt}=\theta2$')
plt.plot(t,theta[:,1],'r--',label=r'$\frac{d\theta2}{dt}=-\frac{b}{m}\theta_2-\frac{g}{L}sin\theta_1$')
plt.ylabel('Plot')
plt.xlabel('time')
#plt.legend(Loc='best')
plt.show()
ct = 1
range = theta[:,0]
for i in range:
x_start = 0
y_start = 0
x_end = l*math.sin(i)
y_end = -l*math.cos(i)
plt.figure()
plt.plot([-0.5,0.5],[0,0],linewidth=8,color='y')
plt.plot([x_start,x_end],[y_start,y_end],linewidth=3)
plt.plot(x_end,y_end,'o',markersize=20,color='r')
plt.plot([0,0],[0,-1.5],'--',color='k')
plt.xlim([-1.25,1.25])
plt.ylim([-2,1])
plt.title('MOTION STUDY OF SIMPLE PENDULUM')
filename = 'test%005d.png' % ct
plt.savefig(filename)
ct = ct + 1
STEPS TAKEN TO WRITE A PROGRAMME
PLOT
SCREENSHOT:-
YOUTUBE LINK:-
https://youtu.be/A9KgtwVuMmg
5.CONCLUSION
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...
Week 6 - Data analysis
1. AIM:- Write a programme read data from the file containing the engine's data and plot PV diagram. 2. BODY:- import matplotlib.pyplot as plt import numpy as np from numpy import trapz import time # Basic Initilization line_count =1 crank = [] volume = [] # FILE PARSING STARTS HERE try : open('engine_data.out') except…
28 Jun 2020 02:38 PM IST
Week 5 - Curve fitting
1. What does popt and pcov mean? ANS. " popt " is an array that stores the values of the coefficients that are being passed in a given function. " pcov " is a two-dimensional array that stores the values of the estimated covariance of popt i.e the coefficients. 2. What does np.array(temperature) do?…
28 Jun 2020 01:27 PM IST
Week 3 - Solving second order ODEs
1. AIM:- Write a programme for solving second order differential equation for a pendulum and also transient behaviour of a pendulum . 2.Governing Equation : 3.OBJECTIVE OF PROJECT: To To study how the time period of a simple changes when its amplitude (θ ) is changed. 4.BODY:- import…
28 Jun 2020 12:57 PM IST
Week 2 Air standard Cycle
AIM: Write a programme for AIR STANDARD CYCLE OBJECTION: The Otto cycle is an air-standard cycle which approximates the processes in petrol or diesel engines. It is based on constant volume heat addition (combustion) and heat rejection processes, and isentropic compression and expansion. …
23 Jun 2020 02:52 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.