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=19
7
m=1
8
g=9.81
9
10
def Atwood(y,t,M,m,g):
11
12
#theta'(t)=omega(t)
13
#radius'(t)=Rho(t)
14
15
#omega'(t)=(1/radius(t))(-g*sin(theta(t))-2(Rho(t)*omega(t))
16
#Rho'(t)=(1/(M+m))(m*radius(t)*(omega(t)^2)-M*g+m*g*cos(theta(t)))
17
18
theta, omega, radius, Rho = y
19
20
#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)))]
21
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)))]
22
23
return dydt
24
25
#y0=[theta, change in theta, radius, change in radius]
26
y0 = [np.pi/2,0 ,1 ,0]
27
#time points
28
t = np.linspace(0,100,1000000)
29
#Solving the ODE
30
sul = odeint(Atwood, y0, t, args=(M,m,g))
31
32
33
plt.plot(sul[:,0], sul[:,1], 'r')
34
plt.ylabel('Angular velocity (radians per second)')
35
plt.xlabel('Angular displacement (radians)')
36
plt.title('Fig 8 - Phase Plot')
37
plt.grid()
38
plt.show()
39