Re: When to use Module inside Manipulate
- To: mathgroup at smc.vnet.net
- Subject: [mg101046] Re: [mg101025] When to use Module inside Manipulate
- From: Porscha Louise McRobbie <pmcrobbi at umich.edu>
- Date: Mon, 22 Jun 2009 04:23:14 -0400 (EDT)
- References: <200906211105.HAA02588@smc.vnet.net>
Bobby, Thanks so much, this works great! If I further change PerformanceGoal from "Quality" to "Speed", the animations run much smoother/faster, and with much less of a delay in using the play/pause button. Quoting DrMajorBob <btreat1 at austin.rr.com>: > I'd start more like this: > > Clear[T, Psi, anima] > Psi[x_, y_, amp_, phase_, a_, b_, T_] = > Sqrt[1 - amp^2] Exp[-I \[Pi]^2/2 (4/a^2 + 1/b^2) T] 2/Sqrt[a b] Sin[ > 2 Pi x/a] Sin[Pi y/b] + > amp Exp[I phase] Exp[-I \[Pi]^2/2 (9/a^2 + 1/b^2) T] 2/ > Sqrt[a b] Sin[3 Pi x/a] Sin[Pi y/b]; > anima[x_, y_, amp_, phase_, a_, b_] := > Animate[GraphicsRow[{Plot3D[ > Re[Psi[x, y, amp, phase, 1, 1, t]], {x, 0, 1}, {y, 0, 1}, > PlotRange -> {{0, 1}, {0, 1}, {-3, 3}}, > PerformanceGoal -> "Quality", ColorFunction -> "Rainbow", > Mesh -> None], > Plot3D[Im[Psi[x, y, amp, phase, 1, 1, t]], {x, 0, 1}, {y, 0, 1}, > PlotRange -> {{0, 1}, {0, 1}, {-3, 3}}, > ColorFunction -> "Rainbow", PerformanceGoal -> "Quality", > Mesh -> None]}, ImageSize -> 600], {t, 0.001, 5}, > AnimationRunning -> False, AnimationRate -> .05] > > DynamicModule[{amp, phase}, > Manipulate[ > anima[x, y, amp, phase, 1, 1], > {{amp, 0.5}, 0, 1, Appearance -> "Labeled", ImageSize -> Small}, > {phase, 0, 2 Pi, Appearance -> "Labeled", ImageSize -> Small}, > ControlPlacement -> Left, > SaveDefinitions -> True] > ] > > Bobby > > On Sun, 21 Jun 2009 06:05:59 -0500, Porscha Louise McRobbie > <pmcrobbi at umich.edu> wrote: > >> Hello, >> >> I have defined a 2D complex function, and made side-by-side animations >> of the Re/Im parts inside a Manipulate. >> >> As written, I have the function definition as well as the animation >> wrapped in Module, and the animation/manipulate commands work fine >> (albeit slowly). However, if I remove that Module (it seems redundant >> to me), leaving only the outer DynamicModule, the cell where the >> graphs appear is highlighted, and the animate/manipulate no longer work. >> >> Any ideas about what I'm doing wrong? I suspect I'm not understanding >> how to localize variables properly. >> >> Thanks in advance, >> Porscha >> >> >> >> DynamicModule[{amp, phase, a, b}, >> >> Manipulate[a = 1; b = 1; >> >> Module[{Psi, T}, >> >> Psi[x_, y_] = >> Sqrt[1 - amp^2] Exp[-I \[Pi]^2/2 (4/a^2 + 1/b^2) T] 2/ >> Sqrt[a b] Sin[(2 Pi x)/a] Sin[(Pi y)/b] + >> amp Exp[I phase] Exp[-I \[Pi]^2/2 (9/a^2 + 1/b^2) T] 2/ >> Sqrt[a b] Sin[(3 Pi x)/a] Sin[(Pi y)/b] ; >> >> Animate[ >> >> GraphicsRow[{Plot3D[Re[Psi[x, y] /. T -> t], {x, 0, 1}, {y, 0, 1}, >> PlotRange -> {{0, 1}, {0, 1}, {-3, 3}}, >> PerformanceGoal -> "Quality", ColorFunction -> "Rainbow", >> Mesh -> None], >> >> Plot3D[Im[Psi[x, y] /. T -> t], {x, 0, 1}, {y, 0, 1}, >> PlotRange -> {{0, 1}, {0, 1}, {-3, 3}}, >> ColorFunction -> "Rainbow", PerformanceGoal -> "Quality", >> Mesh -> None]}, ImageSize -> 600], >> >> {t, 0.001, 5}, AnimationRunning -> False, AnimationRate -> .05]], >> >> {{amp, 0.5}, 0, 1, Appearance -> "Labeled", >> ImageSize -> Small}, {phase, 0, 2 Pi, Appearance -> "Labeled", >> ImageSize -> Small}, ControlPlacement -> Left, >> SaveDefinitions -> True]] >> > > > > -- > DrMajorBob at bigfoot.com > > >
- References:
- When to use Module inside Manipulate
- From: Porscha Louise McRobbie <pmcrobbi@umich.edu>
- When to use Module inside Manipulate