Skip to main content

GRAVITYp

GRAVITYp is a Python package for studying the optical appearance of spherically symmetric compact objects in General Relativity. It stands for Geodesic RAys and Visualization of IntensiTY profiles.

About the project

This is the Python implementation of GRAVITYp, which is originally a numerical code in Wolfram language developed by G.J. Olmo, D. Rubiera García, J.L. Rosa, D. Sáez-Chillón and collaborators arXiv:2307.06778v2. It was developed to study the optical appearance or shadow cast by black holes, wormholes and different kinds of exotic compact objects, inspired by the work of S.E. Gralla et al. arXiv:1906.00873.

Then, Á. Salazar Cuadros preferred to work on Python seeking faster execution times for simulations and a language better suited for Version Control Systems (VCS), and that's how the Python implementation was born. The goal of this open source version is to provide open access to anyone interested in using the package or learning how simulated black hole shadow images are generated.

Installation

GRAVITYp is available on PyPI

pip install gravityp

Alternatively, you can clone GRAVITYp locally in editable mode for research and development and install it in your virtual environment

git clone git@github.com:alvaroslzar/GRAVITYp.git       # SSH
git clone https://github.com/alvaroslzar/GRAVITYp.git   # HTTPS

cd GRAVITYp
pip install -e .

Usage

Quick example

import numpy as np
from gravityp import make_geodesics_plot

def g_rr(r: float, dummy) -> float:
    """Radial function g^{rr} of the Schwarzschild metric in units of M=1"""
    return 1 - 2./r

def g_thth(r: float, dummy) -> float:
    """Areal radius squared g^{theta theta} of the Schwarzschild in units of M=1"""
    return r**2

# Dictionary codifying Schwarzschild metric and required params
Schwarzschild_kwargs = {
    'r_phs': [3.,],         # Photon sphere at r=3M
    'inner_edge': 2.,       # Inner edge of disk at horizon r=2M
    'radial_fun': g_rr,     # Above defined radial function
    'radial_params': None,  # g_rr has no additional params
    'areal': g_thth,        # Above defined areal radius squared
    'areal_params': None,   # g_thth has no additional params
}

# Array of impact parameters from 0M to 10M
impact_parameters = np.arange(0,10,0.2)
make_geodesics_plot(impact_parameters, figsize=(4,4), **Schwarzschild_kwargs)

The output image looks like this:

ray-tracing

For a more detailed explanation, check the Jupyter notebooks in the Examples folder for details.

Intensity profiles and black hole shadows

The primary use is to obtain the observed intensity profile $I_\mathrm{ob}(b)$ as a function of the impact parameter $b$ given some predefined emission profile $I_\mathrm{em}(r)$. The emitted light is due to the matter in the accretion disk, which is assumed to be both geometrically and optically thin. Moreover, the orientation is assumed to be face-on with respect to the accretion disk, so the optical appearance has have rotational symmetry.

In the following images, the emission profile of the accretion disk has been chosen to peak at the event horizon $r=2M$, and the optical appearance corresponds to a Schwarzschild black hole.ç The code properly reproduces the predicted light rings up to two intersections with the accretion disk, as well as the central brightness depression or shadow characteristic of compact objects such as black holes.

emitted observed shadow

Further references

Watch Prof. D. Rubiera García's talk for an overview of the main concepts involved in the ray-tracing method and analysis of intensity profiles.

For an introductory discussion of the inner workings of the Wolfram Mathematica code, watch Prof. G.J. Olmo's tutorial; for a more user-friendly application, watch Dr. J.L. Rosa's talk.

Finally, for a more advanced topic regarding compact objects, watch Prof. D. Sáez-Chillón's contribution.

Citation

The use of GRAVITYp in scientific publications must be properly acknowledged. Please cite the following:

BibTeX

@article{Nojiri:2026tjn,
    author = "Nojiri, Shin'ichi and Odintsov, Sergei D. and S{\'a}ez-Chill{\'o}n G{\'o}mez, Diego and Cuadros, {\'A}lvaro Salazar",
    title = "{Horizon singularity, energy conditions and shadows in time-dependent and spherically symmetric spacetime}",
    eprint = "2608.15740",
    archivePrefix = "arXiv",
    primaryClass = "gr-qc",
    reportNumber = "KEK-TH-2861, KEK-Cosmo-0429",
    month = "8",
    year = "2026"
}

Publications using GRAVITYp

Let us know if you use GRAVITYp in your publication, and we will add it to the list of publications!

Author

The author and mantainer of the Python code is Álvaro Salazar Cuadros.

License

The software is licensed under the MIT license.

Metadata

Release files for gravityp 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gravityp 0.1.1
File Size Uploaded
gravityp-0.1.1.tar.gz 16.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gravityp 0.1.1
File Interpreter ABI Platform
gravityp-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.3 kB

Release files / gravityp-0.1.1.tar.gz

Download URL gravityp-0.1.1.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
433b5661062727512f90049ec3fc68624430a331df9b1168c29368981269ced9
BLAKE2b-256 checksum
How to use checksums
0c53a8cc61f5a9b4d7b9e4fe153f1abd31bb44bb2444070249ab49f696f3444e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / gravityp-0.1.1-py3-none-any.whl

Download URL gravityp-0.1.1-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de1c72c09bbdde7a4e88d9b5b7daf8e5440cfe904876df83f935908968e2f7f5
BLAKE2b-256 checksum
How to use checksums
587c96ebdbc9ddbb095efca5f49d38a224b4baa09951c3ff40144568e5285c2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page