1
$\begingroup$

Just wondering how to control the variable X using a radio button (bar) in Manipulate because it appears to not be working. If anyone could help, that would be great!

Manipulate[
{evals, evecs} = Eigensystem[( {
 {-\[Sigma], \[Sigma], 0},
 {r - X[[3]], -1, -X[[1]]},
 {X[[2]], X[[1]], -\[Beta]}
} )];
 GraphicsColumn[{Show[VectorPlot3D[( {
    {-\[Sigma], \[Sigma], 0},
    {r - X[[3]], -1, -X[[1]]},
    {X[[2]], X[[1]], -\[Beta]}
   } ).{x, y, z}, {x, X[[1]] - 2, X[[1]] + 2}, {y, X[[2]] - 2, 
  X[[2]] + 2}, {z, X[[3]] - 2, X[[3]] + 2}, Axes -> True, 
 PerformanceGoal -> "Quality", AxesLabel -> {"x", "y", "z"}, 
 Ticks -> None],
If[evecs == Re[evecs],
 ParametricPlot3D[Evaluate[t evecs], {t, -3, 3}, 
  PlotStyle -> {{Thick, RGBColor[0.5, 0.21, 0.36]}}], {}], 
PlotRange -> 1, ImageSize -> {275, 275}]}],
Row[{Spacer[60], Dynamic[Style[Text@TraditionalForm[HoldForm[( {
        {x},
        {y},
        {z}
       } )' == Dynamic[( {
         {-\[Sigma], \[Sigma], 0},
         {r - X[[3]], -1, -X[r, \[Beta]][[1]]},
         {X[r, \[Beta]][[2]], X[r, \[Beta]][[1]], -\[Beta]}
        } )] ( {
        {x},
        {y},
        {z}
       } )]], Medium]]}], Delimiter,
{{r, 1, Style["r", Medium]}, 0, 20, .1, Appearance -> "Labeled"},
{{\[Beta], 8/3, Style["\[Beta]", Medium]}, 0, 20, .01, 
Appearance -> "Labeled"},
{{\[Sigma], 10, Style["\[Sigma]", Medium]}, 0, 50, 5, 
Appearance -> "Labeled"},
DynamicModule[{X}, 
RadioButtonBar[
X, { {0, 0, 0} -> "\!\(\*SubscriptBox[\(C\), \(0\)]\)",    
Dynamic[{Sqrt[\[Beta]*(r - 1)], Sqrt[\[Beta]*(r - 1)], r - 1}] -> 
 "\!\(\*SubscriptBox[\(C\), \(+\)]\)",  
Dynamic[{-Sqrt[\[Beta]*(r - 1)], -Sqrt[\[Beta]*(r - 1)], 
   r - 1}] -> "\!\(\*SubscriptBox[\(C\), \(-\)]\)"}]],
{evecs, 0, 1, ControlType -> None},
{evals, 0, 1, ControlType -> None}, 
Dynamic[Graphics[{PointSize[.04], RGBColor[0.5, 0.21, 0.36], 
Point[{Re[#], Im[#]}] & /@ evals}, 
PlotRange -> {{-3 - Max[Abs[evals]], 
  3 + Max[Abs[evals]]}, {-3 - Max[Abs[evals]], 
  3 + Max[Abs[evals]]}}, Axes -> True, 
AxesLabel -> {"Re(Z)", "Im(Z)"}, Ticks -> None, ImagePadding -> 33,
ImageSize -> 250, PlotLabel -> "Eigenvalues"]],
ControlPlacement -> Left, AutorunSequencing -> {1, 2, 3, 4}]

I want to be able to select between the three X values and have the axis of the VectorPlot3D and the {evals, evecs} adjust as X varies.

$\endgroup$

2 Answers 2

1
$\begingroup$

Get rid of the DynamicModule and use the following:

{{X, {0, 0, 0}}, 0, 1, ControlType -> None},
{{X0, 1, "X"}, 
 RadioButtonBar[
   Dynamic[X0, (X0 = #; 
      X = {{0, 0, 0},
           {Sqrt[β*(r - 1)], Sqrt[β*(r - 1)], r - 1},
           {-Sqrt[β*(r - 1)], -Sqrt[β*(r - 1)], r - 1}} ~Part~ X0) &],
   {1 -> "\!\(\*SubscriptBox[\(C\), \(0\)]\)", 
    2 -> "\!\(\*SubscriptBox[\(C\), \(+\)]\)", 
    3 -> "\!\(\*SubscriptBox[\(C\), \(-\)]\)"}] &}

I think it needs to be indirect (i.e. X0 is an index), because the data values for the rules in your construction, such as

{Sqrt[β*(r - 1)], Sqrt[β*(r - 1)], r - 1}

depend on dynamic variables. When you move their sliders, the value of X will no longer match the value for the button.


Maybe this is close to what you're after overall:

Manipulate[
 Show[
  VectorPlot3D[
   ({{-σ, σ, 0}, {r - X[[3]], -1, -X[[1]]}, {X[[2]], X[[1]], -β}}).{x, y, z},
    {x, X[[1]] - 2, X[[1]] + 2}, {y, X[[2]] - 2, X[[2]] + 2}, {z, X[[3]] - 2, X[[3]] + 2}, 
   Axes -> True,(*PerformanceGoal\[Rule]"Quality",*)
   AxesLabel -> {"x", "y", "z"}, Ticks -> None],
  If[evecs == Re[evecs], 
   ParametricPlot3D[Evaluate[t evecs], {t, -3, 3}, 
    PlotStyle -> {{Thick, RGBColor[0.5, 0.21, 0.36]}}, 
    PlotPoints -> 2], {}],
  PlotRange -> 1, ImageSize -> {275, 275}],

 Row[{Spacer[60], 
   Dynamic[Style[
     Text@TraditionalForm[
       HoldForm[({{x}, {y}, {z}})' == 
         Dynamic[({{-σ, σ, 0}, {r - X[[3]], -1, -X(*[r,β]*)[[1]]}, {X(*[r,β]*)[[2]], 
              X(*[r,β]*)[[1]], -β}})] ({{x}, {y}, {z}})]],
      Medium]]}],
 Delimiter,
 {{r, 1, Style["r", Medium]}, 0, 20, .1, Appearance -> "Labeled", 
  TrackingFunction -> ((r = #; updateFN[]) &)},
 {{β, 8/3, Style["β", Medium]}, 0, 20, .01, 
  Appearance -> "Labeled", 
  TrackingFunction -> ((β = #; updateFN[]) &)},
 {{σ, 10, Style["σ", Medium]}, 0, 50, 5, 
  Appearance -> "Labeled", 
  TrackingFunction -> ((σ = #; updateFN[]) &)},

 {{X, {0, 0, 0}}, 0, 1, ControlType -> None},
 {{X0, 1, "X"},
  {1 -> "\!\(\*SubscriptBox[\(C\), \(0\)]\)",
   2 -> "\!\(\*SubscriptBox[\(C\), \(+\)]\)",
   3 -> "\!\(\*SubscriptBox[\(C\), \(-\)]\)"},
  RadioButtonBar, TrackingFunction -> ((X0 = #; updateFN[]) &)},

 {evecs, ControlType -> None}, {evals, 
  ControlType -> None}, {{updateFN, updateFN}, ControlType -> None},
 Dynamic@Graphics[{PointSize[.04], RGBColor[0.5, 0.21, 0.36], 
    Point[Dynamic@ReIm@evals]}, 
   PlotRange -> 
    Dynamic@{{-3 - Max[Abs[evals]], 
       3 + Max[Abs[evals]]}, {-3 - Max[Abs[evals]], 
       3 + Max[Abs[evals]]}}, Axes -> True, 
   AxesLabel -> {"Re(Z)", "Im(Z)"}, Ticks -> None, ImagePadding -> 33,
    ImageSize -> 250, PlotLabel -> "Eigenvalues"],
 ControlPlacement -> Left, AutorunSequencing -> {1, 2, 3, 5},
 Initialization :> (
   updateFN[] := (
     X = {{0, 0, 0}, {Sqrt[β*(r - 1)], Sqrt[β*(r - 1)], r - 1},
        {-Sqrt[β*(r - 1)], -Sqrt[β*(r - 1)], r - 1}} ~Part~ X0;
     {evals, evecs} = 
      Eigensystem[({{-σ, σ, 0}, {r - X[[3]], -1, -X[[1]]}, {X[[2]], X[[1]], -β}})];
     );
   updateFN[]
   )]
$\endgroup$
5
  • $\begingroup$ I want X[[1]], X[[2]] and X[[3]] in the rest of the code to reflect the choice made in the radio buttons. The above for example, does not give me what I want as for $X=C_0$, where $X[[i]]\neq0,~\forall i\in\{1,2,3\}$ $\endgroup$
    – Jelmes
    Commented Jan 8, 2018 at 23:10
  • $\begingroup$ Ok the edited one looks better, but it doesn't adjust the {x, X[[1]] - 2, X[[1]] + 2}, {y, X[[2]] - 2, X[[2]] + 2}, {z, X[[3]] - 2, X[[3]] + 2} in VectorPlot3D $\endgroup$
    – Jelmes
    Commented Jan 8, 2018 at 23:32
  • $\begingroup$ @Jelmes Again, I'm not sure what's supposed to happen. The plot limits change when X changes for me. How are they supposed to be adjusted? Or why do you say it doesn't adjust them? Or how do you know it doesn't? I'm not sure what I'm supposed to look at. $\endgroup$
    – Michael E2
    Commented Jan 8, 2018 at 23:57
  • $\begingroup$ Set Ticks->Automatic and you'll see the values doesn't change. The VectorPlot3D should centralise around X but doesn't. $\endgroup$
    – Jelmes
    Commented Jan 9, 2018 at 0:08
  • $\begingroup$ @Jelmes That's because you override the VectorPlot3D range by setting PlotRange -> 1 in Show. $\endgroup$
    – Michael E2
    Commented Jan 9, 2018 at 0:21
0
$\begingroup$

First you could replace

DynamicModule[{X},...]

to

{{X, {0, 0, 0}, 
  ""}, {{0, 0, 0} -> 
   "\!\(\*SubscriptBox[\(C\), \(0\)]\)", {Sqrt[\[Beta]*(r - 1)], 
    Sqrt[\[Beta]*(r - 1)], r - 1} -> 
   "\!\(\*SubscriptBox[\(C\), \(+\)]\)", {-Sqrt[\[Beta]*(r - 
         1)], -Sqrt[\[Beta]*(r - 1)], r - 1} -> 
   "\!\(\*SubscriptBox[\(C\), \(-\)]\)"}, ControlType -> RadioButton}
$\endgroup$

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.