RepositoryPython
spacetimeengineer

spacetimeengineer/spacetimeengine

A Python utility for analyzing a given solution to the Einstein's field equations. Built on Sympy.

160stars
18forks
16issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: sympy

#1 Repository of the month

1
TINIX TRENDING·Topic: connection

#1 Repository of the month

1
TINIX TRENDING·Topic: einstein-coefficients

#1 Repository of the month

alt text

A Python utility built on Sympy (A symbolic mathematics library) which will analyze any given metric solution to the Einstein field equations.

equation

Prerequisites (Linux)

1.) Install Python3

$ sudo apt install python3

2.) Install pip3

$ sudo apt install python3-pip

3.) Install git

$ sudo apt-get install git

Prerequisites (MacOS)

1.) Install homebrew

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew doctor

2.) Set python as an environmental variable.

$ export PATH="/usr/local/opt/python/libexec/bin:$PATH"

3.) Install git

$ brew install git

4.) Install python3 and pip3 (https://docs.python-guide.org/starting/install3/osx/)

$ brew install python3
$ brew postinstall python3

Prerequisites (Windows)

1.) Install Python3 & pip3

Navigate to https://www.python.org/downloads/

2.) Install git

Navigate to https://gitforwindows.org/

Installation with pip3

1.) Install with pip3

$ pip3 install spacetimeengine  

2.) Enter python shell

$ python3

3.) Import spacetimeengine

>> from spacetimeengine import *

4.) Create a SpaceTime object which describes the Schwarzschild spacetime

>> schwarzschild_spacetime = SpaceTime(Solution().schwarzschild())

5.) Enjoy watching the coefficients get computed.

Installation with git

1.) Clone repository

$ git clone https://github.com/spacetimeengineer/spacetimeengine

2.) Enter directory

$ cd spacetimeengine/spacetimeengine/samples

3.) Run example.py

$ python3 example.py

Suggested Use

If you are a student or researcher, and you find yourself reading a publication based in General Relativity which provides metric solutions, then this utility can be used for working out the curvature coefficients associated with the solution provided by the user. This can be a helpful utility as you read through the literature because you will be able to cross-reference the information provided by the literature with the values the spacetimeengine provides (this is why I developed it originally). More commonly, this utility can be used for error checking.

Metric Tensor

Generally speaking, any metric solution to the Einstein field equations will be packaged into a geometric object known as the metric tensor. The metric tensor is often represented in matrix form, and the spacetimeengine package adopts this representation.

equation

The spacetimeengine package employs the Sympy 'Matrix' object for packaging the metric tensor and it serves as the essential parameter for constructing a 'SpaceTime' object. The Solutions module currently stores some well-known metrics for study, but these can be used for understanding how to construct new solutions.

Constructing a solution (In development)

Currently, all metric solutions are packaged by specifying four key parameters and storing them in an array. These parameters include an index configuration for the given metric solution, the coordinates to define the metric in terms of, the metric itself, and the cosmological constant. It is important to note that a zero-valued cosmological constant indicates the employment of a classical formulation to the Einstein field equations. Below represents a valid definition of the Schwarzschild stationary black hole solution.

def schwarzschild(self):    

    # Assigns meaning to the coordinates.
    x0, x1, x2, x3 = symbols('t r theta phi')
    # Groups the coordinates in an array.
    coordinate_set = [x0, x1, x2, x3]
    
    # Constants required to describe the metric.
    G, M, c = symbols('G M c')
    
    # Metric.
    metric = Matrix([    
                        [ (1-(2*G*M)/(x1*c**2)), 0, 0, 0 ], 
                        [ 0, - (1-(2*G*M)/(x1*c**2))**(-1), 0, 0 ], 
                        [ 0, 0, - x1**2, 0 ], 
                        [ 0, 0, 0, - x1**2*sin(x2)**2 ]
                    ])
    
    # Describes the index configuration which the metric represents.
    index_config = "dd"
    
    # Cosmological constant.
    cosmological_constant = 0
    
    # An array detailing the solution.
    solution_array = [ metric, coordinate_set, index_config, cosmological_constant ]
    
    # Returns solution
    return solution_array

Similar Projects

Discover other similar projects and AI models.

RepositoryC++
MarcVivas/N-body

N-body simulation made with C++ and OpenGL

56
May 24, 2025
RepositoryShell
ohmyzsh/ohmyzsh

🙃 A delightful, community-driven framework for managing your zsh configuration. Built by 2,600+ contributors, with hundreds of plugins (git, rails, laravel, node, python, docker, kubectl, aws, and more), themes to spice up your terminal, and automatic updates to keep your command line feeling like home.

191.0k
Nov 29, 2026
RepositoryPython
kennethreitz/pytheory

Music Theory for Humans.

1.7k
Nov 27, 2026
RepositoryPython
geomstats/geomstats

Computations and statistics on manifolds with geometric structures.

1.5k
Dec 1, 2026
RepositoryPython
geoopt/geoopt

Riemannian Adaptive Optimization Methods with pytorch optim

1.1k
Dec 3, 2026
RepositoryPython
pyRiemann/pyRiemann

Machine learning for multivariate data through the Riemannian geometry of positive definite matrices in Python

786
Nov 28, 2026
RepositoryPython
devitocodes/devito

DSL and compiler framework for automated finite-differences and stencil computation

721
Dec 2, 2026
RepositoryPython
pyccel/pyccel

Python extension language using accelerators

403
Sep 27, 2026
RepositoryPython
gwastro/pycbc

Core package to analyze gravitational-wave data, find signals, and study their parameters. This package was used in the first direct detection of gravitational waves (GW150914), and is used in the ongoing analysis of LIGO/Virgo data.

395
Nov 27, 2026