Sunday, April 11, 2010

Spiral Galaxy Hack



As a sidetrack from my sidetrack I've been reading about galaxy formation (among other things). Galaxies look like a drain swirling, but when you think about it that can't be how they move or else the arms would wind tighter and tighter until they disappeared. Likewise they can't move like a pinwheel since that would require the outer tips to move much, much faster than the inner core, in direct opposition to how gravitational orbits work.

On the Wikipedia page about density wave theory I found this diagram:



The idea is that star orbits are elliptical but they are not oriented in all directions with equal probability. Instead, the orbit's direction correlates with its size. At this point I took the ball and ran my own direction with it, so abandon all hope of physical plausibility, ye who read below.

If stars were influenced primarily by the massive black hole at the center of the galaxy, and not so much by their neighbors, then they'd follow roughly elliptical orbits. This is most likely wrong, but since I had already written a solar-system orrery program with this assumption, that's what I used.

If stars followed elliptical orbits, the ellipses would not be centered as in the diagram above; instead they'd have one focus at the center of the galaxy. The stars would spend more time at the far end of the ellipse than at the near end. If the far ends of the orbits were arranged in a spiral, you'd have a spiral region of high star density, like this:



I don't know what force would cause star orbits to align in this way. If it was a symmetric process you might end up with a separate set of stars following orbits aligned 180 degrees opposite, which would produce a two-arm galaxy:



I took my solar system orrery and replaced the planets and asteroids with random stars whose orbital parameters followed these ad hoc rules:
  • Pick a random eccentricity. I'm using a Guassian-ish distribution around 0.35, plus or minus 0.1.
  • Pick a random orbit size. I'm just picking a uniform number over a range of sizes, which is almost certainly unrealistic.
  • Pick a random initial position in orbit as a fraction of total orbit duration. This should be uniform although you can get some cool effects when it isn't.
  • Compute orbit orientation as a linear function of orbit size.
  • Compute a star color as a linear function of orbit size as well.
  • I'm not tilting orbits out of plane at all right now.


To plot the stars the orbital elements have to be converted to instantaneous positions, which takes a little bit of Newton-Raphson iteration. I used David Vallado's Fundamentals of Astrodynamics and Applications for the algorithm.



Here it is in motion; you can see how the stars come and go across the spiral arms but they are denser there. I don't know if real galaxies move at all like this, though:



If you'd like to scrub time back and forth and examine individual star orbits, here is the Windows program I wrote to generate the movie:
Use the mouse wheel to zoom and the A key to toggle animation. You can also adjust the clock by dragging individual stars around their orbits with the mouse.

4 comments:

LogicalError said...

Whoa.. I just had a weird optical illusion.
After looking at your youtube for a while, I then looked at the real picture above, and I could've sworn it was spinning ;)
Anyway... looks cool!

Tometheus said...

^ You're right, that does make a nice little optical illusion.

Charles Francis said...

Hi,

Basically, you are on the right track.

you might like to see http://en.wikipedia.org/wiki/Gravitationally_aligned_orbits, or http://rqgravity.net/SpiralStructure. We which we published in Proc Roy Soc A

James McNeill said...

Awesome! Thanks for the links!