Table of Contents


nbody5 - Regularized AC N-body code with triple & binary collisions.


nbody5 < parameter_file > log_file


nbody5 is a regularized Ahmed-Cohen N-body code with triple & binary collisions.


The input parameters are given in a small ASCII parameter_file (which can also be read from standard input) in the order as detailed below

Example input parameter_file for the standard internal benchmark (a 100-body problem integrated for 20 crossing times):

1 1000.0                                KSTART TCOMP
100 5 10 30 35 1                        N NFIX NCRIT NRAND NNBMAX NRUN
0.02 0.03 0.4 1.0 1.0 20.0 5.0e-05 1.0 0.6    ETAI ETAR RS0 DTADJ DELTAT TCRIT QE RBAR
1 2 0 0 1 0 1 0 0 0                             KZ(J), J=1,40
0 0 0 1 1 1 1 0 0 1
1 0 2 0 0 1 0 0 0 1
0 1 0 0 0 0 0 0 0 0
2.0e-05 1.0e-03 0.1 1.0 1.0e-06 0.01           DTMIN RMIN ETAU ECLOSE GMIN GMAX
2.3 1.1 0.1 0                                 ALPHAS, BODY1, BODYN, NBIN0
0.5 0.0 0.0 0.0                                Q VXROT VZROT RSPH2
(for comparison the original NBODY1 default parameter set:)
1 1.0                                 KSTART TCOMP
25 1 10 1                               N NFIX NRAND NRUN
0.02 1.0 5.0 2.0E-05 0.03                ETA DELTAT TCRIT QE EPS
1 0 0 0 1 1 0 0 0 0 0 0 0 0 0          KZ(J), J=1,15
2.5 5.0 1.0                            ALPHAS BODY1 BODYN
0.5 0.0 0.0 1.0 1.0                     Q VXROT VZROT RBAR ZMBAR
Note: the order of input lines may change depending on previous ones (KSTART and KZ’s in particular)

Here are, for completeness,the READ statements from the source code

binpop.f:      READ (5,*)  NBIN, SEMI0, ECC0, RATIO, RANGE, NSKIP, IDORM
cloud0.f:      READ (5,*)  NCL, RB2, VCL, SIGMA, (CLM(J),J=1,NCL),
data.f:        READ (10,*)  BODY(I), (X(K,I),K=1,3), (XDOT(K,I),K=1,3)
data.f:       - READ (5,*)  ALPHAS, BODY1, BODYN, NBIN0
hotsys.f:      READ (5,*)  SIGMA0
input.f:       READ (5,*)  N, NFIX, NCRIT, NRAND, NNBMAX, NRUN
input.f:      - READ (5,*)  ETAI, ETAR, RS0, DTADJ, DELTAT, TCRIT, QE, RBAR,
input.f:      - READ (5,*)  (KZ(J),J=1,40)
input.f:      - READ (5,*)  DTMIN, RMIN, ETAU, ECLOSE, GMIN, GMAX
input.f:       READ (5,*)  DELTAS, ORBITS(1), (GPRINT(J),J=1,K)
intide.f:      READ (5,*)  RSTAR, RTSTAR, RSYNC, EPOCH0
intide.f:      READ (5,*)  IMS, IEV, RMS, REV, IMF
modify.f:      READ (5,*)  DTA, DT, TA, TN, TC, QE1, J, K
modify.f:      READ (5,*)  ETA1, ETA2, ETA3, DTM, RM
mydump.f:     - READ (J,ERR=10,END=10)  DUMMY
mydump.f:     - READ (J)   A, B, IC, ID, E, F, G, H, IR
nbody5.f:     - READ (5,*)  KSTART, TCOMP
scale.f:      - READ (5,*)  Q, VXROT, VZROT, RSPH2
scale.f:       READ (5,*)  (X(J,I),J=1,3), (XDOT(J,I),J=1,3)

Definition of input parameters: (parameters with a * start on a new line; their type is the implicit FORTRAN specification: [I-N] for integers, [A-H,O-Z] for floating point parameters)

