n-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by joshua...

44
N-body simulations of interacting galaxies Master of Science Thesis Per Bjerkeli Supervisor: Docent Cathy Horellou Onsala Space Observatory Department of Radio and Space Science CHALMERS UNIVERSITY OF TECHNOLOGY oteborg, Sweden, 2007

Upload: others

Post on 08-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

N-body simulations of interacting galaxies

Master of Science Thesis

Per Bjerkeli

Supervisor: Docent Cathy Horellou

Onsala Space ObservatoryDepartment of Radio and Space ScienceCHALMERS UNIVERSITY OF TECHNOLOGYGoteborg, Sweden, 2007

Page 2: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

N-body simulations of interacting galaxiesc© Per Bjerkeli, 2007

Onsala Space ObservatoryChalmers University of Technology43 992 OnsalaSweden

Cover picture: Simulation of the Medusa galaxy

Page 3: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

Abstract

This master thesis is about N-body simulations of interacting galaxies. Methods have beendeveloped to generate stable spherical systems as well as compound systems containing astellar disk and a dark matter halo. The Medusa galaxy has been modelled as an ongoingmerger between an elliptical galaxy and a smaller spiral galaxy. The simulations clearlyshow how the main observed features, especially the long tidal tail, form and evolve duringthe interaction.

The underlying theory governing potentials, kinematics and structure formation is de-scribed in detail as well as the procedures required to set up initial conditions for vari-ous types of galaxies. The Matlab programs written to generate different kinds of self-gravitating systems are not included in this report but they can be retrieved from thewebsite http://www.bjerkeli.se. The algorithm used to perform simulations is the currentversion of the treecode originally written by Joshua Barnes & Piet Hut in 1986.

i

Page 4: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

ii

Page 5: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

Acknowledgments

I want to thank Cathy Horellou for her never ending support and helpfulness during everyday of this project. The possibility to work with a supervisor that at each part of the pro-cess is so involved, interested and enthusiastic has been a privilege. Also a big ’thank you’ issent to Daniel Johansson for his scientific contribution in the form of numerous discussionsgoverning treecodes, potential theory and much more. I would also like to acknowledgeAlessandro Romeo for his contributions at the early stages of this project.

A necessary tool for this project has been the treecode 1.4 that has been used to makethe simulations. For that reason I want to thank Joshua Barnes who freely distributes thecode from his website. I would also like to thank the people around the coffee table andeveryone else that makes the Onsala Space Observatory such a nice environment to work in.

During the last weeks prior to my presentation I got a lot of help from people whoread my thesis and listened to my presentation. They contributed with valuable recom-mendations and for that reason I would like to thank John, Kalle, Moa, Susanna, Sofia andTong

iii

Page 6: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

CONTENTS CONTENTS

Contents

1 Introduction 1

2 Galaxies 32.1 The Hubble classification scheme . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Light from galaxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.3 The Mass-Luminosity ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Potentials 63.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.2 Spherical potentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.2.1 Point mass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2.2 The homogeneous sphere . . . . . . . . . . . . . . . . . . . . . . . . . 73.2.3 The Plummer model . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2.4 The Hernquist model . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.3 Potentials of flattened systems . . . . . . . . . . . . . . . . . . . . . . . . . . 83.3.1 The Toomre-Kuzmin model . . . . . . . . . . . . . . . . . . . . . . . 83.3.2 The Miyamoto model . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 Kinematics and structures 104.1 Observational background . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.2 Elliptical galaxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.2.1 The surface brightness . . . . . . . . . . . . . . . . . . . . . . . . . . 114.2.2 The Phase-space distribution function . . . . . . . . . . . . . . . . . 124.2.3 The Jeans equations . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.2.4 Deriving the differential energy distribution for a spherical system . . 14

4.3 Spiral galaxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.3.1 Epicyclic theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.3.2 Azimuthal moments of the disk . . . . . . . . . . . . . . . . . . . . . 17

4.4 Interacting galaxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.4.1 Tidal tails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.4.2 Shells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

5 The Barnes-Hut tree code 195.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.2 Structure of the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.3 Running the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

5.3.1 Optimal smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

6 Simulations of isolated systems 226.1 Units and scales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226.2 Elliptical galaxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

6.2.1 Initial conditions for the Plummer distribution . . . . . . . . . . . . . 226.2.2 Initial conditions for the Hernquist distribution . . . . . . . . . . . . 236.2.3 Simulation results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

iv

Page 7: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

CONTENTS CONTENTS

6.3 Disk galaxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246.3.1 The Miyamoto distribution . . . . . . . . . . . . . . . . . . . . . . . . 246.3.2 Simulation results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

6.4 Composite systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276.4.1 Simulation results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

7 Simulations of interacting galaxies 317.1 Interactions between ellipticals and spirals . . . . . . . . . . . . . . . . . . . 327.2 A possible scenario for the Medusa merger . . . . . . . . . . . . . . . . . . . 32

8 Conclusions and personal reflections 34

A How to use treecode 1.4 35A.1 Installation of the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35A.2 Running the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

v

Page 8: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

1 INTRODUCTION

1 Introduction

In the very beginning of time there were small quantum fluctuations in the hot distributionof matter and radiation. Because of the inflationary growth shortly after big bang, thesefluctuations became huge. In areas of high matter concentration, gravity led to the forma-tion of even higher density accumulations. This effect of gravity organized the universe intodifferent structures. The stars were clustered into galaxies. The galaxies were clustered intogroups, the groups into clusters and the clusters were organized into super clusters. Thisis a still ongoing process that can be observed and cosmologic research is made within thearea. The non linear growth of galaxies from the initial baryonic density fluctuation is afield of astronomy where a lot of simulations are carried out.

The gravitationally bound clusters of galaxies are structures of varying size and mass.A cluster may hold between less than hundred up to several thousands of galaxies. Clustersof high density contain a large fraction of elliptical galaxies, while spiral galaxies are foundmainly in low density clusters. Spiral galaxies are also frequently found in the space betweenthe large clusters. From observations one also knows that the size of individual galaxies tendto grow over time. Nearby galaxies tend to be larger than those at a higher redshift. Thefact that galaxies seem to merge with each other agrees with the fact that many observedgalaxies are in an ongoing interaction with one or several companions. Also, the meanseparation between galaxies is not more than a few ten times the galactic diameter, whichis yet another fact that supports this scenario. The characteristics of different interactionsis very much distinguished from the initial conditions. For example, there are distant in-teractions where the partners are hardly disturbed at all but there are also interactionswhere several galaxies merge into a big one. The latter ones are usually the most violenttype of interaction. Compared to the human lifetime, these interactions last for a verylong time. This is the reason why only snapshots of ongoing interactions can be observed.Although a lot of conclusions can be drawn from observations, there is a need for computa-tional simulations because they can improve the understanding of the underlying dynamics.

The first simulations were carried out by the Swedish astronomer Erik Holmberg (1941)who did some pioneering work well before the time of super computers. He used light bulbsas a representation of stars and in this way he was able to calculate the forces between starsin clusters. Although his work was very innovative it did not make any significant impacton the scientific community. It was not until more than 30 years later that the subjectbecame a hot topic. Alar and Jurij Toomre (1972) made the first computer simulations ofinteracting galaxies. Even though the computers in that time couldn’t handle many parti-cles they where able to recreate many of the ongoing collisions between galaxies that areobserved. They also contributed to the understanding of how tidal tails are formed. Fromthat time many simulations have been made and today both stars and gas are included.This makes it possible to learn how star formation is triggered.

The endeavour of understanding has also led to the development of many differentcodes that can be used for simulations. A code that only governs particles is the treecode

1

Page 9: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

1 INTRODUCTION

developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesisto simulate isolated galaxies consisting both stars and dark matter. It is also used whilesimulating interacting systems of two galaxies. One of the initial goals is to resembleinteractions where long tidal tails are created. The questions raised in this thesis work are:

• How is the treecode performing for different kind of particle distributions?

• What is the fundamental theory behind distributions of spherical and flattened sys-tems?

• How does one use this theory to create stable systems?

• What is the stability of a compound system of a disk and a dark matter halo andhow are these systems created in a good way?

• What kind of initial conditions are possible for the NGC 4194 ’Medusa’ merger?

These questions will be discussed. A careful description of the underlying mathematicsgoverning potential theory, kinematics and structure formation will also be given. Finally,a set of possible initial conditions for the Medusa galaxy will be described.

2

Page 10: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

2 GALAXIES

2 Galaxies

