# Moments Computation Tool

## Outline

- What is this tool for?
- What are the parameters?
  - Phase-space distribution
  - Potential
  - Energy threshold
  - GSE rotation matrix
  - Data direction
  - Integration method
- How does it work?
  - Formulas used
  - Integration method 1: sum over bins
  - Integration method 2: integration over tetrahedra

## What is this tool for?

This tool is a generic tool allowing to compute usual moments in particle distributions: density, bulk velocity, pressure tensor, heat flux and temperature. It is largely based on "Paschmann, G, AN Fazakerley, and SJ Schwartz: Moments of plasma velocity distributions, Analysis Methods for Multi-spacecraft Data, ISSI Scientific Report SR-001, 1998." Sets of parameters allow to tune the computation depending on the properties of the plasma and of the spacecraft.

It has been tested successfully comparing its results to those produced by the PEACE and CIS teams on some arbitrarily chosen events. If you get scientific results that seem strange, please ask for advice to the instrument team. If you suspect anything suspicious with the computation of the moments, or if you have any question or query, please feel free to contact the QSAS team: csc-support-dl@imperial.ac.uk.

## What are the parameters?

### Phase-space distribution

The moments computations are based on this set of data. The data must be convertible to Joules ("SI_CONVERSION" attribute), and the coordinates system must be spherical (either latitude or co-latitude for the polar angle). The tool should be able to determine the axes coordinates. If it fails, please report it to csc-support-dl@imperial.ac.uk, adding a sample piece of data to your report.

The "ENTITY" attribute is used to determine the mass and charge of the particle, defaulting to electrons if missing.

### Potential

This entry is used to compensate for the effect of the particles acceleration in the vicinity of the spacecraft. The potential is converted to energy by multiplying it with the particles charge. This value is subtracted from the energies in the distribution. "Negative energies" are discarded.

The potential must be a non-negative value. Any negative value is discarded.

### Energy threshold

This is the threshold under which energy values are discarded (before potential correction). This is used to remove the effect of photoelectrons. No correction is done (yet) to compensate for the removal of this data.

### GSE rotation matrix

In the case where the distribution coordinates are not GSE, this matrix (or sequence of matrices) is applied to the coordinates before every moments computation (first index: row, second index: column).

### Data direction

This field is used to have the possibility to reverse the coordinates if the data is in flow-direction rather than look-direction.

### Integration method

Choice between sum over bins and integration over tetrahedra.

## How does it work?

### Formulas used

Let E be an energy value. If E is lower than the photoelectron threshold, nothing is done. Else, E'=E+P.C, where P is the non-negative potential of the spacecraft and C the signed charge of the particle.

If E' is non-negative, it is converted into velocity v, knowing that 2E'=m.v (m for the particle mass) and knowing the measuring probe coordinates (and the GSE transformation matrix).

If f is the distribution function, the computed moments are:

- Density:
- Bulk velocity:
- Pressure tensor:
- Heat flux:
- Temperature:

The integration itself can be done using any of the following two methods.

### Integration method 1: sum over bins

This method is the faster of the two, it is also the most naive one. It simply consists in the sum of the elementary integrations over the bin volumes, simply approximated by multiplying the data values over the bin volumes.

In the following illustrations, the principles are shown on a partial coverage of a 2D plane. The data values are shown as red shades, and the bin boundaries are dashed lines.

A part of the 2D plane is segmented into bins, each one carrying a value.

As illustrated on two bins, the integrated value is the value multiplied by the bin volume. These values are summed to give the total integrated result.

Despite its speed, this method is flawed when the data is sparse, as gaps are not filled.

### Integration method 2: integration over tetrahedra

In this method, the space is divided into tetrahedra (triangles in the 2D illustration), which allow to fill the (convex hull of the) space even if the actual data is sparse. Each vertex of a tetraheadra carries a data value. These values are interpolated linearly over each tetrahedra and then summed over all of these.

The space is covered by triangles, some points being added by the algorithm to better approximate the data space. As illustrated on one of these triangles, the values are locally linearly integrated.

The tetrahedrisation method used is a Delaunay tetrahedrisation implemented using a QuickHull algorithm.

Two successive iterations of this algorithm may give very slightly different results, as in an homogeneous distribution of points (as often in PSD) the Delaunay triangulation is not unique, and slight perturbations are introduced in the triangulation process to cope with numerical issues.