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

问题描述

这是我的代码

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,args=(Ue,Ta))

fig,ax=plt.subplots()
ax.plot(t/3600,result[:,1],color='tab:red')
ax.grid()
ax.set_xlabel('Time (Hours)'

问题是: 当我尝试用 np 数组替换 Ta 以便它与时间集成时我得到一个错误 “func 返回的数组必须是一维的,但得到 ndim=2。”即使向量 t 和 Ta 具有相同的形状 (24,)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)