pynbody.gravity.all_direct#
- pynbody.gravity.all_direct(f: SimSnap, eps: float | SimArray | None = None)[source]#
Calculate the potential and acceleration for all particles in the snapshot using a direct summation algorithm.
The results are stored inside the snapshot itself, as f[‘phi’] and f[‘acc’].
Warning
The direct summation algorithm is implemented in Cython and parallelised. Nonetheless, given the O(N^2) scaling of the algorithm, it quickly becomes prohibitive for large numbers of particles.
- Parameters:
f – The snapshot to calculate the potential and acceleration for
eps – The gravitational softening length. See
pynbody.gravity.direct()
for details of how this is used, or what happens when it is not specified.