NBODY2014 training workshop on gravitational N-body simulations

The N-body training workshop will be held at KIAA in November 2014. The workshop consists of several lectures, but for most of the time the students will work on practical problems in the field of N-body dynamics. Students are expected to actively participate in all activities. The programming exercises can be carried out individually, but preferably in a group of two or three students. The training workshop is limited to roughly 15 students, and there is no registration fee. If you have a laptop, please bring it to the workshop.

Dates 15, 16, 22, (23) November 2014 (lectures)
17-21 November 2014 (optional research projects and individual meetings)
Location 2nd floor meeting room, Kavli Institute for Astronomy and Astrophysics, Peking University
Organizers Sverre Aarseth (Cambridge)
Rainer Spurzem (NAOC/KIAA/ARI)
Long Wang (KIAA)
Thijs Kouwenhoven (KIAA)
Prerequisites (1) The N-body simulation packages are written in the Fortran77 software package. During the workshop you will have to adjust the codes a bit. So please be familiar with the basics of Fortran77 (see, for example, here or here).
(2) For the parallel and GPU computing sections (last week) you should have an ssh software running on your computer, to make a safe connection to our parallel supercomputer at NAOC. For some exercises you may use your own GPU on your laptop, if the CUDA software is installed. It is not required to have CUDA on your laptop, we will give you access via ssh to another computer which is able to run it.
(3) You should be able to compile Fortran software on your computer. So you should install and test a Fortran compiler in advance.
(4) It is easiest to run N-body simulations from the terminal in Linux or Mac. It may be possible with Windows as well, but this may be more difficult.
Program Saturday 15 November

11:00 - 12:30 Lecture by Sverre Aarseth, hands-on exercises
12:30 - 14:00 Lunch break
14:00 - 16:00 Lecture by Sverre Aarseth, hands-on exercises
16:00 - 16:30 Coffee break
16:30 - 18:00 Lecture by Sverre Aarseth, hands-on exercises

Course materials for today:
nbody2014_hermit.tar (see Hermit4 graphically here)
nbody2014_kavli.tar
nbody2014_kavli1.pdf


Sunday 16 November

11:00 - 12:30 Lecture by Sverre Aarseth, hands-on exercises
12:30 - 14:00 Lunch break
14:00 - 16:00 Lecture by Sverre Aarseth, hands-on exercises
16:00 - 16:30 Coffee break
16:30 - 18:00 Lecture by Sverre Aarseth, hands-on exercises

Course materials for today:
nbody2014_kavli2.pdf
nbody2014_lecture2_files.zip (input.f, scale.f, intgr.f)
nbody2014_nbody6.tar.gz


Monday 17 - Friday 21 November

Individual appointments with students and researchers.


Saturday 22 November

11:00 - 12:30 Lecture by Rainer Spurzem, hands-on exercises (parallel computing)
12:30 - 14:00 Lunch break
14:00 - 16:00 Lecture by Rainer Spurzem hands-on exercises (GPU computing)
16:00 - 16:30 Coffee break
16:30 - 18:00 Lecture by Long Wang, hands-on exercises (NBODY6++GPU)

Course materials for today:
nbody2014_KIAA-lecture-2014.pdf
nbody2014_2004_GTC2010.pdf
nbody2014_2131_GTC2010.pdf
nbody2014_LaohuClusterUserManual-20130604.pdf
nbody2014_nbody6++.tgz


Sunday 23 November

Extra day, if necessary.

Contact Thijs Kouwenhoven and Wang Long

Scientific literature

Links and software downloads


NBODY2013 training workshop on gravitational N-body simulations

Dates 5, 6, 8, 20, 22, 26, and 27 November 2013
Location Seminar room, First floor, Kavli Institute for Astronomy and Astrophysics, Peking University
Organizers Sverre Aarseth (Cambridge)
Rainer Spurzem (NAOC/KIAA/ARI)
Thijs Kouwenhoven (KIAA)
Long Wang (KIAA)
Prerequisites

(1) The N-body simulation packages are written in the Fortran77 software package. During the workshop you will have to adjust the codes a bit. So please be familiar with the basics of Fortran77 (see, for example, here or here).
(2) For the parallel and GPU computing sections (last week) you should have an ssh software running on your computer, to make a safe connection to our parallel supercomputer at NAOC. For some exercises you may use your own GPU on your laptop, if the CUDA software is installed. It is not required to have CUDA on your laptop, we will give you access via ssh to another computer which is able to run it.
(3) You should be able to compile Fortran software on your computer. So you should install and test a Fortran compiler in advance.
(4) It is easiest to run N-body simulations from the terminal in Linux or Mac. It may be possible with Windows as well, but this may be more difficult.

