MathGroup Archive 2010

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

Search the Archive

Re: Re: Modification of Variable in NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108068] Re: [mg108007] Re: Modification of Variable in NDSolve
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sun, 7 Mar 2010 05:09:50 -0500 (EST)
  • References: <hmiikh$3r6$1@smc.vnet.net> <hmlese$jmc$1@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

Looks like a lot of great code, there, but it doen't work, not a bit...  
since dA, dB, and dF are undefined.

Bobby

On Fri, 05 Mar 2010 03:31:55 -0600, Shawn Garbett  
<shawn.garbett at gmail.com> wrote:

> I took these suggestion into account and now have the following, it's
> crude but works. If I can refine it into a loop, then I'll be done.
>
> First Interval
>
> x1 = Reap[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},
>    Method -> {
>      "EventLocator",
>      "Event" -> F[t] - 5,
>      "Direction" -> 1,
>      "EventAction" :> Sow[t]
>      }
>    ]]
>
> sol1 = x1[[1]][[1]]
>
> div1 = x1[[2]][[1]][[1]]
>
> Second Interval
>
> x2 = Reap[NDSolve[
>    {A'[t] == dA, B'[t] == dB, F'[t] == dF,
>     A[div1] == (A[div1] /. sol1),
>     B[div1] == (B[div1] /. sol1),
>     F[div1] == (F[div1] /. sol1)/2},
>    {A, B, F}, {t, div1, 100},
>    Method -> {
>      "EventLocator",
>      "Event" -> F[t] - 5,
>      "Direction" -> 1,
>      "EventAction" :> Sow[t]
>      }
>    ]]
>
> sol2 = x2[[1]][[1]]
>
> div2 = x2[[2]][[1]][[1]]
>
> Third Interval
>
> x3 = Reap[NDSolve[
>    {A'[t] == dA, B'[t] == dB, F'[t] == dF,
>     A[div2] == (A[div2] /. sol2),
>     B[div2] == (B[div2] /. sol2),
>     F[div2] == (F[div2] /. sol2)/2},
>    {A, B, F}, {t, div2, 100},
>    Method -> {
>      "EventLocator",
>      "Event" -> F[t] - 5,
>      "Direction" -> 1,
>      "EventAction" :> Sow[t]
>      }
>    ]]
>
> sol3 = x3[[1]][[1]]
>
> div3 = x3[[2]][[1]][[1]]
>
> AA[t_ /; t <= div1] := (A[t] /. sol1);
> AA[t_ /; div1 < t <= div2] := (A[t] /. sol2) ;
> AA[t_ /; div2 < t <= div3] := (A[t] /. sol3);
>
> BB[t_ /; t <= div1] := (B[t] /. sol1);
> BB[t_ /; div1 < t <= div2] := (B[t] /. sol2) ;
> BB[t_ /; div2 < t <= div3] := (B[t] /. sol3);
>
> FF[t_ /; t <= div1] := (F[t] /. sol1);
> FF[t_ /; div1 < t <= div2] := (F[t] /. sol2) ;
> FF[t_ /; div2 < t <= div3] := (F[t] /. sol3);
>
> disp = Plot[#[t], {t, 0, div3}, PlotRange -> All] &;
> GraphicsGrid[Map[disp, {{AA, BB}, {FF}}, {2}]]
>
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Plotting a recursion tree
  • Next by Date: Re: removing non-numeric elements from the table
  • Previous by thread: Re: Modification of Variable in NDSolve
  • Next by thread: Re: Re: Modification of Variable in NDSolve