Skip to main content

Biblioteca em Python para geometria diferencial simbolica: tensores, conexoes e curvatura.

Project description

Lyra Geometry

Lyra Geometry is a Python library for symbolic differential geometry with a focus on tensor spaces, connections, and curvature in Lyra geometry. It is built on SymPy to support exact tensor manipulation in scripts and notebooks.

Highlights

  • Tensor spaces with index notation (up/down indices).
  • Lyra connection and curvature tensors derived from a metric.
  • Automatic Einstein summation for repeated labels.
  • Covariant derivatives, torsion, and non-metricity support.
  • Friendly API designed for interactive exploration.

Requirements

  • Python >= 3.9
  • SymPy >= 1.12

Installation

python -m pip install lyra-geometry

For local development:

python -m pip install -e .[dev]

Getting started

Create a space with a metric, then inspect its basic objects:

import sympy as sp
import lyra_geometry as pl

x, y = sp.symbols("x y", real=True)
metric = sp.diag(x + 2*y, x**2 * y)

st = pl.SpaceTime(coords=(x, y), metric=metric)

st.g          # metric tensor
st.metric_inv # inverse metric matrix
st.detg       # determinant of the metric

Indices, raising/lowering, and components

Use index labels and variance markers to access components:

a, b, c = st.index("a b c")

st.g[-a, -b]  # g_ab
st.g[+a, +b]  # g^ab

st.g[-a, -b](0, 0)  # component access

Generic tensors and contraction

Create symbolic tensors and let repeated labels contract automatically:

v = st.tensor.generic("v", (pl.U,))
w = st.tensor.generic("w", (pl.D,))

scalar = v[+a] * w[-a]  # automatic contraction

Explicit contraction and a simple index-string parser are also available:

st.contract(v[+a], w[-a])
st.eval_contract("v^a w_a")

Covariant derivative

The Lyra covariant derivative adds one covariant index:

dv = st.nabla(v)
dv.signature  # (D, U)
dv[-b, +a](0, 0)

Connection and curvature

When a metric is provided, the Lyra connection and curvature tensors are computed automatically:

st.gamma            # Gamma^a_{bc}
st.riemann          # Riemann tensor
st.ricci            # Ricci tensor
st.einstein         # Einstein tensor
st.scalar_curvature # scalar curvature

Scale, torsion, and non-metricity

You can set a scale field and provide torsion/non-metricity explicitly:

phi = sp.Function("phi")(x)
st.set_scale(phi)

st.set_torsion(st.zeros((pl.D, pl.D, pl.D)))
st.set_nonmetricity(st.zeros((pl.U, pl.D, pl.D)))

st.update()

Custom connection strategies

If you already have Gamma components, you can fix the connection manually:

Gamma0 = sp.ImmutableDenseNDimArray([0] * (2**3), (2, 2, 2))

st2 = pl.SpaceTime(
    coords=(x, y),
    metric=sp.diag(1, 1),
    connection_strategy=pl.FixedConnectionStrategy(Gamma0),
)

st2.gamma

Simplification with fmt

Use fmt() to expand and simplify expressions:

st.ricci.fmt()
st.einstein.fmt()
st.scalar_curvature.fmt()

Notebook examples

The notebook examples/example.ipynb walks through:

  • A quick tutorial of the core API.
  • Schwarzschild spacetime: metric, connection, and curvature tensors.
  • FLRW spacetime: metric, curvature, and covariant derivative of a scalar.
  • A spherically symmetric LyST solution with scale field and field equations.

Project structure

  • src/lyra_geometry/core.py: core implementation.
  • src/lyra_geometry/__init__.py: public exports and version.
  • examples/example.ipynb: tutorial and physics examples.
  • tests/: pytest smoke tests.

Development and testing

python -m pytest

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lyra_geometry-0.1.10.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lyra_geometry-0.1.10-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file lyra_geometry-0.1.10.tar.gz.

File metadata

  • Download URL: lyra_geometry-0.1.10.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lyra_geometry-0.1.10.tar.gz
Algorithm Hash digest
SHA256 311f2ef08d425063a6774c7a88a5220c75128280f1f25d9966c10d6ed83ec3fb
MD5 8debdb3ed13bf042f22c5ea4d755f9f6
BLAKE2b-256 c299f813949377954a20befef381fe9ad4882ee4eda8993841c712ed3ce08bf7

See more details on using hashes here.

File details

Details for the file lyra_geometry-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: lyra_geometry-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lyra_geometry-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 7cf7309b1fc4ec81799b869da7721a1d1698d27de74011191037278787c89aa4
MD5 884dfa116b66b98a48ea4b8427843200
BLAKE2b-256 951072673bd81e674dc06b9c44583f51c7b4d7370e42f1998d190e719c9eb795

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page