5
$\begingroup$

I am having trouble with Animate. For no reason I can discern, my animation stop running, again and again, just about 1.5 seconds after the evaluation get started. Even with slight changes to the code, it still stops.

I am using Mathematica V10.3 on Windows 7 OS. And the computer system has enough spaces in the memory (8 GB).

My code is very simple. I just want to animate the motion of a spring. What is wrong with this?

spring[length_, radius_, n_] := 
   Module[{t = 0}, 
     ParametricPlot3D[
       {length t, radius Cos[n 2 Pi t], radius Sin[n 2 Pi t] + 1}, 
       {t, 0, 1}, 
       Boxed -> False, 
       Axes -> False, 
       PlotStyle -> {Gray, Thickness[0.015]}]];
Animate[
  Show[
    Graphics3D[{Polygon[{{0, -2, 0}, {0, 2, 0}, {0, 2, 2}, {0, -2, 2}}]}], 
    spring[time, 0.5, 10]], 
  {time, 0, 5}]

enter image description here enter image description here enter image description here enter image description here

EDIT// Solved! This was solved by inactivating the checkbox, "Suggestions bar after last output" in the Preferences.

$\endgroup$
  • 1
    $\begingroup$ Your code works fine for me, Windows 10x64 with Mathematica 10.3. Try to close "Show Suggestions Bar ..." in Preferences before you run the animation. $\endgroup$ – user36273 Dec 17 '15 at 13:51
  • 1
    $\begingroup$ This works for me on Win 7 Pro 64bit with 10.3 $\endgroup$ – Edmund Dec 17 '15 at 14:03
  • 1
    $\begingroup$ Can you clarify what you mean by "the kernel crashes" precisely (or what you mean when you say that "the kernel goes into infinite loop mode")? Use screenshots if necessary. I worry that we may not all be using the word "crash" the same way. $\endgroup$ – Szabolcs Dec 17 '15 at 16:39
  • 1
    $\begingroup$ @SmartHumanism Thanks for the clarification, the screenshot helps. This is not what is usually called a crash, so I removed that word from your post to avoid confusion. It might be some sort of performance problem. Can you check the CPU usage of both Mathematica.exe and any WolframKernel.exe processes? There will be at least two WolframKernel.exe processes, can you check both? $\endgroup$ – Szabolcs Dec 17 '15 at 18:20
  • 1
    $\begingroup$ Additionally, can you try the following: disable the suggestions bar and disable the Korean annotations. These two boxes should be unchecked. Restart Mathematica (not just the kernel, but the front end too), and try again. Is the problem still there? $\endgroup$ – Szabolcs Dec 17 '15 at 18:23
5
$\begingroup$

The problem is caused by the Suggestions Bar. I can reproduce the issue on OS X if I turn the Suggestions Bar on. I believe this is a bug.

To work around the issue, please permanently disable the Suggestions Bar as described here:

(Hiding it temporarily may not work.)

$\endgroup$
3
$\begingroup$

I recommend that you specify the step size in the Animate and use a fixed PlotRange. I also recommend that you pull the definition of the Polygon outside of the Animate since it doesn't change.

spring[length_, radius_, n_] :=
  Module[
   {t = 0},
   ParametricPlot3D[
    {length t, radius Cos[n 2 Pi t], radius Sin[n 2 Pi t] + 1},
    {t, 0, 1},
    Boxed -> False,
    Axes -> False,
    PlotStyle -> {Gray, Thickness[0.01]}]];

Module[
 {poly =
   Graphics3D[{
     Polygon[
      {{0, -2, 0}, {0, 2, 0},
       {0, 2, 2}, {0, -2, 2}}]}]},
 Animate[
  Show[
   poly,
   spring[time, 0.5, 10],
   PlotRange ->
    {{0, 5}, {-2, 2}, {0, 2}}],
  {time, 0, 5, .05}
  ]
 ]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you for your answer and advice. I will try it in a short time. $\endgroup$ – Smart Humanism Dec 17 '15 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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