Skip to main content

local_coordinates

A JAX-based framework for differential geometry computations on Riemannian manifolds.

Overview

The local_coordinates library provides a type-safe, coordinate-aware system for performing differential geometry computations. It leverages JAX's automatic differentiation to compute not just gradients, but also Hessians, enabling second-order geometric computations like curvature tensors and geodesics.

Key use cases:

  • Computing Riemannian metrics and their properties
  • Calculating curvature tensors (Riemann, Ricci, scalar)
  • Working with coordinate transformations and pullback metrics
  • Computing geodesics via exponential and logarithmic maps
  • Transforming to Riemann normal coordinates

Features

  • Jets: Second-order automatic differentiation storing value, gradient, and Hessian
  • Riemannian Metrics: Define metrics, compute inner products, raise and lower indices
  • Connections: Levi-Civita connection and Christoffel symbols
  • Curvature: Riemann curvature tensor, Ricci tensor, and scalar curvature
  • Coordinate Transformations: Pullback metrics under coordinate changes
  • Normal Coordinates: Transform to Riemann normal coordinates where the metric is locally Euclidean
  • Geodesics: Exponential and logarithmic maps via Taylor approximation or ODE integration

Installation

pip install localgeom

For development, clone the repo and install in editable mode:

git clone https://github.com/EddieCunningham/local_coordinates.git
cd local_coordinates
pip install -e ".[test]"

Requires Python 3.11 or newer.

Quick Start

import jax
import jax.numpy as jnp
from jax import Array
from local_coordinates.jet import Jet, function_to_jet
from local_coordinates.basis import BasisVectors, get_standard_basis
from local_coordinates.metric import RiemannianMetric
from local_coordinates.connection import Connection, get_levi_civita_connection
from local_coordinates.riemann import (
    RiemannCurvatureTensor,
    RicciTensor,
    get_riemann_curvature_tensor,
    get_ricci_tensor,
)

# Define a position-dependent metric
def metric_components(x: Array) -> Array:
    return jnp.array([
        [1 + 0.1*x[0]**2, 0.0],
        [0.0, 1 + 0.1*x[1]**2]
    ])

# Create the metric at a point
p: Array = jnp.array([1.0, 1.0])
basis: BasisVectors = get_standard_basis(p)
metric_jet: Jet = function_to_jet(metric_components, p)
metric: RiemannianMetric = RiemannianMetric(basis=basis, components=metric_jet)

# Compute geometric quantities
connection: Connection = get_levi_civita_connection(metric)
riemann: RiemannCurvatureTensor = get_riemann_curvature_tensor(connection)
ricci: RicciTensor = get_ricci_tensor(connection, R=riemann)

# Scalar curvature
g_inv: Array = jnp.linalg.inv(metric.components.value)
scalar_curvature: Array = jnp.einsum("ij,ij->", g_inv, ricci.components.value)

print(f"Metric at p:\n{metric.components.value}")
print(f"Scalar curvature: {scalar_curvature}")

Library Architecture

local_coordinates/
├── jet.py              # Jets: second-order Taylor data (value, gradient, hessian)
├── jacobian.py         # Jacobians for coordinate transformations
├── basis.py            # BasisVectors: tangent space bases
├── frame.py            # Frame: basis vectors with Lie brackets
├── tangent.py          # TangentVector: vectors in tangent spaces
├── tensor.py           # Tensor: generic (k,l) tensors
├── metric.py           # RiemannianMetric: inner products on tangent spaces
├── connection.py       # Connection: Christoffel symbols, covariant derivatives
├── riemann.py          # RiemannCurvatureTensor and RicciTensor
├── normal_coords.py    # Riemann normal coordinates
└── exponential_map.py  # Exponential and logarithmic maps

Documentation

For comprehensive documentation with examples, see TUTORIAL.md.

AI assistant skills for task-specific guidance are available in .cursor/skills/:

Skill Description
create-riemannian-metric Create RiemannianMetric objects from metric functions
compute-curvature Compute Levi-Civita connection, Riemann tensor, Ricci tensor
pullback-metric Compute pullback metrics under coordinate transformations
riemann-normal-coordinates Transform objects to Riemann normal coordinates
compute-geodesics Compute geodesics via exponential/logarithmic maps
jet-differentiation Use Jets for second-order automatic differentiation

Important Conventions

Column-Vector Convention

The library uses the column-vector convention throughout:

  • Basis vectors are stored as columns of matrices
  • E[:, j] represents the j-th basis vector
  • E[a, j] is the a-th component of the j-th basis vector

Index Conventions

  • Christoffel symbols: Gamma[i, j, k] = Γ^k_ij
  • Riemann tensor: R[i, j, k, m] = R^m_ijk
  • Tensors use 1-based indexing for raise/lower operations

License

See LICENSE for details.

Metadata

Release files for localgeom 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for localgeom 0.1.1
File Size Uploaded Provenance
localgeom-0.1.1.tar.gz 199.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for localgeom 0.1.1
File Interpreter ABI Platform
localgeom-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 253.7 kB

Release files / localgeom-0.1.1.tar.gz

Download URL localgeom-0.1.1.tar.gz
Size 199.1 kB
Tags Source
SHA-256 checksum
How to use checksums
724bdc1c3e26b960d6a30c5a9946b262dd37722f10d251ccab5340041a67f329
BLAKE2b-256 checksum
How to use checksums
fd2c515811ed08c23608d6825e8f7b7e3c61547d41ff92c1614378c62678613f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / localgeom-0.1.1-py3-none-any.whl

Download URL localgeom-0.1.1-py3-none-any.whl
Size 54.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4e43eff2632d76c35f021791645e71c96751f7ad1461489cc5e09d4d8960689
BLAKE2b-256 checksum
How to use checksums
1c65c7eb35dba217a58f5bb28d8149cb39c811a66df4e174dc782e1874502e41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Security for localgeom 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page