Chris Beaumont's IDL Library

Download source code

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



result = poten(pos, mass)

This function calculates the potential energy of a collection of point masses. It is a wrapper to poten_slow and poten_tree, and attempts to call the most efficient program.

Return value

The gavitational potential energy, given by PE = sum_i (sum j > i (m_i * m_j / r_ij) )

DESCRIPTION: The poten_tree program scales as N log N, but has more overhead than the N^2 poten_slow algorithm. Tests on a uniform grid of particles suggest that the algorithms run in similar times for ~10^4 particles. For larger systems, poten_tree is faster. This algorithm calls poten_tree, with a theta of 1.5, when nobj > 10^3


pos in required

A [3, n] array of 3D positions

mass in required

An n-element vector of masses

File attributes

Modifcation date: Mon Jul 12 20:52:14 2010
Lines: 29