# How can I use FeynCalc in ParallelTable or ParallelSum?

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:

FeynCalcDiracTrace[FeynCalcGA[\[Mu]].FeynCalcGA[\[Nu]],FeynCalcDiracTraceEvaluate->T
FeynCalcDiracTrace[FeynCalcGA[\[Mu]].FeynCalcGA[\[Nu]],FeynCalcDiracTraceEvaluate->T
FeynCalcDiracTrace[FeynCalcGA[\[Mu]].FeynCalcGA[\[Nu]],FeynCalcDiracTraceEvaluate->T
FeynCalcDiracTrace[FeynCalcGA[\[Mu]].FeynCalcGA[\[Nu]],FeynCalcDiracTraceEvaluate->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.

• I don't have this package, but what happens if you just say "DistributedContexts->Automatic"? Oct 19, 2022 at 15:16
• @HansOlo same thing. Oct 19, 2022 at 16:09

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}
]

• 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. Oct 20, 2022 at 6:43