1
$\begingroup$

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.

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

1 Answer 1

0
$\begingroup$

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}
 ]
$\endgroup$
1
  • 1
    $\begingroup$ 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. $\endgroup$ Oct 20, 2022 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.