Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Real time progress of NDSolve
Replies: 3   Last Post: Feb 8, 2013 5:10 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
psycho_dad

Posts: 66
Registered: 4/28/07
Real time progress of NDSolve
Posted: Feb 3, 2013 2:52 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi all,
Lately I'd been trying to solve some very complicated ODEs (they arise from modifications of General Relativity), but there were two problems:
1) NDSolve would take several (15+) minutes to solve them,
2) Many times it would actually fail as the system is very stiff.
Trying to understand what was going on and also having a real time estimate of the progress of NDSolve, I came up with the following code that actually helped me address the issues mentioned above:

data = {{0, 1}};
k = 0;
ProgressIndicator[Dynamic[k], {0, 30}]
Dynamic[ListPlot[data, Frame -> True,
PlotRange -> {{0, 31}, {0, 1.2}}]]
NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30},
StepMonitor :> (Pause[.02]; Set[k, x]; AppendTo[data, {x, y[x]}])];

The ProgressIndicator provides the real time estimate of the progress and the Dynamic+ListPlot show where NDSolve has a certain "difficulty" (notice the "hiccup" in this example at x~12). The ODE used is of course very simple and not the one I used in practice.

In any case, this is not groundbreaking or anything, but it helped me and I thing it's quite cool, so I decided to share it.

Cheers




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.