This has been a long time coming, and I am thrilled that we are finally making this codebase public! Our group is releasing GPUmonty: a GPU-accelerated Monte Carlo radiative transfer code that simulates the appearance of hot gas falling onto a black hole. The big news is that our code is the first to solve this problem using GPUs, and it is over ten times faster than previous solutions. The entire stack is built on CUDA C.

<h2 id=tracking-photons-in-curved-spacetime>Tracking Photons in Curved Spacetime</h2><p>Doing this properly is tricky business. First, this is no ordinary ray tracing, because photons are moving through the curved spacetime around a black hole. GPUmonty handles any background metric provided by the user; in black hole physics, it is customary to adopt the Kerr metric, which describes a spinning black hole.</p>

We must then propagate photons from their origin to the observer. To do so, we solve two sets of equations: the geodesic equation, which governs particle motion, and the radiative transfer equation, which determines whether a photon is absorbed or scattered on its way to the observer. The first set is nonlinear, while the second is linear, but each comes with its own challenges. For example, it is currently impossible to solve these equations for every individual photon, so one trick we use is to model families of photons with similar energies called "superphotons."

output Figure 1: Sketch of the physics of photon propagation from hot gas around a black hole.

Another challenge is modeling the light source: the hot plasma flowing around the event horizon. In reality, we do not know the conditions of such plasma in nature very well, but we have a pretty good idea thanks to intense work by observers and the theorists who model their observations. For example, most supermassive black holes in nearby galaxies are surrounded by tenuous plasma that is incredibly hot, reaching temperatures of about one trillion Kelvin ((\sim 10^{12}) K). This type of plasma model is called a radiatively inefficient accretion flow, or RIAF.

Another source of uncertainty is the magnetic topology of the flow — in other words, what is the shape of the magnetic field lines threading the plasma as it moves around the black hole? This is a major topic of debate in the community. So before generating a spectrum, you first have to model the plasma and its magnetic fields, and then you fire up GPUmonty to see what it would look like to an astronomer far away.

Once the photons reach the mock camera, we count them and produce a histogram binned by photon energy (we astrophysicists call that a spectrum) that looks like this:

sane_comparison Figure 2: Electromagnetic spectrum produced by hot gas swirling around a Kerr black hole. One million superphotons were considered here. Parameters chosen for Sagittarius A*, the supermassive black hole at the center of Our Galaxy. The (y)-axis is luminosity; the (x)-axis is frequency. From Motta et al.

<h2 id=why-is-this-important>Why Is This Important?</h2><p>Sadly — or thankfully, depending on your background — we do not live close to a black hole given our current technology. We cannot simply travel to one and take in situ measurements of the accretion flow and magnetic fields. Instead, we rely on astronomical observations and then solve the inverse problem of extracting parameters from those observations to test our models. Fortunately, we have a wealth of telescopes observing the universe from long radio wavelengths all the way to gamma rays whose wavelengths are smaller than an atom.</p>

This is why codes such as GPUmonty are so important in astrophysics: using these simulations, we can generate synthetic spectra produced by gas as it falls onto a black hole, and then by comparing those models to actual multiwavelength observations of stellar-mass and supermassive black holes, we can learn about the plasma density, temperature, magnetic fields, and even black hole spin.

As our observatories improve, the volume of data they generate is growing so rapidly that theorists have to play catch-up. This is strong motivation for faster codes. Another reason for accelerating our codes is that we often need to perform parameter sweeps in which we generate many models across a range of values. GPUmonty will be invaluable on that front as well.

gpumonty_vs_igrmonty Figure 3: How GPUmonty scales with the number of superphotons, compared to a CPU-based solution. We reach up to 12× speedups. From Motta et al.

<h2 id=paper-and-code>Paper and Code</h2><p>To play with our code, visit our GitHub repository. You will need an NVIDIA GPU, a black hole plasma snapshot to serve as the light source, and several libraries, all described in the repo.</p>

Details of the (astro)physics, numerical methods, CUDA kernels, and profiling are available in the paper we just submitted to The Astrophysical Journal.