Program Tuesday 5 November

19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 1"
20:30 - ........ Programming exercises

  • The main exercise of today is to modify the basic N-body code HERMIT, such that it includes gravitational softening.
  • Download this file to your computer. It is a gzipped tar file. On Linux or Mac, you can unpack it using the following command: tar xvfz nbody2013_lecture1_exercises.tgz
  • Compile HERMIT. This is most easily done using the Makefile. Just go into the directory of HERMIT and type make. When the compilation gives an error, you may have to adjust the commands FC and LD in the file named Makefile.
  • Before you start modifying the code, check if it runs properly. Is the total energy conserved? Do the stars and planets move how you expect them to move?
  • After you have changed the program files, you should re-compile the program again by typing make. If this doesn't work, try removing all the *.o files, and type make again.
  • Please take a look at this figure for an overview of the subroutines of HERMIT
  • Hint: change a line in fpoly1.f, in nbint.f, and in energy.f.

Wednesday 6 November

19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 2"
20:30 - ........ Programming exercises

  • Today we will continue the exercise of last week. If you haven't finished yet, try to include softening into HERMIT today.
  • For the units, please take a look at the units description of NBODY0 and HERMIT4 below.
  • If you want to calculate the semi-major axis or eccentricity of the planets orbiting the central star, you can take a look at section 4.1 of this paper.
  • The next exercise will be upgrade the HERMIT code using the additional files that were in the package that you downloaded yesterday.
  • It may help to take a look at the flow diagrams of the versions of nbody2 and nbody2h as found on the website of Sverre Aarseth.
  • NBODY6 is slightly more complicated.

Friday 8 November

19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 3"
20:30 - ........ Programming exercises

  • Today we will modify nbody2h and include general relativity. It is in the package that you downloaded yesterday. Its name is nb2.tar. You will need some other routines that are in the package, such as rpmax.f, tides3.f, tgr.f, etc.
  • The light speed should be in common.h. Note that it is in N-body units.
  • Don't forget to take a look at the file README which is included in the package.
  • In case of trouble, also take a look at the NBODY2 manual.
  • You can find a working version here (thanks Maxwell!).
  • How large will you choose the light speed? You can choose a realistic value, but you can also play god and see what happens when you lower the light speed!

Wednesday 20 November

19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 4"
20:30 - ........ Programming exercises

  • Today we learn using NBODY6, an advanced package for star cluster simulations.

Friday 22 November

19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 5"
20:30 - ........ Programming exercises

  • Be sure to take a look at the files doc/man6.pdf and at Ncode/define.f

Tuesday 26 November

19:00 - 20:30 Lecture by Rainer Spurzem "Parallel and GPU Computing with NBODY6++ (1)"
20:30 - ........ Programming exercises


Wednesday 27 November

19:00 - 20:30 Lecture by Rainer Spurzem "Parallel and GPU Computing with NBODY6++ (2)"
20:30 - ........ Programming exercises


Following weeks

Regular N-body group meetings
Question-and-answer sessions

Contact Thijs Kouwenhoven and Wang Long


NBODY2012 training workshop on gravitational N-body simulations

Dates 30 October - 22 November 2012
Location Seminar room, First floor, Kavli Institute for Astronomy and Astrophysics, Peking University
Organizers Sverre Aarseth (Cambridge), Rainer Spurzem (NAOC), Thijs Kouwenhoven (KIAA), Long Wang (DoA/KIAA)
Program 30 October 19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 1"
20:30 - ........ Programming exercises
• Take a look at Sverre's download site
• The NBODYLAB website may also be useful

1 November 19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 2"
20:30 - ........ Programming exercises
• Download the HERMIT2 code here.
• Compile the program and use the included input file to run a simulation
• How well the total energy of the system conserved? How long can you run the simulation?

6 November 19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 3"
20:30 - ........ Programming exercises
• Download Kozai0 here
• Download Kozai2 here
• Download KSREG2 here

8 November 19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 4"
20:30 - ........ Programming exercises
• Download and install NBODY6. Don't forget to look at the manual file and at the file define.f
• Play with the three-body simulator and four-body simulator

13 November 19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 5"
20:30 - ........ Programming exercises
• Look at input.pdf
• Download gpu.tar.gz

