pynbody.gravity.calc.all_direct#
- pynbody.gravity.calc.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. If not provided, the value of
f['eps']
will be used.