The main building block of the universe are the galaxies. There is a wide range of them,some more common than others. There are simple spherical galaxies containing mainlystars that show no special features. But there are also complex systems made of neutraland ionized gas, stars, dust, magnetic fields etc. The galaxies can be found as individualsystems or in groups of many galaxies. The luminosity from a galaxy can vary a lot. Thefaintest ones discovered have a luminosity not more than 100 000 times that of the sunwhile normal galaxies have a luminosity about 1012 times that of the sun. Also, the size ofa galaxy is a parameter than can have a wide range of values and it seems that galaxies aremostly made out of dark matter. This makes it even more difficult to estimate their size.Finally, galaxies collide with each other and that distinguishes them from the stars.

2.1 The Hubble classification scheme

Hubble (1926) made the first attempt to give a systematic description of the most commonstructures among galaxies. The scheme made in his paper, known as the Hubble scheme,is still used. Although the classifications to some extent are dependent on the astronomersdoing them, it is a good reference when one discusses different types of galaxies. The Hubblescheme sorts galaxies from early types on the left hand side to late types on the right. Thereare also three different types of galaxies within the scheme.

1. Elliptical galaxies are collections of stars that take the form of an ellipse. The onlything that defines the ellipse is the shape and it can for that reason vary a lot in size.They are classified as En, where n can be calculated from the formula

n = 10

(1− b

a

)(2.1)

where a is the major and b is the minor axis of the galaxy. It is easy to understandthat this makes the classification sensitive to the direction it is viewed from. Forexample, an E0 galaxy can be truly spherical or just a disk viewed face on. Furtheron, one can say that the density falls of from the middle to the outer regions and theinfluence on the brightness from the interstellar medium is small compared to othergalaxies. Approximately 2/3 of all galaxies can be classified as ellipticals.

2. Lenticular galaxies or S0 galaxies are found between the spirals and the ellipticals inthe Hubble scheme. They have in common with the ellipticals that they contain littleinterstellar matter. Like the spirals they have a flat disk made of stars but this diskdoes not show any evidence of a spiral pattern.

3. Spiral galaxies are galaxies that have a spiral pattern in the galactic disk. Spiralgalaxies can be divided into three main components. The stellar disk is the biggestvisible component that consists mainly of stars, gas and other interstellar matter. Inaddition, there is a central bulge that individually could be classified as an ellipticalgalaxy. There is also evidence for a third component of dark matter that surroundsthe disk and the bulge. The evidence for the dark matter halo is the very characteristic

3

Page 11: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

2 GALAXIES 2.2 Light from galaxies

rotation curves that spiral galaxies have. This will be discussed in detail in chapter4. The spiral structure that origins from the formation of stars in the disk can bedivided into two different subgroups. The normal Sa, Sb, Sc and the barred SBa,SBb, SBc galaxies. In barred spirals the spiral arms origin from a central bar. TheMilky Way is a spiral galaxy somewhere between an Sb and Sc.

4. Irregular galaxies are those that do not fit into any of the other three groups in theHubble scheme. The irregulars can be divided into two subgroups. The IrrI that showsome structure and the IrrII that don’t. Other galaxies that can be classified into thisgroup are the dwarf galaxies and the starburst galaxies.