15 November 19:00 - 20:30 Lecture by Sverre Aarseth "Gravitational N-body simulations 6"
20:30 - ........ Programming exercises

20 November 19:00 - 20:30 Lecture by Rainer Spurzem "Parallel and GPU Computing with NBODY6++ (1)"
20:30 - ........ Programming exercises

22 November 19:00 - 20:30 Lecture by Rainer Spurzem "Parallel and GPU Computing with NBODY6++ (2)"
20:30 - ........ Programming exercises
• Look at the CUDA tutorial summary
• Look at the Introduction to CUDA C
• Look at the Languages, Application Programmer Interfaces and Development Tools

23 November 20:00 - ........ Informal get-together.

Following
weeks
Regular N-body group meetings
Question-and-answer sessions
Contact Thijs Kouwenhoven (柯文采)

 

N-body training workshop by Sverre Aarseth (Cambridge), 10-21 October 2010

The N-body training workshop will be held at KIAA from 10-21 October 2010. The workshop consists of several lectures, but for most of the time the students will work on practical problems in the field of N-body dynamics. Students are expected to actively participate in all activities. The programming exercises can be carried out individually, but preferably in a group of two students. The training workshop is limited to roughly 15 students, and there is no registration fee. If you have a laptop, please bring it to the workshop.

Workshop information

Dates 10-21 October 2010
Location Seminar room, Kavli Institute for Astronomy and Astrophysics, Peking University
Lecturer Sverre Aarseth (Cambridge University, UK)
Organizers Thijs Kouwenhoven (KIAA) and Doug Lin (KIAA)
Program 10 October 19:00 - 19:30 Introduction to the training workship
19:30 - 20:00 Lecture: introduction to astrophysics N-body simulations
20:00 - 21:00 Schedule and group assignments

11 October 14:00 - 15:30 Lecture 1 (groups AF)
15:30 - 18:00 Programming exercises (groups AF)
19:00 - 20:30 Lecture 1 (groups BCDEG)
20:30 - 23:00 Programming exercises (groups BCDEG)

12 October 09:00 - 12:00 Free programming
14:00 - 16:30 Lecture 2 (groups AF)
16:30 - 18:00 Programming exercises (groups AF)
19:00 - 21:30 Lecture 2 (groups BCDEG)
21:30 - 23:00 Programming exercises (groups BCDEG)

13 October 09:00 - 12:00 Free programming
14:00 - 15:30 Lecture 3 (groups AFG)
15:30 - 18:00 Programming exercises (groups AFG)
19:00 - 20:30 Lecture 3 (groups BCDE)
20:30 - 23:00 Programming exercises (groups BCDE)

14 October

09:00 - 12:00 Free programming
14:00 - 15:30 Lecture 4 (groups BFG)
15:30 - 16:00 Programming exercises (groups BFG)
16:00 - 17:00 KIAA colloquium
19:00 - 20:30 Lecture 4 (groups ACDE)
20:30 - 23:00 Programming exercises (groups ACDE)


15 October 09:00 - 12:00 Free programming
14:00 - 15:30 Lecture 5 (groups ...)
15:30 - 18:00 Programming exercises
19:00 - 20:30 Lecture 5 (groups ...)
20:30 - 23:00 Programming exercises

16 October No class

17 October 19:00 - 23:00 Exercises (all groups)

21 October 19:30 - 23:00 Practical N-body simulations with HERMIT4 (all groups)

24 October 19:30 - 23:00 Practical N-body simulations with NBODY6 (all groups)

Following
weeks
Regular N-body group meetings
Question-and-answer sessions
Contact Thijs Kouwenhoven (柯文采)

Registered participants

  • Group A - Liu Beibei, Yu Jincheng, & Li Yun
  • Group B - Du Wei & Chen Xu
  • Group C - Gao Xun & Zhang Quntao
  • Group D - Ju Wenhua & Zhang Datong
  • Group E - Zhu Wei, Liang Chen, & Jin Yifei
  • Group F - Zhang Xiaojia, Hao Wei & Zhang Zhimeng
  • Group G - Zhou Tingtao & Gong Munan

