autograv 0.1.2

Tensor calculus engine for numerical relativity (Christoffel, Riemann, Einstein, ...) built on diffable's typed automatic differentiation
Documentation

Numerical-relativity tensor calculus in Rust, built on diffable's typed tensor algebra and forward-mode automatic differentiation.

Installation

cargo add autograv diffable

diffable is included explicitly because coordinate values use its public Coords type.

Quick start

use autograv::{as_t3, christoffel_symbols, ricci_scalar, SphericalPolar};
use diffable::coords::Coords;

fn main() {
    let point = Coords([
        5.0,
        std::f64::consts::FRAC_PI_3,
        std::f64::consts::FRAC_PI_2,
    ]);

    let metric = SphericalPolar;
    let christoffel = as_t3::<3>(&christoffel_symbols(&metric, &point));

    // Γʳ_θθ = −r
    assert!((christoffel[0][1][1] + 5.0).abs() < 1e-12);

    // Spherical coordinates describe flat Euclidean space.
    assert_eq!(ricci_scalar(&metric, &point), 0.0);
}

Implemented quantities

The crate currently computes:

  • Christoffel symbols
  • torsion tensor
  • Riemann curvature tensor
  • Ricci tensor
  • Ricci scalar
  • Kretschmann invariant
  • Einstein tensor
  • stress-energy-momentum tensor

Built-in metrics

  • Minkowski
  • SphericalPolar
  • Schwarzschild

SphericalPolar is the three-dimensional Euclidean metric

dr² + r²dθ² + r²sin²(θ)dφ²

in spherical coordinates. It has nonzero coordinate connection coefficients but zero curvature.

Coordinate and scalar model

Metric implementations are generic over their scalar type. This permits diffable Taylor jets to flow through metric, connection, and curvature calculations.

The public API uses diffable::coords::Coords for coordinate presentation and nested tensor views for rank-2, rank-3, and rank-4 results.

API documentation

Verification

The repository verifies:

  • Minkowski flatness
  • spherical-coordinate flatness
  • Schwarzschild vacuum identities
  • Schwarzschild Kretschmann invariant
  • tensor-valued automatic differentiation
  • documentation examples
  • clippy and formatting cleanliness

License

MIT. See LICENSE.