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
from scipy.integrate import odeint
4
5
6
7
def Atwood(y,t,M,m,g):
8
9
g=9.81
10
M = int(input())
11
m = int(input())
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
22
return dydt
23
24
#y0=[theta, change in theta, radius, change in radius]
25
y0 = [0 ,2 ,1 ,1]
26
#time points
27
t = np.linspace(0,10,101)
28
#Solving the ODE
29
sul = odeint(Atwood, y0, t, args=(M,m,g))
30
31