Momentum-conserving self-gravity in the Phantom. Parallel dual tree traversal for the fast multipole method
Tree codes that approximate groups of distant particles with multipole expansions accelerate gravitational force calculations. While momentum-conserving fast multipole methods exist, parallelisation is non-trivial inside a modern SPH framework. We aim for a parallel momentum and angular momentum-conserving Cartesian multipole method for the computation of the gravitational force in smoothed particle hydrodynamics (SPH) with adaptive gravitational force softening in {\sc Phantom}. We modified Dehnen's original dual tree traversal algorithm to fit the parallel architecture of {\sc Phantom} by replicating the node-node interaction on the ancestors of each leaf node in the tree. While this notionally duplicates work, it greatly simplifies the parallelisation of the algorithm. We then recover the $\mathcal{O}(N)$ scaling of the algorithm by use of caches. We also adapt the tree opening criterion for adaptive softening lengths, such that all interactions within the softening kernel are handled pairwise (as in SPH) rather than with multipole expansions, also allowing the gravity calculation to be performed alongside the SPH force evaluation. We demonstrate that the new code conserves linear and angular momentum to machine precision while giving similar force accuracy and better computational performance to the previous (non-symmetric) self-gravity solver in Phantom. Our new fast multipole method is now the default for computing self-gravity in the public code.