Skip to content

Ray tracing in a curved spacetime around black holes or neutron stars. Light bending near extremely highly magnetized neutron starts due to non-linear QED effects.

Notifications You must be signed in to change notification settings

ikicic/black-hole-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Black hole renderer (BHR)

BHR is a C++ code for visualizing black holes and neutron stars with simple accretion disks.

Implemented features:

  • integration of geodesics (ray tracing) in flat and curved spacetime (rotating and non-rotating black holes) [1]
  • computation of polarization of light along the geodesic [2]
  • relativistic Doppler effect [2]
  • bending of light caused by nonlinear interaction with very strong magnetic fields of neutron stars [3]
  • Shakura-Sunyaev accretion disk (outer layer) [4, 5, 6]

Other aesthetic features:

  • "sky" background texture
  • quadtree-based anti-aliasing and optimization

Compilation

Use the following commands to compile the code:

mkdir -p build
cd build
cmake ..
make

Usage

Note: The BHR code is quite experimental and not entirely user-friendly at the moment. The settings like the type of the spacetime, the spacetime parameters, the disk type and what quantities are visualized are all currently set at compile time (see src/bhr/config.h, src/bhr/parameters.h and src/bhr/main.cpp). This is because the integration of geodesics is quite slow, so the idea was to disable everything unused and help the compiler optimize the code as much as possible. Maybe one day I refactor the code and make everything configurable at runtime. The output image resolution, camera position and similar parameters are currently configurable through command-line arguments (see src/bhr/settings.h).

To run the code, execute the following:

# Go back from build/ to the repository root.
cd ..

# Prepare output folders.
mkdir -p output/preprocess
mkdir -p output/raw

# Run.
./build/bhr --width 1024 --aspect 16:9 --output_image output.tga --no-cache

By default, the code renders a rotating black hole of mass 1.25 MSun with an angular moment of 0.998 (relative). (The mass is so small because it actually represents a neutron star, but its radius is set to 0.)

The expected output is the following, with a different color scheme and no legend:

The black lines denote the polarization, and the colors the light intensity. Due to the Doppler effect, the left side (rotating towards the camera) is a few orders of magnitude brighter than the right side.

Lite version

A smaller single-file code for rendering a black hole with a disk is available in src/lite.cpp. The code supports only the Kerr metric (rotating black hole) and dummy disk coloring.

Use the following commands to compile and run it:

mkdir -p build
cd build
cmake ..
make lite
./lite

Alternatively, compile manually with the following:

cd src
g++ -O3 -march=native -std=c++17 lite.cpp -o lite
./lite

The lite code produces the following image (stored as output_lite.tga).

The black hole is marked in red. The colors on the disk denote the location on the disk. Multiple images of the same disk can be seen.

Gallery

More renders are available here.

References

  1. Müller, T., & Grave, F., Catalogue of spacetimes. arXiv preprint (2009) arXiv:0904.4184

  2. Chen, B., Kantowski, R., Dai, X., Baron, E., & Maddumage, P., Algorithms and programs for strong gravitational lensing in Kerr space-time including polarization. The Astrophysical Journal Supplement Series (2015) 10.1088/0067-0049/218/1/4 arXiv:1505.02714

  3. Kim, J. Y., & Lee, T., Light bending by nonlinear electrodynamics under strong electric and magnetic field. Journal of Cosmology and Astroparticle Physics (2011) 10.1088/1475-7516/2011/11/017 arXiv:1101.3433

  4. Shakura, N. I., & Sunyaev, R. A., Black holes in binary systems. Observational appearance. Astronomy and Astrophysics (1973) [pdf]

  5. Novikov, I. D., & Thorne, K. S., Astrophysics of black holes. Black holes. (1973)

  6. Page, D. N., & Thorne, K. S., Disk-accretion onto a black hole. Time-averaged structure of accretion disk. The Astrophysical Journal (1974)

About

Ray tracing in a curved spacetime around black holes or neutron stars. Light bending near extremely highly magnetized neutron starts due to non-linear QED effects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages