 ## Lecture 1   Course overview: Computational Physics I (N-body problem)

Computer modeling plays a very important role in science today. In the past, physical sciences were characterized by an interplay between experiment and theory. In experiment, a system is subjected to measurements, and results, expressed in numeric form, are obtained. In theory, a model of the system is constructed, usually in the form of a set of mathematical equations. The model is then validated by its ability to describe the system behavior in a few selected cases, simple enough to allow a solution to be computed from the equations. In many cases, this implies a considerable amount of simplification in order to eliminate all the complexities invariably associated with real world problems, and make the problem solvable.

In the past, theoretical models could be easily tested only in a few simple "special circumstances''. So, for instance, in condensed matter physics a model for intermolecular forces in a specific material could be verified in a diatomic molecule, or in a perfect, infinite crystal. Even then, approximations were often required to carry out the calculation. Unfortunately, many physical problems of extreme interest (both academic and practical) fall outside the realm of these ``special circumstances''. Among them, one could mention astrophysical problems, like star formation, collisions of galaxies, and the large scale structure of the universe, the theory of the strong force which confines quarks permanently within the nucleon, termonuclear fusion, turbulunce, the physics and chemistry of defects, surfaces, clusters of atoms, organic molecules, involving a large amount of degrees of freedom; an accurate treatment of temperature effects, including anharmonicities and phase transitions; disordered systems in general, where symmetry is of no help to simplify the treatment; and this list could be continued almost indefinitely. Each computer simulation project outside the "special circumstances'' requires three major components:

### The physical problem and its theoretical model

In computer modeling you are first and foremost a scientist. It is necessary to master the underlying physics of the problem we attack on the computer and to understand analytically as much as possible. We only want to ask the computer to do the things which cannot be done otherwise. The more analytic input we use, the more robust and powerful the computer simulation becomes. Needless to say, the development of computer experiments altered substantially the traditional relationship between theory and experiment. On one side, computer simulations increased the demand for accuracy of the models. For instance, a molecular dynamics simulation allows to evaluate the melting temperature of a material, modelled by means of a certain interaction law. This is a difficult test for the theoretical model to pass--and a test which has not been available in the past. Therefore, simulation "brings to life'' the models, disclosing critical areas and providing suggestions to improve them. On the other side, simulation can often come very close to experimental conditions, to the extent that computer results can sometimes be compared directly with experimental results. When this happens, simulation becomes an extremely powerful tool not only to understand and interpret the experiments at the microscopic level, but also to study regions which are not accessible experimentally, or which would imply very expensive experiments, such as under extremely high pressure. Last but not least, computer simulations allow thought experiments--things which are just impossible to do in reality, but whose outcome greatly increases our understanding of phenomena--to be realized. Creativity is very important in computer modeling with transformational power of the studied field!

### Algorithm and software implementation

The advent of high speed computers--which started to be used in the 50s--altered the picture by inserting a new element right in between experiment and theory: the computer experiment. In a computer experiment, a model is still provided by theorists, but the calculations are carried out by the machine by following a "recipe'' (the algorithm, implemented in a suitable programming language). In this way, complexity can be introduced and more realistic systems can be investigated, opening a road towards a better understanding of real experiments. Innovation in algorithmic developments is key to the rapid progress we have seen in the last ten years. The Treecode in N-body problems, as applied to galaxy collisions, is an impressive illustration of this point.

### Analysis and visualization

Analysis involves the physical interpretation of the data generated by the computer simulation. Visualization tools are indispensable in the interpretation of the results. For illustration we will discuss briefly the three components on the main theme of this course which is the computer modeling of N-body problems with particular applications to the collision of two galaxies and molecular dynamics.

## 1. Physics and the theoretical model

This part will illustrate the physical problem and its theoretical model as the first component of computer modeling in the general topic of N-body simulations. We will start with the underlying theoretical framework which is general enough to capture a very broad range of physical applications.

### N-body equations of motion

Any gravitational system may be idealized as a collection of N point-sized bodies, each with mass mi , position ri , and velocity vi . The energy E=K+V for such a system is given by Newtonian mechanics where E depends on all body positions and velocities. The equations of motion are Newtonian:.  N-body systems obey several basic conservation laws which are derived by manipulating Newton's equations. Noether's theorem states that each symmetry of the Lagrangian gives rise to a corresponding conservation law. A symmetry of the Lagrangian L=K - V is a transformation which leaves the physical system unchanged. For example, translation in time, t -> t + Delta t, is a symmetry because L is not an explicit function of time; consequently the total system energy E = K + U is conserved. Likewise, symmetry with respect to translation in space, r -> r + Delta r, implies conservation of total linear momentum, and symmetry with respect to rotation gives rise to conservation of total angular momentum.

Newton's equations also apply to molecular dynamics, if we replace the gravitational force by the appropriate molecular force acting between molecules in the system we are modeling.

### Galaxy collisions (the Final project)

We will illustrate the power of solving the N-body equations with the simulation of two colliding galaxies. At close encounter during the collision, the simulation is a close match to what is observed on the sky for galaxy N4676 which is also known as the Mice. The observation on the sky is shown on the left and the simulation results are shown on the right: ## 2. Algorithm and software implementation

The 6N coupled ordinary differential equations have to be solved numerically using some finite discretization of the time variable. Variable discretization schemes are used in the literature, like the leapfrog algorithm, Euler algorithm, or the Runge-Kutta method. The force calculation is also a challenging problem. A naive approach will require N^2 calculations, sophisticated procedures, like FFT or the Treecode will reduce the number of operations to NlogN. To keep software development accessible to every student, the code we will work with will be available in Fortran and C/C++ programming languages. It will be the student's choice which language to use. Since the discussions and applications will never be completely symmetric, it is advantageous if teams have some knowledge in both languages but it is not required or necessary. The Fortran implementation of the famous Treecode for the collision of two galaxies is about 3000 lines and organized in a very transparent fashion. We will also work in the class with its equivalent C language implementation. Python, Matlab or Mathematica which are available in the lab can also be used in several applications.

In fact, Python will be the preferred platform for the assignments.

## 3. Analysis and visualization

Example of N-body simulations are shown here.

### Three movies on the Mice (N4676)

The first Mice movie is the final product of a team project on galaxy collisions. The second Mice (rotate) movi shows that the two tidal tails are not in the same plane which explains the observed skyview of N4676.

High resolution with million particle simulation.

### Andromeda collision with Milky Way

The Andromeda movie of a very large scale N-body simulation shows the collision course of our Milky Way with the Andromeda galaxy on the time scale of several hundred million years.

High resolution with million particle simulation.

### Cartwheel collsion

One of the team projects is the Cartwheel collision.

### Black Hole at the Galactic Center (Milky Way)

Black hole at galatic center is seen from the observation of 13 orbiting stars. The mpeg movie of star motion around the black hole.