Follow the reluctant adventures in the life of a Welsh astrophysicist sent around the world for some reason, wherein I photograph potatoes and destroy galaxies in the name of science. And don't forget about my website, www.rhysy.net



Tuesday 16 February 2016

How To Build A Galaxy

Take one part gas, ten parts stars, a hundred parts dark matter, mix together and simmer lightly for a billion years. Serve warm with a booming godlike voice.

Alas, no-one has any idea what the real recipe for galaxies is. Actually that's not true : lots of people have lots of different ideas, but hardly anyone agrees with anyone else. We're reasonably sure of the ingredients, but as to the cookery method we're definitely still at the pre-school level of making mud pies.


Ordinary spiral galaxies contain lots of stars, a fair bit of gas, some dust, and probably lots and lots of mysterious dark matter. But trying to work out the best way to cook all these together and get a galaxy isn't easy. Or rather, making a spiral galaxy is remarkably easy, but figuring out the method nature actually uses is much more difficult.

Sometimes it's best to avoid trying to figure out where galaxies come from and concentrate on what they're doing. After all, we're a lot more sure of what galaxies are than how they're made. For example, we know of several dozen clouds of hydrogen gas without any stars, seemingly just floating freely in space without any nearby galaxies. Most people wave their hands and say, "tidal debris !" by which they mean the gas must have been ripped out galaxies somehow, even if its properties don't match expectations at all.


A few people think that maybe these clouds are themselves "dark galaxies" - clouds of gas held together by dark matter that have never formed stars. I'll discuss the arguments for and against this in a future post. For now, it's enough to know that I want to test one simple hypothesis : could a dark galaxy survive in the chaotic environment of a cluster of galaxies ?

To do this, of course I need a dark galaxy to start with. That means I need to tell the computer to simulate a rotating disc of gas inside a cloud of dark matter. Doesn't sound so hard, does it ?

Building a galaxy turned out to be a fascinating exercise. With massive naivety, I thought it would be better to start with a "simple" uniform density disc of gas and nothing else. It wasn't. Now, I expected that because gas is rather more complicated than stars, it wouldn't be perfectly stable. I thought it would probably develop a few clumps and spiral arms and whatnot. But I didn't expect it to insist on turning into a ring and then explode.

Particle trajectories. You can see the original disc as the faint circle in the centre.
It turned out that I'd made a very rudimentary error here. There is a well-known and very simple equation that gives the velocity for a particle to maintain a circular orbit. In fact, it's so simple I'm going to show it here :
M is the mass of the object, G is the gravitational constant, and r is how far away you are from the centre. You can use this to calculate the speed of satellites around the Earth or planets around the Sun no problem at all.

But I had forgotten a very important assumption behind this equation. Here, M is the mass within the radius r - that is, all the mass that's below you. The assumption is that if you're inside a sphere, all the mass beneath you (closer to the centre) can be treated as though it was an infinitely small point at the centre, whereas all the mass above you can be ignored. It turns out that this is perfectly fine for spherical masses, but it is not true in general. I assumed that since a uniform density disc is just a thin slice of uniform density sphere, it would still work. But no matter what parameters I tried, I always ended up with a ring.


The problem is the assumption that you can treat a disc as being like a slice of a sphere. It turns out that really doesn't work.

Imagine that you're floating around inside a giant shell with the mass of a planet, and you look around with a telescope. Or, to better illustrate it, you shine a torch at the surface. Actually make that two torches, pointing in opposite directions.


Clearly the area illuminated by the more distant region is bigger than the the part of the shell illuminated that's nearer to you. The two flashlights have the same beam angle, it's just distance that makes the difference. It turns out that the gravitational force pulling you towards the more distant but more massive area is exactly cancelled out by the smaller nearer one. Because it's a sphere, it doesn't matter which way you look - the two opposite areas in any direction will always cancel.

The reason for this, essentially, is that the force of gravity depends on the distance squared and the mass, but the mass itself also depends on distance squared. If the more distant area is twice as far away, then the force it exerts will be four times smaller at the same mass... but it's also actually four times more massive. So it exerts exactly the same force as the nearest area ! Everything is in perfect balance.


