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 commentaires

Marc
Marc le 26 Oct 2013
Do you get an error from ode45? I assume you have defined the initial conditions.
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

Connectez-vous pour commenter.

Réponses (2)

Youssef  Khmou
Youssef Khmou le 27 Oct 2013

0 votes

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 commentaire

Jonas Hoen
Jonas Hoen le 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?

Connectez-vous pour commenter.

lisa
lisa le 20 Fév 2014

0 votes

I think the energy in the reaction rate expression should be negative, otherwise, the rate will be too large.

Catégories

En savoir plus sur Chemistry dans Centre d'aide et File Exchange

Réponse apportée :

le 20 Fév 2014

Community Treasure Hunt

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

Start Hunting!

Translated by