pynbody.gravity.pm

Contents

pynbody.gravity.pm#

pynbody.gravity.pm(f: SimSnap, ipos: ndarray, ngrid: int = 10, x0=None, x1=None)[source]#

Calculate the potential and acceleration for a set of particles using a Particle-Mesh algorithm.

For large numbers of particles, this is faster than, but much less accurate than, pynbody.gravity.direct(). It also takes into account periodicity of the box.

Parameters:
  • f – The snapshot to calculate the potential and acceleration for

  • ipos – The positions of the particles to calculate the potential and acceleration for

  • x0 – The lower bound of the grid in each dimension. If None, the minimum of the snapshot’s positions will be used.

  • x1 – The upper bound of the grid in each dimension. If None, x0 + f.properties['boxsize'] will be used.

Returns:

  • phi (array.SimArray) – The gravitational potential at the specified positions

  • grad_phi (array.SimArray) – The gravitational acceleration at the specified positions