我想使用 CSTR 相对于反应器温度的稳态浓度数据来拟合反应常数(k0 和 EoverR)。我只使用了一个简单的线性方程来生成要拟合的操作数据。(Ca_data = -1.5*T_reactor/100 + 4.2)
因为这是稳态数据,所以不需要时间步长 (m.time)。请就如何将以下模拟代码转换为“Ca vs. T_reactor”的估计代码提供建议。
import numpy as np
import matplotlib.pyplot as plt
from gekko import GEKKO
# Feed Temperature (K)
Tf = 350
# Feed Concentration (mol/m^3)
Caf = 1
# Steady State Initial Conditions for the States
Ca_ss = 1
T_ss = 304
#%% GEKKO
m = GEKKO(remote=True)
m.time = np.linspace(0, 25, 251)
# Volumetric Flowrate (m^3/sec)
q = 100
# Volume of CSTR (m^3)
V = 100
# Density of A-B Mixture (kg/m^3)
rho = 1000
# Heat capacity of A-B Mixture (J/kg-K)
Cp = 0.239
# Heat of reaction for A->B (J/mol)
mdelH = 5e4
# E - Activation energy in the Arrhenius Equation (J/mol)
# R - Universal Gas Constant = 8.31451 J/mol-K
EoverR = 8700
# Pre-exponential factor (1/sec)
k0 = 3.2e15
# U - Overall Heat Transfer Coefficient (W/m^2-K)
# A - Area - this value is specific for the U calculation (m^2)
UA = 5e4
# initial conditions = 280
T0 = 304
Ca0 = 1.0
T = m.MV(value=T_ss)
rA = m.Var(value=0)
Ca = m.CV(value=Ca_ss)
m.Equation(rA == k0*m.exp(-EoverR/T)*Ca)
m.Equation(Ca.dt() == q/V*(Caf - Ca) - rA)
m.options.IMODE = 1
m.options.SOLVER = 3
T_reactor = np.linspace(220, 260, 11)
Ca_results = np.zeros(np.size(T_reactor))
for i in range(np.size(T_reactor)):
T.Value = T_reactor[i]
m.solve(disp=True)
Ca_results[i] = Ca[-1]
Ca_data = -1.5*T_reactor/100 + 4.2 # for generating the operation data
# Plot the results
plt.plot(T_reactor,Ca_data,'bo',linewidth=3)
plt.plot(T_reactor,Ca_results,'r-',linewidth=3)
plt.ylabel('Ca (mol/L)')
plt.xlabel('Temperature (K)')
plt.legend(['Reactor Concentration'],loc='best')
plt.show()