Lorenz example

Introductory Notes

This notebook looks at the real-time trajectory of the Lorenz Attractor.
The evolution is shown as a static blue path and dynamically uses spheres at equally spaced time intervals. This approach allows the visualization of the evolution speed at different parts of the path. 
The initialization cells create the graphics in Dynamic Visualizer but do not run the animations.
Macintosh users: The amount of memory required depends on the length of path considered (set by tMax). For tMax = 16, at least 4 MB of free kernel memory is required. Additionally, we would suggest that you give Dynamic Visualizer as much memory as you can (the  partition size of 5120K should be sufficient for most systems).

Create the Graphics (Initialization)

\(Off[General::"spell1"]; 
<< DynamicVisualizer`\)

ClearVisualizer[];

Chaotic Equation Solver

tMax = 16;
LorenzCurve=NDSolve[{x'[t]==-3 (x[t] - y[t]),y'[t]==-x[t] z[t] + 26.5 x[t] - y[t],z'[t]==x[t] y[t] - z[t],x[0] == z[0] == 0,y[0] == 2},{x, y, z},{t, 0, tMax},MaxSteps -> 100 tMax];

Create Ball Graphics

\($DisplayFunction\  = \ Identity; 

    gBall = ParametricPlot3D[{Sin[u]\ Cos[t], Sin[u]\ Sin[t], Cos[u]}, {u, 0, 
          π}, {t, 0, 2\ π}, PlotPoints -> {10, 10}]; \)

Create Line Graphics

gTrajectoryLine = 
      Graphics3D[{Thickness[0.001], 
          Line[Table[
              Flatten[Evaluate[{x[t], y[t], z[t]} /. LorenzCurve]], {t, 0, 
                tMax, (1/40)}]]}];

Create the Objects in Dynamic Visualizer (Initialization)

SetOptions[$DefaultModel3D,{BoundingBox -> Off,ModelRange 
                -> {{-50, -50, -25}, {50, 50, 75}},Scale -> 2}];

CreateObject[ Object3D["Trajectory"], gTrajectoryLine, 
      Opacity -> 1, RenderMode -> WireFrame, 
      Color -> RGBColor[0, 0, 1], InteractiveMovement -> False];

\(nBalls = 4; 

    Do[ball[i] = Visualize[gBall]; 
	
      \(SetOptions[
        ball[i], {Color -> Hue[0], Scale -> 2, 
          Opacity -> 1 - \(i - 1\)\/nBalls, 
          RenderMode -> SmoothShaded, 
          InteractiveMovement -> False}]; \), {i, nBalls}]; \)

\(\(	\(SetOptions[
      ball[1], {Color -> Hue[0], Scale -> 2, 
        Opacity -> 1 - \(2 - 1\)\/nBalls, 
        RenderMode -> SmoothShaded, InteractiveMovement -> False}]; 
    \)\)\)

Animation Dynamics

ballLocations = 
      Table[Flatten[Evaluate[{x[t], y[t], z[t]} /. LorenzCurve]], {t, 0, 
          tMax, (1/20)}];

ballAnim = 
      Table[DV`SetOptions[ball[i], 
          Location -> 
            ballLocations
              [[Max[frame - (i - 1), 1]
                ]]], {frame, 1, Length[ballLocations]}, {
          i, nBalls}]; AppendTo[ballAnim, First[ballAnim]];

Visualize[ballAnim];

Adding a Rotation to the Previous Animation

angleStep = N[((4 π)/Length)[ballAnim]]; \(anim2 = 
      MapIndexed[{#1, 
            DV`SetOptions[$DefaultModel3D, 
              EulerAngles 
                -> {0, 
                  0, #2[[1]]\ 
                    angleStep}]}&, ballAnim]; 
Visualize[anim2]; \)

Move to a Specific Animation Frame

Visualize[ballAnim[[{20}]]];