New EinsteinPy 0.5.0 — Python 3.10 to 3.15 →

General relativity,
in plain Python.

Compute geodesics, manipulate tensors symbolically and visualise curved spacetime — in Schwarzschild, Kerr and Kerr-Newman geometries, right next to NumPy, SciPy and Astropy.

$ pip install einsteinpy
MIT licensedPython 3.10 – 3.15Built on Astropy, NumPy & SymPy
Schwarzschild geodesic · periapsis advance
From idea to trajectory

A few lines from equations to a plot

Define the initial conditions, pick a metric and let EinsteinPy integrate the geodesic.

  geodesic.py
import numpy as np
from einsteinpy.geodesic import Timelike
from einsteinpy.plotting.geodesic import StaticGeodesicPlotter

geod = Timelike(
    metric="Schwarzschild",
    metric_params=(0.,),
    position=[40., np.pi / 2, 0.],
    momentum=[0., 0., 3.83405],
    steps=5500,
    delta=1,
    return_cartesian=True,
)

plotter = StaticGeodesicPlotter()
plotter.plot(geod)
plotter.show()
1

Pick a spacetime

Schwarzschild, Kerr or Kerr-Newman — or bring your own metric.

2

Integrate

Timelike and null geodesics with higher-order integrators, accelerated by Numba.

3

Visualise

Static, interactive and animated plots that make Einstein's ideas visible.

Symbolic relativity

Curvature, derived exactly

Build a metric, then get Christoffel symbols, Riemann, Ricci, Einstein and Weyl tensors as SymPy expressions you can simplify, differentiate and lambdify.

  symbolic.py
from sympy import simplify
from einsteinpy.symbolic import (
    Schwarzschild, ChristoffelSymbols,
    RicciTensor, RicciScalar, EinsteinTensor,
)

m = Schwarzschild()            # predefined metric

ch = ChristoffelSymbols.from_metric(m)
simplify(ch[0, 0, 1])   # r_s / (2*r*(r - r_s))
simplify(ch[1, 2, 2])   # -r + r_s
simplify(ch[2, 3, 3])   # -sin(2*theta)/2

ricci = RicciTensor.from_metric(m)       # every component -> 0
R     = RicciScalar.from_metric(m)       # -> 0
G     = EinsteinTensor.from_metric(m)    # -> 0 (vacuum)
output · rendered from SymPySchwarzschild
Metric
Christoffel symbols
Riemann curvature
Vacuum check
Predefined metrics
SchwarzschildKerrKerr-NewmanReissner-Nordströmde SitterGödelAlcubierre warp…and custom metrics
Tensors
ChristoffelRiemannRicciEinsteinWeylSchoutenStress-energy

Browse the symbolic notebooks →

Key features

Everything you need to explore relativity

A focused toolkit for students, researchers and the curious — open source from core to plotting.

Geodesic trajectories

Calculate geodesic trajectories in Schwarzschild, Kerr and Kerr-Newman geometries with a few lines of code.

Visualisation

A plotting module that turns Einstein’s ideas into plots anyone can understand — static, interactive or animated.

Symbolic calculation

SymPy-based tensors and operations: Christoffel symbols, Riemann, Ricci, Einstein, Weyl and more.

Productive

Work close to the scientific Python tools you already know — Astropy, NumPy and friends.

Coordinate systems

No more guessing which coordinates to use — EinsteinPy converts between them smoothly.

Open source

Core, plotting and symbolic modules are MIT licensed and developed in the open on GitHub.

Metrics SchwarzschildKerrKerr-NewmanGeodesics timelike & nullOutput Matplotlib & Plotly

Help sustain EinsteinPy

We are in dire need of sponsorships to help sustain the project's activities. If EinsteinPy is creating some change for you, please consider donating.

♥ Donate