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"]
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
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!
"for model.xlsx"
? $\endgroup$X
equation is decoupled and has a trivial analytic solution. Making use of that may help. $\endgroup$F
andX
. Your weird solution is because theX
function is struggling to match theF
initial condition and vice versa. $\endgroup${F,X}
to{X, F}
inParametricNDSolveValue
gives a nice result.. $\endgroup$