Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
1931 views
ubuntu2004
1
import numpy as np
2
import matplotlib.pyplot as plt
3
import math
4
from scipy.integrate import odeint
5
6
M=2.394
7
m=1
8
g=9.81
9
10
def Atwood(y,t,M,m,g):
11
12
theta, omega, radius, Rho = y
13
14
#dydt = [omega, (1/radius)*(-g*(np.sin(theta))-2*(Rho*omega)),Rho, (1/(M+m))*(m*radius*(omega^2)-M*g+m*g*(np.cos(theta)))]
15
dydt = [omega, (1/radius)*(-g*(np.sin(theta))-2*(Rho*omega)), Rho, (1/(M+m))*(m*radius*(omega**2)-M*g+m*g*(np.cos(theta)))]
16
17
return dydt
18
19
#y0=[theta, change in theta, radius, change in radius]
20
y0 = [np.pi/2,0 ,1,0]
21
#time points
22
t = np.linspace(0,100,1000000)
23
#Solving the ODE
24
sul = odeint(Atwood, y0, t, args=(M,m,g))
25
26
27
plt.plot(sul[:,0], sul[:,1], 'r')
28
plt.ylabel('Angular velocity')
29
plt.xlabel('Angular displacement')
30
plt.title('Fig 5.6 - Phase Plot')
31
plt.grid()
32
plt.show()
33