MathGroup Archive 2010

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

Search the Archive

Modification of Variable in NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107886] Modification of Variable in NDSolve
  • From: Shawn Garbett <shawn.garbett at gmail.com>
  • Date: Tue, 2 Mar 2010 03:35:26 -0500 (EST)

I need to modify a variable while a system of ODE's are being solved.
I've simplified the problem to the following:

dA = B[t];
dB = (1 - A[t]^2) B[t] - A[t];
dF = B[t] + 0.2;

Module[{count = 0, last = 0.},
 sol = NDSolve[{A'[t] == dA, B'[t] == dB, F'[t] == dF, A[0] == 1,
    B[0] == 1, F[0] == 1}, {A, B, F}, {t, 0, 100},
   StepMonitor :> If[last <= 5 <= F[t] && last < F[t],
     count++; last = F[t],
     last = F[t]]
   ]; count]

This does a threshold crossing of 5 for the variable F from below. The
count that results is correct, but one more thing is needed. This
shows the graphs

disp = Plot[#[t] /. sol, {t, 0, 100}, PlotRange -> All] &;
GraphicsGrid[Map[disp, {{A, B}, {F}}, {2}]]

What I need is for F to be set to half it's value at each threshold
crossing from below. I've been trying introducing another variable,
but so far nothing I've tried seems to work.


  • Prev by Date: Re: learning calculus through mathematica
  • Next by Date: Re: learning calculus through mathematica
  • Previous by thread: Re: Re: Annoying error in Hypergeometric2F1
  • Next by thread: Re: Modification of Variable in NDSolve