Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13403 > unrolled thread

Re: Real time progress of NDSolve

Started byAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
First post2013-02-06 10:51 +0000
Last post2013-02-08 10:10 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Real time progress of NDSolve Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2013-02-06 10:51 +0000
    Re: Real time progress of NDSolve "Kevin J. McCann" <kjm@KevinMcCann.com> - 2013-02-07 02:27 +0000
      Re: Real time progress of NDSolve psycho_dad <s.nesseris@gmail.com> - 2013-02-08 10:10 +0000

#13403 — Re: Real time progress of NDSolve

FromAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
Date2013-02-06 10:51 +0000
SubjectRe: Real time progress of NDSolve
Message-ID<ketckd$l7n$1@smc.vnet.net>
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

Hi,
That's a nice example. I just would like to note that with advent of M9 there is a possibility to use also Gauges for the same purpose as the indicator. Makes the same, but looks less boring. Evaluate this:

Clear[x, y, data, k];
data = {{0, 1}};
k = 0;
HorizontalGauge[Dynamic[k], {0, 30}]
Dynamic[BulletGauge[k, 20, {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]}])];

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu




[toc] | [next] | [standalone]


#13409

From"Kevin J. McCann" <kjm@KevinMcCann.com>
Date2013-02-07 02:27 +0000
Message-ID<kev3fb$pf4$1@smc.vnet.net>
In reply to#13403
It is cool. Thanks for sharing.

Kevin

On 2/6/2013 5:51 AM, Alexei Boulbitch wrote:
> 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
>
> Hi,
> That's a nice example. I just would like to note that with advent of M9 there is a possibility to use also Gauges for the same purpose as the indicator. Makes the same, but looks less boring. Evaluate this:
>
> Clear[x, y, data, k];
> data = {{0, 1}};
> k = 0;
> HorizontalGauge[Dynamic[k], {0, 30}]
> Dynamic[BulletGauge[k, 20, {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]}])];
>
> Have fun, Alexei
>
> Alexei BOULBITCH, Dr., habil.
> IEE S.A.
> ZAE Weiergewan,
> 11, rue Edmond Reuter,
> L-5326 Contern, LUXEMBOURG
>
> Office phone :  +352-2454-2566
> Office fax:       +352-2454-3566
> mobile phone:  +49 151 52 40 66 44
>
> e-mail: alexei.boulbitch@iee.lu
>
>
>
>
>

[toc] | [prev] | [next] | [standalone]


#13417

Frompsycho_dad <s.nesseris@gmail.com>
Date2013-02-08 10:10 +0000
Message-ID<kf2iuv$3o4$1@smc.vnet.net>
In reply to#13409
BTW, the original thread is here:
https://groups.google.com/d/topic/comp.soft-sys.math.mathematica/Dtkz7OQmgiI/discussion

I don't know why the messages were split.

Cheers

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web