1
$\begingroup$

Can You advice me how to put the whole thing below into an interactive Panel, so I can values of parameters dynamically - type other values (alpha, beta, x0, y0, R, tmax) and plot updates

α = 1.0;
β = 3.2;
x0 = Pi;
y0 = 0;
R = 0.3;
tmax = 2;
splot = StreamPlot[{z*(β - α*Cos[2*ϕ]), α*(1 - z^2)*Sin[2*ϕ]}, {ϕ, 0, 2 Pi}, {z, -1, 1}, StreamStyle -> GrayLevel[0.2], PlotRange -> {{0, 2 Pi}, {-1, 1}}, StreamPoints -> Fine, StreamScale -> Tiny, ImageSize -> 1000, FrameTicks -> {{{-1, -0.5, 0.0, 0.5, 1.0}, None}, {{0, Pi/2, Pi, 3 Pi/2, 2 Pi}, None}}, FrameTicksStyle -> Directive[Black, 16], FrameLabel -> {Style["ϕ", 18, Black, "Arial"], Style["z", 18, Black, "Arial"]}, AspectRatio -> 1/Pi];
flow = Function[{t, a, b}, Evaluate[{ϕ[t, a, b], z[t, a, b]} /. First@NDSolve[{D[ϕ[t, a, b], t] == z[t, a, b]*(β - α*Cos[2*ϕ[t, a, b]]), D[z[t, a, b], t] == α*(1 - z[t, a, b]^2)*Sin[2*ϕ[t, a, b]], ϕ[0, a, b] == a, z[0, a, b] == b}, {ϕ, z}, {t, 0, tmax}, {a, x0 - R, x0 + R}, {b, y0 - R, y0 + R}]], Listable];
circlePts = With[{n = 1000}, Table[{x0, y0} + R*{Cos[t], Sin[t]}, {t, 0, 2 Pi - 2 Pi/n, 2 Pi/n}]];
Manipulate[Show[splot, Graphics[GraphicsComplex[Dynamic@flow[t, circlePts[[All, 1]],  circlePts[[All, 2]]], {Opacity[0.6], Red, Polygon[Range@Length@circlePts]}]], AspectRatio -> Automatic], {t, 0., tmax}]

based on How to draw the image of a circle under the action of a transformation of the phase flow?.

$\endgroup$
1
  • 2
    $\begingroup$ In your comments to my deleted answer you said you want a dynamic module. That information should be explicit in the question. See other examples on this site of DynamicModule and you will be able to convert the manipulate to a dynamic module without much problem. When you have given it a try post your code if you are still having problems. $\endgroup$ Commented Jan 17, 2015 at 23:17

1 Answer 1

1
$\begingroup$
Manipulate[
 splot = StreamPlot[{z*(\[Beta] - \[Alpha]*
        Cos[2*\[Phi]]), \[Alpha]*(1 - z^2)*Sin[2*\[Phi]]}, {\[Phi], 0,
     2 Pi}, {z, -1, 1}, StreamStyle -> GrayLevel[0.2], 
   PlotRange -> {{0, 2 Pi}, {-1, 1}}, StreamPoints -> Fine, 
   StreamScale -> Tiny, ImageSize -> 1000, 
   FrameTicks -> {{{-1, -0.5, 0.0, 0.5, 1.0}, 
      None}, {{0, Pi/2, Pi, 3 Pi/2, 2 Pi}, None}}, 
   FrameTicksStyle -> Directive[Black, 16], 
   FrameLabel -> {Style["\[Phi]", 18, Black, "Arial"], 
     Style["z", 18, Black, "Arial"]}, AspectRatio -> 1/Pi];
 flow = Function[{t, a, b}, 
   Evaluate[{\[Phi][t, a, b], z[t, a, b]} /. 
     First@NDSolve[{D[\[Phi][t, a, b], t] == 
         z[t, a, b]*(\[Beta] - \[Alpha]*Cos[2*\[Phi][t, a, b]]), 
        D[z[t, a, b], t] == \[Alpha]*(1 - z[t, a, b]^2)*
          Sin[2*\[Phi][t, a, b]], \[Phi][0, a, b] == a, 
        z[0, a, b] == b}, {\[Phi], z}, {t, 0, tmax}, {a, x0 - R, 
        x0 + R}, {b, y0 - R, y0 + R}]], Listable];
 circlePts = 
  With[{n = 1000}, 
   Table[{x0, y0} + R*{Cos[t], Sin[t]}, {t, 0, 2 Pi - 2 Pi/n, 
     2 Pi/n}]];
 Show[splot, 
  Graphics[GraphicsComplex[
    Dynamic@flow[t, circlePts[[All, 1]], 
      circlePts[[All, 2]]], {Opacity[0.6], Red, 
     Polygon[Range@Length@circlePts]}]], 
  AspectRatio -> Automatic], {t, 0., tmax},
 {\[Alpha], .5, 1.5},
 {\[Beta], 2, 4},
 {x0, \[Pi]/2, 3 \[Pi]},
 {y0, -.5, .5},
 {R, .1, .5},
 {tmax, 1, 3}]
$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.