• No results found

2.3 Numerical Simulations of the Antennae Galaxies

3.1.1 The N body Method

3.1.1.2 Planting and Growing a Tree Code

The most direct numerical approach to calculate the gravitational accelerations in an astrophysical N-body system would be a straight-forward summation of Equation

1

The Plummer sphere was originally introduced, and is still used routinely today, as a few- parameter fitting function to the density distribution of globular clusters (seePlummer 1911).

3.1 The Numerical Code 25

Figure 3.1: Three-dimensional cell structure of an oct-tree. The lines represent the global oct- tree structure of two systems each hostingN = 64particles; taken fromBarnes & Hut (1986).

(3.1). This approach is most often called “DirectN-body method” or “Particle-Particle (PP) method” (for a review, refer e.g. to Hockney & Eastwood 1981). However, this approach imposes prohibitively high computational costs with rising particle numbers since the number of numerical operations needed to calculate the accelerations of all

N particles increases steeply with N(N 1)N2. Nowadays, the highest-resolution

simulations of cosmological structure formation employ typical particle numbers of up to & 1011 particles (e.g. the “Millennium XXL” simulation, R. Angulo priv. comm.),

and up to a few times107 particles if gas physics is included (e.g. the “Eris” simulation

by Guedes et al. 2011). These simulations obviously have to be carried out by other code architectures, for example by structuring particles into so-called “hierarchical tree- codes” (see e.g. Appel 1985; Barnes & Hut 1986; Dehnen 2000).

In the hierarchical tree methods, contributions to the forces from nearby particles are calculated via a straight-forward direct summation. At larger distances, however, the gravitational attraction on a single particle due to a group of particles is approxi- mated by a low-order multipole expansion of the group’s gravitational potential about its common center of mass. As we will see below, the advantage of a tree code is its faster - albeit approximate - force calculation reducing the computational costs with a much more favorable scaling of only Nlog(N). This benefit can be achieved thanks to a novel method of sorting the particles into a hierarchical structure in order to achieve a quick access to single particles or whole particle groups during the force calculation.

There are different approaches of organizing theN particles of a given system in the tree. They are characterized by three main categories. First, this is the type of group-

ing the particles, which itself branches, again, into two categories: the “oct-tree” and the “binary-tree”. A comparison between these two schemes may be found in Makino

(1990), but we will outline here only the tree algorithm used by Gadget 2 which is based on the so-called “oct-tree” (Barnes & Hut 1986; Barnes 1990). As depicted graphically in Figure 3.1, in this method the tree is constructed by starting from one major cell, which contains all the particles in the system. This “root” cell is then split into eight equal-sized sub-cubes, which themselves are iteratively split into further sub- cubes in the same way. The process continues until each cell contains only one particle, representing a “leaf” of the tree, or no particle at all. The second characteristic is the order of the multipole expansion. While in Gadget 1 the expansion is calculated up to quadrupole order, from Gadget 2 on, only monopole terms are used in the force

approximations. Finally, as the third characteristic, when calculating the forces on particlei, an acceptance criterion determines whether the force due to a group of other particles at a certain distance is accepted for the force calculation or whether it has to be broken up further into smaller cells, ultimately reaching single particles in the “leaves” of the tree, if appropriate. Hence, this criterion controls the size of the error introduced into the force calculation by the approximated particle-group interaction, as well as the overall computing time. Hence, for a lower termination of the multipole extension generally a stricter acceptance criterion needs to be chosen to achieve a given accuracy in the force calculations.

The simplest and most intuitive cell-opening criterion is usually defined as

Rcrit = lj

θ +ǫ, (3.10)

where ǫ is the particle’s softening length (see Section 3.1.1.1) and lj the physical size of cell j. The accuracy parameterθ may range between zero and one, and determines the minimum distance Rcrit at which a cell may be accepted for the force calculation.

However, Gadget employs a slightly more sophisticated cell-opening criterion, after the initial start-up, which is given by

GMj R2 crit lj Rcrit 2 = α|aold i |. (3.11)

Here, Mj is the mass of cell j and aold

i is the particle’s acceleration at the last time

step. The advantage of this definition owes to the fact that the cell-opening criterion is not defined geometrically fixed, but may also adapt to the dynamics of the system.

Despite some overheads due to periodic updates and reconstructions of the tree structure, hierarchical tree-codes have led to huge savings in computing time since both tree construction and force evaluation require an order of∼ O(N(logN)) opera- tions compared to∼ O(N2) for the direct summation.

3.1 The Numerical Code 27