ODE45 solving rate too low

I am trying to model a reactor and solving a series of differential equations using ODE45.
The rate of reaction is very low when solved on MATLAB but when I take the equation conditions and put it into excel I am getting a much higher rate, which is the same answer as my hand calculated values.
I think there is an error with the equation itself and how I've written it, but I've looked at it all day and can't seem to locate where it is wrong. Below is the equation from literature and the code snippet shows my implementation.
T = var(1);
P = var(2);
FA = var(3);
FB = var(4);
FC = var(5);
FD = var(6);
F_tot = FA + FB + FC + FD + F_E0 + F_F0 + F_G0; %mol/hr
molA = FA/F_tot;
molB = FB/F_tot;
molC = FC/F_tot;
molD = FD/F_tot;
K = exp((4577.8/T)-4.33);
P_atm = P*0.00986923; %atm
FPress = P_atm^(0.5-(P_atm/250));
r_A = -FPress * (1.69*10^9) * exp(-88000/(R * T)) * (molA^0.9) * (molB ^0.31) * (molC^-0.156) * (molD ^ -0.05) * (1-((molC * molD)/(molA * molB * K)));
The differential equations look like this:
diffeqs = [
(H_rxn*r_A)/(F_A0 * (CO_eng + H20_eng + CO2_eng + H2_eng + Ar_eng +N2_eng + CH4_eng))
- ((alpha/2*p)*(T/T_0))
r_A
(H20/CO)*r_A
-(H2/CO)*r_A
-(CO2/CO)*r_A

回答(1 个)

Torsten
Torsten 2022-4-1

0 个投票

I can't see something wrong in the equation itself, but of course I don't know if the inputs have the correct units etc.
But for reaction engineering simulations, you should use ode15s instead of ode45 for better performance.

1 个评论

Thanks for the advice.
I think I know what is happening, but I don't know why. As i move through the iteration, the error vs excel and hand calculated values becomes greater for the final term (4) in the equation. Early in the iteration, the error isn't too large.
yco etc are given by: FA in above code.
Keq is exp((4577.8/T)-4.33); and isn't giving different values to what it should do.

请先登录,再进行评论。

类别

产品

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by