I'm working on a N-body simulation within Mathematica, and currently I have something along these lines:
Manipulate[
{r, v, a} = Step[G, m, r, v, a, ts dt];
Show[Visualize[names, colors, radius1, r1],
PlotRange -> {{-d, +d}, {-d, +d}}, ImageSize -> 1200],
Dynamic[MatrixForm[r]],
{{dt, 0.02}, 0.0001, 1, 0.0001}]
Step[...]
simply steps the simulation forward in time. This works fine and I can confirm it works perfectly fine independent of anything else.
However, occasionally the Dynamic[MatrixForm[r]]
expression stops evaluating. I can't really figure out why it does this.
Furthermore, sometime after the Dynamic
stops evaluating, the Show[Visualize[...], ..]
expression stops evaluating.
At some point earlier when I had something much simpler along the lines of
Manipulate[f = Step[f]; Show[SimpleVisualize[f]], {...}]
The code within Manipulate
would run indefinitely. Now it seems to randomly stop. It never stops at the same time, but it always does. Any ideas why?
An example of where this occurs is available here: http://dl.dropbox.com/u/9450720/minimal.nb
Environment Information: Mathematica 8.0.4.0 on Windows 7 64-bit
Here is a basic example of what I'm doing:
Step[r_, v_, a_, dt_] := Block[{nr, nv, na},
nv = v + dt/2 a;
nr = r + dt nv;
na = -nr;
nv = nv + dt/2 a;
{nr, nv, na}]
r = {1, 0};
v = {0, 1};
a = {-1, 0};
Manipulate[{r, v, a} = Step[r, v, a, dt];
Dynamic[Show[{Graphics@Circle[{0, 0}, 1],
Graphics[{PointSize[Large], Red, Point[r]}]}]],
Dynamic[{r, Norm@r}],
{{dt, 0.005}, 0.00001, 1, 0.00001}]
This evaluates fine and runs indefinitely.
t = 3.64
$\endgroup$