General Relativity computation library built on Symbolica (Rust-powered CAS).
Gravica computes the full GR tensor chain — from metric tensor to Einstein tensor — using Symbolica's high-performance symbolic algebra engine, achieving 23x–4300x speedup over EinsteinPy/SymPy.
- Full GR computation chain: Metric → Christoffel → Riemann → Ricci → Einstein → Weyl
- Curvature invariants: Kretschner scalar, Ricci scalar
- Schouten tensor, Stress-Energy-Momentum tensor
- Geodesic equation generator
- Index raising/lowering utilities
- Built-in metrics: Minkowski, Schwarzschild, Kerr, FLRW, Reissner-Nordström, de Sitter, anti-de Sitter, Gödel
- Lazy evaluation with caching
- Cross-validated against EinsteinPy
API reference: https://site.jijinbei.jp/gravica/
| Tutorial | Topics |
|---|---|
| Getting Started | Schwarzschild metric, full pipeline (Metric → Christoffel → Riemann → Ricci → Einstein) |
| Predefined Metrics | All 8 built-in metrics: Minkowski, Schwarzschild, Kerr, FLRW, Gödel, Reissner–Nordström, de Sitter, Anti-de Sitter |
| Weyl Tensor & Kretschner Scalar | Curvature invariants, singularity detection, vacuum identity |
| Geodesic Equations | Symbolic equations of motion for Schwarzschild and Kerr spacetimes |
| Index Manipulation | Raising and lowering tensor indices, round-trip verification |
| Kerr Black Hole | Full tensor pipeline on the Kerr metric, vacuum solution verification |
| FLRW Cosmology | Stress-energy tensor, cosmological constant, Schouten tensor |
All benchmarks measured on the same machine. Median of 3 runs with GC disabled.
| Computation | Minkowski | Schwarzschild | FLRW |
|---|---|---|---|
| Christoffel | 33x | 23x | 23x |
| Riemann | 91x | 149x | 147x |
| Ricci | 72x | 40x | 296x |
| Ricci Scalar | 472x | 2021x | 544x |
| Einstein | 1391x | 4342x | 1029x |
Metric inverse is ~0.3–0.5x (Python cofactor overhead), but this is amortized by the massive speedups in downstream computations.
uv run benchmarks/run_benchmarks.py # Run benchmarks
uv run benchmarks/plot_benchmarks.py # Generate chartsMetricTensor → ChristoffelSymbols → RiemannTensor → RicciTensor → EinsteinTensor
↓ ↓ ↓ → WeylTensor
GeodesicEquations KretschnerScalar SchoutenTensor
↓
StressEnergyTensor
| Module | Computes |
|---|---|
metric.py |
|
christoffel.py |
|
riemann.py |
|
ricci.py |
|
einstein.py |
|
weyl.py |
|
kretschner.py |
|
geodesic.py |
|
schouten.py |
|
stress_energy.py |
|
indexing.py |
Index raising / lowering for rank-2 tensors |
uv run pytestVerified properties:
-
Minkowski: All tensors
$= 0$ -
Schwarzschild:
$R_{ab} = 0$ ,$G_{ab} = 0$ (vacuum),$K = 12,r_s^2/r^6$ -
Riemann symmetries:
$R^a_{\ bcd} = -R^a_{\ bdc}$ -
Christoffel known values:
$\Gamma^r_{\ tt} = r_s(r-r_s)/(2r^3)$ - de Sitter / anti-de Sitter: Ricci scalar matches analytic values
- Geodesic equations: Free particle in Minkowski
- Index roundtrip: Raise then lower recovers original tensor
- EinsteinPy cross-validation: Christoffel and Ricci match
MIT

