我有代码:
import numpy as np
import scipy.optimize
基本变量:
eee=0.289;
nn=0.63;
E1k=0.0935;
pp=1.25;
B1k=0.12;
v1k=0.126;
Bkk=3.14;
VKb=0.76;
rKb=1.754;
运动模型,这些方程在数值上整合:
def D2(y,t):
Vr,Vn,r,v,Q,dQ_dt=y
dVr_dt=(aob2*np.sin(Q))/(1-(aob2*t/wb))-1/(r**2)+(Vn**2)/r
dVn_dt=(aob2*np.cos(Q))/(1-((aob2*t)/wb))-(Vr*Vn)/r
dr_dt=Vr
dB_dt=Vn/r
Qt=0
dQ_dtt=0
return [dVr_dt,dVn_dt,dr_dt,dB_dt,Qt,dQ_dtt]
功能,我们寻求的根源:
#-----------------------------------------------------------------
def VrVnRB(x):
v2oA=2*np.arctan(np.sqrt((1+eee)/(1-eee))*np.tan(x[0]/2))
if v2oA>v1k:
v2o=v2oA
else:
v2o=v2oA+2*np.pi
t2=np.linspace(0,x[3],500)
tpas=1/nn*(x[0]-E1k+eee*(np.sin(E1k)-np.sin(x[0])))
Vro2=eee*np.sin(v2o)/np.sqrt(pp)
Vno2=(1+eee*np.cos(v2o))/np.sqrt(pp)
ro2=pp/(1+eee*np.cos(v2o))
Bo2=B1k+v2o-v1k
yo2=[Vro2,Vno2,ro2,Bo2,x[1],x[2]]
EE2=odeint(D2,yo2,t2)
Vrk=EE2[:,0]
Vrk=Vrk[-1]
Vnk=EE2[:,1]
Vnk=Vnk[-1]
rk =EE2[:,2]
rk= rk[-1]
Bk =EE2[:,3]
Bk= Bk[-1]
return [Vrk,Vnk-VKb,rk-rKb,Bk-Bkk]
x0=[E20,Qo2,dQ_dt2,t2b]
#-----------------------------------------------------------------
t1k=scipy.optimize.fsolve(VrVnRB,x0)
但是口译员不满意:
File "<tmp 2>", line 36, in <module>
t1k=scipy.optimize.fsolve(VrVnRB,x0)
File "C:\pyzo2013c\lib\site-packages\scipy\optimize\minpack.py", line 139, in fsolve
res = _root_hybr(func, x0, args, jac=fprime, **options)
File "C:\pyzo2013c\lib\site-packages\scipy\optimize\minpack.py", line 208, in _root_hybr
ml, mu, epsfcn, factor, diag)
TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'
我不明白我的错误。请帮忙。