SSC Observatories

Facilities    Research    Publications    Patents    Software    SSC    Contact Us

Playing Cosmic Billiards

by John E. Hoot
San Clemente, CA
23 December 2002

Example of The Result NGC 4038 Type Collision Simulation

Click Here To See Whole Evolution

It looks like it is going to be another El-Nino winter. What is a manic amateur astronomer to do? All my observing journals are up to date. All my astro-images are processed and my equipment is cleaned and ready. Lately my answer has been to play God, at least in a figurative way. I have discovered N-body simulators.

Those of us that have studied the mathematics of astronomy know Kepler's laws, Newton's gravity and Einstein's spacetime. But all of the problems we have worked have been very simple. One planet around one star, or at most a handful of planets and we only worry about the Sun and Jupiter. Beyond that, for even the most gifted mathematicians among us, the eyes roll up in our head and we toss the pencil on the desk. But with the advent of the computer, brute force can move much more complex problems.

Over the past decade, astrophysicists have been working on a variety of computer programs that simulate large numbers of bodies (planets, stars, asteroids, comets, moons etc. to you and me). With these programs you can generate your own globular star cluster and watch it buzz like a hive of bees. Or you can create a couple of model galaxies and smack them together to see what happens. Astrophysicists are using these programs to attempt to answer fundamental questions about why the universe has evolved as it has.

Until recently, these programs have been the exclusive domain of places like the Lawrence Livermore Laboratories, CERN, The Max Planck Institute and UCSD Super computer center. Now that 2 GigaHertz machines sit on many of our desks, this stuff is within our grasp. Most of the time your PC is sitting on our desk, it is doing ABSOLUTELY NOTHING. As for that old 233MHz PC in the garage, it is certainly doing nothing. I have loaded several old machines up with these N-Body simulators and am happily smacking galaxies together as I write this note.

Most of the N-Body programs are written to run under Unix or Linux. But if you want to learn more you can find a great deal about these programs on The Web. Additionally, there is at least one website that will let you play with N-Body problems on a PC-based super computer. Here is a list of a couple of websites that you can use to learn more about N-body simulators:
This site is a good starting point. It is maintained my Pier Hut, one of the leading researchers in this field. It provides an overview of most of the simulation programs in use and links to where you can find out more about each one of them.
The Pomona college site is set up for students in their astronomy courses. It has a nice general introduction to N-body problems and then has a web based interface to NEMO, a popular simulator that will allow you to run simple models on their computers and then download the results to view in your browser. This is the easiest and most painless way to play the N-body billiards.

How The Simulators Work:
While modern computers have made numerical simulations possible, they are by no means simple. The most straightforward way to make a simulator is to create a file that contains information about your system of bodies at a discrete time. At time zero, you must specify for each object, its mass, position and velocity. Then you must write a program that projects the system forward in time and other tools to output snapshots of the system at arbitrary times in the future. This is by no means a trivial task.

The notion of entering the position, mass and velocity of 250 to 10,000 or more objects immediately leads you to realize, that you will need computer assistance to generate the initial system sets too. Most simulators allow you to automatically generate initial conditions by shape, mass distribution within the system, position and velocity of the center of mass of the system, total angular momentum of the system and so on.

Finally, you will want to create systems of systems, such as two solar systems moving past each other, or two galaxies colliding, so you must write tools to combine system, adding velocities and displacements to the sub systems. Whew! And Genesis said God did all this in 6 days!

Once you have your initial conditions, you must numerically project the system state at future times. If the only force that concerns you is gravity, you can simply use Newton's law to calculate the forces of each body with respect to all other bodies in the system using the equation:

F(a,b)= -(GMaMb/r^2)

where F is the force exerted between two objects "a" and "b" separated by distance "r". You then sum all the forces on F(a,x) where x is all the other bodies in the system. Compute what those forces will do to the position and velocity of the object during a short time interval and you have the next system state for object "a". Repeat that for all the rest of the objects and now you have the whole system state. (Sorry - no more math will follow and no quizzes)

One of the nasty aspects of this approach is that the number of calculations required increases in proportion to the square of the number of objects in the system. As systems increase in size, the computer time required goes up geometrically.

Back in the late 1980's a number of researchers at the Institute For Advanced Studies at Princeton got to looking at this problem and devised alternate solution methods where the computer time increased linearly with number of objects rather than geometrically. Several different techniques were employed. One method, call tree code, collapses multiple objects in groups. This allows you to compute the forces for each object relative to groups of objects instead of individuals. Another trick is to compute objects subject to large forces more often than objects with weak forces acting on them. Finally, some methods compute the gravitational field as a whole and them compute the field's interaction with the objects.

Regardless of the computational methods employed, any of these programs are nothing more than video games unless they are faithful simulations of the way the universe operates. Of the two programs I run, NEMO, is primarily a gravitation simulator. As such, it does not handle collisions, stellar evolution, electromagnetic forces and systems that coalesce. It also does not handle Hubble expansion, dark matter or a non-zero cosmological constant. While it has provision to add an array of static imperturbable bodies to simulate dark, weakly interacting matter, it completely ignores electromagnetic effects. The other program, STARLAB, does handle stellar evolution and interacting stellar system, but due to its astrophysical completeness it is too slow to use on models with galactic scale systems (at least on my computers).

The good news is that these are open source programs. The source and object code is freely distributed. The only request is that work based on them in publications should credit to original authors. As a programmer, I may take a cut at modifying them to test some ideas I have about the hydrodynamic effects of interstellar dust and ionizing radiation on galactic evolution.

But What Does It All Mean?
When dealing with subjects as complex as galactic evolution, the old closed form mathematics will never be adequate to understand the implication of even simple physical laws. Simulation and numerical methods are going to be a key methodology in future astrophysical theory. Such simulation systems are very difficult to verify and peer review. To be accurate, the theory they embody must be correct, the numerical realization must be appropriate and the programming must be correct. These present a daunting challenge to the scientific tradition of peer review.

One of the best practical methods is to have many different theoreticians developing codes and compare their results against each other and empirical observation. The future is promising, and thanks to the generosity of the authors and the availability of inexpensive computers, you too can play at computational astrophysics. So get out there and whack a few stars together for me.


SSC Observatories Offices:
1303 S. Ola Vista
San Clemente, CA 92682
Email: observatory <at>

Home | Consulting Principals | Support | Observatory