For my 4th year undergraduate project I invesitgated the possibility of forming a disc galaxy without dark matter via numerical simulation. The only tool to create animations necessary to understanding the simulations was an impossibly crude piece of in-house code. Sadly at the time I had neither the time nor sufficent understanding of Blender to do anything about it.
For my PhD I moved into observational astronomy, but my stalwart friend Dr Rory Smith (now somewhere in Chile) remained loyal and true to simulations, for some reason. By this point I was adventurous enough to start teaching myself Python to import simulation data into Blender. Note that I didn't run any of these simulations myself, and they NOT done using Blender's physics simulations !!
I began with the obvious and simplest approach of importing each data point as a seperate object and animating each one through keyframing. This turned out to be a really Dumb Thing To Do, because, as explained in "FITS in Blender", the software isn't optimised for it. But it's useful for certain things. Rory was simulating a galaxy falling into a cluster, where they other galaxies are modelled as single points. Which of course can easily be made to look quite pretty in Blender.
It's also fun, though not very useful, to plot the trajecotry of each of these point-galaxies.
SInce the most obvious method of importing individual particles from a simulation fails miserably - each simulation will have upwards of 20,000 particles - I concocted another approach. The first frame of the simulation is read into Blender and each particle is a vertex in the same mesh. This mesh object is keyframed so that it appears in layer 1 only in frame 1. The second frame is read in as another mesh of verticies, but this only appears in layer 1 only on frame 2. And so on, and so forth. In this way it appears exactly as if the data was animated, when really it's just a series of snapshots, and the script runs very fast and doesn't require much memory.
Stars are rendered as blue-white points while the gas is shown as a white haze
Unfortunately Rory was pretty much the entire of Cardif's Department for Extragalactic Numerical Simulations, so when he left the webpage was removed. So I feel obligated to try and offer a few words of explanation. The above movie shows what happens when a small disc galaxy moves into the malestrom of a galaxy cluster. Its gas is removed by a process called ram pressure stripping, and the effect of having its gas dragged out is to transorm the disc into a spheroid. Below, a disc galaxy collides with an elliptical, producing something quite similar to the infamous "Cartwheel" galaxy.
This approach of animated snaphots proved to be very useful. However, we eventually hit upon a much more advanced approach that's faster and reduces the file size considerably, memory being at a premium due to the almost 1 terabyte of data being used for the raw data. This involves importing each particle as a seperate cube mesh, but only for 1 frame, and assigning each a material. No keyframes are set. Instead, the script checks the current frame and reads from the correct point in a supplied text file to update the view. This is extremely fast, since it only has to alter existing values rather than create new ones (except on the initial frame, but this can be saved to prevent the need to re-create it each time).
The above view shows this method, illustrating again what happens to a galaxy in a cluster. Here, colour is dictated by the gravitational force experienced by each particle. As other galaxies (not rendered) move through the disc they show up as white, representing an increase in the force. The tidal force from the cluster as a whole shows up as a red-white gradient. In this simulation the galaxy's morphology is dramatically altered by all these interactions, in a process called harrasment.
A quite different project we attempted - mostly because it seemed worth a try - was to assign the individual stars colours based on their age. Knowing the age of a star allows us to calculate a temperature (provided you do lots of complicated stuff like assume a particular mass function) and temeperatue corresponds to colour. Having found a colour-temperatue plot somewhere on the web, I wrote a little script to assign each star particle the appropriate RGB colour. We were, of course, hoping that we'd see a nice red bluge and blue, star-forming spiral arms. It sort of works. and at least looks pretty.