Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am wondering if there is a way to pass parameter values during the NDSolve'Reinitialize step of the NDSolve process? I've read that one way to possibly speed up repeated calls to NDSolve is to Process the equations once, and then use NDSolve'Reinitialize to update the initial conditions. In the ODE example below, the initial conditions will never change, instead I am searching for the rate parameters ka and kb that minimize a scoring function. How could I use NDSolve'Reinitialize to pass different values of those parameters, and more efficiently search for the optimal parameter sets?

k

a = .1;
kb = .01;

decay = First[

NDSolve`ProcessEquations[
   {
     A'[t] == -ka*A[t],
    B'[t] == ka*A[t] - kb*B[t],
    c'[t] == kb*B[t],
    A[0] == 35.,
    B[0] == 0.,
    c[0] == 0.
    },
   {A, B, c},
   t,
   Method -> "Automatic"]]
NDSolve`Iterate[decay, 200]

sol = NDSolve`ProcessSolutions[decay]

Plot[
 Evaluate[
  {A[t], B[t], c[t]} /. sol,
  {t, 0, 200}
  ],
 PlotStyle -> {Red, Blue, Green}]
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.