Published online by Cambridge University Press: 04 May 2021
The global total-$f$ gyrokinetic particle-in-cell code XGC, used to study transport in magnetic fusion plasmas or to couple with a core gyrokinetic code while functioning as an edge gyrokinetic code, implements a five-dimensional continuum grid to perform the dissipative operations, such as plasma collisions, or to exchange the particle distribution function information with a core code. To transfer the distribution function between marker particles and a rectangular two-dimensional velocity-space grid, XGC employs a bilinear mapping. The conservation of particle density and momentum is accurate enough in this bilinear operation, but the error in the particle energy conservation can become undesirably large and cause non-negligible numerical heating in a steep edge pedestal. In the present work we update XGC to use a novel mapping technique, based on the calculation of a pseudo-inverse, to exactly preserve moments up to the order of the discretization space. We describe the details of the implementation and we demonstrate the reduced interpolation error for a tokamak test plasma using first- and second-order elements with the pseudo-inverse method and comparing with the bilinear mapping.