MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Parallelize a sequence of NDSolve's

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117755] Re: Parallelize a sequence of NDSolve's
  • From: Oliver Ruebenkoenig <ruebenko at wolfram.com>
  • Date: Thu, 31 Mar 2011 03:57:36 -0500 (EST)

On Wed, 30 Mar 2011, Iv=E1n Lazaro wrote:

> Hi all!
>
> I don't understand yet the way in which the Parallel functions do the
> distribution of the job, neither how the "setup" functions distribute
> definitions. This is why I don't know what is happening in the next example:
>
> DistributeDefinitions[Bx, By, Bz, Func2, IntVar, Rhor, Al, InDelta, TRI,
> QUA, CIR, Sx1, Sy1, Sz1, B0, Theta, h, Tf, k, Axx, Axy, Axz, Ayx, Ayy, Ayz,
> Azx, Azy, Azz]
> SetSharedVariable[Phi, sol1, list, t, Bxn, Byn, Bzn]
>
> list = {};
> ParallelDo[{
>  Bxn = Bx[Theta, Phi];
>  Byn = By[Theta, Phi];
>  Bzn = Bz[Theta, Phi];
>  sol1 = NDSolve[Func2[], IntVar[], {t, 0, Tf}];
>  AppendTo[list,
>   Flatten[Subscript[Rho, 0, 0, 0, 0, 0, 0][t] + Subscript[Rho, 1, 0, 0, 1,
> 0, 0][t] /. sol1 /. t -> Tf,
>    1]];
>  }, {Phi, 0, 1, 0.1}]
> Clear[sol1];
>
> I think that the problem is with "list" variable, but this code thinks
> forever, and doesn't show any message. The function Func2[] calls a huge
> amount of another functions, Rhor, which just write down a set of 64
> differential equations. The functions TRI, QUA, CIR, Sx1, Sz1, Al, InDelta,
> are acting in there. IntVar writes down the variables to be integrated. The
> other terms that appear in DistributeDefinitions are constants. I know that
> without the actual set of equations is difficult to say something, but maybe
> i'm missing the obvious in the preamble of the parallelization.
>
> Well, thanks in advance!
>
>

Hi,

you could start from a code like this and then add the functions you need

ParallelTable might be better suited.

res = ParallelTable[
    NDSolve[{x'[t] == -y[t] - x[t]^2, y'[t] == param *x[t] - y[t]^3,
      x[0] == y[0] == 1}, {x, y}, {t, 20}]
    , {param, 2, 4, 0.1}
    ]

Manipulate[
   ParametricPlot[Evaluate[{x[t], y[t]} /. res[[i]]], {t, 0, 20}],
   {i, 1, Length[res], 1}]

Hth,

Oliver


  • Prev by Date: Re: Why Mathematica does not issue a warning when the calculations
  • Next by Date: Re: Keep Fractions Displayed Using HoldForm From Scaling Down
  • Previous by thread: Parallelize a sequence of NDSolve's
  • Next by thread: OT: structure of threads