I'm trying to solve a system of seven ODEs with seven conditions.
Since the following approach using DSolve is yielding the same output as the input, Mathematica can't find a solution.
DSolve[
{EA'[t] == k1 e[t] a[t] + k22 EAB[t] - k2 b[t] EA[t] - k11 EA[t],
EB'[t] == k4 e[t] b[t] - k44 EB[t] + k33 EAB[t] - k3 a[t] eb[t],
EAB'[t] ==
k2 EA[t] b[t] + k3 EB[t] a[t] - k22 EAB[t] - k5 EAB[t] + k33 EAB[t],
p'[t] == k5 EAB[t],
e'[t] == k44 EB[t] + k11 EA[t] - k4 e[t] b[t] - k1 e[t] a[t] ,
a'[t] == k11 EA[t] - k1 e[t] a[t] + k33 EAB[t] - k3 EB[t] a[t],
b'[t] == k44 EB [t] - k4 e[t] b[t] + k22 EAB[t] - k2 EA[t] b[t] ,
EA[0] == 0,
EB[0] == 0,
EAB[0] == 0,
a[0] == 1,
e[0] == 1/10,
b[0] == 100,
p[0] == 0
}, {EAB[t], EB[t], EA[t], a[t], e[t], b[t], p[t]}, t]
I then attempted this problem using ParametricNDSolve, and then subsequently fitting to the parameters using NonlinearModelFit and FindFit. With FindFit, I get the error:
"The function value {<<1>>} is not a list of real numbers with \
dimensions "
With NonlinearModelFit, I get
NDSolve Parametric Function is not a list of real \ numbers with dimensions
What I'm doing is here:
pSoln = ParametricNDSolve[
{EA'[t] ==
k1* e[t]* a[t] - k11* EA[t] + k22 *EAB[t] - k2* b[t] *EA[t] ,
EB'[t] == k4 e[t] b[t] - k44 EB[t] + k33 EAB[t] - k3 a[t] EB[t],
EAB'[t] ==
k2 EA[t] b[t] + k3 EB[t] a[t] - k22 EAB[t] - k5 EAB[t] +
k33 EAB[t],
p'[t] == k5 EAB[t],
e'[t] == k44 EB[t] + k11 EA[t] - k4 e[t] b[t] - k1 e[t] a[t] ,
a'[t] == k11 EA[t] - k1 e[t] a[t] + k33 EAB[t] - k3 EB[t] a[t],
b'[t] == k44 EB [t] - k4 e[t] b[t] + k22 EAB[t] - k2 EA[t] b[t] ,
EA[0] == 0,
EB[0] == 0,
EAB[0] == 0,
a[0] == 1,
e[0] == .1,
b[0] == 100,
p[0] == 0},
p, {t, 0, 1000}, {k1, k11, k2, k22, k3, k33, k4, k44, k5}]
fit = FindFit[data,
pSoln[k1, k11, k2, k22, k3, k33, k4, k44, k5][
t], {{k1, .15}, {k11, 1}, {k2}, k22, k3,
k33, {k4, .75}, {k44, 0}, {k5, .75}}, t];
For the NonlinearModelFit error, I just changed FindFit to NonlinearModelFit.
UPDATE: I think that ParametricNDSolve is the way to go based on the other stack posts I've viewed; however, I'm unable to plot the output of ParametricNDSolve/ParametricNDSolveValue. I had made the following function where I could tune the values of the constants:
pFunction[t_?NumericQ, k1_?NumericQ, k11_?NumericQ, k2_?NumericQ,
k22_?NumericQ, k3_?NumericQ, k33_?NumericQ, k4_?NumericQ,
k44_?NumericQ, k5_?NumericQ] :=
Evaluate[pSoln][k1, k11, k2, k22, k3, k33, k4, k44, k5][t];
With that, I then wanted to do NMinimize using the values from the manual sliders to find the actual fits:
{rmse, params} = NMinimize[{Sqrt[
Mean[(pFunction[data[[1]][[All, 1]], k1, k11, k2, k22, k3,
k33, k4, k44, k5] - data[[1]][[All, 2]])^2]],
0 < k1 < 0.2,
0 < k11 < 2,
0 < k2 < 0.05,
0 < k22 < 1,
0 < k3 < 0.2,
0 < k33 < 0.2,
0 < k4 < 2,
0 < k44 < 3,
0 < k5 < 1},
{k1, k11, k2, k22, k3, k33, k4, k44, k5}
]
Whether or not I used ?NumericQ or _Real for the inputs in pFunction, NMinimize crashes with
"The function value .... is \
not a number at {k1,k11,k2,k22,k3,k33,k4,k44,k5}"
PS. The question was edited.
eb[t]
term supposed to beEB[t]
ore[t] b[t]
? $\endgroup$ParametricNDSolveValue
instead, although with 9 parameters, I expect it will take a long time. $\endgroup$