Re: ParallelTable doesn't work, but Table does
- To: mathgroup at smc.vnet.net
- Subject: [mg101772] Re: [mg101689] ParallelTable doesn't work, but Table does
- From: Iván Lazaro <gaminster at gmail.com>
- Date: Thu, 16 Jul 2009 08:21:56 -0400 (EDT)
- References: <200907140937.FAA01989@smc.vnet.net> <4A5CD404.4040301@mit.edu>
This is the almost complete code without parallelization. Thanks for all the answers. Num = 4; Time = 600; r[r4_] := {1, 1, 1, r4}; A[a13_, a14_, a23_, a24_, a32_, a34_, a42_, a43_] := {{1, 1, a13, a14}, {1, 1, a23, a24}, {1, a32, 1, a34}, {1, a42, a43, 1}}; Variable[] := Flatten[Table[Subscript[x, i][t], {i, 1, Num}]] JacobianMatrix[funs_List, vars_List] := Outer[D, funs, vars] CondIni[] := Table[{Subscript[x, i][0] == 0.1*i}, {i, 1, Num}] Y = Table[{Subscript[x, i][t], Subscript[x, i + 4][t], Subscript[x, i + 8][t], Subscript[x, i + 12][t]}, {i, 5, 8}]; YI9 = Flatten[ Table[{Subscript[x, i][0] == If[Mod[i, 5] == 0, 1, 0, 0], Subscript[x, i + 4][0] == If[Mod[i + 4, 5] == 0, 1, 0, 0], Subscript[x, i + 8][0] == If[Mod[i + 8, 5] == 0, 1, 0, 0], Subscript[x, i + 12][0] == If[Mod[i + 12, 5] == 0, 1, 0, 0]}, {i, 5, 8}]]; YI3 = Flatten[CondIni[]]; Ecua[r4_, a13_, a14_, a23_, a24_,a32_, a34_, a42_, a43_] := Flatten[Table[ r[r4][[i]]* Subscript[x, i][ t]*(1 - Sum[ A[a13, a14, a23, a24,a32, a34, a42, a43][[i, j]] *Subscript[x, j][t], {j, 1, Num}]), {i, 1, Num}]] ; Do[ J = JacobianMatrix[ Ecua[r4_, a13_, a14_, a23_, a24_,a32_, a34_, a42_, a43_], Variable[]]; E1 = Flatten[Transpose[J.Y]]; EQ3 = Table[ D[Subscript[x, i][t], {t, 1}] == Ecua[r4_, a13_, a14_, a23_, a24_,a32_, a34_, a42_, a43_][[i]], {i, 1, 4}]; EQ9 = Table[D[Subscript[x, i][t], {t, 1}] == E1[[i - 4]], {i, 5, 20}]; sol = NDSolve[Join[EQ9, EQ3, YI3, YI9], Table[Subscript[x, i][t], {i, 1, 20}], {t, 0, Time}, MaxSteps -> Infinity, AccuracyGoal -> 2]; PhiT = Table[{Subscript[x, i][t], Subscript[x, i + 4][t], Subscript[x, i + 8][t], Subscript[x, i + 12][t]}, {i, 5, 8}] /. sol /. t -> Time]; EL=Log[PhiT] If[EL > 0, PutAppend[Join[A[a13, a14, a23, a24,a32, a34, a42, a43], r[r4], EL],"File"]], {a13, 0, 2.00, 0.01}, {a14, 0, 2.00, 0.01}, {a23, 0, 2.00, 0.01}, {a24, 0, 2.00, 0.01}, {a32, 0, 2.00, 0.01}, {a34, 0, 2.00, 0.01}, {a42, 0, 2.00, 0.01}, {a43, 0, 2.00, 0.01}, {r4, 0.01, 0.50, 0.01}] 2009/7/14 Zach Bj=F8rnson <bjornson at mit.edu> > Hi- Can you send me your notebook so I can play with it, please? -Zach > > > On 7/14/2009 3:45 PM, Iv=E1n Lazaro wrote: > >> Thanks for the answer. >> >> I tried that, but did't work. >> >> A and r, are a 4x4 matrix and a vector, respectivily. Ecua[] simply >> construct equations for NDSolve, and Variables[] do the same. JacobianMatrix >> make the Jacobian of equations given by Ecua, using the variables >> Variable[]. EQ3, EQ9, YI3, YI9 are simply defintions of equations to be >> given to NDSolve a 3-dimensional system of equations and a 9-dimensional >> respectivly. >> >> The problem i'm triyng to resolve is very time consuming, so I expected >> that parallelizing could make it faster. As an alternative, i tried with Do >> instead of Table (and ParallelDo instead of ParallelTable), but the error >> doesn't disapper. The problem seems to be in NDSolve; maybe is not posible >> parallelize many NDSolve solutions, altought they are not related. >> >
- References:
- ParallelTable doesn't work, but Table does
- From: Iván Lazaro <gaminster@gmail.com>
- ParallelTable doesn't work, but Table does