Chris Beaumont's IDL Library

Download source code

single page | use frames     summary     class     fields     routine details     file attributes



result = poten_slow(pos, mass)

This function computes the potential energy of a mass distribution. It directly sums the interactions between all particles, so it is exact (to within machine precision) but scales as N^2. The poten_tree routine is slightly (1%) less accurate, but scales as NlogN. This routine is faster for <<10^4 particles, because the algorithm is simpler. Furthermore, this routine can calculate the potential in any dimension, whereas poten_tree is restricted to 3 dimensions.

Return value

The potential energy of the system. It is assumed that G=1, so that PE = sum_i (sum j > i (m_i * m_j / r_ij) )


pos in required

A [ndim, n] array of n-dimensional particle locations

mass in required

A n element vector of masses

File attributes

Modifcation date: Mon Jul 12 19:53:21 2010
Lines: 50