Lecture notes and exercises

  • Lecture 1
    • Download lecture 1
    • At which distance r from an object is its force F(r) largest, as a function of the softening parameter (page 3)?
    • Derive the Hermit equations in the lecture notes (page 4)
    • Install a Fortran 77/90/95 compiler on your laptop
    • Install NBODY0, and simulate a small Solar System with several planets
    • How long can you run the code before the orbits are disturbed by numerical errors?
  • Lecture 2
    • Download lecture 2
    • Why use regularization? To avoid numerical problems during close encounters.
    • What is regularization? A smart transformation in the space/time coordinates.
    • Install HERMIT4 and try simulate a full planetary systems. Will your planets collide?
  • Lecture 3
    • Download lecture 3
    • Download the upgraded version TRIPLE_NEW to carry out a simulation of three stars. Use time-reversal, to let time go backwards after some time, and look at the energy error.
    • An even newer version, TRIPLE_NEW_RELATIVISTIC, can now be downloaded. It is similar to TRIPLE_NEW, but also includes General Relativity. See you you can simulate the orbit of Mercury and Venus around the Sun, and whether you detect the periastron advance.
  • Lecture 4
    • Download lecture 4
    • Can you reproduce the Kozai cycle? What happens if you turn on General Relativity?
    • Go to www.sverre.com and play with the three-body and four-body Java simulations.
  • Lecture 5
    • Download lecture 5
    • Download NBODY6 and install it on your computer. Read the manual, and try to run one of the simulation examples.
    • Create your own input file using MCluster
  • Exercises (21 October)
    • Install and test HERMIT4
    • Modify HERMIT4, so that it outputs for each snapshot: m, x, y, z, vx, vy, vz, a, e
    • Make plots of (x,y), (vx,vy), and (x,y). How do these plots change if you vary the initial eccentricity of the Earth?
    • Make a simulation of the Earth orbiting the Sun. How well are the energy and angular momentum conserved?
    • Include the Moon as well. Make sure you use the correct velocities
    • Simulate a system with two planets. Look at the long-term evolution of the semi-major axis and eccentricity of the planets. What do you see, and why does this happen?
    • Make a simulation of a Sun and two Earths. Both Earths are in exactly the same orbit, but they are 180 degrees out of phase. How long is this system stable?
  • Exercises (24 October)
    • Coming soon...


Programming hints: NBODY0

NBODY0 is a small and elegant code which can be used to carry out N-body simulations, and can be downloaded from Sverre Aarseth's homepage. In the beginning of the code nbody0.f the initial conditions are read in:

      READ (5,*) N, ETA, DELTAT, TCRIT, EPS2
      READ (5,*) (BODY(I), (X(K,I),K=1,3), (XDOT(K,I),K=1,3),I=1,N)

You can provide the initial conditions with an input file, or by typing. The following example produces a system with one central star and two planets. The positions and velocities of all objects will be printed to the screen (100/5)=20 times during the simulation. The first line shows the program parameters. Lines 2-4 show the initial conditions for the the central star and the two planets.

      3 0.02 5 100 0
      1 0 0 0 0 0 0
      0.01 1 0 0 0 1 0
      0.001 5 0 0 0.3 -0.5 0.1

The input parameters are defined as follows:

     N = total number of objects
     ETA = accuracy parameter. For example, you can set it to 0.02 for star clusters (see warning below!)
     DELTAT = snapshot output interval, in units of [year/2π]
     TCRIT = total runtime of the simulation, in units of [year/2π]
     EPS2 = the square of the softening parameter
     BODY = mass of the object, in solar masses
     X(1), X(2), X(3) = the initial coordinates of the object, in units of [AU]
     XDOT(1), XDOT(2), XDOT(3) = the initial velocities of the object, in units of [Earth velocity]

The output parameters can be found near the bottom of nbody0.f. Note that WRITE (6,12) and WRITE (6,18) instruct the fortran compiler to look at lines 12 and 18 for the format of the output. You can easily change the output statements if necessary.

           DO 15 I = 1,N
           WRITE (6,12) BODY(I),(X(K,I),K=1,3),(XDOT(K,I),K=1,3),STEP(I)
     12   FORMAT (' M R V STEP ',F8.3,2X,3F8.3,2X,3F7.2,F10.6)
     (...........)
           WRITE (6,18) TIME, NSTEPS, 0.5*EK - POT
     18   FORMAT (' TIME =',F6.2,' NSTEPS =',I6,' ENERGY =',F12.8)

Instead of printing the results to your screen, you can also write them into a text file. This is very useful if you want to make a plot of the results with another program. To do this, you need to open an output file, and you need to adjust the WRITE statement slightly. If you want to read in the initial conditions from a file, you can follow a similar approach.

     OPEN(51,FILE='output.txt',status='unknown')
     (...........)
     WRITE(51,12) BODY(I),(X(K,I),K=1,3),(XDOT(K,I),K=1,3),STEP(I)

