| Crates.io | tensor-calc |
| lib.rs | tensor-calc |
| version | 0.1.3 |
| created_at | 2025-09-07 09:04:21.829329+00 |
| updated_at | 2025-09-07 11:31:29.754775+00 |
| description | World's first Rust-based Einstein field equation solver with symbolic tensor calculus |
| homepage | https://github.com/nightness/tensor-calc |
| repository | https://github.com/nightness/tensor-calc |
| max_upload_size | |
| id | 1827947 |
| size | 92,856 |
The first Rust-based Einstein field equation solver, bringing the memory safety and performance of Rust to spacetime physics with symbolic tensor calculus, automatic solution generation, and efficient computation.
While Python libraries like EinsteinPy and SageMath Manifolds provide excellent GR capabilities, this is the first to bring Rust's performance and safety to Einstein equation solving.
sin(theta)^2, exp(H*t), M/r^2This provides an alternative to expensive, proprietary software with:
cargo install tensor-calc
git clone https://github.com/nightness/tensor-calc.git
cd tensor-calc
cargo build --release
Download prebuilt binaries from the GitHub Releases page.
# Build the project
cargo build --release
# 🌌 SOLVE EINSTEIN FIELD EQUATIONS
# Solve vacuum Einstein equations for spherically symmetric spacetime
./target/release/tensor-calc solve-vacuum \
--coords '["t", "r", "theta", "phi"]' \
--symmetry "spherical"
# Solve for cosmological spacetimes (FLRW, de Sitter)
./target/release/tensor-calc solve-vacuum \
--coords '["t", "r", "theta", "phi"]' \
--symmetry "cosmological"
# Solve for axisymmetric spacetimes (Kerr black holes)
./target/release/tensor-calc solve-vacuum \
--coords '["t", "r", "theta", "phi"]' \
--symmetry "axisymmetric"
# Verify that Schwarzschild metric solves Einstein equations
./target/release/tensor-calc verify-solution \
--metric '[["-(1-2*M/r)", "0", "0", "0"], ["0", "1/(1-2*M/r)", "0", "0"], ["0", "0", "r^2", "0"], ["0", "0", "0", "r^2*sin(theta)^2"]]' \
--coords '["t", "r", "theta", "phi"]'
# 🧮 TENSOR CALCULUS OPERATIONS
# Calculate Christoffel symbols
./target/release/tensor-calc christoffel \
--metric '[["1", "0"], ["0", "r^2"]]' \
--coords '["r", "theta"]'
# Calculate Riemann curvature tensor
./target/release/tensor-calc riemann \
--metric '[["1", "0"], ["0", "r^2"]]' \
--coords '["r", "theta"]'
# Calculate Einstein tensor
./target/release/tensor-calc einstein \
--metric '[["1", "0"], ["0", "r^2"]]' \
--coords '["r", "theta"]'
{
"result_type": "vacuum_solutions",
"data": [
{
"solution_type": "exact",
"metric_tensor": [
["-(1 - 2*M/r)", "0", "0", "0"],
["0", "1/(1 - 2*M/r)", "0", "0"],
["0", "0", "r^2", "0"],
["0", "0", "0", "r^2*sin(theta)^2"]
],
"physical_parameters": {
"M": "Mass of the black hole"
},
"solution_domain": "r > 2M (outside event horizon)",
"constraints_satisfied": true
}
]
}
{
"solution_type": "exact",
"metric_tensor": [
["-1", "0", "0", "0"],
["0", "a(t)^2", "0", "0"],
["0", "0", "a(t)^2 * r^2", "0"],
["0", "0", "0", "a(t)^2 * r^2 * sin(theta)^2"]
],
"physical_parameters": {
"a(t)": "Scale factor - universe expansion",
"H": "Hubble parameter",
"Omega_m": "Matter density parameter",
"Omega_Lambda": "Dark energy density parameter"
},
"solution_domain": "Spatially homogeneous universe"
}
{
"metric_tensor": [
["-(1 - 2*M/r + Q^2/r^2)", "0", "0", "0"],
["0", "1/(1 - 2*M/r + Q^2/r^2)", "0", "0"],
["0", "0", "r^2", "0"],
["0", "0", "0", "r^2*sin(theta)^2"]
],
"physical_parameters": {
"M": "Mass",
"Q": "Electric charge"
},
"solution_domain": "r > M + sqrt(M^2 - Q^2)"
}
This standalone Rust binary can be integrated into any system through its JSON CLI interface:
The implementation uses exact symbolic computation of Einstein's field equations:
G_μν + Λg_μν = 8πT_μν
Where:
Γ^μ_αβ = (1/2) * g^μν * (∂g_νβ/∂x^α + ∂g_να/∂x^β - ∂g_αβ/∂x^ν)R^ρ_σμν = ∂Γ^ρ_σν/∂x^μ - ∂Γ^ρ_σμ/∂x^ν + Γ^ρ_λμ*Γ^λ_σν - Γ^ρ_λν*Γ^λ_σμG_μν = R_μν - (1/2) * g_μν * RThis project represents a significant step forward in computational physics accessibility:
Einstein's equations are now accessible to everyone through a modern, safe, and efficient implementation.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Built with ❤️ and a passion for making the universe computable.