# What is VELOCIraptor?

In SWIFT it is possible to run a cosmological simulation and at the same time do on the fly halo finding at specific predefined intervals. For finding the halos SWIFT uses VELOCIraptor (See Elahi, Thacker and Widrow (2011) and Elahi et al. (2019)), this is a C++ halo finder that can use MPI. It differs from other halo finder algorithms in the sense that it uses the velocity distributions of the particles in the simulations and the the positions of the particles to get a better estimate of which particles are part of a specific halo and whether there are substructures in halos. The code is hosted and maintained publicly by the theory group at ICRAR on their GitHub repository.

## The Algorithm

The VELOCIraptor algorithm consists basically of the following steps (See papers for details):

A kd-tree is constructed based on the maximization of the Shannon-entropy, this means that every level in the kd-tree an equal number of particles are distributed between the 8 lower nodes. This is based on their position and their corresponding density, this results in more equal density distributed nodes. This is also the implicit step in the algorithm that takes into account the absolute positions of the particles.

The next part is calculating the the centre of mass velocity and the velocity distribution for every individual node in the kd-tree.

Then the algorithm estimates the background velocity density function for every particle based on the cell of the particle and the six nearest neighbour cells. This prevents the background velocity density function to be over sensitive for variations between different cells due to dominant halo features in the velocity density function.

After this the algorithm searches for the nearest velocity neighbours (\(N_v\)) from a set of nearest position neighbours (\(N_x>N_v\)). The neighbours’ positions do not need to be in the cell of the particles, in general the set of nearest position neighbours is substantially larger than the nearest velocity neighbours, the default is set as \(N_x=32 N_v\).

The individual local velocity density function is calculated for every particle.

The fractional difference is calculated between the local velocity density function and the background velocity density function.

Based on the calculated ratio, outliers are picked and the outliers are grouped together in halos and subhalos.