next up previous contents
Next: 8. A More Modular Up: 7. A General -Body Previous: 7.5 Variable Time Steps:

7.6 Further Improvements

That's all it took to change our code from a toy version of an integrator to a real $N$-body code with which we are ready to start doing production runs on concrete astrophysical problems.

There are two caveats. Although the hermite6.C code is fully able to tackle a number of small-to-moderate size $N$-body calculations in a reasonably efficient way, it is still possible to make significant additional speed-ups, which can make the program run orders of magnitude faster for reasonably large $N$ values. One natural extension is to give each particle an individual time step. When two, three, or more particles have a simultaneous close encounter, it is important that they slow down enough to resolve the curvature in their orbits, but there is no reason, really, to force the rest of the system to join in the slow crawl. Efficient and accurate ways to implement individual time step schemes complicate the code significantly, and therefore we will postpone a treatment of that approach till a later volume in the current Pure Gravity series.

The second caveat concerns the ease of use of hermite6.C. As it stands, the user only has two handles on the way the code runs, through the command line arguments that initialize the variables dt_param and t_end. As soon as one starts performing laboratory experiments on $N$-body systems, the need will arise to have more control over, for example, the frequency of output of snapshots or the frequency of output of diagnostic information concerning energy conservation. In addition, in some cases it is convenient to echo the initial snapshot to the output as the first snapshot reported by the integrator; in other cases we may only be interested in the final snapshot, without having the output file cluttered by an extra copy of the initial conditions. Also, for debugging purposes, it would be nice to be able to specify on the command line that we would like to see information about accelerations and jerks, in addition to the standard information about positions and velocities. Finally, a `help' option would be nice to remind us how to invoke all these options.

There are other serious shortcomings in hermite6.C. Although it has two functions, it is easy to make the whole code significantly more modular, and therefore easier to extend when we want to add extra functionality. In addition, it is high time to add comments, so that other users (and we ourselves in the near future) will be reminded of what is going on, both in the flow of information and control throughout the whole file, as well as inside each function.

In the next chapter, we will address this second caveat. Without changing the overall functionality of hermite6.C, we will wind up with a far more robust, flexible, and extendible version of the program. With that version in hand, we will then try our hand at experimentation, laboratory style, simulating the behavior of star clusters.


next up previous contents
Next: 8. A More Modular Up: 7. A General -Body Previous: 7.5 Variable Time Steps:
The Art of Computational Science
2004/01/25