By Andrey Mirtchovski and Chris Worman

Note: view the power point presentation: ppp.ppt


This report describes the simulation of galaxies with an emphasis on galaxy collision. This includes a description of the physics required for a galaxy simulation and the desired properties of simulated galaxies. Accurately modeling complex physical systems such as galaxies requires large amounts of computational power. This requirement renders an accurate galaxy simulation to be infeasible using current microcomputers. The galaxy simulation methods described are meant to reduce the accuracy of the simulation, so as to make it feasible to implement the methods described using current microcomputer technology, while at the same time keeping many of the desired simulation properties. The techniques involved describe both two-dimensional and three-dimensional implementations.

Galactic Model

A galaxy is large grouping of stars that rotate about a galactic center.

It is proposed that the galactic center of many galaxies is a supermassive black hole [KAU 633], this appears to be the case at least for our Milky Way Galaxy. Since the mass of the supermassive black hole is much larger than that of the orbiting stars, the stars orbit the black hole much like the Earth orbits the Sun. Also because of its large mass, the galactic center has a central bulge around it. The central bulge is a spherical distribution of stars near the galactic center.

The galactic model used for the simulation was based on a galactic center that is a relatively massive body, representing a supermassive black hole. The ratio of star mass to galactic mass used in the simulation was on the order of one to twenty-five thousand.

In a real galaxy, each star experiences gravitational influence from every other star in the galaxy. This implies that an accurate simulation would have to calculate the gravitational force exerted on each star from every other star that is modeled in the simulation. If the total number of stars in the simulation is n then the brute force approach requires O(n2) gravity calculations (see the section on gravity for an explanation of the gravity equations used in the simulation). Hierarchical methods have been developed that require O(n log n) operations per force calculation [BAR 1]. Although this is a significant speed-up, it still requires computational power that exceeds the capabilities of current microcomputers for systems as large as galaxies. Peter Williams and Alistair Nelson, from the Edinburgh Parallel Computing Center, recently performed a simulation that illustrates how processor intensive galaxy simulation is. They performed a simulation of galaxy formation using 128,000 particles. The simulation took 15 days to run on a Cray T3E computer system with 32 processors [WIL].

Since the effects of gravity between two bodies is proportional to the inverse of their distance squared, stars that are far apart will have little gravitational effect on each other. Gravitational force is proportional to mass, which implies that bodies with low mass will have only a small influence on other bodies. These two properties regarding gravitation are the key to speed-up in our proposed model. If the interacting gravitational force that exists between stars is ignored then the number of gravitational calculations is reduced. In this model there are only two types of gravitational calculations that remain. The first of these is the calculations required for forces that exist between each star and each galactic center. The second type of calculation is for the gravitational forces that exist between the various centers of mass.


ts = 0.0 // this is the time step we are currently on
ep = Gravitational constant

loop until simulation done

// Galactic center interaction
for each i, j where i j and i < Galaxy count and j < Galaxy count

x1 = G[i].x - G[j].x
x2 = G[i].y - G[j].y

G[i].acc_x = x1 * ep * G[j].mass / ((x1*x1 + x2*x2)^0.5)^2
G[i].acc_y = x2 * ep * G[j].mass / ((x1*x1 + x2*x2)^0.5)^2
G[i].vel_x += ts * G[i].acc_x
G[i].vel_y += ts * G[i].acc_y

G[i].x += ts * G[i].vel_x
G[i].y += ts * G[i].vel_y


// Star interaction with galactic centers
for each i where i < Galaxy count

for each j where j < Number of stars in G[i]

for each c, where c < Galaxy count

x1 = G[i].stars[j].pos_x - G[c].pos_x
x2 = G[i].stars[j].pos_y - G[c].pos_y
d = (x1*x1 + x2*x2)^0.5

G[i].stars[j].acc_x = x1 * ep G[c].mass / (d*d)
G[i].stars[j].acc_y = x2 * ep G[c].mass / (d*d)

G[i].stars[j].vel_x += ts * G[i].stars[j].acc_x
G[i].stars[j].vel_x += ts * G[i].stars[j].acc_y

G[i].stars[j].pos_x += ts * G[i].stars[j].vel_x
G[i].stars[j].pos_y += ts * G[i].stars[j].vel_y





ts += t

end of simulation loop


Here are some images that were created using the methods described above.

3 galaxies about to collide (3d)
2 galaxies after a collision (3d)
2 galaxies about to collide (2d)

For those that do not have access to java3d, there is an assembled series of screenshots of a two-galaxy collision with 500 stars each: click here to view screenshots


These are several simulations of different galaxy collisions. Note that all of them require a java3d plugin (your browser will attempt to download the plugin when you visit the page) making them available only for IE and Netscape browsers. You can also run them as standalone programs on Sun and IRIX (linux java3d will be available soon from blackdown). A list of class files and sources is given with each program.

A two-galaxy collision in 3d (500 stars per galaxy)
A galaxy and a black hole (500 stars galaxy)
A single spinning galaxy
A galaxy of 100 000 stars


[KAU] Kaufmann, William J. III and Roger A. Freedman.  Universe.  New York: W. H.  
Freeman and Company, 1999. [BAR 1] Joshua E. Barnes. Retrieved November 20, 2000, from the World Wide Web:
[BAR 2] Joshua E. Barnes. Retrieved November 19, 2000, from the World Wide Web:
[WIL] Peter Williams and Alistair Nelson. Retrieved November 20, 2000, from the World Wide