All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Gdrive: https://drive.google.com/drive/folders/1mwlGUaGJyMrs0zaj7CcsVDp8T3jkt2CQ AIM Your objective is to write a program that solves the following ODE. This ODE represents the equation of motion of a simple pendulum with damping. Program import numpy as np from scipy.integrate import odeint # for intagration purpose…
KANNAN SARAVANAN
updated on 09 Nov 2020
Gdrive: https://drive.google.com/drive/folders/1mwlGUaGJyMrs0zaj7CcsVDp8T3jkt2CQ
AIM
Program
import numpy as np
from scipy.integrate import odeint # for intagration purpose
import matplotlib.pyplot as plt
import math
def model (theta,t,b,g,l,m):
theta1= theta[0] # coverting the second order ODE into simpleform
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.02 #damping coefficient.
g=9.81 #gravity m/sec2
l=1 # length of the pendulum in m,
m=0.1 #mass of the ball in kg,
#initial conditions
theta_0=[0,5] #the angle between string and plane is 5
#time points
t=np.linspace(0,20,150)
#solve ode
theta= odeint(model,theta_0,t,args=(b,g,l,m))
#plot results
plt.plot(t,theta[:,0])
plt.plot(t,theta[:,1])
plt.ylabel('plot')
plt.xlabel('time')
plt.show()
ct=1
for theta in theta[:,0]:
x0=0
y0=0
x1=l*math.sin(theta)
y1=-l*math.cos(theta)
plt.figure()
plt.plot([-1,1],[0,0])
plt.plot([0,x1],[0,y1])
plt.plot(x1,y1,marker='o', markersize =30)
plt.xlim([-1.5,1.5])
plt.ylim([-1.5,1.5])
#plt.show()
filename='test%05d.png' % ct
plt.savefig(filename)
ct=ct+1
Procedure
OUTPUT
Result
from this assignment we learn the how to slove the second order ode by using the python
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 3 - Solving second order ODEs
Gdrive: https://drive.google.com/drive/folders/1mwlGUaGJyMrs0zaj7CcsVDp8T3jkt2CQ AIM Your objective is to write a program that solves the following ODE. This ODE represents the equation of motion of a simple pendulum with damping. Program import numpy as np from scipy.integrate import odeint # for intagration purpose…
09 Nov 2020 10:30 AM IST
Week 2 Air standard Cycle
g_drive link: https://drive.google.com/drive/folders/1mwlGUaGJyMrs0zaj7CcsVDp8T3jkt2CQ Aim write the code for otto cycle and ploting the pv diagram and output the thermal efficiency of the engine. Introduction the cycle is defined as the series of operation or processes performed…
06 Nov 2020 08:02 AM IST
Bird Strike - Project - 2
G dive link: https://drive.google.com/drive/folders/1S18pT4BTUAOJ-_CcfmpdcvvKG5dY2Guq Aim: The bird, casing, and the blades should be in different input files and there should be one main file referencing all the input files. The main file should contain only references. Control cards and boundary conditions…
01 Oct 2020 02:53 PM IST
week-11 Joint creation and Demonstration
G-drive link: https://drive.google.com/drive/u/0/folders/1S18pT4BTUAOJ-_CcfmpdcvvKG5dY2Guq Simulation video link: https://drive.google.com/drive/u/0/folders/16dxW1p2dg8mwujoqqLEpOK45ycAKQg3g Aim: to create the various type of joints based on the ls dyna user guide 1.revoulte joints 2.spherical joints 3.cyclinderical…
17 Sep 2020 02:56 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.