我正在尝试重现下面显示的两个图表,它们是温度和浓度曲线随时间的变化。我已经检查了我的方法和代码一百万次但似乎无法在其中找到错误,但我无法重现这些图形。除了CA和T之外,所有值都是常量。这可能是scipy中odeint准确性的问题吗?任何帮助将非常感激!
这两个方程式如下:
dCA / dt = q *(CAi - CA)/ V - k * CA
dT / dt = w *(Ti - T)/(V p)+ d_HR k CA /(p C)+ UA *(Tc - T) /(V p 的C)
代码是:
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def ODESolve(y, t, q, CAi, V, k0, w, Ti, p, dH_R, C, UA, Tc):
CA, T = y
k = k0*np.exp(8750*1/T)
dydt = [q*(CAi - CA)/V - k*CA, w*(Ti - T)/(V*p) + \
dH_R*k*CA/(p*C) + UA*(Tc - T)/(V*p*C)]
return dydt
q = 100
CAi = 1.0
V = 100
p = 1000
C = .239
dH_R = 5*(10**4)
k0 = 7.2*(10**10)
UA = 5*10**4
CA0 = .5
T0 = 350
Ti = T0
w = p*q
y0 = [CA0, T0]
t = np.linspace(0, 20, 100)
Tc = 305
sol1 = odeint(ODESolve, y0, t, args = (q, CAi, V, k0, w, Ti, p, dH_R, C, UA, Tc))
Tc = 300
sol2 = odeint(ODESolve, y0, t, args = (q, CAi, V, k0, w, Ti, p, dH_R, C, UA, Tc))
Tc = 290
sol3 = odeint(ODESolve, y0, t, args = (q, CAi, V, k0, w, Ti, p, dH_R, C, UA, Tc))
plt.figure(1)
plt.plot(t, sol1[:,0], label = 'Tc = 305')
plt.plot(t, sol2[:,0], label = 'Tc = 300')
plt.plot(t, sol3[:,0], label = 'Tc = 290')
plt.ylim(ymax = 1, ymin = 0)
plt.title ('CA(t)')
plt.legend(loc = 'best')
plt.figure(2)
plt.plot(t, sol1[:,1], label = 'Tc = 305')
plt.plot(t, sol2[:,1], label = 'Tc = 300')
plt.plot(t, sol3[:,1], label = 'Tc = 290')
plt.ylim(ymax = 450, ymin = 300)
plt.legend(loc = 'best')
plt.title ('T(t)')
plt.show()
这是图表应该产生的内容:
这是我上面代码的输出:
答案 0 :(得分:1)
显然,公式k = k0*np.exp(8750*1/T)
中存在符号错误。如果您将其更改为k = k0*np.exp(-8750*1/T)
,那么您将获得与预期相似的图表。