Figure 2.1: The Hubble classification scheme (http://www.astro.psu.edu)

2.2 Light from galaxies

The classification of galaxies, discussed in section 2.1, is based on optical images. But alsothe distance to the galaxy is of importance when analysis are to be carried out. Distancesare an important property when it comes to the determination of absolute luminosities andmasses. In the immediate neighborhood of our own galaxy distances can be measured withthe help from variable stars. On larger scales one has to use the expansion of the universeitself to measure the distance. Consider the well known Hubble law that in terms of redshiftcan be written as

v = cz = Hd (2.2)

where z is the redshift, c the speed of light, H the Hubble constant and d the distance.There is also a range of distances too large to make use of standard candles like variablestars but too close to show any cosmological redshift that can be separated from the peculiarvelocity of the galaxy itself. In this region the distances can be inferred from observations ofdifferent components such as the sizes of H II regions or the magnitudes of globular clusters.There are also other properties that can be used to determine distances such as the color,the surface brightness and the velocity components of the galaxy. Rotational velocities can

4

Page 12: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

2 GALAXIES 2.3 The Mass-Luminosity ratio

be measured with a high accuracy from the 21 cm hydrogen line (see Sect. 4.1).

A galaxy does not have a sharp edge, which makes it impossible to determine an exacttotal luminosity. Instead one usually measures the surface brightness out to a certainvalue. 26.5 mag per square arc second is a popular choice more known as the Holmbergradius. The distribution of luminosities is determined by a luminosity function. From ob-served magnitudes of galaxies one can assume a function that determines the total numberof galaxies within a certain luminosity interval L and L+ dL. One version of this relationis the Schechter relation in the form given by Karttunen et al. (1996)

φ(L)dL = φ∗(L

L∗

)αexp

(L

L∗

)d

(L

L∗

)(2.3)

where φ∗, L∗ and α are determined from observations. The number of galaxies brighterthan the luminosity L∗ drops very rapidly. The parameter φ∗ is proportional to the spacedensity of galaxies in the region observed. The formula (2.3) overestimates the density offaint galaxies and even predicts that the total number density of galaxies is infinite whenL goes to 0. Nevertheless, most of the light comes from the galaxies with luminosities closeto L∗, and equation (2.3) can be integrated to estimate the total luminosity density.

2.3 The Mass-Luminosity ratio

The rotational velocity can be an indicator of the total mass of the galaxy. The measuredmasses can be combined with the observed luminosity to calculate the mass to light ratio,or mass to luminosity ratio M/L. The value in the solar neighborhood is M/L = 3 andassuming that this ratio is constant makes it possible to estimate the masses while observingthe luminosity. Furthermore, the masses of elliptical galaxies can be estimated using thespectral broadening caused by the velocity dispersion. The virial theorem reads

2T + Φ = 0 (2.4)

where T is the kinetic energy and Φ is the potential energy. A rough estimate of the totalkinetic energy and the total potential energy of an elliptical galaxy can be made from therelations

T =Mv2

2(2.5)

Φ = −GM2

2R(2.6)

Inserting these relations into equation (2.4) gives the total mass from the velocity dispersionv and the suitable average radius R.

M =2Rv2

G(2.7)

Knowing the total mass of the galaxy one can, due to the assumption that M/L is constant,calculate the luminosity. It seems that for very early type galaxies, no dark matter isrequired inside the Holmberg radius. The rotation curve of these kind of galaxies is alsofalling outside a certain radius.

5

Page 13: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

3 POTENTIALS

3 Potentials

3.1 Introduction

This section will encompass the details regarding potential theory. This is required knowl-edge when realistic galaxy models are to be made. The models discussed in this chapterwill be treated in more detail in chapter 6

In Newtonian physics, gravity is a force that acts instantly between all bodies in a system.With the theory of special relativity this is of course not true. However, the rotationalperiod of a typical galaxy is far longer than the time it takes the light to cross the galaxy.To use Newtonian physics while calculating forces within galaxies is not to commit a bigerror. A real galaxy contains approximately 1011 stars. Even though such a high numbercan not be modelled in a computer, as many particles as possible can be used to calculatethe forces between each particle. To avoid strong or weak encounters between stars thepotential of particles is smoothed when other particles come close.

Given a distribution of point masses in space ρ(x), the total gravitational potential canbe written as

Φ(x) = −G∫

ρ(x′)

|x′ − x|d3x′. (3.1)

The gradient of the potential is defined as the force acting on a body

F(x) = ∇∫

Gρ(x′)

|x′ − x|d3x′

= −∇Φ.

(3.2)

Calculating∇·F(x) and making use of the divergence theorem, converting a volume integralto a surface integral, the Poisson equation can be obtained

∇2Φ = 4πGρ. (3.3)

If the density is equal to 0, the right hand side of this equation becomes 0 and it is called theLaplace equation. The Poisson equation is a very important relation between gravitationalpotential and density, and the various potential density pairs that can be calculated are offundamental importance when modelling galaxies. To make a model of a galaxy, differentpotentials for different parts of the galaxy can be chosen. As an example, one potential canbe used for the dark matter halo while other potentials are used for the disk and the bulge.The Poisson equation for a compound system can be written as

∇2Φ = 4πG(ρdisk + ρbulge + ρhalo). (3.4)

Another important property of the particle distributions is the circular speed of a particlein a stable orbit. This value can be calculated from the gravitational potential as

vc(r) =

√rdΦ(r)

dr. (3.5)

The escape speed is another important quantity that is defined as

ve(r) =√

2|Φ(r)|. (3.6)

6

Page 14: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

3 POTENTIALS 3.2 Spherical potentials

3.2 Spherical potentials

When modelling spherical galaxies, halos and bulges, the natural first choice should besome kind of spherical potential. There is however an infinite number of them and someare more valid as a galaxy model than others. It is instructive to show these distributionsand in this chapter some of them will be analyzed more carefully. The mass inside a certainradius can be calculated from the density distribution

M(r) =

∫ r

0

∫ π

0

∫ 2π

0

ρ(r, θ, φ) r2 sin θdrdθdφ (3.7)

3.2.1 Point mass

The simplest spherical model is that of a point mass

Φ(r) = −GMr. (3.8)

From equation (3.5) the circular velocity is obtained

vc(r) =

√GM

r(3.9)

and the escape speed can be calculated from equation (3.6)

ve(r) =

√2GM

r. (3.10)

3.2.2 The homogeneous sphere

In the case where the density is constant, the mass distribution M(r) = 43πr3ρ and the

circular velocity is equal to the rigid body rotational speed

vc(r) =

√4πGρ

3r. (3.11)

3.2.3 The Plummer model

The models discussed up until now are of course not realistic choices when it comes todescribing spherical galaxies, bulges or halos. A better alternative is the Plummer potential.It was originally developed to characterize the distribution of stars in globular clusters butit has been widely used to model spherical galaxies. According to Plummer (1911) one canwrite the density profile as

ρ(r) =3

M

a3

[1 +

(ra

)2]−5/2

(3.12)

where a is the scale radius of the sphere. Using this density relation, the massfraction insideradius r can be calculated from equation (3.7)

M(r)

M=(ra

)3[1 +

(ra

)2]−3/2

. (3.13)

7

Page 15: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

3 POTENTIALS 3.3 Potentials of flattened systems

Using the Poisson equation (3.3), the potential can be calculated from

∇2Φ =1

r2

∂r

(r2∂Φ

∂r

)= 4πGρ(r). (3.14)

This equation can be solved analytically and the solution is

Φ(r) = −GMa

[1 +

(ra

)2]−1/2

. (3.15)

The escape velocity is now

ve(r) =

(2GM

a

)1/2 [1 +

(ra

)2]−1/4

. (3.16)

3.2.4 The Hernquist model

An even more realistic model is the one proposed by Hernquist (1990).

ρ(r) =M

a

r

1

(r + a)3. (3.17)

Again, the mass fraction inside radius r can be calculated by evaluating the integral (3.7)and dividing by the total mass

M(r)

M=

r2

(r + a)2. (3.18)

The potential can once again be calculated analytically by use of the Poisson equation (3.3)

Φ(r) = − GM

r + a. (3.19)

The maximum speed at radius r is the escape velocity. Using equation (3.6) one obtains

ve(r) =

(2GM

r + a

)1/2

. (3.20)

3.3 Potentials of flattened systems

In this section, two potentials that can be used to model flattened systems, are introduced.

3.3.1 The Toomre-Kuzmin model

The first potential is the one introduced by G. Kuzmin in 1956 and re-derived by Toomre(1963).

Φ(R, z) =GM√

R2 + (a+ |z|)2. (3.21)

8

Page 16: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

3 POTENTIALS 3.3 Potentials of flattened systems

Integrating both sides of the Poisson equation over an arbitrary volume containing the totalmass M , one can write ∫

V

∇2φ dV = 4πG

∫V

ρ dV = 4πGM. (3.22)

Applying the divergence theorem leads to

4πG

∫V

ρ dV =

∫S

∇φ ·N dS (3.23)

where ∇φ =(∂φ∂R, ∂φ∂z

)and ∂φ

∂z= GM(a+|z|)

(R2+(a+|z|)2)3/2 . For a flat system where z = 0, the surface

integral on the right hand side of equation (3.23) has the normal direction parallel to thez-axis. Since the system is flat, one can also write the volume integral on the left hand sideas a surface integral over the surface density. Using cylindrical coordinates one obtains

4πG

∫ R

0

Σ(R) dR = 2

∫ R

0

aGM

(R2 + a2)3/2dR. (3.24)

Differentiating this with respect to r for all different r gives

4πGΣ(R) = 2aGM

(R2 + a2)3/2(3.25)

which leads to the surface density

Σ(R) =1

aM

(R2 + a2)3/2. (3.26)

3.3.2 The Miyamoto model

The second potential is a combination of the Plummer sphere and the Toomre-Kuzminmodel. Depending on the choice of the constants a and b one can use it to represent eithera spherical or infinitesimally thin galaxy. Miyamoto & Nagai (1975) proposed the potential

Φ(R, z) = − GM√R2 + (a+

√z2 + b2)2

. (3.27)

Also in this case the Poisson equation can be solved analytically to obtain the density

ρ(R, z) =

(b2M

)aR2 + (a+ 3

√z2 + b2)(a+

√z2 + b2)2

[R2 + (a+√z2 + b2)2]5/2(z2 + b2)3/2

. (3.28)

The advantage of using this potential is that it is defined everywhere and its shape can beused to model a real galactic disk with a bulge. To use a flat potential is of course alsopossible but this requires the bulge to be modelled individually. The Miyamoto potentialis the one that will be used in chapter 6 and 7 to model disk galaxies.

Apart from these two potentials there are also logarithmic potentials. These can be used toobtain the flat rotation curves without adding the extra component of a dark matter halo.This theory will however not be described here.

9

Page 17: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES

4 Kinematics and structures

In chapter 3 different potentials and their behavior were discussed. The attention will nowbe turned to the orbits of stars and matter moving in these potentials. The phase spacedistribution function, which is of fundamental importance when modelling galaxies, willbe discussed as well as the mathematics behind the epicycles that stars undergo duringtheir orbits. These are the origin of the beautiful spiral arms and bars that arise in manydisk galaxies. The phase space distribution function will be examined even more in laterchapters when some specific potentials used in this work will be analyzed.

4.1 Observational background

Until 1970 all information about the kinematics of galaxies were obtained through opticalobservations. Starting from the 1920’s one had used absorption lines in spectra from ex-ternal galaxies to determine the velocities as a function of radius in galactic disks. Theserotation curves can be measured from optical observations where one looks at emission linesfrom H II regions in the outer parts of the disks. The drawback of these kind of opticalobservations is that the integration times required are very long. Also, they do not coverthe entire disk. However, they are very important to infer how stars move in the galaxy.While radio observations mainly look at the gas one can combine the two methods to drawthe conclusion that the velocity of the stars and the gas does not differ more than themeasurement error (∼ 30 km/s). This is however not entirely true in the galactic bulgewhere the gas typically has velocities two times as big as those for the stars. To study thedifferences in velocities of the two components is important when making research in thefield of star formation.

One thing that strikes the observer who looks at a rotation curve from a disk galaxy isthe shape of the curve. If one assumes a simple axisymmetric potential one may expect arapid increase in velocity from the center and outwards. This velocity will at some pointstart to decrease the farther out in the galaxy one look. Instead, when looking on a realrotation curve one may see that the curve climbs rapidly out to a distance less than a fewkpc. Instead of declining, it then remains constant throughout the entire disk. The reasonfor this is believed to be due to the presence of some dark matter that does not emit light.A large dark matter halo surrounding the galaxy could be an explanation of the problemwith flat rotation curves. In this work the presence of a dark matter halo will be used toobtain the flat rotation curves observed. When observing the gas in radio one usually usesthe 21 cm emission line of H I. This line is produced when the hydrogen electron is changingspin. This is very unlikely to happen in a single hydrogen atom. But in the interstellarmedium, the amount of hydrogen is so huge, that this transition is possible to observe.Since H I is a gas with a weak velocity dispersion it is a good trace of the spiral structurein galaxies. Even better is to observe the CO molecule that is colder and therefore tracksthe density waves at a greater detail.

10

Page 18: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES 4.2 Elliptical galaxies

Figure 4.1: The rotation curves for some spiral galaxies. (Rubin et al. (1978))

4.2 Elliptical galaxies

The analysis of kinematics governing different classes of galaxies will start with the ellipticalgalaxy. The reason is that this is the simplest one. The word simple is somewhat misleadingsince the physicists did not understand these systems in a correct way until the 1970s. Thesimple shape of a sphere or a flattened sphere led to the conclusion that elliptical galaxieswhere just spheroids more or less flattened by axisymmetric rotation. Now it is known thatan elliptical galaxy does not have any global rotation. The spectroscopic observation ofthese systems are made by studying stellar absorption lines (Ca II, Na I, Mg I, etc). Fromthese lines it is possible to determine the redshift and also the velocity dispersion from thebroadening of the lines.

4.2.1 The surface brightness

The de Vaucouleurs law describes the surface brightness as a function of radius

log10

[I(R)

I(Re)

]= −3.331

[(R

Re

)1/4

− 1

]. (4.1)

In this equation, 50 percent of the total light is radiated from within the effective radius Re

and I(Re) is the surface brightness at that radius. This relation is purely empirical and byfitting equation (4.1) to observed brightness profiles, Re and I(Re) can be determined. Stillthere may be deviations from this law in the outer parts of the galaxy. The reason couldbe that the outer parts have been disturbed by some interacting companion. For exampledwarf spherical galaxies have a surface brightness that is generally steeper than what ispredicted by equation (4.1).

11

Page 19: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES 4.2 Elliptical galaxies

4.2.2 The Phase-space distribution function

Stars in a galaxy do not collide with each other. Not even distant weak encounters areimportant when it comes to stellar interactions. For that reason a galaxy can be viewed asa non collisional system. This implies that the net force acting on a star origins from thepotential of the entire galaxy and not the potentials of nearby stars. A consequence of thisis that the speed of a star varies slowly while the star is moving on its orbit in the galacticpotential.

In a system with N stars that moves in a galactic potential Φ, the state of the systemcan be defined by the distribution function f(x,v, t). This function, that is also called thephase-space density, gives the probability density in the six dimensional phase space. Thenumber of stars at a certain position and time can be evaluated by the integral

n(x, t) =

∫ ∞

−∞

∫ ∞

−∞

∫ ∞

−∞f(x,v, t)d3xd3v. (4.2)

Using the same reasoning as Binney & Tremaine (1987) one can write the coordinates inphase space as (x,v) = w. Differentiating this, the velocity flow is obtained as w = (x, v) =(v,−∇Φ). The flow with coordinates in six dimensions can be regarded in the same wayas a flow of particles with only three dimensional coordinates. By visualizing a box wherestars enters and exits, it is reasonable to assume that the average number of stars in thebox stays the same over time. The phase space density of stars can therefore be assumed toobey a continuity equation in the same way as the density is obeying a continuity equation.

∂f

∂t+ v · ∇f −∇Φ · ∂f

∂v= 0 (4.3)

or, equivalently

∂f

∂t+

3∑i=1

(vi∂f

∂xi− ∂Φ

∂xi

∂f

∂vi

)= 0. (4.4)

Equation (4.4) is only true if stars are neither destroyed nor created. It is also requiredthat they change their positions and velocities smoothly. Otherwise an additional collisionalterm has to be included in the equation. To sum this up one can say that there has to bean incompressible fluid. In section 4.3 the spiral structures will be studied in detail. It istherefore convenient to include the cylindrical version of equation (4.4) in the mathematicalrepository

∂f

∂t+vR

∂f

∂R+vφR

∂f

∂φ+vz

∂f

∂z+

(v2φ

R− ∂Φ

∂R

)∂f

∂vR− 1

R

(vRvφ +

∂Φ

∂φ

)∂f

∂vφ− ∂Φ

∂z

∂f

∂vz= 0 (4.5)

4.2.3 The Jeans equations

Integrating the distribution function over all velocities gives∫∂f

∂td3v +

∫vi∂f

∂xid3v − ∂Φ

∂xi

∫∂f

∂vid3v = 0. (4.6)

12

Page 20: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES 4.2 Elliptical galaxies

In the first term of this equation the partial derivative may be taken outside the integralsince the velocities integrated over does not depend on time. In the same way v does notdepend on x. This makes it possible to rewrite the equation. But once again referring tothe argumentation used by Binney & Tremaine (1987) the last term on the left hand sideof the equation can be removed due to an application of the divergence theorem and thefact that f(x,v, t) = 0 at enough large velocities. The spatial density may now be definedas

ν ≡∫fd3v. (4.7)

and the mean stellar velocity

vi ≡1

ν

∫fvd3v. (4.8)

Using this in equation (4.6) one obtains

∂ν

∂t+∂(νvi)

∂xi= 0. (4.9)

Using these relations and a multiplication of equation (4.4) by vj and integrating it over allvelocities one can write

∂(νvj)

∂t+∂(νvivj)

∂xi+ ν

∂Φ

∂xj= 0 (4.10)

where

vivj ≡1

ν

∫vivjfd

3v. (4.11)

To obtain a version of the continuity equation (4.9) in cylindrical coordinates, equation(4.5) is integrated over all velocities. The equation obtained is

∂ν

∂t+

1

R

∂(RνvR)

∂R+∂(νvz)

∂z= 0. (4.12)

The mean value vivj of equation (4.11) may be broken into two parts. The first one vivjcomes from the streaming motion and the other one comes from the fact that not all starsclose to a certain position has the same velocity

σ2ij ≡ (vi − vi)(vj − vj) = vivj − vivj. (4.13)

This relation can be used in equations (4.9) and (4.10) to derive a version of the Eulerequation

ν∂vj∂t

+ νvi∂vj∂xi

= −ν ∂Φ

∂xj−∂(νσ2

ij)

∂xi. (4.14)

Equations (4.9), (4.10) and (4.14) were originally derived by Maxwell but are known as theJeans equations.

13

Page 21: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES 4.2 Elliptical galaxies

4.2.4 Deriving the differential energy distribution for a spherical system

Of fundamental importance when modeling spherical galaxies is the ability to distribute thespeeds from a given distribution function. In this section the differential energy distributionfunction will be derived from a given density profile of a spherical system.

Even if there is a risk of mix up different equations it is convenient for the calculationsto define the relative potential

ψ ≡ −Φ + Φ0 (4.15)

and the relative energy ε

ε ≡ −E + Φ0 = ψ − 1

2v2. (4.16)

Φ0 is chosen in such a way that f > 0 for ε > 0 and f = 0 for ε ≤ 0. Also, the distributionfunction is only dependent on the energy and not the angular momentum. The derivationis started by observing the Poisson equation

∇2ψ = −4πGρ = −4πG

∫fd3v. (4.17)

From equation (4.16) the energy per unit mass of a star is defined as ε = ψ−v2/2. Rearrang-ing this gives the speed as a function of the relative potential and energy v =

√2 (ψ − ε). To

leave the gravitational system a particle needs to have a speed corresponding to the relativepotential. Setting the relative energy equal to zero gives the escape velocity vesc =

√2ψ.

Using spherical symmetry one can step by step write

1

r2

d

dr

(r2dψ

dr

)= −16π2G

∫ √2ψ

0

f

(ψ − 1

2v2

)v2dv

= −16π2G

∫ ψ

0

f (ε)2(ψ − ε)√2(ψ − ε)

= −16π2G

∫ −ψ

0

f (ε)√

2 (ψ − ε)dε

= −16π2G

∫ ψ

0

f (ε)√

2 (ψ − ε)dε.

(4.18)

In order to derive the distribution function from the density profile one has to solve theAbel integral. Consider an integral of the form

f(x) =

∫ x

0

g(t)dt

(x− t)α, 0 < α < 1. (4.19)

Solving for g(t) one obtains

g(t) =sin πα

π

d

dt

∫ t

0

f(x)dx

(t− x)1−α

=sin πα

π

[∫ t

0

df

dx

dx

(t− x)1−α +f(0)

t1−α

].

(4.20)

14

Page 22: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES 4.3 Spiral galaxies

A new variant of the Poisson equation has already been derived. One can use (3.3) toget an expression for the density at radius r

ρ(r) = 4π

∫ ψ

0

f(ε)√

2(ψ − ε)dε. (4.21)

But ρ can also be expressed as a function of ψ

1√8πρ(ψ) = 2

∫ ψ

0

f(ε)√

2(ψ − ε)dε (4.22)

Differentiating this leads to1√8π

dψ=

∫ ψ

0

f(ε)dε√(ψ − ε)

. (4.23)

Equation (4.23) is an Abel integral and the solution is

f(ε) =1√8π2

d

∫ ε

0

dψ√ε− ψ

(4.24)

which is equivalent to

f(ε) =1√8π2

[∫ ε

0

d2ρ

dψ2

dψ√ε− ψ

+1√ε

(dρ

)ψ=0

]. (4.25)

Equation (4.25) is called Eddington’s formula due to its originator. This equation is ofsubstantial importance when it comes to modelling spherical galaxies in a computer.

4.3 Spiral galaxies

Spiral galaxies are the most common type of galaxy and more than 70 percent of themhave a well developed two-armed spiral structure. Also in spiral galaxies, the time betweenstar collisions is far greater than the age of the universe and it is a correct assumptionthat also the spiral galaxies are non collisional systems. Also in this case one can assumethat there is a smooth galactic potential and the stars moving in it changes their velocitiesand positions in a smooth fashion. The theoretical background that governs stability ofaxisymmetric systems will also be considered. For a flat potential it is straightforward tocalculate the rotational velocity for a particle. However, in the case where particles aregiven their rotational velocity without any dispersion, the system will immediately developinstabilities. To avoid these so called Jeans instabilities one has to introduce velocitydispersions into the system.

4.3.1 Epicyclic theory

The theory of how Jeans instabilities form and grow will not be considered in any detailin this thesis. There is a lot of literature that encompasses this subject. On the otherhand there will now be focus on the theory of how to calculate the velocity dispersions and

15

Page 23: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES 4.3 Spiral galaxies

the orbits of stars in flattened systems. The start will be with the theory describing theorbits in a galactic disk. In a similar manner as Combes et al. (2002), consider a flattenedaxisymmetric potential. One can write

r = R + δr

θ = Ωt+ δθ(4.26)

where δR and δθ are the radial and azimuthal deviations respectively and Ω is the angularvelocity for a particle on a circular orbit. The angular velocity is related to the gravitationalpotential by

Ω2 =1

R

∂Φ(R, 0)

∂r. (4.27)

If the gravitational potential is expanded in a Taylor series in a region of the circular orbitand it is also taken into consideration that there is a symmetry in the z direction one canwrite

∂Φ(R, 0)

∂R=∂Φ

∂R+ δr

∂2Φ(R, 0)

∂r2. (4.28)

The radial and azimuthal equations of motion in polar coordinates are

r − θ2r = −∂Φ

∂r

rθ + 2rθ = 0.(4.29)

Combining (4.28) and (4.29) one can write

δr − 2ΩδθR− Ω2δr = −δr∂2Φ(R, 0)

∂r2

Rδθ + 2δrΩ = 0.

(4.30)

The Taylor expansion made earlier is only true to the first order. The approximation madeby not expanding the series longer is called the epicyclic approximation. Integrating thesecond equation in (4.30) and inserting it into the first one leads to

δr − 2Ω(a− 2δrΩ)− Ω2δr = −δr∂2Φ(R, 0)

∂r2(4.31)

where a is the constant from the integration. When a = 0 and the oscillations are occurringaround δr = 0 this equation may be written in the form

δr + κ2δr = 0

δθ = −2Ωδr

R

(4.32)

where κ is the epicyclic frequency and

κ2 =∂2Φ(R, 0)

∂r2+ 3Ω2. (4.33)

16

Page 24: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES 4.3 Spiral galaxies

Combining this with equation (4.27) yields

κ2 = RdΩ2

dR+ 4Ω2. (4.34)

This implies that the motion of a star in a flattened potential is not just a circular orbit. Itis also an epicyclic orbit where the star is rotating on a small elliptic orbit in the rotatingframe of reference. As mentioned earlier there will not be focus on the theory behindJeans instabilities. This thesis will be content by stating that the minimum radial velocitydispersion needed to stabilize a flat disk is

σr,crit =3.36GΣ(r)

κ(4.35)

where Σ(r) is the surface density of the disk. Now, the parameter Q is defined as the ratiobetween the observed and the critical velocity dispersion. When Q > 1 there is a stablesystem. This is called the Toomre criterion. If this Toomre parameter is calculated in theneighborhood of the sun one obtains a value between 1 and 2.

4.3.2 Azimuthal moments of the disk

For a moment the discussion started in section 4.2.3 will be resumed in purpose of derivingthe equivalent equations for an axisymmetric system. In this case there will be no depen-dence in the φ direction. To compute the azimuthal moments from the velocity field of adisk equation (4.5) is multiplied by vR. Using the same procedure as Binney & Tremaine(1987) one integrates over the radial velocity to obtain

∂(νvR)

∂t+∂(νv2

R)

∂R+∂(νvrvz)

∂z+ ν

(v2R − v2

φ

R+∂Φ

∂R

)= 0. (4.36)

Assuming that the disk is in steady state the first term on the left hand side of equation(4.36) will be zero. Multiplication by R/ν and identification of the circular velocity vc =√R(∂Φ/∂R) leads to

R

ν

∂(νv2R)

∂R+R

ν

∂(νvRvz)

∂z+ v2

R − v2φ + v2

c = 0. (4.37)

The azimuthal velocity dispersion is defined as

σ2φ = v2

φ − v2φ. (4.38)

For an infinitesimally thin axisymmetric disk the spatial density ν is equal to the surfacedensity Σ. This quantity is not dependent on z and equation (4.37) can be written in theform

σ2φ − v2

R −R

Σ

∂(Σv2R)

∂R−R

∂(vRvz)

∂z= v2

c − v2φ. (4.39)

17

Page 25: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

4 KINEMATICS AND STRUCTURES 4.4 Interacting galaxies

4.4 Interacting galaxies

4.4.1 Tidal tails

The tidal force experienced by an object in a gravitational potential is the differential ofthe attraction force. Since the tidal force is decreasing with distance as 1/d3 the forceswill diminish rapidly. This implies that the effect of tidal interaction is at a maximumwhen the galaxies are at the smallest distance of separation. At this point the particlesare undergoing an acceleration that triggers the formation of the tail. Because of symme-try, the tidal forces of a target galaxy that is perturbed by a companion, will trigger theformation of two tails, one on each side of the galaxy. This is beautifully illustrated fromthe interaction between M51 and its companion. If two spiral galaxies interact with eachother, these symmetries will lead to the formation of four spiral arms, two in each galaxy.If the two galaxies are of approximately the same size, these arms can join each other toform a bridge. In the antenna galaxy the bridge has already disappeared while the othertwo spirals are forming the remaining two large ’antennas’.

The shape of the tidal tails created in a merger are dependent on the initial conditionsof the interaction. For a heads on collision the spiral arms are closed up to a ring, which isthe case of the Cartwheel galaxy, while the arms of a distant merger is very open.

4.4.2 Shells

Figure 4.2: The M51 galaxy illustrates the phe-nomenon of spiral wave generation from tidal inter-actions

In 1983 Malin & Carter (1983) ob-served 137 galaxies with fine ringssurrounding elliptical galaxies. Theshells have in common that they arecircular in the plane of sight withorigin in the center of the ellip-tical galaxy. This indicates thatthey are actually three dimensionalobjects. Although these structureswere not discovered until very re-cently they are quite common. Al-most 20% of all elliptical galaxies haveshells.

The structures are believed to originatefrom an interaction between a big ellip-tical galaxy and a small spiral galaxy.In these kind of collisions almost noth-ing will happen to the structure of theelliptical while the spiral will be totally swallowed up. Simulations made by Quinn (1984)showed that a collision of this kind makes the spiral galaxy stars oscillate within the ellipti-cal galaxy potential. Since the speed of these stars are at a minimum further out from thecenter, they will spend the longest time in this region and that will form the optical shell.

18

Page 26: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

5 THE BARNES-HUT TREE CODE

5 The Barnes-Hut tree code

5.1 Introduction

When simulating systems like isolated or interacting galaxies the true number of systemparticles can never be reached due to limitation of computer power. The largest simulationever made is the Millennium simulation that handles more than 1010 particles but thisis still less than the 1011 particles in a typical galaxy. To keep a great computationalaccuracy in simulations, the target is always to keep the number of particles as high aspossible. Calculating forces between bodies in an N-body system of particles requireso(N2) operations if all forces are calculated. To do this for a large system would be awaste of computer time and this is the reason why different hierarchical methods have beendeveloped. One of these hierarchical methods that requires only o(NlogN) operations isthe treecode that will be described in detail in this chapter (Barnes & Hut (1986)). Ahierarchical algorithm like the treecode organizes the particles into a tree structure whereeach level contain information about particles in a certain volume. By using this methoda lot of simplifications can be made while calculating the forces. In the treecode used inthis project the calculations are also speeded up by the fact that nearby particles havesimilar interaction lists. In this way the program does not have to make interaction lists forall particles in the simulation. Another advantage with treecodes is the performance withabnormal particle distributions. Since the tree structure is adaptive, there is an advantagein comparison with particle mesh methods.

5.2 Structure of the code

The treecode uses an oct-tree that consists of cells at different levels. Building the treestructure can be described in the following way. The program starts by constructing aroot cell big enough to hold all the particles of the system. The particles are then loadedinto this large cell. The idea of the treecode is that a cell is divided into eight sub cellsas soon as the number of particles in a cell exceeds one. The first cell will therefore bedivided into eight sub cells as soon as one has a system of more than one particle. Thissystem of dividing cells into sub cells is continued until all particles are loaded. The resultwill be a system of cells with a maximum of one particle in each cell. Every cell is thenassigned information about its sub cells, mass, center of mass and gravitational multipolemoments. The force on a particle can now be recursively calculated in the following way.If the cell containing the particle has sides of length l and the distance from the particleto the center of mass for the root cell is D the interaction is included if l/D < θ whereθ is a parameter, usually 0.75. Otherwise the root cell is resolved into its sub cells andthe criterion is rechecked. In this way the force on each particle can be calculated and thesystem can be advanced by calculating the new positions and velocities.

5.3 Running the code

The treecode is freely available and can be retrieved from Joshua Barnes’ homepage athttp://ifa.hawaii.edu/∼barnes/treecode. More detailed information about the structure of

19

Page 27: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

5 THE BARNES-HUT TREE CODE 5.3 Running the code

Figure 5.1: A 2-D illustration of how the subcells are created depending on the position of aparticle

the code and how to use it can be retrieved from that website but it is also described inAppendix A. The parameters used to run the code are:

• in: is the input file that contain the mass, position and velocity of each particle

• out: is the output file in the same format as the input file.

• dtime: is the parameter that determines the time step of integration.

• eps: is the gravitational force softening used to smooth the mass distribution. Eachparticle is replaced by a plummer sphere with scale length ε. This parameter is morecarefully discussed in section 5.3.1

• theta: is the opening angle mentioned in section 5.2. A lower value calculates moreaccurate forces on the cost of computing time.

• usequad: determines whether quadropole moments are used while calculating grav-itational potentials or not.

• options: is a set of options used to include various information

• tstop: is the time when the calculation ends

• dtout: is the time between output files. This value should be a multiple of dtime

20

Page 28: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

5 THE BARNES-HUT TREE CODE 5.3 Running the code

5.3.1 Optimal smoothing

Smoothing the forces in an N-body code is necessary to avoid close encounters betweenstars. The idea behind smoothing is to obtain more accurate forces that in a correct wayrepresents the real smooth system being modelled. Intuitively it is easy to realize that a tooshort smoothing length will lead to fluctuations in the force field while a to large smoothinglength will lead to a system where the real features disappears in the smoothing.

Merritt (1996) considered the simplest N-body algorithm which is the direct summationmethod. Since the difference between imposing the softening via a fix smoothening lengthand other methods are small, the force acting on a particle can be written

Fi = Gm2

N∑j=1

xj − xi(ε2 + |xi − xj|2)3/2

(5.1)

where ε is the smoothening length and m is the mass of each star. Since there is a real valuefor the forces, the aim is to minimize the average difference between the two forces. Merritt(1996) has minimized the mean value of the integrated square error which is defined as∫

ρ(x)|F(x)− Ftrue(x)|2dx (5.2)

where ρ(x) is normalized density from the true distribution. Minimizing the mean of thisintegral gives the following optimal smoothing lengths for the Plummer and the Hernquistdistributions.

εPlummer ≈ 1.1 ·N−0.28

εHernquist ≈ 1.5 ·N−0.44 (5.3)

In the simulations made in chapter 6 and 7, these smoothing lengths has been used also inthe case of composite systems. Although an error is committed for the disk particles, nosignificant change in the dynamics of the system is observed while changing the smoothing.

21

Page 29: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS

6 Simulations of isolated systems

6.1 Units and scales

For numerical and physical reasons it is often convenient to reduce equations to a non di-mensional form. In galactic dynamics one combines huge values describing distances andmasses with a small value for the gravitational constant. This makes the risk of round offerrors imminent. To avoid problems of this kind one often uses non dimensional units andthat practise is used also in this thesis.

A typical galaxy has a size that can be measured in kilo-parsec and a mass that can bemeasured in hundred billion sun masses. Using dimensional arguments one can calculate atypical rotational velocity from (3.5)

v '√

10−11 · 1011 · 1030

1019' 300 km/s. (6.1)

The same argumentation can be used to calculate a typical timescale

t ' (1019)3/2

√10−11 · 1011 · 1030

' 106 years. (6.2)

Consider a galaxy like the Milky with 400 billion stars and a radius of around 30 kpc, thenthere is a corresponding typical time scale of 122 million years.

6.2 Elliptical galaxies

In section 3.2, the Plummer and Hernquist profiles and their suitable density distributionswere discussed. Elliptical galaxies are slowly rotating objects and their dynamic is governedby the chaotic motion of stars. Many elliptical galaxies are thought to be very old due tothe many red giant stars. They are also showing little evidence of gas or other interstellarmaterial. It is therefore a good choice to model these galaxies as spherical Plummer orHernquist halos containing only stars. The Hernquist profile is the one that best agree withde Vaucouleurs law (4.1) but in this project there has also been made simulations withPlummer distributions for comparison.

6.2.1 Initial conditions for the Plummer distribution

To generate the positions of particles equation (3.13) is used. By drawing random numbersfor the mass fraction, different radii can be calculated. Since the task is to model sphericalsystems, each particle is randomly distributed on the corresponding sphere. The densitydistribution and the potential are recalled from section 3.2.3.

ρ(r) =3

M

a3

[1 +

(ra

)2]−5/2

(3.12)

Φ(r) = −GMa

[1 +

(ra

)2]−1/2

. (3.15)

22

Page 30: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS 6.2 Elliptical galaxies

First, the distribution function has to be derived. In the same way as Aarseth et al. (1974)one starts from equation (3.12) and (3.15) to obtain

ρ(r) =3

R2

M4G5Φ5(r). (6.3)

We have that (dρ/dΦ)Φ=0 = 0 and the second derivative of the density with respect to Φ is

d2ρ

dΦ2=

15

π

R2

M4G5Φ3. (6.4)

This can now be used in the Eddington formula (4.25) to obtain

f(E) =1√8π2

15

π

R2

M4G5

∫ E

0

Φ3√(Φ− E)

=24√

2

7π3

R2

M4G5(−E)7/2.

(6.5)

The procedure to generate the velocities is straightforward. For each of the particles arandom number between 0 and the escape velocity is drawn. Then the total energy for aparticle with this velocity is calculated. Finally a acceptance rejection method is used tokeep the values that fall under the distribution function and reject the values that are abovethe distribution function. Note that the distribution function is calculated in the possibleinterval of energies corresponding to the current radius.

6.2.2 Initial conditions for the Hernquist distribution

The procedure to generate particle positions for the Hernquist distribution is similar tothat for the Plummer distribution. The density distribution and the potential are recalledfrom section 3.2.4

ρ(r) =M

a

r

1

(r + a)3(3.17)

Φ(r) = − GM

r + a. (3.19)

Hernquist (1990) defines dimensionless forms of the density and potentials.

ρ = −2πa3

Mρ(r) (6.6)

Φ = − a

GMΦ(r). (6.7)

Combining this with equations (3.17) and (3.19) leads to the simple relation

ρ =Φ4(r)

1− Φ(r)(6.8)

23

Page 31: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS 6.3 Disk galaxies

Figure 6.1: The density distribution for Plum-mer (dashed) and Hernquist (solid line) whena = 1

Figure 6.2: The distribution function whena = 0.45. The Plummer (dashed) and Hernquist(solid line) distributions is compared with that forthe R1/4 law (dashed dotted)(see Binney, 1982)

Using the same method as for the Plummer distribution Hernquist (1990) derive the dis-tribution function

f(E) =M

8√

2π3a3v3g

1

(1− q2)5/2

(3 arcsin q + q(1− q2)1/2(1− 2q2)(8q4 − 8q2 − 3)

). (6.9)

where q =√−aE/GM and vg =

√GM/a. To generate velocities, the same procedure as

for the Plummer distribution is used.

6.2.3 Simulation results

As already mentioned it is the Hernquist profile that best agree with observations of realelliptical galaxies. It is also the model used in this thesis work to describe the ellipticalgalaxy. Simulations has been carried out for both Hernquist and Plummer distributionsand the density distributions for the systems stays the same over a long time of evolution.For simulations with a small number of particles the system starts to drift in some randomdirection since the code does not conserve linear momentum. This is however not a problemwhen many particles are used.

6.3 Disk galaxies

6.3.1 The Miyamoto distribution

As there are a variety of models describing spherical galaxies, one can use different methodsto model a disk galaxy. In this thesis however, the Miyamoto distribution has been usedbecause of its simplicity. In the event of modelling compound systems one does not haveto use separate distributions for the disk and the bulge of a galaxy. Instead the Miyamoto

24

Page 32: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS 6.3 Disk galaxies

distribution can be used to describe both components. It also defines the potential every-where which makes it easy to calculate velocities. As already mentioned in section 3.3.2, themodel by Miyamoto & Nagai (1975) is a generalization of the Plummer and the Toomre-Kuzmin models. For different values on a and b one can create disks of various thickness.A comparison of four different disks with different b/a ratios are shown in figure 6.3. In

Figure 6.3: The density contours of the Miyamoto disk when b/a = 10 (upper left), b/a = 1(upper right), b/a = 0.1 (lower left) and b/a = 0.01 (lower right). The density is normalized sothat the peak density equals unity. The ratio b/a = 0.1 is the is used when modelling disk galaxies.

the Milky Way, the ratio b/a is approximately 0.1. One can to a good approximation saythat the disk is 100.000 light years wide and 10.000 light years thick. Using these quantitiesand once again M = G = 1 gives a density distribution like the one in Figure 6.4. Anacceptance-rejection technique is once again used to distribute particles according to thisdensity distribution.

Observations made by van der Kruit & Searle (1981) shows that the radial velocity dis-persion is proportional to the surface density that decreases exponentially with radius.

25

Page 33: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS 6.3 Disk galaxies

Therefor, the radial velocity dispersion scales as

v2R ∼ e−R/a (6.10)

where a is the scale radius. For the isothermal sheet, the vertical velocity dispersion isrelated to the surface density of the disk Hernquist (1993)

v2z = πGΣ(R)z0. (6.11)

Hernquist (1993) also suggest that the azimuthal velocity dispersion can be related to theradial velocity dispersion from the epicyclic approximation

σ2φ = v2

R

κ2

4Ω2. (6.12)

Knowing that the surface density is decreasing exponentially, equation (6.12) can be usedto rewrite (4.38). This leads to the expression

vφ2 − v2

c = v2R

[1− κ2

4Ω2− R

a+∂(ln v2

R)

∂ lnR+R

v2R

∂(vRvz)

∂z

]. (6.13)

This equation can be even more simplified with help from the assumption in (6.10)

vφ2 − v2

c = v2R

(1− κ2

4Ω2− 2

R

a

). (6.14)

The procedure to assign speeds to each particle is as follows. The circular speed is firstcalculated from equation (3.5). v2

R, v2z , κ and Ω are then calculated from equations (4.35),

(6.11), (4.33) and (4.27). When this is done the azimuthal velocity dispersion is calculatedfrom equation (6.12). Finally the azimuthal streaming velocity is obtained from equation(6.14). The total random velocity is now the sum of the streaming velocity and a randomvelocity drawn from σφ. In the radial and vertical directions random velocities are drawn

from v2R and v2

z respectively.

6.3.2 Simulation results

The way to characterize the velocity dispersion in the disk is through the choice of theToomre parameter, Q. The development of spiral structure is dependent on this value.Several tests has been made for different Q′s and the difference in result is the amount oftime it takes the spiral structure to be visible. One of the simulations is shown in figure6.4. It is also important to point out the need of a large number of particles in these kindof simulations. In the case where a spherical distribution is simulated, it is enough to use∼ 1000 particles to show the stability. Although the treecode does not conserve the linearmomentum very well for few particles one can at least observe that the system is stable inits shape. However, when simulating disk galaxies a large number of particles is required.To have the ability to resolve the spiral structure that is formed, a large number of particlesis favorable.

26

Page 34: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS 6.4 Composite systems

Figure 6.4: The Miyamoto disk for N = 10000 particles projected on the x-y plane when t = 0(left) and t = 20 (right). In the simulation M = G = a = 1, b = 0.1 and Q=1.2. The timestepused in the simulation is 1/1024. The bar and the two spiral arms are clearly visible.

6.4 Composite systems

There are several ways to describe a model of a galaxy containing a stellar disk, bulge and asurrounding dark matter halo. In the procedure introduced by Barnes (1988) the differentcomponents are allowed to relax in the presence of each other until equilibrium is reached.The drawback of this procedure is of course that the galaxy is modified by the adjustmentto equilibrium. Another approach is the one used by Hernquist (1993). In that method, thedensity profiles are implemented exactly while the distribution function is approximated.In this thesis yet another method has been used. Instead of approximating the distributionfunction a Miyamoto potential has been combined with a Plummer or a Hernquist potential.The initial velocities in the halo are calculated from the distribution function and in additionthey are given a circular velocity in a random direction that corresponds to the circularvelocity around the Miyamoto distribution. In this way the velocities are not any longerexactly equivalent to the distribution function but the error committed should be smallwhen taking into consideration that the disk is much smaller and lighter. The disk is alsonot a spherical system which result in yet another small error. For the disk particles, thevelocities are calculated from the potential of the combined system. Recalling equation(3.4) the total gravitational potential can be written

Φtotal = Φdisk + Φhalo. (6.15)

As a consequence of the dark matter halo, the rotational velocity of the disk will change.In figure 6.5 and 6.6 the circular velocities at different radii are plotted for all the particlesat the beginning of a simulation. Also the speeds with no dark matter halo are plotted.As one can see the rotational curve becomes flat to a varying degree for different mass andsize of the halo. From these figures it is clear that at suitable flat rotationcurve is obtainedwhen Mhalo = 10Mdisk and ahalo = 10adisk for both the case with a Plummer halo and thecase with a Hernquist halo.

27

Page 35: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS 6.4 Composite systems

Figure 6.5: The o’s represents the rotational velocities for a system with 100 particles in thedisk and 3000 particles in the Plummer halo while the +’s represents the rotational velocities fora isolated disk with 100 particles. In all four figures Mdisk, adisk and G is equal to 1 Upper left:Mhalo = 20 and ahalo = 10 Upper right: Mhalo = 10 and ahalo = 5 Lower left: Mhalo = 5 andahalo = 10 Lower right: Mhalo = 10 and ahalo = 10.

28

Page 36: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS 6.4 Composite systems

Figure 6.6: The o’s represents the rotational velocities for a system with 100 particles in thedisk and 3000 particles in the Hernquist halo while the +’s represents the rotational velocities fora isolated disk with 100 particles. In all four figures Mdisk, adisk and G is equal to 1 Upper left:Mhalo = 20 and ahalo = 10 Upper right: Mhalo = 10 and ahalo = 5 Lower left: Mhalo = 5 andahalo = 10 Lower right: Mhalo = 10 and ahalo = 10.

29

Page 37: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

6 SIMULATIONS OF ISOLATED SYSTEMS 6.4 Composite systems

Figure 6.7: At T=0, the solid line represent the massfraction for the disk. The dotted-dashedline represent the massfraction for the disk and the halo. The dashed line represents the halomassfraction. At T=50, that for unit scaling corresponds to ∼ 5 rotations for the galaxy, the massfractions are plotted with +, * and . respectively. In the simulation, a halo that is ten times asheavy and 10 times as large as the disk has been used. As one can see the distribution stays thesame over a long time.

6.4.1 Simulation results

Simulations has been carried out for the case where G = 1, Mdisk = 1, adisk = 1, Mhalo = 10,ahalo = 10 and Q = 1.2 with the Plummer and Hernquist distributions representing thedark matter halo. The difference with these simulations and the simulations made withan isolated Miyamoto disk is that the rotation curves now are represented more correct.Depending on the masses and sizes of the disk and halo the system will react different. Fora simulation with a Hernquist halo, the massfractions remains fairly constant over a longtime. This is illustrated in figure 6.7. Simulations has also been made with a Plummerdark matter halo. In this case, the halo undergoes a slight infall in the beginning of thesimulation. This is however stabilized quickly.

30

Page 38: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

7 SIMULATIONS OF INTERACTING GALAXIES

7 Simulations of interacting galaxies

One of the initial goals of this project has been to make simulations of interacting E0 andspiral galaxies. This chapter will focus on some specific interactions between galaxies thatto some extent can explain the behavior of the the Medusa Galaxy (NGC 4194) and otherinteracting galaxies.

Several papers governing the interaction between ellipticals and spirals have been written.Quinn (1984) and Kojima & Noguchi (1997) are two examples where the shell structure andthe tidal tail has been showed in simulations. In the Medusa case, optical imaginary showsstructure that is believed to be a kind of shell oscillation in the center of the system. Also along tidal tail, approximately six times larger than the optical nucleus, is visible. This tailis however composed of neutral hydrogen and contains almost no stars. One believes thatthis structure formed when a small spiral galaxy fell into a bigger elliptical galaxy. Thedistribution of stars near the center of the system could be caused by parts of the originalspiral galaxy oscillating in the elliptical galactic potential. There is only one nucleus visiblein the system which leaves two possible scenarios. Either, the spiral galaxy is in an ongoingpassage through the elliptical nucleus, or the two nuclei have already merged completely.

Figure 7.1: The left picture shows the center of the Medusa merger at optical wavelengths. Thereare stars that surround the center in a shell like structure. The right hand picture is a contourplot of the H I distribution. (Manthey et al. in prep)

31

Page 39: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

7 SIMULATIONS OF INTERACTING GALAXIES 7.1 Interactions between ellipticals and spirals

7.1 Interactions between ellipticals and spirals

The galaxy models used in the simulations are built on the content in previous chapters.The spiral galaxy is modelled with a Hernquist halo surrounding a Miyamoto disk. Testshave been made with a spiral galaxy containing no dark matter. However, these tests showthat the dark matter plays an important role for the dynamics of the system. Tidal tailformation is for example more sensitive to external forces in a non halo system. For thatreason, most tests have been carried out with the presence of a dark matter halo. It is inter-esting to observe that the type of halo is not very important. Tests made with a Plummerhalo give approximately the same results as tests made with a Hernquist halo.

7.2 A possible scenario for the Medusa merger

Different initial conditions have been used for the Medusa merger. The initial separationhas however been chosen not more than a few times the scale radius of the elliptical galaxy.The reason is that the tidal forces goes as 1/d3 and thus diminish rapidly. In the simulationshowed in figure 7.2, the spiral galaxy has fallen in on prograde motion. The reason for thischoice is that a retrograde motion does not form the type of tidal tail that can be seen inthe HI images. Also, it has fallen in on a non-stable orbit to be able to merge completelywith the elliptical galaxy. From the time sequence showed in the figure one can see that thetidal tail starts to form early in the interaction. What is not visible in the figures, but canbe analyzed, is that it is the outer parts of the spiral galaxy that forms the tail. Althoughgas is not included in the simulation one can at least draw the conclusion that it is theregions normally containing a lot of gas that forms the tail. To model the observed tailmore accurately one has to include gas since the HI region is not a collisionless system. Inthe simulations showed in figure 7.2 non dimensional units have been used for simplicity.

32

Page 40: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

7 SIMULATIONS OF INTERACTING GALAXIES 7.2 A possible scenario for the Medusa merger

Figure 7.2: A time sequence for T = 12,21,30 and 39 is shown. The spiral disk is plotted inyellow while the elliptical galaxy is plotted in white. The dark matter Hernquist halo is not plotted.The spiral galaxy has Mdisk = 7,Mhalo = 71,adisk = 1 and ahalo = 10. The elliptical galaxy hasM = 400 and a = 4. The initial separation between the galaxies is x = 40, y = 20 and z = 0. Theinitial velocity for the spiral galaxy is vx = −0.6,vy = 1.2 and vz = 0.

33

Page 41: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

8 CONCLUSIONS AND PERSONAL REFLECTIONS

8 Conclusions and personal reflections

When I started to work on this thesis I had the preconceived notion that it would be an easytask to build the model galaxies. At the end it turned out not to be so. In my preliminaryplan I was also determined to invoke gas in my simulations. Unfortunately the time hasnot been long enough to do so. The most time consuming part of the work has actuallybeen to build the models. The composite system used to model galaxies in section 6 hasdrawn my attention for several hours. Nevertheless, this has been a time of great learning,especially in the theory behind galactic structure and behavior. A great deal of knowledgeabout galactic dynamics can also be retrieved from particles simulations.

Beside building models of various types of galaxies I have also made some special testswith the ambition to reproduce the main features of the Medusa merger. From the sim-ulations it has been shown how the infall of a small spiral galaxy into a bigger ellipticalgalaxy can be the initial condition for the observed scenario. The formation of a long tidaltail from the outer parts of the disk is clearly visible as well as the shell oscillations ofstars in the center of the system. Although the particles are collisionless one can see thatthe tail is formed of particles originating from the regions normally containing a lot of gas.One can also assume that the inclusion of a gaseous component might make the choice ofinitial conditions even more complicated. Already with two fairly simple galaxy modelsthe complexity of the system is obvious. A slight change in the initial infall angle mightfor example result in a totally different kind of shell oscillation in the center. With thesethings in mind I find it reasonable to argue that an N-body simulation very well can showthe main features of this particular merger.

However, future research in this area should include simulations of the gas. More testsof different initial conditions should also be made to get a better match for this system.

34

Page 42: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

A HOW TO USE TREECODE 1.4

A How to use treecode 1.4

A.1 Installation of the code

The treecode can be downloaded as a gzipped tar file from Joshua Barnes homepage. Theaddress is http://ifa.hawaii.edu/∼barnes/treecode/treecode.tar.gz. When the file has beendownloaded to its appropriate catalogue it has to be unzipped and unpacked with the com-mands

gunzip treecode.tar.gz

tar xvf treecode.tar

The catalogue should now contain the files treecode.h treedefs.h treecode.c treegrav.c

treeio.c treeload.c getparam.c mathfns.h stdinc.h vectdefs.h vectmath.h clib.c

getparam.c mathfns.c and Makefile. In the case where where the treecode is installedinto a linux system no changes to the Makefile have to be made. The treecode can be builtby giving the command

make treecode

Whether the installation has succeeded or not can be tested by giving the command

treecode

In this case the treecode will make a test calculation. The steps will be visible on thescreen and the calculation can be aborted anytime by typing Ctrl - C.

A.2 Running the code

The parameters given to the treecode have already been listed in 5. The use of the treecodeis illustrated by an example

treecode in=galaxy.data out=outgalaxy.data dtime=1/1024 eps=0.0128 tstop=200

dtout=1

In this case the treecode uses the input file galaxy.data and writes the result to outgalaxy.data.The simulation uses a timestep (dtime) of 1/1024. It is preferable to give this number onthe form n/d where n is an integer and d is a power of 2. The smoothing length is 0.0128and the simulation continues until T = 200 and writes to the output file at a time intervalof T = 1.

The input file used has to be on the form

35

Page 43: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

A HOW TO USE TREECODE 1.4 A.2 Running the code

nbody

dimension

time

mass(1)

↓mass(nbody)

x(1) y(1) z(1)

↓ ↓ ↓x(nbody) y(nbody) z(nbody)

vx(1) vy(1) vz(1)

↓ ↓ ↓vx(nbody) vy(nbody) vz(nbody)

The output files are written in the same format with each timestep adding up at the bottomline of the outputfile. In the case where an output file already exists, the new values willalso be added up starting from the bottom line. There is a risk of making mistakes and forthat reason it is recommended to check whether files with similar names exist.

36

Page 44: N-body simulations of interacting galaxiesbjerkeli.se/onewebmedia/thesis.pdf · developed by Joshua Barnes and Piet Hut (1986). The code is used in this master thesis to simulate

REFERENCES REFERENCES

References

Aarseth S. J., Henon M., Wielen R., 1974, A&A, 37, 183

Barnes J., Hut P., 1986, Nature, 324, 446

Barnes J. E., 1988, ApJ, 331, 699

Binney J., 1982, MNRAS, 200, 951

Binney J., Tremaine S., 1987, Galactic dynamics. Princeton, NJ, Princeton UniversityPress, 1987, 747 p.

Combes F., Boisse P., Mazure A., Blanchard A., Seymour M., 2002, Galaxies and cosmol-ogy. Galaxies and cosmology (2nd ed.). by F. Combes et al. (M. Seymour, Trans.). NewYork: Springer, 2002.

Hernquist L., 1990, ApJ, 356, 359

Hernquist L., 1993, ApJ, 86, 389

Holmberg E., 1941, ApJ, 94, 385

Hubble E. P., 1926, ApJ, 64, 321

Karttunen H., Kroger P., Oja H., Poutanen M., Donner K. J., 1996, Fundamental Astron-omy. Fundamental Astronomy, XV, 521 pp. 402 figs., 36 in color. Springer-Verlag BerlinHeidelberg New York

Kojima M., Noguchi M., 1997, ApJ, 481, 132

Malin D. F., Carter D., 1983, ApJ, 274, 534

Merritt D., 1996, AJ, 111, 2462

Miyamoto M., Nagai R., 1975, PASJ, 27, 533

Plummer H. C., 1911, MNRAS, 71, 460

Quinn P. J., 1984, ApJ, 279, 596

Rubin V. C., Thonnard N., Ford Jr. W. K., 1978, ApJ, 225, L107

Toomre A., 1963, ApJ, 138, 385

Toomre A., Toomre J., 1972, ApJ, 178, 623

van der Kruit P. C., Searle L., 1981, A&A, 95, 105

37