问题描述
我正在尝试解决一个系统,在该系统中,鲍勃安装在框架上,该框架以恒定的角速度旋转,并且绳索的长度也在减少。使用拉格朗日方程式,我得到了方程。但是,在尝试使用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 (将#修改为@)