Warnings for NBODY0 users:

Programming hints: HERMIT4

Hermit4 is an N-body integrator which is optimized for planetary systems. The package comes with a manual; please read it carefully. A typical set of initial conditions is the following.

     1 1000.0
     4 0 0.003 10.0 100.0
     0 0 1 0 0 0 1 0 1 2
     2.0D-05 0.002 0.05 1.0D-06
     0.001 0.9 0.0 0.0 0.0 0.9 0.0
     0.001 -0.7 0.0 0.0 0.0 -1.3 0.0
     0.001 0.8 0.0 0.0 0.0 1.1 0.0
     0.001 2.0 0.0 0.0 0.0 0.7 0.0

The initial conditions are gathered in different subroutines:

     In hermit4.f
          READ (5,*) KSTART, TCOMP
     In input.f
          READ (5,*) N, NRAND, ETA, DELTAT, TCRIT
          READ (5,*) (KZ(J),J=1,10)
          (...........)
          READ (5,*) DTMIN, RMIN, ETAU, GMIN
     In data.f
          READ (5,*) BODY(I), (X(K,I),K=1,3), (XDOT(K,I),K=1,3)

The first four lines of input parameters determine the flow of the simulations. The remaining lines list the initial conditions of all particles, except the central star. In many cases, you don't need to worry too much about most of the program flow settings.

     KSTART = Restart parameter (1 = new run; 2 = restart)
     TCOMP = Maximum CPU time

     N = number of objects (except the central star!)
     NRAND = randomness parameter
     ETA = accuracy parameter. The recommended value is 0.003, but you may need to adjust it
     DELTAT = snapshot output interval
     TCRIT = total runtime of the simulation

     DTMIN = close encounter timestep
     RMIN = critical two-body separation for close encounters
     ETAU = regularized timestep parameter
     GMIN = maximum perturbation factor for unperturbed binary motion

     KZ(1) = Common dump on unit #1 on 'touch STOP' or TCRIT.
     KZ(2) = Common dump on unit #2 at TCRIT.
     KZ(3) = Indirect force terms.
     KZ(4) = Output of individual bodies (=1) or binaries (>1).
     KZ(5) = Alternative time-step expression (not recommended).
     KZ(6) = Output of eccentricity and semi-major axis.
     KZ(7) = Inelastic collision (comps replaced by c.m.).
     KZ(8) = Output on fort.8 of TIME, SEMI, R for I = KZ(8).
     KZ(9) = Removal of escapers or ECC > ECRIT (see OUTPUT).
     KZ(10) = Diagnostic output of NEW BHREG and END BHREG.

     BODY = mass of the particle
     X(1), X(2), X(3) = the initial coordinates of the object
     XDOT(1), XDOT(2), XDOT(3) = the initial velocities of the object

Programming hints: TRIPLE

TRIPLE is a fast package to simulate the interaction between three stars. The input parameters are very similar to those of the programs above. An example input file is shown below.

     1.0E-12 80.0 10.0
     3.0 1.0 4.0 0.0 0.0 0.0 0.0
     4.0 -2.0 0.0 0.0 0.0 0.0 0.0
     5.0 1.0 0.0 0.0 0.0 0.0 0.0
     5.0 -2.0 0.0 0.0 0.0 0.0 0.0
     5.0 1.0 0.0 0.0 0.0 0.0 0.0
     -5.0 1.0 0.0 0.0 0.0 0.0 0.0

The following lines read the input parameters (note that not all numbers in the above file are used):

     In triple.f:
          READ (5,*) TOL0, TCRIT
     In data.f:
          READ (5,*) M(I), (X(K,I),K=1,3), (XDOT(K,I),K=1,3)

All input parameters are identical to those in NBODY0 and HERMIT4. However, instead of ETA, we now define the accuracy of the simulations using the tolerance level TOL0. Note that the code will not work if you only put three stars in the initial conditions. You have to add another three (fake) stars. If one of the masses is negative, the program will finish succesfully.

Programming hints: TRIPLE_NEW and TRIPLE_NEW_RELATIVISTIC

TRIPLE_NEW (download) and TRIPLE_NEW_RELATIVISTIC (download) are almost the same as TRIPLE above. The integrate the motion of three stars, and allow time to reversal. So you can run the simulation for several years, reverse the velocity, and run it for the same time. In the ideal case, the stars should be back at the original positions. But due to numerical errors, there will be a small difference. You can turn on time reversal by setting the last number of on the first line to "1". TRIPLE_NEW_RELATIVISTIC also includes the effect of general relativity.

