## Ray Tracing in Curved Space TimeAn example of a HPC task is to calculate the trajectories of photons near a black hole. The extreme physics means that they no longer travel in straight lines due to the curvature of space-time. So object near a black hole will be gravitationally lensed, when viewed from afar. Here, we will investigate how to calculate the observed shape of a thin disk surrounding the hole. Having a thin disk around a black hole isn't too outlandish. When gas orbits around a black hole, the conservation of angular momentum means that friction forces will eventually convert it into an "accretion disk". In common situations, that disk will be thin compared to its extent. Astronomers using telescopes to observe such systems need to understand their results, so having a theoretical model of what the simplest possible case will produce is quite helpful. The first step is to model the rays of light as they travel. The problem here is that gravity curves space-time near a black hole. Using simple geometry to calculate intersections no longer is possible. (You might be able to describe the trajectories in terms of elliptic functions... but that doesn't help all that much for more complex problems.) Instead, we can describe the motion of the photon as a set of coupled differential equations in Boyer-Lindquist Coordinates:
Where we have used some constants of the motion to simplify things a bit: To start the photons off, we need some initial conditions:
Where we have an observer at some distant location described by r0,theta0 looking back at the disk. The photons are parameterized by x, y in the "view port" of the observer. By scanning over x and y, we can build up an image once we know where each photon goes. Now that we have the math out of the way, the next step is to worry about calculating the motion. Since we have a set of coupled ordinary differential equations, we use a Runge-Kutta algorithm for this. It numerically solves the equations, giving us the position and direction of the photon at discrete points along its path. The R-K algorithm will dynamically tune the sizes of the steps it takes in order to maintain error within some given tolerance. We take a standard R-K routine, and rewrite it so that the compiler can easily vectorize the loops:
The driver routine that determines the step sizes can be more standard:
This allows us to follow the photon where-ever it goes. The next trick is to worry about imaging the disk. The problem here is that the R-K routine will give us discrete steps as output. These steps most likely will not ever exactly hit the disk, and instead will skip over it. What we need is some way to tune the size of the step in order to hit the disk to within some tolerance. Since space-time is curved, there is no easy way of guessing the size of step needed. Instead, we use a binary search technique by noticing which hemisphere the photon happens to lie in.
With that done, it is an easy matter to fire rays from our observer, and then see if they hit the disk or not. In order to image the disk, we break it up into a checker-board pattern. The following routine then will return the rgb value of the pixel corresponding to a ray. If the ray avoids the disk, and either escapes to infinity, or hits the black hole, we colour the pixel black. Otherwise, we will colour it a blue shade based on where in the disk it hit.
So now, we just need to worry about outputting the rgb image data. The easiest way of doing that is to use the Targa (tga) format. It has a very simple header, and raw rgb follows it. A couple of routines to output the header are:
Where in the above we are careful, and make sure the writes complete correctly. It is easy to just assume that they always will... but it doesn't hurt very much to write a wrapper function that makes 100% sure. Finally, we can complete our program. This outputs a file called "image.tga" of size 100x100 pixels with a non-spinning black hole (a=0), with a disk viewed at an inclination of 85 degrees.
## Using MPIThe above code doesn't take too long to run, even when the output image is a thousand pixels on a side. However, more realistic simulations require better models of the physics, and perhaps higher-order scattering, where the initial rays can generate many others. The resulting simulations can take weeks or months on a single machine. So it is important to worry about how to make the simulation parallel. Using MPI, this isn't too difficult. What we do is split the task into two. Most processes can fire rays, and see where they go. However, we need one process to coordinate everything, and output the results. Thus the
Where the "master" function handles the output from the many "slave" processes. This isn't too hard to do if we split the work by scan-line. The master process can just wait for each individual line, and then write them into the write spots in the output file, using the
Slightly trickier is the slave code. The most obvious way of doing it is to use Instead, we can use two buffers and
The above is highly efficient, but we have glossed over something. Note how the master task has a different amount (and type) of work to do than the slaves. With most MPI implementations, this wouldn't be very well designed. The problem is that they will cause the master process to spin inside The fact that processes can go to sleep in Lockless MPI means that load balancing is much simpler than in other MPI implementations. The scan-line hack works well here, but a more advanced code would require the master thread to hand out work units on an as-needed basis. (Otherwise some processes may finish their work well before others, wasting time at the end.) By using a customized control process that load-balances the others, that is easy to accomplish. ## ResultsWe model a disk ranging from 20 Gravitational Radii from the black hole down to the innermost stable orbit. Firstly, we will look at disks around non-rotating "Schwarzschild" black holes. When viewed from 45 degrees, our disk looks like: The Gravitational Lensing is a little bit subtle in the image, but it is fairly easy to see that the top of the disk has an apparent shape slightly distorted compared to the bottom. However, the biggest feature is the strange ring in the middle, between the innermost stable orbit and the black hole itself. This actually is an image of the bottom of the disk! What happens is that light rays can half-orbit the black hole, and then come from the bottom along those trajectories. Even more difficult to see is a third-order image where light orbits once completely around the hole. In fact there are an infinite series of these images, each smaller than the last. Now what happens when we view from 85 degrees: Here, the lensing of the primary image is extreme. The back part of the disk appears to "jump up" due to the photons being bent towards the hole. The second order image below the plane is also becoming quite prominent. (You can also see how left and right sides are swapped there due to the colouration.) When we move to a spinning black hole, the effects of space-time curvature become more extreme. (We choose a maximally spun-up "Kerr" hole with a=0.998) Viewing again at 45 degrees yields: Here the most obvious difference is that the disk is much larger. It approaches closer to the event horizon due to the marginally stable orbit decreasing in radius. (And hides the higher order images in the process.) The effects of inertial-frame dragging are also apparent. The innermost part of the image appears to swirl around the black hole. This is caused by the spinning of the black hole imparting a sideways motion onto the photons. (Remember, the disk still has the same shape as it originally did - it just looks different due to the changed lensing.) Finally, we look at the 85 degree version around our Kerr black hole: The asymmetry introduced by the spin is highly obvious in this image. We can also see the bottom of the disk peaking out down below. Even though the object near the black hole is a simple 2D ring, the result is quite complex. This shows how difficult it may be to interpret data from such objects. Inverting all the distortions is a complex challenge. However, those distortions themselves can tell us information about the extreme physics involved. |

About Us | Returns Policy | Privacy Policy | Send us Feedback |

Company Info |
Product Index |
Category Index |
Help |
Terms of Use
Copyright © Lockless Inc All Rights Reserved. |

## Comments

Nobody said...