Re: How to make fitting code using NDSolve?
- To: mathgroup at smc.vnet.net
- Subject: [mg127764] Re: How to make fitting code using NDSolve?
- From: christopher arthur <chris.arthur1 at gmail.com>
- Date: Mon, 20 Aug 2012 21:28:23 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <20120820081427.111DE6838@smc.vnet.net>
- Reply-to: chris.arthur1 at gmail.com
Subscript[Dye, 0] hasn't been a good variable name...maybe in v8 it doesn't matter. Try just Dye0.
Chris
JYeom a écrit :
> Hello,
> I am trying to fit some basic data to a partial differential equation- here are the data points:
>
> data = {
> {2.113, 2.915*^-7}, {2.256, 2.758*^-7}, {2.303, 2.567*^-7}, {2.493,
> 2.343*^-7}, {2.635, 2.085*^-7}, {2.825, 1.838*^-7}, {3.015,
> 1.614*^-7}, {3.205, 1.412*^-7}, {3.538, 1.199*^-7}, {3.775,
> 1.03*^-7}, {4.108, 8.173*^-8}, {4.487, 6.266*^-8}, {4.915,
> 4.695*^-8}, {5.295, 3.349*^-8}, {5.912, 2.34*^-8}, {6.672,
> 1.554*^-8}, {7.527, 7.692*^-9}, {8.524, 5.448*^-9}, {9.426,
> 4.326*^-9}, {10.23, 3.205*^-9}, {10.99,
> 2.083*^-9}, {11.99, -1.608*^-10}
> }
>
> And there are four parameters to fit in our fitting equation:
>
> model[ka_?NumberQ, kr_?NumberQ, kd_?NumberQ,
> kb_?NumberQ] := (model[ka, kr, kd, kb] =
> First[Subscript[Dye, 0] /. NDSolve[{
> Derivative[1][Subscript[Dye, 0]][
> t] ==\[VeryThinSpace]-ka Subscript[Dye, 0][t] +
> kr Subscript[Dyes, 0][t], Subscript[Dye, 0][0] == 1.22 10^-6,
> Derivative[1][Subscript[Dye, 1]][
> t] == -ka Subscript[Dye, 1][t] + kr Subscript[Dyes, 1][t],
> Subscript[Dye, 1][0] == 0,
>
> Derivative[1][Subscript[Dyes, 0]][t] ==
> ka Subscript[Dye, 0][t] - kr Subscript[Dyes, 0][t] -
> kd Subscript[CI, 0][t] Subscript[Dyes, 0][t] -
> kd /2 * Subscript[CI, 1][t] Subscript[Dyes, 1][t],
> Subscript[Dyes, 0][0] == 0,
> Derivative[1][Subscript[Dyes, 1]][t] ==
> ka Subscript[Dye, 1][t] -
> kd Subscript[CI, 1][t] Subscript[Dyes, 0][t] -
> kr Subscript[Dyes, 1][t] -
> kd Subscript[CI, 0][t] Subscript[Dyes, 1][t],
> Subscript[Dyes, 1][0] == 0,
>
> Derivative[1][Subscript[CI, 0]][
> t] == -kd Subscript[CI, 0][t] Subscript[Dyes, 0][t] -
> kd/2* Subscript[CI, 1][t] Subscript[Dyes, 1][t] -
> kb Subscript[CI, 0][t] Subscript[HDye, 0][t] -
> kb/2* Subscript[CI, 1][t] Subscript[HDye, 1][t],
> Subscript[CI, 0][0] == 3.18 10^-3,
> Derivative[1][Subscript[CI, 1]][
> t] == -kd Subscript[CI, 1][t] Subscript[Dyes, 0][t] -
> kd/2* Subscript[CI, 0][t] Subscript[Dyes, 1][t] -
> kb Subscript[CI, 1][t] Subscript[HDye, 0][t] -
> kb/2*Subscript[CI, 0][t] Subscript[HDye, 1][t],
> Subscript[CI, 1][0] == 0,
>
> Derivative[1][Subscript[HDye, 0]][t] ==
> kd Subscript[CI, 0][t] Subscript[Dyes, 0][t] +
> kd/2* Subscript[CI, 1][t] Subscript[Dyes, 1][t] -
> kb Subscript[CI, 0][t] Subscript[HDye, 0][t] -
> kb /2* Subscript[CI, 1][t] Subscript[HDye, 1][t],
> Subscript[HDye, 0][0] == 0,
> Derivative[1][Subscript[HDye, 1]][t] ==
> kd Subscript[CI, 1][t] Subscript[Dyes, 0][t] +
> kd Subscript[CI, 0][t] Subscript[Dyes, 1][t] -
> kb Subscript[CI, 1][t] Subscript[HDye, 0][t] -
> kb Subscript[CI, 0][t] Subscript[HDye, 1][t],
> Subscript[HDye, 1][0] == 0
> }, {Subscript[Dye, 0][t], Subscript[Dyes, 0][t],
> Subscript[CI, 0][t], Subscript[HDye, 0][t],
> Subscript[Dye, 1][t], Subscript[Dyes, 1][t],
> Subscript[CI, 1][t], Subscript[HDye, 1][t]}, {t, 0, 12}]])
>
> In the NDSolve, what we want to fit is Dye0[t]. So we wrote code for fitting using FindFit:
>
> fit = FindFit[data,
> model[ ka, kr, kd, kb][Subscript[Dye,
> 0]], {{ka, 10^(-4)}, {kr, 10^(-4)}, {kd, 500}, {kb, 500}},
> Subscript[Dye, 0]]
>
> However, we encountered the error message like this:
>
> FindFit::nrlnum: "The function value {-2.915*10^-7+Subscript[Dye, 0][2.113],-2.758*10^-7+Subscript[Dye, 0][2.256],-2.567*10^-7+Subscript[Dye, 0][2.303],<<16>>,-3.205*10^-9+Subscript[Dye, 0][10.23],-2.083*10^-9+Subscript[Dye,0][10.99],1.608*10^-10+Subscript[Dye, 0][11.99]} is not a list of real numbers with dimensions {22} at {ka,kr,kd,kb} = {0.0001,0.0001,500.,500.}."
>
> The desirable solution for parameter is around ka= 0.67, kr = 10^(-3), kd=1600, kb=1600.
>
> Does anyone know what I am doing wrong?
>
>
>
- References:
- How to make fitting code using NDSolve?
- From: JYeom <cygnis@hanmail.net>
- How to make fitting code using NDSolve?