Now, if you nest a bunch of shells inside one other, you get a filled sphere. By the shell theorem, you won't feel the force of any shells above you - only below. This is ground into us at undergraduate level so much that I completely forgot to check whether this assumption still holds if you're in a disc or a ring.

It doesn't.

The geometry of a ring is fundamentally different to that of a sphere. If you're inside a hoop and illuminate the two opposite sides with your torches, the mass of each segment now depends only on their distance. Not the distance squared, just the distance. But gravity still depends on distance squared... so the two opposing forces do not cancel. If you're floating inside a giant hoop, you'll be pulled towards the nearest part.

If the segment on the far side is twice as far away, the force it exerts at any given mass is still four times smaller... but the actual mass will only be twice as large. Hence the nearby smaller segment exerts more force. Rings are much more similar to Mr Burn's unstable equilibrium state than spheres.
Or imagine an even simpler example : two identical planets floating in space. Unless you're exactly midway between the two, you'll be pulled towards the closer one. In short, the gravitational field depends very strongly on geometry - you can't use the classical sqrt(GM/r) equation to determine the velocity in every case.

Anyway, my first reaction on finding out that my galaxy had exploded was to call the author of the code, my good friend Rory Smith (who we've previously met destroying a galaxy, albeit last time deliberately) and ask him why the hell it wasn't working. His reaction was not encouraging.
Where to start. Setting up disks is a nightmare ! I spent about 6 months of my PhD on it and they still weren't great. And its not just me - DICE is a very clever parallelised code used for setting up galaxies. It runs on 8 cores, chugging away for half an hour,  carefully measuring the potential gradients everywhere on logarithmic grids. Then you run the initial conditions and the disk collapses, bars, forms rings, etc, etc!
Rory also sent me a link to a paper where the authors had calculated how to set the rotational velocity for a uniform disc, just like what I was trying to do. It was even more dispiriting than Rory's own response. I mean just look at it. LOOK AT IT !!!




It doesn't even end with a nice simple equation I can use. No way am I prepared to slog through that many equations, so instead I came up with another approach.


The simulation code can directly measure the accelerations every single particle experiences. They aren't derived from some clever formula, they're directly measured. Fortunately, the equation for circular motion is very simple (v^2 = a*r) once you know the acceleration a in the radial direction, which of course we do. So by feeding in the particle disc into the simulation we can measure the initial accelerations and use them to determine the velocity needed for circular motion. A little bit of vector analysis is needed to make sure we're measuring the acceleration in the right direction, but it's not too difficult.

And so I did that... and lo ! It didn't work. But at least now it didn't work in a slightly different way.


This time the disc simply fragments and breaks apart without any large-scale motion turning it into a ring. The problem is that the gas is cold. Because the particles are distributed at random, by chance there are some regions which are denser than others and tend to collapse. In reality these would form stars, but that won't help with my nice "simple" pure gas disc. Another solution is to make the gas hotter, so that its random motions will smooth out any condensations that start to form. Trouble is we don't want to make the gas so hot that the thing just turns into a sphere or completely evaporates.

After a great deal of trial and error tweaking, the best I could come up with was this :


Any colder than this and the disc becomes a few large fragments which disperse because the system is no longer symmetrical. Any hotter and the whole thing evaporates. As it is there's just one large fragment in the center - so it remains a disc, just not a uniform density one. I concluded (along with some dodgy mathematics) than uniform density discs are probably impossible.

Fortunately, there is a solution. As we examined last time with Rory, observations show that galaxies are spinning much faster than expected. This implies there's a lot of extra mass holding them together - without "dark matter", they'd just fly apart. Adding dark matter just makes everything better. After a few failed attempts where I made some silly mistakes, pretty soon I had this gobsmackingly stable disc :


OK, sure, it's not perfectly stable. It gets a bit denser in the centre, but not very much. Some rings appear but they more or less disappear by the end. And it definitely does not explode or fragment.

The beautiful thing about dark matter is that it provides lots of extra stability to the disc. The extra gravity means the gas can be much hotter without it evaporating, which means it's much less prone to fragmentation. It also changes the rotation velocity curve (that is, how fast it's rotating at different distances from the centre), making it much more stable against differential rotation.

