2
$\begingroup$

I'm trying to evaluate the kinetics of the chemical reaction. For that I need to fit my experimental data to the kinetic equation. These are my steps in Mathematica.

data = Import["for model.xlsx"][[4]]
(* {{0., 182.115, 0.}, {1., 166.486, 1.87153}, {5., 136.178, 9.76618}, {10., 112.277, 19.1688}, {15., 111.448, 27.2978}, {25., 81.5446, 43.3609}, {35., 73.6962, 56.2542}, {45., 62.9892, 62.6874}, {55., 50.7161, 68.5274}, {65., 45.2139, 79.0054}} *)
{time, Xylose, Furfural} = Transpose[data];
Fin = Furfural[[1]];
Xin = Xylose[[1]];

sol = ParametricNDSolveValue[
   {X'[t] == -a X[t] - b X[t], X[0] == Xin
   , F'[t] == a X[t] - c F[t], F[0] == Fin}
   , {F, X}
   , {t, 0, 240}, {a, b, c}];
transformeddata = {ConstantArray[Range@Length[{Xylose, Furfural}], Length[time]] // Transpose, ConstantArray[time, Length[{Xylose, Furfural}]], {Xylose, Furfural}}~Flatten~{{2, 3}, {1}};
model[a_, b_, c_][i_, t_] := Through[sol[a, b, c][t], List][[i]] /; And @@ NumericQ /@ {a, b, c, i, t};
fit = NonlinearModelFit[transformeddata, model[a, b, c][i, t], {a, b, c}, {i, t}];
fit["RSquared"]
(* 0.398171 *)
fit["ParameterTable"]

enter image description here

Show[ListPlot[Table[Take[data, All, {1, l, l - 1}], {l, 2, 3}], PlotStyle -> PointSize[0.02]], Plot[{fit[1, t], fit[2, t]}, {t, 0, 70}]]

And as a final result I got this picture

enter image description here

And that was the best what I was able to get. I tried to put the guess for the values, nothing helped. The results and the fit doesn't make any sense. Can you help me to understand is it a problem in my coding or is it something wrong with my kinetic equations? Thank in advance!

$\endgroup$
5
  • $\begingroup$ ...and where's "for model.xlsx"? $\endgroup$ Nov 17, 2015 at 18:19
  • $\begingroup$ first you may notice your X equation is decoupled and has a trivial analytic solution. Making use of that may help. $\endgroup$
    – george2079
    Nov 17, 2015 at 18:21
  • 1
    $\begingroup$ Also, Without digesting the whole thing, you have somewhere transposed F and X. Your weird solution is because the X function is struggling to match the F initial condition and vice versa. $\endgroup$
    – george2079
    Nov 17, 2015 at 18:26
  • $\begingroup$ indeed switching {F,X} to {X, F} in ParametricNDSolveValue gives a nice result.. $\endgroup$
    – george2079
    Nov 17, 2015 at 18:30
  • $\begingroup$ Dear george2079, thanks a lot for the comment! Seems that I messed up! :) I switched {F,X} to {X, F} in ParametricNDSolveValue and now it works! $\endgroup$
    – OlgaE
    Nov 18, 2015 at 9:39

0