Control index (1: new run; >1: restart; >2: new params).
Maximum computing time in minutes, if the software knows how to compute it.
* N
Total particle number (the program is compiled with a maximum, NMAX)
Output frequency, in terms of DELTAT, of data save or binaries (option 3 & 6).
Random number sequence skip.
Run identification index.
Time-step accuracy parameter for total force polynomial.
Output time interval in units of the crossing time.
Termination time in units of the crossing time.
Energy tolerance (stop if DE/E > 5*QE & KZ(2) <= 1; restart if KZ(2) > 1)
Softening parameter.
* KZ(J)
Non-zero options for alternative paths (see table below).
Power-law index for initial mass function. (option 4 not 2)
Maximum particle mass (before scaling, if scaling option KJ(10) choosen).
Minimum particle mass before scaling.
* Q
Virial ratio (Q = 0.5 for equilibrium).
XY-velocity scaling factor (> 0 for solid-body rotation).
Z-velocity scaling factor (not used if VXROT = 0).
Virial radius in pc (for scaling to physical units).
Mean mass in solar units.
Maximum number of movie frames (option 7).
Time interval for movie output (in units of crossing time).
Displacement for subsystem (option 8).
Eccentricity of relative motion for subsystem (ECC =< 1).
Semi-major axis of binary orbit (options 10 & 12).
Eccentricity of binary.

Definition of options KZ:


  1  COMMON save on unit 1 if TCOMP > CPU or if TIME > TCRIT.
  2  COMMON save on unit 2 at output (=1); restart if DE/E > 5*QE <=2).
  3  Basic data written to unit 3 at output time (frequency NFIX). File:
  4  Initial conditions on unit 4 (=1: output; =2: input; 3=input+output).
  5  Initial conditions (=0: uniform & isotropic; =1: Plummer law).
  6  Output of significant binaries on printout.
  7  Output of movie frames on unit 7 (read NFRAME, DELTAF).
  8  Generation of two subsystems (merger experiment) (read XCM, ECC).
  9  Individual bodies printed at output time (MIN(5**KZ9,N)).
 10  No scaling of initial conditions to physical units.
 11  Modification of ETA by tolerance QE.
 12  Initial parameters for binary orbit (read SEMI, ECC).
 13  Escaper removal (R > 2*RTIDE; RTIDE = 10*RSCALE).
 14  Adjustment of coordinates & velocities to c.m. condition.
 15  --read but not used--

Input Order

The order of the input lines is very important, and can depend on previous lines. Here’s a sketch that hopefully helps you in creating input parameter files. Basically there are two types of input files: 1) a new run, and 2) restart of an unfinished run.
if KSTART=1 then          new run
    read: N, NFIX, NRAND, NRUN                            input.f
    read: ETA, DELTAT, TCRIT, QE, EPS                     input.f
    read: KZ(J),J=1,15                                    input.f
    if KZ(4)=2 then
        read(unit 4)                                      data.f
        read: ALPHAS, BODY1, BODYN                        data.f
    if KZ(12)>0 then
        read: SEMI, ECC                                   data.f
    read: Q, VXROT, VZROT, RBAR, ZMBAR                    scale.f
    if KZ(7)>0 then
        read: NFRAME, DELTAF                              scale.f
    if KZ(8)>0 then
        read: XCM, ECC                                    subsys.f
    read (unit=1)       restart                 nbody1.f
    if (KSTART>2)       restart with new parameters
        if KSTART=4 then
            read: DELTAT, TNEXT, TCRIT, QE, J, KZ(J)       modify.f
        if KSTART>=4 then
            read: ETA                                     modify.f


The above benchmark 100-body 20 crossing time experiment takes:
486dx2-66 linux 1.2.3          433"    -O
sparc 10/30 (bootes)          250"    -O
sparc 20/50? (phoenix)           90"    -O
sparc 20/50? (phoenix)           96"!!    -O4 -libmil -cg92 (bizarre!)


For NEMO the following modifications would have to be made in order for other programs to work:
The INTEGER*2 NAME(NMAX) array, defined in common5.h should not be output to OUT3, instead a local INTEGER NAMEO(NMAX) is used for this. This in order for u3tos(1NEMO) to work.
Various as yet undocumented changes by pjtl (and es).


Sverre Aarseth -


fort.1    common block restart dump file (option 1)
fort.2    common block restart dump file (option 2)
OUT3    output file (option 3)
fort.4    initial conditions input or output file  (option 4) *** not in nbody5
fort.7    formatted frame files (option 7) *** not in nbody5 ***
OUT9    ???
ESC    ascii file containing the times of each escaper
STOP    control file, when exists, program will prematurely stop.

See Also

u1tos(1NEMO) , u3tos(1NEMO) , u4tos(1NEMO) , stou4(1NEMO)

Direct Methods for N-Body Simulations by S.J. Aarseth in: Multiple Time Scales, eds. J.U. Brackbill & B.L. Cohen, Academic Press, p. 377 (1984).

NBODY0 source code in Binney & Tremaine’s Galactic Dynamics (Princeton University Press, 1987). pp.678.

Small-N Systems by S.J. Aarseth in: XXX eds. Benz, Barnes and XXX (to be published, 1994)


22-may-95    manual page written    PJT

Table of Contents