Table of Contents


directcode - simple direct N-body code


directcode [parameter=value] ...


directcode is a simple leapfrog equal-timestepping direct N-body code.

The infra-structure of the code is derived from hackcode1(1NEMO) , though most of the save and restore state code has been removed to keep the code simple.

It is possible with this code to change the softening to mean a pseudo-Newtonian interaction, using 1/r -> 1/(r-eps), where eps=3GM/c^2.


The following parameters are recognized; they may be given in any order if supplied with their keyword.
If given, initial conditions will be read from in-file in snapshot format. At most one of in, restart, or continue may be specified.
If given, results are written to out-file in snapshot format.
Number of bodies for test data, generated only if none of in, restart, or continue are specified. Default is 128.
Random number seed used in generating initial conditions. Default is 123.
If true, generate centrally concentrated test system. Default is false.
Inverse time-step, to be used with a leap-frog integrator. Default is 32.0 (32 steps per unit time).
Force softening parameter. If a negative value is given, the potential is turned into a pseudo-Newtonian one with the meaning of -eps = 3GM/c^2. Default is 0.05.
Miscellaneous control options, specified as a comma-separated list of keywords. Currently recognized keywords are: reset_time: when reading initial data, set tnow to zero; new_tout: when restarting, set new output times; mass, phi, acc: output mass, potential, acceleration data with major data outputs. The phase space coordinates are always output. It also seems that the reset_time and new_tout options have not been implemented yet. Default: mass,phase.
Time to stop integration in N-body model units. Default is 2.0.
Frequency of major N-body data outputs. Default is 4.0 (4 frames per unit time).
Frequency of minor diagnostic outputs. If this frequency is not a simple fraction of freq (see above), the program can waiste significant amounts of time. Default is 32.0 (32 diagnostic measurements per unit time).
Value for the gravitational constant. Although normally 1 in N-body units (see also units(1NEMO) ), this allows you to work in more natural units. [Default: 1]


Using eps<0 to activate the pseudo-Newtonian option does not change the units, all units need to be absorbed into eps. For example, for given eps<0, the precession rate of a planet around a star should then be 2.pi.eps/(a*(1-e^2)).

See Also

newton0(1NEMO) , hackcode1(1NEMO)


Peter Teuben


src/nbody/evolve/directcode/    source code


17-feb-04    V1.0  code written, cloned off hackcode1    PJT
29-jul-09    V1.2  allow eps<0 for pseudo-Newtonian hack    PJT
30-jul-09    V1.3  added gravc=    PJT

Table of Contents