[Shootout-list] n-body anomalies
Will M. Farr
farr@MIT.EDU
Thu, 5 May 2005 21:49:47 -0400
Hello,
>> What does a negative energy imply (i.e. the answer is -0.169)?
>
> Negative energy probably implies nothing at all. Energy is often taken
> from an
> arbitrary origin, such as the potential energy when all particles are
> infinitely separated
This is precisely what is happening here; E = 0 would be all the
planets at infinite distance from each other. E < 0 implies that the
system is bound (i.e. that the outer planets will not suddenly fly away
from the sun).
> but you also have to add terms like:
>
> - G M m / r
>
> for each pair of particles, where "r" is their separation.
>
> I haven't looked carefully but it looks like the code is missing "G"
> and a
> factor of "2" (as it only counts (i, j) pairs satisfying i > j). Also,
> the
> sun doesn't weigh 39kg. ;-)
Actually, the code is correct. The potential energy for each *pair* of
particles is - G m_i m_j / r_ij; the code computes the gradient of the
potential (the force on a particle) only once per pair, since grad_i(-
G m_i m_j / r_ij) = - grad_j(- G m_i m_j / r_ij) (i.e. the forces are
equal in magnitude and opposite in direction). The sun's mass is
arbitrary; in effect, you are choosing units for G by saying solar_mass
= 4 * pi * pi (an odd choice, I think; 1 would have been more natural).
Since the acceleration of particle i due to the force on particle j is
proportional to G m_j / r_ij^2, the relevant combination is G m_j.
Will