tensor_calc/lib.rs
1//! # tensor-calc
2//!
3//! A Rust library for symbolic tensor calculus and Einstein field equation solving.
4//!
5//! This library provides comprehensive tools for:
6//! - Symbolic tensor calculus operations
7//! - Einstein field equation solving
8//! - Spacetime metric computations
9//! - General relativity calculations
10//!
11//! ## Quick Start
12//!
13//! ```rust
14//! use tensor_calc::{solve_vacuum_einstein_equations};
15//!
16//! // Solve for Schwarzschild spacetime
17//! let coords = vec!["t".to_string(), "r".to_string(), "theta".to_string(), "phi".to_string()];
18//! let solutions = solve_vacuum_einstein_equations(&coords, "spherical", &[]).unwrap();
19//! assert!(!solutions.is_empty());
20//! ```
21//!
22//! ## Examples
23//!
24//! ### Computing Einstein Solutions
25//! ```rust
26//! use tensor_calc::{solve_vacuum_einstein_equations};
27//!
28//! let coords = vec!["t".to_string(), "r".to_string(), "theta".to_string(), "phi".to_string()];
29//! let solutions = solve_vacuum_einstein_equations(&coords, "spherical", &[]).unwrap();
30//!
31//! // Should find Schwarzschild and Reissner-Nordström solutions
32//! assert_eq!(solutions.len(), 2);
33//! assert_eq!(solutions[0].solution_type, "exact");
34//! ```
35
36pub mod symbolic;
37pub mod tensor;
38pub mod einstein;
39
40// Re-export commonly used types and functions
41pub use symbolic::*;
42pub use tensor::*;
43pub use einstein::*;
44
45// Re-export error type
46use serde::{Deserialize, Serialize};
47use thiserror::Error;
48
49#[derive(Error, Debug)]
50pub enum TensorError {
51 #[error("JSON parsing error: {0}")]
52 JsonError(#[from] serde_json::Error),
53 #[error("Invalid metric tensor: {0}")]
54 InvalidMetric(String),
55 #[error("Computation error: {0}")]
56 ComputationError(String),
57}
58
59#[derive(Serialize, Deserialize, Debug)]
60pub struct TensorResult {
61 pub result_type: String,
62 pub data: serde_json::Value,
63 pub coordinates: Vec<String>,
64 pub success: bool,
65 pub error: Option<String>,
66}