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


Groups > comp.soft-sys.math.mathematica > #1299

Re: Parallelize a sequence of NDSolve's

From Oliver Ruebenkoenig <ruebenko@wolfram.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Parallelize a sequence of NDSolve's
Date 2011-03-31 08:57 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <in1fm3$4ai$1@smc.vnet.net> (permalink)

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Parallelize a sequence of NDSolve's Oliver Ruebenkoenig <ruebenko@wolfram.com> - 2011-03-31 08:57 +0000

csiph-web