I am trying to numerically solve Bloch equations using Euler's method. My code is the following
γ = 1.;
b = {0., 0., 1.};
θ = π/6.;
ϕ = 0.;
ic = {Cos[ϕ] Sin[θ], Sin[ϕ] Sin[θ], Cos[θ]};
m0 := ic;
m[Δt_] := m0 + Δt γ Cross[m0, b];
run[Δt_, n_] := Table[α = m[Δt]; ic = α, {t, 1, n}];
run1 = run[0.01, 1000];
ListPlot[Table[Flatten[Take[run1, All, {j}]], {j, 3}], Joined -> True, PlotRange -> All, PlotStyle -> Thick]
This gives the correct result. However if I use ParallelTable instead of Table
run[Δt_, n_] := ParallelTable[α = m[Δt]; ic = α, {t, 1, n}];
I get the following
What is the cause of this? ParallelTable also takes longer than Table as well. Sorry I can't get the formatting of the greek letters correctly...
\[Phi]
.) $\endgroup$ic
. Better, I believe to calculate trajectories of multiple particles in parallel than to try to compute the trajectory of one particle with multiple processors. $\endgroup$