Programming hints: NBODY6

NBODY6 is the largest among Sverre Aarseth's code. It can be used to carry out N-body simulations, and includes stellar evolution, tidal fields, and many other astrophysical phenomena. The package comes with a user manual, which provides a good introduction to the package. If you install NBODY6 properly, it may also be able to use your Graphical Processing Unit (GPU) of your computer. These GPUs provide a massive speed-up of your simulations. Your laptop may have a GPU, even if you don't know it!

When compiling NBODY6 under Windows, make sure that you include all subroutines in the other directories, and also the *.h files. Under Linux or Mac, you can use the Makefile, by typing "make". There are instructions, examples, and a manual in the subdirectory "doc".

As NBODY6 is quite complex, the initial conditions files is quite large. However, there is software available that can be used to generate the initial conditions: MCluster. This package may help you save you some time when you are getting started with NBODY6. You can also use the example below for your initial conditions. The first one is the standard input file; the second one is given by Sverre Aarseth during the lecture.

     1 10000.0
     2048 1 10 199 150 1
     0.02 0.03 0.24 2.0 2.0 0.0 2.0D-04 1.0 0.5
     0 1 0 0 1 0 0 0 0 0
     0 0 0 0 0 1 0 0 0 0
     1 0 0 0 0 0 0 0 0 0
     0 0 0 0 0 0 0 0 0 1
     2.0E-06 0.0001 0.2 1.0 1.0E-06 0.001
     2.3 10.0 0.1 0 0 0.002 0.0 5.0
     0.5 0.0 0.0 0.0
     1.0

     1 10000.0
     1000 1 20 53000 100 1
     0.02 0.02 0.3 2.0 10.0 200.0 2.0E-05 0.2 0.6
     0 0 0 0 5 0 1 0 0 0
     0 0 0 1 1 1 1 0 3 4
     1 0 2 0 0 2 0 1 0 2
     1 0 2 1 1 1 0 1 0 3
     0 0 0 0 0 0 0 0 0 0
     4.0E-05 0.0003 0.2 1.0 1.0E-06 0.01
     2.3 5.0 0.2 0 0 0.02 0.0 100.0
     0.5 0.0 0.0 0.0
     0.125

Installing NBODY6 under Microsoft Windows

These instructions are ONLY for those who want to run NBODY6 under Windows. If you have Linux and Mac, please don't follow these instructions, but read the manual instead. If you are compiling NBODY6 under Windows, do the following:

  1. Save a copy of nbody6.tar.gz on a safe place. When you mess up, you can easily re-install the original files.
  2. When you unpack nbody6.tar.gz, you see four directories with data: CHAIN, DOCS, NCHAIN, and NCODE
  3. Make a new folder NWIN
  4. Copy all files of CHAIN, NCHAIN, and NCODE into the new folder NWIN
  5. Your computer will tell you that the files "params" is double. There are two copies: one is good and one is bad. Choose the file "params" that is in the NCODE directory. Check that the file contains some numbers.
  6. Same with "common6.h". You will need the file from the NCODE directory. Make sure there are some numbers and text in the file, so you know you copied the correct file.
  7. We will not need the files "Makefile", so you don't have to care about those. You can even delete them if you want.
  8. Delete the file "newhut.f". If you don't delete it, you may get an error message.
  9. Open the file RKINT.F. Change "CALL DERIV(" to "CALLDERIV5(".
  10. Open the file HIMOD.F. Change "CALL DERIV(" to "CALLDERIV6(".
  11. At the bottom of RKINT.F you find the subroutine names "deriv". Copy the whole subroutine, and paste it at the bottom of the file HIMOD.F
  12. In RKINT.F, change "subroutine deriv" to "subroutine deriv5".
  13. In HIMOD.F, change "subroutine deriv" to "subroutine deriv6".
  14. Load all files into the compiler. Make sure you load all files, not only the *.f or *.f90 files, but also *.h files etc.
  15. Clean. You can do that by selecting BUILD --> CLEAN in your compiler menu. It removes all the temporary files. You should do this regularly, before building. Especially if you keep getting errors.
  16. Ignore all warnings. We only care about the real errors now.
  17. Compile. Build. Run!
  18. Note that the installation above may not work if you have a different version of Windows or a different version of NBODY6.