PM: Adding cosmology
Mostly taken from Andrey’s PM notes
In proper coordinates, gravitational potential and equations of motion for particles:
time and spatial derivatives are also with respect to proper coordinates.
Now we change to comoving variables and make them dimensionless:
where , is the peculiar velocity and is the peculiar potential defined as (Peebles 1980)
where
To make the variables dimensionless we define:
Now using the scale factor as the time variable, the Poisson equation and the equations of motion are:
here is the overdensity in comoving coordinates and is given by:
In dimensionless variables these equations become:
where and
To do the time evolution of the DM particles, these last equations are used in the three main steps of the PM code:

Solve the Poisson equation using the density field estimated with the current particle positions.

Advance the momentum of the particles using the new potential.

Update particle positions using the new momenta ( LeapFrog scheme ).