einsteinengine 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,83 @@
1
+ import symengine as se
2
+ import sympy as sp
3
+ from einsteinengine.symbolic import metric
4
+ from einsteinengine.symbolic.tensor import BaseRelativityTensor
5
+ from einsteinengine.symbolic.ricci_tensor import RicciTensor
6
+ from einsteinengine.symbolic.ricci_scalar import RicciScalar
7
+ from einsteinengine.symbolic.riemann import RiemannCurvatureTensor
8
+
9
+ class WeylTensor(BaseRelativityTensor):
10
+
11
+ @classmethod
12
+ def from_metric(cls, metric, riemann=None, verbose=False):
13
+ dims = metric.dims
14
+ syms = metric.syms
15
+
16
+ # 1. Pipeline check: If Riemann tensor is not provided, compute it from metric
17
+ if riemann is None:
18
+ riemann = RiemannCurvatureTensor.from_metric(metric, verbose=verbose)
19
+
20
+ # 2. Leverage your native OOP contraction pipeline to build Ricci structures
21
+ ricci_tensor = RicciTensor.from_riemann(riemann, verbose=verbose)
22
+ ricci_scalar_obj = RicciScalar.from_ricci_tensor_and_metric(ricci_tensor, metric, verbose=verbose)
23
+
24
+ # Extract the underlying raw data arrays for high-speed element access
25
+ r_tensor_data = ricci_tensor.get_raw_data()
26
+
27
+ # Ensure the Ricci Scalar data is unboxed properly if wrapped in a single-element list
28
+ r_scalar_data = ricci_scalar_obj.get_raw_data()
29
+
30
+ # Robust unboxing: Drill down in case the scalar is trapped in nested lists (e.g., [[value]])
31
+ while isinstance(r_scalar_data, list):
32
+ r_scalar_data = r_scalar_data[0]
33
+
34
+ # Explicitly cast to a SymEngine object.
35
+ r_scalar_data = se.sympify(r_scalar_data)
36
+
37
+ g_inv = metric.inv().get_raw_data()
38
+ g_cov = metric.get_raw_data()
39
+
40
+ # 3. Raise one index on the Ricci Tensor manually to build R^mu_rho for the Weyl formula
41
+ # Mathematical definition: R^mu_rho = g^mu_alpha * R_alpha_rho
42
+ ricci_up_tensor = ricci_tensor.raise_index(0, metric.inv(), verbose=verbose)
43
+ ricci_up = ricci_up_tensor.get_raw_data()
44
+
45
+ # 4. Initialize the 4D nested list to store the final Weyl components
46
+ c_array = [[[[0 for _ in range(dims)] for _ in range(dims)] for _ in range(dims)] for _ in range(dims)]
47
+
48
+ if verbose:
49
+ print(f"Building Weyl Tensor from {metric.name} components...")
50
+
51
+ # 5. Core 4D Tensor Contraction: Trace-free subtraction of Ricci curvature from Riemann
52
+ for mu in range(dims):
53
+ for nu in range(dims):
54
+ for rho in range(dims):
55
+ for sigma in range(dims):
56
+ # Inline evaluation of Kronecker delta terms
57
+ kronecker_mu_rho = 1 if mu == rho else 0
58
+ kronecker_mu_sigma = 1 if mu == sigma else 0
59
+
60
+ # Retrieve the base Riemann component
61
+ term_riemann = riemann.get_raw_data()[mu][nu][rho][sigma]
62
+
63
+ # Part 1: Ricci Tensor corrections (trace removal)
64
+ term_ricci = (
65
+ kronecker_mu_rho * r_tensor_data[nu][sigma]
66
+ - kronecker_mu_sigma * r_tensor_data[nu][rho]
67
+ + g_cov[nu][sigma] * ricci_up[mu][rho]
68
+ - g_cov[nu][rho] * ricci_up[mu][sigma]
69
+ )
70
+
71
+ # Part 2: Ricci Scalar corrections
72
+ term_scalar = (
73
+ kronecker_mu_rho * g_cov[nu][sigma]
74
+ - kronecker_mu_sigma * g_cov[nu][rho]
75
+ )
76
+
77
+ # Combine all geometric pieces according to the 4D Weyl formulation
78
+ c_val = term_riemann - sp.Rational(1, 2) * term_ricci + sp.Rational(1, 6) * r_scalar_data * term_scalar
79
+ # Enforce optimization by wrapping the result as a native SymEngine object
80
+ c_array[mu][nu][rho][sigma] = se.sympify(c_val)
81
+
82
+ # Return the final object using your base relativity constructor configuration
83
+ return cls(c_array, syms, config="ulll", name=f"Weyl_{metric.name}", verbose=verbose)
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: einsteinengine
3
+ Version: 0.5.0
4
+ Summary: A high-performance, object-oriented symbolic tensor engine for General Relativity.
5
+ Author-email: Rafael Salazar <rsalazard2005@gmail.com>
6
+ Project-URL: Homepage, https://github.com/RSalazarD/EinsteinEngine
7
+ Project-URL: Bug Tracker, https://github.com/RSalazarD/EinsteinEngine/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Scientific/Engineering :: Physics
12
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: sympy>=1.12
16
+ Requires-Dist: symengine>=0.11.0
17
+ Requires-Dist: numpy>=1.24.0
18
+ Requires-Dist: scipy>=1.10.0
19
+
20
+ # EinsteinEngine
21
+
22
+ **A high-performance, object-oriented symbolic tensor engine for General Relativity, powered by Python and C++.**
23
+
24
+ EinsteinEngine is designed to solve the performance bottlenecks of traditional pure-Python symbolic calculators. By wrapping `SymEngine` (C++) backend inside a Python API, it computes Christoffel Symbols, Riemann Tensors, and other complex relativistic structures faster than standard pure Python libraries.
25
+
26
+ ---
27
+
28
+ ## Key Features
29
+
30
+ * **⚡ C++ Backend:** Mathematical heavy-lifting (partial derivatives, massive tensor contractions) is routed directly to `SymEngine`, bypassing Python's native performance limits.
31
+ * **🧠 Smart Memoization:** Built-in memory caching prevents redundant calculations of highly complex objects like inverse metric tensors.
32
+ * **📦 Clean Object-Oriented API:** Complex tensor pipelines are reduced to a few lines of readable code using class inheritance.
33
+ * **🛡️ Exact Mathematics:** Built to handle rational numbers securely, preventing floating-point contamination and ensuring textbook-perfect algebraic simplifications.
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ EinsteinEngine calculates the entire Riemann Curvature Tensor of a Black Hole in just two lines of code:
40
+
41
+ ```python
42
+ import sympy as sp
43
+ from einsteinpy.symbolic.metric import MetricTensor
44
+ from einsteinpy.symbolic.riemann import RiemannCurvatureTensor
45
+
46
+ # 1. Define your symbols and metric array
47
+ t, r, theta, phi = sp.symbols('t r theta phi', real=True)
48
+ M = sp.symbols('M', real=True)
49
+
50
+ g_schwarzschild = [
51
+ [-(1 - 2*M/r), 0, 0, 0],
52
+ [0, 1/(1 - 2*M/r), 0, 0],
53
+ [0, 0, r**2, 0],
54
+ [0, 0, 0, r**2 * sp.sin(theta)**2]
55
+ ]
56
+
57
+ # 2. Run the EinsteinEngine Pipeline
58
+ metric = MetricTensor(g_schwarzschild, [t, r, theta, phi], name="Schwarzschild")
59
+ riemann = RiemannCurvatureTensor.from_metric(metric)
60
+
61
+ # 3. Extract exact, simplified textbook results
62
+ print(riemann.get_component(1, 0, 1, 0))
63
+ # Output: 2*M*(2*M - r)/r**4
@@ -0,0 +1,20 @@
1
+ einsteinengine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ einsteinengine/symbolic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ einsteinengine/symbolic/christoffel.py,sha256=nAtV9Cvb-CfD2v5wxc74XKyPKgHdQKQZdVyGU30KE3Q,1768
4
+ einsteinengine/symbolic/connection.py,sha256=p7D_ytOfgF_RSjX8j4fD1Luc9mmyURQLpi6iE3IKVk4,5204
5
+ einsteinengine/symbolic/core.py,sha256=BHs1rqPKuE7u-48bP3apJrS_6DHmE1txx8lhYp0DELk,5658
6
+ einsteinengine/symbolic/einstein_tensor.py,sha256=KOCzbpIYZdwJIaI5dxB4On4p53RjXT0Mr0xyknIZYMg,2459
7
+ einsteinengine/symbolic/energy_momentum.py,sha256=0cgKJkkJVdHb-XkihLu-Q7qMj2Ti-adhrFQqVRwjLLs,1855
8
+ einsteinengine/symbolic/geodesics.py,sha256=sr6UrBcfuDyyTLYGc-T4h60jgjzGBGY_j57qLciEuqY,4528
9
+ einsteinengine/symbolic/metric.py,sha256=gKCWndCJhDA7VimeOsdaZBxOdmlxMrbTOe89O2nttP8,2171
10
+ einsteinengine/symbolic/ricci_scalar.py,sha256=UDAghYaSEMAPB7Z2UwOt7aerdoYPvJd8NBzXH9MJVzY,1178
11
+ einsteinengine/symbolic/ricci_tensor.py,sha256=uJqiqzooO0CfucSheDPO7kb7x3sfQ_eagZ0OkFNkvCw,826
12
+ einsteinengine/symbolic/riemann.py,sha256=3vluw9gUIFg3fY69i96KOxLp667h6vJWTRbiTGKpVeY,5371
13
+ einsteinengine/symbolic/spin_connection.py,sha256=M1AS1qW2MJX8rMOSjPv3Yo6kP2US_ZB_0hUMmA7vAts,1995
14
+ einsteinengine/symbolic/tensor.py,sha256=K1PD6sOb0tRXYyv0YCCam6H8pcPi-NftP5e_RB0g4v0,20003
15
+ einsteinengine/symbolic/tetrad.py,sha256=F5qPGQOAujnDa610Y_4k6dn1boK4YHlwoiO09Kt5HK8,2114
16
+ einsteinengine/symbolic/weyl.py,sha256=Wct6TS66qshZ4O3f-heXKUQiVFdfQWvFJhz6hBfAzj0,4351
17
+ einsteinengine-0.5.0.dist-info/METADATA,sha256=04G0lda-UkB5yWBBFOysKsDzPKz_kjy47fszEB15SE0,2784
18
+ einsteinengine-0.5.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
19
+ einsteinengine-0.5.0.dist-info/top_level.txt,sha256=Ck8GEuFHyZekPtEtAO8DH4czTx7oTaFn2bEmFACiglw,15
20
+ einsteinengine-0.5.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ einsteinengine