University of Washington N-Body Shop
  N-Body Home  About Us    Search    Contact Info 

Overview of Direct

Direct is a tool designed to test more complicated gravity codes such as Barnes-Hut, Fast Multipole and error-controlling tree-codes as well as FFT codes. It is also the method of choice when dealing with less than about 10000 particles. The primary application remains the testing and error analysis of more sophisticated codes. Typical things looked at in analysis of errors are the distribution of relative and absolute errors in the acceleration as well as the maximum and rms values. Another application when a well understood mass distribution is calculated (such as a king model), is the analysis of the discreteness noise as a function of N. Direct uses no approximations in its calculation of the gravitational interaction, it simply sums over all pairwise interactions. This causes direct to scale as O(N^2) in CPU time.

Most gravity codes use some form of softened gravitational interaction. Direct now supports three softening methods, uniform density sphere, plummer and cubic spline softening. Both uniform density sphere and cubic spline softening (like that used in SPH) ensure that the gravitational interaction is newtonian for particles separated by more than the softening radius (twice the softening radius in the case of cubic spline). The more popular plummer softening does not have this property, and the effects of this are noticable on equilibrium models.

The method used by direct to calculate the gravitaional acceleractions and potentials is to process the interaction matrix (an NxN matrix with entry_ij being the interaction between particle i and particle j ) in blocks. The interaction matrix is also anti-symmetric with respect to accelerations (a_ij + a_ji = 0, i!=j ) and symmetric with respect to potentials (p_ij - p_ji = 0, i!=j ). This allows only the lower triangle of blocks to be calculated, with special treatment of the diagonal blocks. These considerations make direct quite a bit faster than the simplest implementation since optimal primary cache utilization is possible. A related property of this is that direct scales exactly as O(N^2) in CPU time.

Output files

Direct produces two output files, direct.acc and direct.pot:

Release 1.2 new features

New feature for release 1.2 is full support for periodic boundary conditions. The Ewald summation technique is used to take into consideration periodic boundary conditions in calculating the gravitational interactions.

Obtaining and Building Direct

To obtain direct, get the tar file from our Anonymous ftp-site at The relevant tar file is /pub/hpcc/direct-1.2.tar.Z.

To build direct,

zcat direct-1.2.tar.Z | tar xfv -


This should build direct on most systems.

See MAN page for help on using direct.

Support for this software is now being hosted on SourceForge. For problems, questions and comments concerning this software, please go to the SourceForge Astrophysical N-body Tools site.

N-Body Shop
University of Washington
Box 351580
Seattle, WA  98195-1580
(206) 543-2888 voice, (206) 685-0403 FAX
[comments to]