[Shootout-list] n-body anomalies
Jon Harrop
jon@ffconsultancy.com
Fri, 6 May 2005 00:59:46 +0100
On Thursday 05 May 2005 03:44, Greg Buchholz wrote:
> Just a few questions about the n-body test. It looks like we're
> mostly computing the amount of round-off error in simulating our
> algorithm, correct?
Do you mean most of the code or most of the time is spent computing round-off
error?
In molecular dynamics, the particles are artificially sped up or slowed down
to maintain the energy (or, more often, the temperature). So round-off error
doesn't cause the energy to deviate when it is supposed to remain constant.
> 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.
> And why isn't energy simply computed as 1/2*m*v^2?
By "energy", you probably mean the total energy = kinetic + potential. So
you've got that kinetic term:
1/2 m v^2
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. ;-)
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists