Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在odeint scipt中使用vector作为参数_Vector_Scipy_Odeint - Fatal编程技术网

如何在odeint scipt中使用vector作为参数

如何在odeint scipt中使用vector作为参数,vector,scipy,odeint,Vector,Scipy,Odeint,这是我的代码: Ue=2.16 #Ta=np.random.randint(20,30,24) Ta=34 A=3 C=1000*750*0.15 h=6 Gc=h*A def C001(T,t,Ue,A,C,Gc,Ta): T1,T2=T dTdt=[ (Ue*A*(T2-T1)+Gc*(Ta-T1))/C, (Ue*A*(T1-T2)+Gc*(Ta-T2))/C] return dTdt Ts=[25

这是我的代码:

Ue=2.16
#Ta=np.random.randint(20,30,24)
Ta=34
A=3
C=1000*750*0.15
h=6
Gc=h*A

def C001(T,t,Ue,A,C,Gc,Ta):
    T1,T2=T
    dTdt=[
          (Ue*A*(T2-T1)+Gc*(Ta-T1))/C,
          (Ue*A*(T1-T2)+Gc*(Ta-T2))/C]
           
    return dTdt

Ts=[25,25] #initial conditions
t=np.linspace(0,24,24)*3600  #integration interval
result=odeint(C001,Ts,t,args=(Ue,A,C,Gc,Ta))

fig , ax=plt.subplots()
ax.plot(t/3600,result[:,1],color='tab:red')
ax.grid()
ax.set_xlabel('Time (Hours)'
问题是: 当我试图用np数组替换Ta,使其与时间t集成时,我得到的误差为
“func返回的数组必须是一维的,但得到的ndim=2。”即使向量t和Ta具有相同的形状(24,)

t
是一维数组
[T1,T2]
,而
dtdtt
也是(应该)一维数组。制作
Ta
一个数组会改变它,这是不可接受的。所以我必须改变T,使其具有与Ta(24,)相同的dim,你能告诉我怎么做吗?