Without dark matter I had to very very carefully tweak parameters to get something that even vaguely works; with dark matter I found I could set things almost however I wanted and the thing would be incredibly well behaved. I could even send it hurtling through a galaxy cluster and nothing much happened. Unlike Mr Burns, who is in terrible danger from even a light breeze, it really is practically indestructible.

Dark matter shown in pink.


But what about that paper with the scary maths ?

The problem here is that despite the mathematical horrors, it's actually an over-simplification. It considers only velocity and gravity - the thermal motions and fluid properties of the gas are ignored. And as we've seen, these can be extremely important. It was also written by non-astronomers who concluded that because the gravitational field of a disc is different to a sphere, there's no need for dark matter. Which, as I've expounded many times previously, is just not true.

And yet... when I measured the rotation velocities needed to support the uniform pure gas disc, I found something very close to what the authors said it should be. That this didn't actually make a stable disc didn't stop me from being intrigued.



The black line is what you'd expect if you could use the shell theorem and ignore the mass beyond any given radius. The blue line is what my code produced based on the actual accelerations experienced by the particles - there's some scatter in it because there are only a finite number of particles in the simulation (which is another complication that I won't go in to). The green line is the mathematical result from the paper, linearly stretched to fit the blue line as best as possible. It works pretty well except at the very end, where the mathematical solution goes to infinity which is obviously nonsense.

This extremely good agreement perked my interest, and reassured me that my code was working correctly. But could it really be that dark matter was an illusion based on a faulty assumption ? The authors claim that a nice flat rotation curve arises if you use a linearly-decreasing density profile instead of a uniform density as above. I wrote a code that could distribute particles according to any input density profile, so I tested the linear density profile too.


Pretty darn good ! This time the red points are measuring the curve for the gas particles and the blue points use massless "test particles" placed beyond the edge of the disc, just to see how the curve would extend. The green is from the paper again - it looks rather flatter in their paper only because they use a different scaling. It does not, however, resemble the flat (or slightly rising) rotation curve from observations. Like this one for M33, from Wikipedia :


But there's worse. The author's assumed that the density of the disc decreases linearly with radius. This is simply not the case at all for real galaxies, which usually have an exponentially decreasing density profile. So I constructed a rotation curve using a realistic density distribution for M33. Very realistic, because I simply took it directly from observational data. I used the Arecibo data I've described previously for the gas and Digital Sky Survey data for the optical. Google searching for papers gave me reasonable values for the total mass in stars. It was quick and dirty, but far superior to assuming a uniform or linearly-decreasing density profile.

The gas density is uniform in the centre then exponential beyond
the stellar disc, while the stellar disc is always exponential. Hence
the combination produces something a bit weird.
Oh. Well that's not very much like the observations at all, is it ? No, no it isn't. An exponential density profile means there's much less material in the outskirts than in the uniform or linear case. So much less, in fact, that the classical v = sqrt(GM/r) becomes a good approximation after all. Why the authors felt they should use a linear density profile I've no idea, because even a Google image search for "galaxy density profile" reveals that their profiles aren't linear at all. That's more supporting evidence for my theory that mathematical abilities are no guarantee of intelligence, or even simple knowledge in this case.

And it gets worse. In all of the above cases, including the uniform and linear densities, I assumed a total mass equivalent to the combined observable gas and stars. Have a look at the rotation velocity values : maxima of 50-70 km/s. The real M33 rotation velocity exceeds 100 km/s even at the highest distance to which we can measure the rotation curve. Unless you want to modify gravity or invoke another force entirely, there's no way to avoid the need for extra mass. You just can't avoid dark matter that easily.


In summary, there's a heck of a lot of physics in just a rotating disc of gas. It's an under-appreciated point that the gravitational field of a disc is very different to a sphere... but accounting for that isn't enough to keep it stable. The distribution of the material matters, but so too does its temperature and rotation. Ironically, it really does seem to need such a large amount of mass that it brings the rotation back to what you'd expect if it was a sphere after all - even if the disc is uniform, when its velocity profile should be very different if you ignore all the other factors at work.

If I'd just started with a disc inside a dark matter cloud, I'd have been completely unaware just how complicated the situation really is. So the old cliché is true : you learn more from mistakes than successes. That's a nice warm fuzzy feeling to end on, so let's throw in a dose of cynicism to keep it real.