Kernel: Python 3 (system-wide)
In [2]:
import numpy as np import matplotlib.pyplot as plt import math from scipy.integrate import odeint M=1 m=1 g=9.81 def Atwood(y,t,M,m,g): #theta'(t)=omega(t) #radius'(t)=Rho(t) #omega'(t)=(1/radius(t))(-g*sin(theta(t))-2(Rho(t)*omega(t)) #Rho'(t)=(1/(M+m))(m*radius(t)*(omega(t)^2)-M*g+m*g*cos(theta(t))) theta, omega, radius, Rho = y #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)))] 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)))] return dydt #y0=[theta, change in theta, radius, change in radius] y0 = [np.pi/2,0 ,1 ,0] #time points t = np.linspace(0,100,1000000) #Solving the ODE sul = odeint(Atwood, y0, t, args=(M,m,g)) plt.plot(sul[:,0], sul[:,1], 'r') plt.ylabel('Angular velocity') plt.xlabel('Angular displacement') plt.title('Periodic Trejectories') plt.grid() plt.show()
Out[2]:
In [0]: