微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

scipy.integrate的Odeint函数显示在此调用上完成的多余工作

如何解决scipy.integrate的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). 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,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.86]
theta = odeint(model,theta_0,args = (g,frame_length),atol=abserr,rtol=relerr)

plt.plot(t,theta[:,0])
#plt.plot(t,2])
#plt.plot(t,3])
plt.show()

This is the plot of Theta vs time. Which is incorrect

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。