OGRePy: An Object-Oriented General Relativity Package for Python

More info:  external link


OGRePy is the official Python port of the popular Mathematica tensor calculus package OGRe (Object-Oriented General Relativity) – a powerful, yet user-friendly, tool for advanced tensor calculations in mathematics and physics, especially suitable for general relativity.

The Python port uses the same robust and performance-oriented algorithms as the original package, and retains its core design principles. However, its truly object-oriented interface, enabled by Python, is more intuitive and flexible than the original Mathematica implementation. It utilizes SymPy for symbolic computations and Jupyter as a notebook interface.

OGRePy allows calculating arbitrary tensor formulas using any combination of addition, multiplication by scalar, trace, contraction, partial derivative, covariant derivative, and permutation of indices. Transformations of the tensor components between different index configurations and/or coordinate systems are performed seamlessly behind the scenes as needed, eliminating user error due to combining incompatible representations, and guaranteeing consistent results. In addition, the package provides facilities for easily calculating various curvature tensors and geodesic equations in multiple representations.

Features:

* Define coordinate systems and the transformation rules between them. The Jacobians are automatically calculated. Tensor components are then transformed automatically between coordinates behind the scenes as needed.
* Each tensor is associated with a specific metric. Tensor components are then transformed automatically between different index configurations, raising and lowering indices behind the scenes as needed.
* Display any tensor in any index configuration and coordinate system, either in vector/matrix form or as a list of all unique non-zero elements. Metrics can also be displayed as a line element.
* Automatically simplify tensor components, optionally with a user-defined simplification function.
* Easily calculate arbitrary tensor formulas using any combination of addition, multiplication by scalar, trace, contraction, partial derivative, covariant derivative, and permutation of indices.
* Built-in methods for calculating the Christoffel symbols (Levi-Civita connection), Riemann tensor, Ricci tensor and scalar, Einstein tensor, Kretschmann scalar, curve Lagrangian, and volume element from a metric.
* Calculate the geodesic equations in terms of an affine curve parameter, in two different ways: from the Christoffel symbols or from the curve Lagrangian. For spacetime metrics, the geodesic equations can be calculated in terms of the time coordinate.
* Easily keep track of all tensors created in a notebook session, including the relations between them – for example, see which metrics were created and which tensors are associated with each metric.
* Export tensor components in TeX or Mathematica format.
* Designed with speed and performance in mind, using optimized algorithms developed specifically for this package.
* Clear and detailed documentation, with many examples, in Jupyter Notebook, HTML, and PDF formats.
* Open source. The code is extensively documented; please feel free to fork and modify it as you see fit.
* Under continuous and active development. Bug reports and feature requests are welcome, and should be made via GitHub issues.

Documentation is available at the following links:

* Jupyter Notebook: https://github.com/bshoshany/OGRePy/blob/master/OGRePy/docs/OGRePy_Documentation.ipynb
* HTML: https://github.com/bshoshany/OGRePy/blob/master/OGRePy/docs/OGRePy_Documentation.html
* PDF: https://github.com/bshoshany/OGRePy/blob/master/OGRePy/docs/OGRePy_Documentation.pdf

To install, simply type:

pip install OGRePy