Python scipy.integrate中的Odeint函数显示此调用中完成的多余工作
我试图解决一个系统,在这个系统中,一个鲍勃被固定在一个框架上,这个框架以恒定的角速度旋转,绳子的长度也在减少。我用拉格朗日方法得到了方程。但在试图使用odeint解决问题时,它会显示警告,而不会给出正确的结果 警告包括:-Python scipy.integrate中的Odeint函数显示此调用中完成的多余工作,python,scipy,odeint,Python,Scipy,Odeint,我试图解决一个系统,在这个系统中,一个鲍勃被固定在一个框架上,这个框架以恒定的角速度旋转,绳子的长度也在减少。我用拉格朗日方法得到了方程。但在试图使用odeint解决问题时,它会显示警告,而不会给出正确的结果 警告包括:- lsoda-- warning..internal t (=r1) and h (=r2) are such that in the machine, t + h = t on the next step (h = step size). so
lsoda-- warning..internal t (=r1) and h (=r2) are
such that in the machine, t + h = t on the next step
(h = step size). solver will continue anyway
in above, r1 = 0.2435612782638D+01 r2 = 0.1535595158470D-16
lsoda-- warning..internal t (=r1) and h (=r2) are
such that in the machine, t + h = t on the next step
(h = step size). solver will continue anyway
in above, r1 = 0.2435612782638D+01 r2 = 0.1117559787661D-16
lsoda-- above warning has been issued i1 times.
it will not be issued again for this problem
in above message, i1 = 10
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scipy/integrate/odepack.py:247: ODEintWarning: Excess work done on this call (perhaps wrong
Dfun type). Run with full_output = 1 to get quantitative information.
warnings.warn(warning_msg, ODEintWarning)
我的代码:-
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import math
def model(theta,t,g,omega,frame_length):
theta1 = theta[0]
theta2 = theta[1]
theta3 = theta[2]
theta4 = theta[3]
psi = 0.5233 + omega*t
rope_speed = 0.075
rope_length = 6 + 0.075*t
dtheta2_dt = - (2*rope_speed/rope_length)*theta2 + (frame_length*omega*omega)*(math.sin(theta1)*math.sin(psi)+ math.cos(theta1)*math.cos(psi)*math.cos(theta3))/(rope_length) + (theta3*theta3*math.sin(theta1)*math.cos(theta1)) - (g/rope_length)*math.sin(theta1)
dtheta4_dt = -(2*theta4*theta2*np.arctan(theta1)) - (frame_length*omega*omega*math.sin(theta3)*math.cos(psi)/math.sin(theta1))/(rope_length) -(2*rope_speed*theta4/rope_length)
return [theta2, dtheta2_dt, theta4, dtheta4_dt]
t = np.linspace(0, 60, 200)
abserr = 1.0e-8
relerr = 1.0e-6
omega = 0.0174
frame_length = 9.2
g =9.81
theta_0 = [np.pi/6,0.86,0,0.86]
theta = odeint(model, theta_0,t,args = (g,omega,frame_length),atol=abserr, rtol=relerr)
plt.plot(t,theta[:,0])
#plt.plot(t,theta[:,2])
#plt.plot(t,theta[:,3])
plt.show()