MathGroup Archive 2009

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

Search the Archive

Re: Slow/jerky animations inside manipulate (more details)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100672] Re: Slow/jerky animations inside manipulate (more details)
  • From: dh <dh at metrohm.com>
  • Date: Wed, 10 Jun 2009 17:12:50 -0400 (EDT)
  • References: <h0nui5$b8s$1@smc.vnet.net>


Hi,

You have to distinguish between global and localized version of a 

variable. Here I cleand up "tp" and "T1". After this the following runs 

pretty smooth.



======================================

A = 1; De = 1; xe = 0; tp = 10;



Animate[

  sols = NDSolve[{q'[t] == p[t],

      p'[t] == 2 A De (Exp[-2 A (q[t] - xe)] - Exp[-A (q[t] - xe)]),

      q[0] == q0, p[0] == p0}, {q, p}, {t, 0, 100}][[1]];

  p1 = Graphics[{Point[{tp, Evaluate[q /. sols][tp]}]}];

  p2 = Quiet@

    Plot[Evaluate[q /. sols][T1], {T1, 0, tp},

     PerformanceGoal -> "Speed"];

  FIRSTplot = Show[p1, p2]

  , {q0, .1, 1}, {p0, .1, 1}]

======================================

Daniel







Porscha Louise McRobbie wrote:

> As several people have kindly pointed out, my first post was a bit too 

> vague (my first time with Mathgroup). I am adding more specific 

> details here. Thanks!

> 

> ------Original post: "Slow/jerky animations inside manipulate" ---------

> I have an Animate command (I'm using GraphicsRow to show two 

> side-by-side synchronized animations) inside of Manipulate. The 

> resulting animations play very fast and are jerky. I can adjust the 

> play speed using AnimationRate, but  it must be slowed down by a 

> ridiculous amount in order to look smooth. I've tried adjusting the 

> RefreshRate, as wellas making time a slider variable and animating 

> from within the Manipulate control panel,both with little success.

> How can I create smooth animations, appropriate for class demonstrations?

> -------------------------------------------------------------------------

> 

> 

> -----Additional Comments-------------------------------------------------

> My plots are actually simple. I am, however, solving an ODE inside of the

> Manipulate/Animate commands. I've played around with the NDSolve 

> options thinking it might make things faster, but again no success. 

> Basically I just want two sliders to choose initial conditions for the 

> ODEs, then animate the results.

> 

> Inside Manipulate, I solve the following ODEs, where the initial 

> conditions q0,p0 are the slider variables:

> 

> sols = First@NDSolve[{q'[t] == p[t], p'[t] == 2 A De (Exp[-2 A (q[t] - xe)] -

>           Exp[-A (q[t] - xe)]), q[0] == q0, p[0] == p0}, {q, p}, {t,0, 100}];

> 

> Inside Animate, I have two plots (tp is the animation variable):

> 

> 1.  Plot solution q(tp) vs. tp, as well as a circle that moves along 

> as the curve is being traced out:

> 

> p1 = Graphics[{ Point[{tp, Evaluate[q[tp] /. sols]}]}];

> p2 = Quiet@Plot[Evaluate[q[T1] /. sols], {T1, 0, tp}, 

> PerformanceGoal->"Speed"];

> FIRSTplot = Show[p1, p2];

> 

> 2. Plot a static background curve "Staticplot" (computed outside 

> Animate), with a circle moving on it. The equation for the background 

> curve is:

> 

> f(q)=De(1+Exp[-2 A (q-xe)]-2 Exp[-A (q-xe)])

> 

> The coordinates for Point below are {q,f(q)}.

> 

> p7 = Graphics[{Point[{Evaluate[q[tp] /. sols],

>        De (1 + Exp[-2 A (Evaluate[q[tp] /. sols] - xe)] -

>           2 Exp[-A (Evaluate[q[tp] /. sols] - xe)]) }]  }];

> SECONDplot=Show[Staticplot,p7];

> -------------------------------------------------------------------------

> Thanks again for any help.

> 




  • Prev by Date: Re: What should be a simple task....
  • Next by Date: Re: What should be a simple task....
  • Previous by thread: Slow/jerky animations inside manipulate (more details)
  • Next by thread: a graph problem-> heptagon analog to the dodecahedron