POTEN_TREE Purpose
This function computes the potential energy of a mass
distribution. It uses a divide and conquer algorithm based on the
Barnes-Hut algorithm, and scales as N(log(N)). The poten_slow
program is more accurate, but scales as N^2. Generally, this
procedure will calculate energies accurate to 1%
Inputs
pos: A [3, n] array of 3D particle locations
mass: A n element vector of masses
Keyword Parameters
theta: A precision pramater which controls the algorithm. Higher
values translate to faster run time and larger errors. A value of 1
is recommended, and usually achieves 1% accuracy. A value of 1.5
achieves 1% accuracy for >100 evenly distributed particles. Default
is 1 Outputs
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) )
Modification History
July 2010: Written by Chris Beaumont.