Chemical reaction rate with ODE?

7 views (last 30 days)
Jonas Hoen
Jonas Hoen on 26 Oct 2013
Answered: lisa on 20 Feb 2014
Hello im having some trouble solving a system of differential eqs. with ode45
The Chemical Reaction look like this
  • A -> B+B (k1)
  • B+C -> M (k2)
  • B+D -> C (k3)
My function code
function [f] = kinetic(t,Conc,R,K)
k1=9.2*10^6*exp(108400/(R*K));
k2=2.5*10^14*exp(244600/(R*K));
k3=2.2*10^14*exp(317500/(R*K));
f=zeros(length(Conc),1);
f(1)=-k1*Conc(1);
f(2)=k1*Conc(1)^2-k2*Conc(2)*Conc(3)-k3*Conc(2)*Conc(4);
f(3)=-k2*Conc(2)*Conc(3)+k3*Conc(2)*Conc(4);
f(4)=-k3*Conc(2)*Conc(4);
And the main script
P=101325;
R=8.314;
K=1193;
Conc=[A B C D] %The initial values of the concentrations
[t, Conc]=ode45(@kinetic,[0:0.1:0.3],Conc,[],R,K);
When i run the script i get the following answer for
Conc
A B C D
NaN NaN NaN NaN
NaN NaN NaN NaN
NaN NaN NaN NaN
What im i doing wrong?
  2 Comments
Marc
Marc on 26 Oct 2013
Do you get an error from ode45? I assume you have defined the initial conditions.
Jonas Hoen
Jonas Hoen on 26 Oct 2013
I dont get an error only the NaN [A B C D] is replaced by a calculated mol pr volume
This is the result i get
Conc =
0.5108 0 0.0020 0.5469
NaN NaN NaN NaN
NaN NaN NaN NaN
NaN NaN NaN NaN

Sign in to comment.

Answers (2)

Youssef  Khmou
Youssef Khmou on 27 Oct 2013
You did not mention the parameters A,B,C and D :
i tried with A=12.2;B=14.3;C=15.5;D=17.6; it gives :
Conc =
1.0e+030 *
0.0000 0.0000 0.0000 0.0000
-0.0000 -0.3894 0.4416 -0.4419
-0.0000 -0.7788 0.8831 -0.8837
-0.0000 -1.1683 1.3247 -1.3256
  1 Comment
Jonas Hoen
Jonas Hoen on 27 Oct 2013
If i insert the values in the function i get what u get but isnt the ODE function supposed to get the initial values from the script and not write it directly in the function?

Sign in to comment.


lisa
lisa on 20 Feb 2014
I think the energy in the reaction rate expression should be negative, otherwise, the rate will be too large.

Categories

Find more on Chemistry in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!