1

I want to speed up a FeynCalc calculation. However I found out that it doesn't seem to work in ParallelSum or ParallelTable.

MWE:

<<FeynCalc`

ParallelTable[ With[ {exp = DiracTrace[GA[[Mu]] . GA[[Nu]], DiracTraceEvaluate -> True]}, Print[exp] ], {i, 1, 4}, DistributedContexts -> "FeynCalc`" ]

Expected Output:

4 Pair[LorentzIndex[\[Mu]], LorentzIndex[\[Nu]]
4 Pair[LorentzIndex[\[Mu]], LorentzIndex[\[Nu]]
4 Pair[LorentzIndex[\[Mu]], LorentzIndex[\[Nu]]
4 Pair[LorentzIndex[\[Mu]], LorentzIndex[\[Nu]]

Actual Output:

FeynCalc`DiracTrace[FeynCalc`GA[\[Mu]].FeynCalc`GA[\[Nu]],FeynCalc`DiracTraceEvaluate->T
FeynCalc`DiracTrace[FeynCalc`GA[\[Mu]].FeynCalc`GA[\[Nu]],FeynCalc`DiracTraceEvaluate->T
FeynCalc`DiracTrace[FeynCalc`GA[\[Mu]].FeynCalc`GA[\[Nu]],FeynCalc`DiracTraceEvaluate->T
FeynCalc`DiracTrace[FeynCalc`GA[\[Mu]].FeynCalc`GA[\[Nu]],FeynCalc`DiracTraceEvaluate->T

To me this looks like the Context is not recognized. I thought I accomodated this with DistributedContexts->"FeynCalc" but apparently this does not work.

How can I get this running?

I also tried DistributedContexts->Automatic but got the same result.

infinitezero
  • 1,419
  • 8
  • 18

1 Answers1

0

I just tried it for the heck of it and it worked.

One has to load FeynCalc` in each Kernel.

ParallelTable[<<FeynCalc`;,{i,1,4}] (* execute once *)

Now we dont even have to distribute any context

ParallelTable[
 With[
  {exp = DiracTrace[GA[\[Mu]] . GA[\[Nu]], 
     DiracTraceEvaluate -> True]},
  Print[exp]
  ], {i, 1, 4}
 ]
infinitezero
  • 1,419
  • 8
  • 18
  • 1
    I searched "parallel package" here on stack exchange and found this which might answer your question. I did not read everything but the answer uses ParallelNeeds which your parallel table might be reproducing to some degree. It might be safer/better to use ParallelNeeds, not sure. – userrandrand Oct 20 '22 at 06:43