Astronomers, as everyone knows, use telescopes to do their work. But not all astronomy is done using telescopes - there are in fact many astronomers who never make use of them. I’m one of them; I work mostly with computer simulations. Since people are often surprised to hear how much astronomy is done by computer, I thought I’d dedicate a post to talking about what an astronomical simulation is, how they’re used, and how important they are.
The goal of astronomy, like any science, is to produce models of the world - or certain aspects of it - which explain it as well and as simply as possible. A scientific model begins with an observation of some phenomenon and an idea for a rule or law which could explain it. For example, Tycho Brahe made a series of painstaking observations of the motion of the planets over many years, which his student Kepler explained using a set of three laws of planetary motion. These in turn allowed Newton to develop his law of gravitation.
The aim of a theory though is to be able to make predictions about other observations yet to be made. That’s partly because we’d like our science to be useful, to tell us what to expect tomorrow as well as to explain what happened yesterday. But it’s also for the theory’s own good. Every prediction which turns out to be correct is another piece of evidence in its favour (as when Herschel discovered Uranus in 1781, and its motion was found to obey the same laws Kepler had derived previously). And every prediction which is false tells us we must be missing some data (as when irregularities in Uranus’s orbit compared to theory suggested the presence of another planet, Neptune, beyond it) or that our theory needs to be refined or replaced (as with changes in Mercury’s orbit not due to any known planet, which are now explained brilliantly by General Relativity).
Of course the difficulty of taking the second set of observations - to confirm or deny the predictions of the theory - can vary a lot. If I have a prediction about the orbits of planets I can take my telescope and test it; if I have a prediction about how atoms behave when I smash them together I can build a particle accelerator and do some smashing.
But many of the things we study in astronomy are so big, so far away and so slow that direct experiment is impossible. Suppose I want to test a prediction about what will happen when our galaxy collides with its neighbour Andromeda three billion years hence - I can hardly wait around to observe it or experiment by throwing two other galaxies at each other.
This is where computer simulations come in. If I can’t throw two galaxies at each other, I can program a computer to construct two model galaxies, and throw them together in a simulation capable of tracking a billion years of evolution in a few hours or days. It’s not quite as good as a real experiment since there might be things I’ve missed out of my model, but often it’s the best we can do.
The gravitational N-body problem
One area of astronomy where simulation is invaluable is studying the behaviour of objects moving under the influence of gravity - like the planets and galaxies above. Newton’s theory of gravity is fairly simple: if you tell me the mass of two objects and the distance between them, I can work out the force between them due to gravity using a simple formula. And if you also tell me the speeds and directions the objects are moving with at some start point, I can work out how that force will change their motion over time. I can do all this on a sheet of paper without too much difficulty, and at the end I’ll have a set of equations which will describe the complete future motion of the two objects: ask me what their positions and speeds will be a day, a year or a billion years in the future and I can tell you (assuming, of course, that the initial data you gave me was accurate enough).
But two objects completely alone together in space is not a situation that comes up in the real universe. Even if I’m talking about a single planet orbiting a star, there will be slight effects from passing asteroids or other stars. So it’s natural to ask whether we can write down a similar set of equations for three or more objects.
The answer is, unfortunately, no. Adding even a third object makes the equations vastly more complicated, such that we can’t write down an exact solution to them. And increasing the number of objects further just makes things worse. This is called the N-body problem, with N denoting the number of objects, and it’s an example of a chaotic system. Tiny changes in initial conditions produce huge changes in behaviour, and the motion of the objects seems ‘random’ and unpredictable, without falling into any obvious pattern.

