MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: What is the actual simulation time of NDSolve?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131371] Re: What is the actual simulation time of NDSolve?
  • From: Patrick McCarter <mccarter.patrick at gmail.com>
  • Date: Sun, 14 Jul 2013 01:48:26 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <krlhe9$88g$1@smc.vnet.net>

On Thursday, July 11, 2013 1:56:25 AM UTC-4, Bill Rowe wrote:
> On 7/10/13 at 3:36 AM, mccarter.patrick at gmail.com wrote:
>
>
>
> >I am trying to determine how long my simulation is going to run with
>
> >NDSolve. Without knowing what the time step is for the simulation,
>
> >is it possible to obtain the actual final time of the run?
>
>
>
> No.
>
>
>
> >For example, lets say I want to run a simulation for a total of 1000
>
> >seconds, procedurally I could specify a dt = 0.01 and then a total
>
> >number of steps = 100000. Then dt*number of steps = 1000. I need to be
>
> >able to do this, but am not sure if it is possible with NDSolve?
>
>
>
> This computation only means something *if* the 1000 seconds is a
>
> *simulated* 1000 seconds. If your meant 1000 seconds real time,
>
> then your result is highly unlikely to have match the actual
>
> time required.
>
>
>
> Every call to NDSolve will take some finite time. The actual
>
> time required will depend on details of the model you are using
>
> NDSolve and this will be highly variable.
>
>
>
> A possible way to get an estimate of how many steps for your
>
> specific problem can be done in 1000 seconds real time would be
>
> to use TimeConstrained. If you add a counter to your model so
>
> that you can easily determine how many times NDSolve is called,
>
> you could put a constraint of say 10 seconds or whatever you are
>
> willing to wait and see how many times NDSolve was called. Using
>
> that information it should be a simple matter to see how many
>
> steps can be done in 1000 seconds and set up the problem accordingly.

Hi, perhaps I should clarify a little more. What I am trying to do is fit some time course data. I have data points that have been observed at different time points, and I want to fit this data over a simulated time span that represents the actual experiment. I'm not concerned with the real time of the simulation, but only the simulated time of the simulation. At the end of the simulation, I must quantify the rate parameters of the model to the form molecules sec^-1 or min^-1. I'll add an example code to clarify.
Suppose I ran a fitting routine such as MCMC using the function below. At the end I would need to define the rate parameters kA and kB. Put more simply, when NDSolve solve equations over the time period {t, 0.0,100.0}, what does the t = 100.0 truly represent? I'm sorry if this is confusing. But thank you for your help!

texp = {0.2, 2.2, 4.0, 5.0, 6.0, 8.0, 11.0, 15.0, 18.0, 26.0, 33.0,
   39.0, 45.0};
dexp = {35., 25., 22.1, 17.9, 16.8, 13.7, 12.4, 7.5, 4.9, 4.0, 2.4,
   1.4, 1.1};
chi2[ka_?NumberQ, kb_?NumberQ] := Block[{sol, A, B, c}, sol NDSolve[
      {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, 0., 100.}][[1]];
   Apply[Plus, (dexp - (A[t] /. sol /. t -> texp))^2]];



  • Prev by Date: Re: inconsistent refinement behavior
  • Next by Date: An analytical solution to an integral not currently in Mathematica?
  • Previous by thread: Re: What is the actual simulation time of NDSolve?
  • Next by thread: Arrow on arc using Circle