Motion of three objects under gravity, showing chaotic non-repeating behaviour (the animation repeats because it's on a loop).
This seems like a pretty big problem. If we want to know how a system of several planets moves - or worse, how two galaxies of a hundred billion stars each collide - then things seem pretty hopeless!
Luckily, this problem is ideally suited to computer modelling. I can put those initial positions and speeds of my objects into a computer, and give it a rule for working out gravitational forces. Instead of trying to solve the equations directly, I can have the computer work out the force at certain intervals of time - maybe every day if I’m looking at a planet, or every thousand years for a collection of stars. It works out the forces and changes the objects’ speeds at these times, and then lets them carry on at the same speed until the next update. Of course that’s not how gravity really works - the Earth’s course is being changed continuously as it moves - but it lets the computer solve the problem by just storing a bit list of numbers (positions and speeds) and repeatedly updating them using a formula. And that, unlike manipulating equations, is something computers are extremely good at.
Andromeda and the Milky Way
Here’s a video of a gravitational simulation, by John Dubinski at the University of Toronto. It represents a collision between two galaxies similar to Andromeda and the Milky Way. The initial conditions contain about a hundred million ‘particles’ representing groups of stars and gas, which are distributed like two spiral galaxies and then allowed to evolve under gravity.
Cosmology with the Horizon Simulation
Another example of a gravitational simulation project is the Horizon Simulation, whose output I’m involved in interpreting. As astronomical simulations go it’s a big one: it represents a cubic volume of universe about 9 billion light-years on a side*, containing hundreds of millions of galaxies.
This simulation is designed to test our ideas about how the largest scale structures in the universe formed over time. This time the initial condition is a distribution of matter that’s almost smooth but has a few wobbles in it, based on our measurements of what the early universe looked like.
embedded by Embedded Video
Download Video
The video above shows the distribution of matter in the final state of the simulation, representing the universe today. The white blobs give the position of galaxies, and they’re obviously clustered together into clumps and long filaments. That’s just what we see with real galaxies, and by comparing just how ‘clumpy’ the two distributions are we can test our ideas about the early universe, and see what changes we have to make to get the best possible agreement with reality.
Summary
Hopefully you now have some idea what a computational astrophysicist does, and why it can be useful. There are many other problems which can be solved this way besides the N-body problem: some simulations represent the interior of stars, or the behaviour of matter falling into a black hole. In these cases they’ll need more rules in addition to gravity, such as rules for how hot gas behaves under pressure.
Simulations are used in most other areas of science too, but astronomy’s a field in which they’re particularly invaluable. That’s partly because of the difficulty in performing experiments as I said above. But there’s another reason too, which is to do with the complexity of the rules a simulation would need to encapsulate. I’m sure psychologists would love a simulated human to subject to a range of simulated stimuli, but at present we don’t understand anything like enough about the basic laws of brain operation to produce a realistic model of the whole mind. A lot of astronomical phenomena, on the other hand, are governed by physical processes of which we have a reasonable understanding. The rule for gravity is simple enough that programming a computer to adjust speeds with it isn’t too hard (although there are lots of clever tricks used to make the computations faster and more efficient). The same goes for many other physical laws which apply, allowing simulations to provide a very fruitful area of research and making them indispensable for modern astronomy.
* The caption in the video says it’s 6 billion, but that’s a mistake.



Nice. The 2nd video made me finally understand the title of your blog. Just one question: with 100 billion galaxies in the universe, isn’t it quite likely that two of them are colliding right now? Couldn’t you just look at them?
Good question Brandon. Yes, there are lots of examples of interacting and colliding galaxies (for some pictures, see the bottom section of this page), and we can learn a lot just by looking at them. But the process is so ridiculously slow that essentially no change occurs on the timescale of human civilisation, so for each pair of galaxies we just have a single snapshot. Putting snapshots from many pairs together to form a story of the merger is possible, but each pair might differ in the galaxies’ masses, speed and angle of approach, ratio of gas to stars, and so on. With simulations we can directly change each of those parameters and re-run the collision, to find out just how each one effects the progress of the merger.
And yes, I’ve been meaning for a while to dedicate a post to the cosmic web itself - it seems reasonable to explain the site’s name. Pretty video, isn’t it?
[...] Davis of the Cosmic Web talks about the importance of computer simulations in astrophysics; how seemingly simple problems can be [...]