|
1 | | -================================================================================ |
2 | | -SpacetimeEngine: Symbolic Einstein Field Equation Analyzer |
3 | | -================================================================================ |
| 1 | + |
4 | 2 |
|
5 | | -A Python utility built on Sympy (a symbolic mathematics library) that analyzes any given metric solution to the Einstein field equations. |
| 3 | +A Python utility built on Sympy (A symbolic mathematics library) which will analyze any given metric solution to the Einstein field equations. |
6 | 4 |
|
7 | | -Einstein Field Equations: |
8 | | - G_{μν} + Λg_{μν} = (8πG / c⁴) T_{μν} |
| 5 | + |
9 | 6 |
|
10 | | --------------------------------------------------------------------------------- |
11 | | -Prerequisites |
12 | | --------------------------------------------------------------------------------- |
| 7 | +# Prerequisites (Linux) |
13 | 8 |
|
14 | | -Linux |
15 | | ------ |
16 | | -1. Install Python 3: |
17 | | - $ sudo apt install python3 |
18 | | - |
19 | | -2. Install pip3: |
20 | | - $ sudo apt install python3-pip |
21 | | - |
22 | | -3. Install git: |
23 | | - $ sudo apt-get install git |
24 | | - |
25 | | -MacOS |
26 | | ------ |
27 | | -1. Install Homebrew: |
28 | | - $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
29 | | - |
30 | | -2. Set Python environment variable: |
31 | | - $ export PATH="/usr/local/opt/python/libexec/bin:$PATH" |
32 | | - |
33 | | -3. Install git: |
34 | | - $ brew install git |
35 | | - |
36 | | -4. Install Python 3 and pip3: |
37 | | - $ brew install python3 |
38 | | - $ brew postinstall python3 |
39 | | - |
40 | | -Windows |
41 | | -------- |
42 | | -1. Install Python 3 and pip3: |
43 | | - https://www.python.org/downloads/ |
44 | | - |
45 | | -2. Install git: |
46 | | - https://gitforwindows.org/ |
47 | | - |
48 | | --------------------------------------------------------------------------------- |
49 | | -Installation |
50 | | --------------------------------------------------------------------------------- |
51 | | - |
52 | | -With pip3: |
53 | | ----------- |
54 | | -1. Install package: |
55 | | - $ pip3 install spacetimeengine |
56 | | - |
57 | | -2. Enter Python shell: |
58 | | - $ python3 |
59 | | - |
60 | | -3. Import the package: |
61 | | - >>> from spacetimeengine import * |
62 | | -
|
63 | | -4. Create a SpaceTime object (Schwarzschild example): |
64 | | - >>> schwarzschild_spacetime = SpaceTime(Solution().schwarzschild()) |
65 | | -
|
66 | | -With git: |
67 | | ---------- |
68 | | -1. Clone the repository: |
69 | | - $ git clone https://github.com/spacetimeengineer/spacetimeengine |
70 | | - |
71 | | -2. Navigate to the sample directory: |
72 | | - $ cd spacetimeengine/spacetimeengine/samples |
73 | | - |
74 | | -3. Run the example: |
75 | | - $ python3 example.py |
76 | | - |
77 | | --------------------------------------------------------------------------------- |
78 | | -Suggested Use |
79 | | --------------------------------------------------------------------------------- |
80 | | - |
81 | | -SpacetimeEngine is useful for students and researchers studying General Relativity. If you're analyzing a metric solution in published literature, this tool can compute curvature tensors and help verify or explore their physical implications. |
82 | | - |
83 | | -It is especially useful for validating metrics, checking errors, and learning how different tensors arise from a given spacetime configuration. |
84 | | - |
85 | | --------------------------------------------------------------------------------- |
86 | | -Metric Tensor |
87 | | --------------------------------------------------------------------------------- |
88 | | - |
89 | | -Any solution to the Einstein field equations is represented by a metric tensor, often in matrix form. SpacetimeEngine uses Sympy's Matrix object to represent this tensor. |
90 | | - |
91 | | -Example: Schwarzschild Metric |
| 9 | +1.) Install Python3 |
92 | 10 |
|
93 | | -g_{μν} = |
94 | | -⎡ (1 - 2GM/rc²) 0 0 0 ⎤ |
95 | | -⎢ 0 -1/(1 - 2GM/rc²) 0 0 ⎥ |
96 | | -⎢ 0 0 -r² 0 ⎥ |
97 | | -⎣ 0 0 0 -r²sin²θ ⎦ |
| 11 | + $ sudo apt install python3 |
98 | 12 |
|
99 | | --------------------------------------------------------------------------------- |
100 | | -Constructing a Solution (In Development) |
101 | | --------------------------------------------------------------------------------- |
| 13 | +2.) Install pip3 |
102 | 14 |
|
103 | | -All metric solutions are packaged into an array with the following elements: |
104 | | -1. Metric (Sympy Matrix) |
105 | | -2. Coordinate set |
106 | | -3. Index configuration (e.g., "dd", "uu") |
107 | | -4. Cosmological constant |
| 15 | + $ sudo apt install python3-pip |
108 | 16 |
|
109 | | -Example: Schwarzschild solution |
| 17 | +3.) Install git |
110 | 18 |
|
111 | | - def schwarzschild(self): |
112 | | - x0, x1, x2, x3 = symbols('t r theta phi') |
113 | | - coordinate_set = [x0, x1, x2, x3] |
114 | | - G, M, c = symbols('G M c') |
| 19 | + $ sudo apt-get install git |
115 | 20 |
|
116 | | - metric = Matrix([ |
117 | | - [ (1 - (2*G*M)/(x1*c**2)), 0, 0, 0 ], |
118 | | - [ 0, -1/(1 - (2*G*M)/(x1*c**2)), 0, 0 ], |
119 | | - [ 0, 0, -x1**2, 0 ], |
120 | | - [ 0, 0, 0, -x1**2*sin(x2)**2 ] |
121 | | - ]) |
| 21 | +# Prerequisites (MacOS) |
122 | 22 |
|
123 | | - index_config = "dd" |
124 | | - cosmological_constant = 0 |
| 23 | +1.) Install homebrew |
125 | 24 |
|
126 | | - return [metric, coordinate_set, index_config, cosmological_constant] |
| 25 | + $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew doctor |
127 | 26 |
|
128 | | -To use: |
| 27 | +2.) Set python as an environmental variable. |
129 | 28 |
|
130 | | - >>> spacetime = SpaceTime(Solution().schwarzschild()) |
| 29 | + $ export PATH="/usr/local/opt/python/libexec/bin:$PATH" |
131 | 30 |
|
132 | | -Note: Only certain index configurations are currently supported. |
| 31 | +3.) Install git |
133 | 32 |
|
134 | | --------------------------------------------------------------------------------- |
135 | | -Stress-Energy-Momentum Tensor |
136 | | --------------------------------------------------------------------------------- |
| 33 | + $ brew install git |
137 | 34 |
|
138 | | -The tensor T_{μν} represents the distribution of mass and energy. The cosmological constant (Λ) can be set as a parameter. |
| 35 | +4.) Install python3 and pip3 (https://docs.python-guide.org/starting/install3/osx/) |
139 | 36 |
|
140 | | -Example: |
| 37 | + $ brew install python3 |
| 38 | + $ brew postinstall python3 |
141 | 39 |
|
142 | | - >>> cosmological_constant = 0 |
143 | | - >>> mu = 0 # dt |
144 | | - >>> nu = 1 # dr |
145 | | - >>> index_config = "dd" |
146 | | - >>> spacetime.print_stress_energy_coefficient(index_config, mu, nu) |
| 40 | +# Prerequisites (Windows) |
147 | 41 |
|
148 | | - 0 |
| 42 | +1.) Install Python3 & pip3 |
149 | 43 |
|
150 | | -(Schwarzschild is a vacuum solution, so T_{μν} = 0) |
| 44 | + Navigate to https://www.python.org/downloads/ |
151 | 45 |
|
152 | | --------------------------------------------------------------------------------- |
153 | | -Einstein Tensor |
154 | | --------------------------------------------------------------------------------- |
| 46 | +2.) Install git |
155 | 47 |
|
156 | | -G_{μν} = R_{μν} - (1/2)Rg_{μν} |
| 48 | + Navigate to https://gitforwindows.org/ |
157 | 49 |
|
158 | | -Describes curvature of spacetime. |
| 50 | +# Installation with pip3 |
159 | 51 |
|
160 | | -Example: |
| 52 | +1.) Install with pip3 |
161 | 53 |
|
162 | | - >>> mu = 0 |
163 | | - >>> nu = 1 |
164 | | - >>> index_config = "dd" |
165 | | - >>> spacetime.print_einstein_coefficient(index_config, mu, nu) |
| 54 | + $ pip3 install spacetimeengine |
166 | 55 |
|
167 | | - G₀₁ = 0 |
| 56 | +2.) Enter python shell |
168 | 57 |
|
169 | | --------------------------------------------------------------------------------- |
170 | | -Ricci Tensor |
171 | | --------------------------------------------------------------------------------- |
| 58 | + $ python3 |
172 | 59 |
|
173 | | -The Ricci tensor R_{μν} measures how much volumes in curved space deviate from flat space. |
| 60 | +3.) Import spacetimeengine |
174 | 61 |
|
175 | | - R_{ij} = R^k_{ikj} |
| 62 | + >> from spacetimeengine import * |
176 | 63 |
|
177 | | -Example: |
| 64 | +4.) Create a SpaceTime object which describes the Schwarzschild spacetime |
178 | 65 |
|
179 | | - >>> spacetime.print_ricci_coefficient("dd", 3, 2) |
| 66 | + >> schwarzschild_spacetime = SpaceTime(Solution().schwarzschild()) |
180 | 67 |
|
181 | | - R₃₂ = 0 |
| 68 | +5.) Enjoy watching the coefficients get computed. |
182 | 69 |
|
183 | | --------------------------------------------------------------------------------- |
184 | | -Riemann Tensor |
185 | | --------------------------------------------------------------------------------- |
| 70 | +# Installation with git |
186 | 71 |
|
187 | | -Measures how the metric deviates from flat space at a point. |
| 72 | +1.) Clone repository |
188 | 73 |
|
189 | | - R^ρ_{σμν} = ∂μΓ^ρ_{νσ} - ∂νΓ^ρ_{μσ} + Γ^ρ_{μλ}Γ^λ_{νσ} - Γ^ρ_{νλ}Γ^λ_{μσ} |
| 74 | + $ git clone https://github.com/spacetimeengineer/spacetimeengine |
190 | 75 |
|
191 | | -Example: |
| 76 | +2.) Enter directory |
192 | 77 |
|
193 | | - >>> spacetime.print_reimann_coefficient("uddd", 3, 2, 2, 3) |
| 78 | + $ cd spacetimeengine/spacetimeengine/samples |
194 | 79 |
|
195 | | - -2⋅G⋅M |
196 | | - R³₂₂₃ = ─────── |
197 | | - 2 |
198 | | - c ⋅x₁ |
| 80 | +3.) Run example.py |
199 | 81 |
|
200 | | --------------------------------------------------------------------------------- |
201 | | -References |
202 | | --------------------------------------------------------------------------------- |
| 82 | + $ python3 example.py |
203 | 83 |
|
204 | | -- Metric Tensor: https://en.wikipedia.org/wiki/Metric_tensor |
205 | | -- Stress-Energy Tensor: https://en.wikipedia.org/wiki/Stress-energy_tensor |
206 | | -- Einstein Tensor: https://en.wikipedia.org/wiki/Einstein_tensor |
207 | | -- Ricci Tensor: https://en.wikipedia.org/wiki/Ricci_curvature |
208 | | -- Riemann Tensor: https://en.wikipedia.org/wiki/Riemann_curvature_tensor |
| 84 | +# Suggested Use |
| 85 | + |
| 86 | +If you are a student or researcher, and you find yourself reading a publication based in General Relativity which provides metric solutions, then this utility can be used for working out the curvature coefficients associated with the solution provided by the user. This can be a helpful utility as you read through the literature because you will be able to cross-reference the information provided by the literature with the values the spacetimeengine provides (this is why I developed it originally). More commonly, this utility can be used for error checking. |
| 87 | + |
| 88 | +## [Metric Tensor](https://en.wikipedia.org/wiki/Metric_tensor) |
| 89 | + |
| 90 | +Generally speaking, any metric solution to the Einstein field equations will be packaged into a geometric object known as the metric tensor. The metric tensor is often represented in matrix form, and the spacetimeengine package adopts this representation. |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +The spacetimeengine package employs the Sympy 'Matrix' object for packaging the metric tensor and it serves as the essential parameter for constructing a 'SpaceTime' object. The Solutions module currently stores some well-known metrics for study, but these can be used for understanding how to construct new solutions. |
| 95 | + |
| 96 | +# Constructing a solution (In development) |
| 97 | + |
| 98 | +Currently, all metric solutions are packaged by specifying four key parameters and storing them in an array. These parameters include an index configuration for the given metric solution, the coordinates to define the metric in terms of, the metric itself, and the cosmological constant. It is important to note that a zero-valued cosmological constant indicates the employment of a classical formulation to the Einstein field equations. Below represents a valid definition of the Schwarzschild stationary black hole solution. |
| 99 | + |
| 100 | +```python |
| 101 | +def schwarzschild(self): |
| 102 | + |
| 103 | + # Assigns meaning to the coordinates. |
| 104 | + x0, x1, x2, x3 = symbols('t r theta phi') |
| 105 | + # Groups the coordinates in an array. |
| 106 | + coordinate_set = [x0, x1, x2, x3] |
| 107 | + |
| 108 | + # Constants required to describe the metric. |
| 109 | + G, M, c = symbols('G M c') |
| 110 | + |
| 111 | + # Metric. |
| 112 | + metric = Matrix([ |
| 113 | + [ (1-(2*G*M)/(x1*c**2)), 0, 0, 0 ], |
| 114 | + [ 0, - (1-(2*G*M)/(x1*c**2))**(-1), 0, 0 ], |
| 115 | + [ 0, 0, - x1**2, 0 ], |
| 116 | + [ 0, 0, 0, - x1**2*sin(x2)**2 ] |
| 117 | + ]) |
| 118 | + |
| 119 | + # Describes the index configuration which the metric represents. |
| 120 | + index_config = "dd" |
| 121 | + |
| 122 | + # Cosmological constant. |
| 123 | + cosmological_constant = 0 |
| 124 | + |
| 125 | + # An array detailing the solution. |
| 126 | + solution_array = [ metric, coordinate_set, index_config, cosmological_constant ] |
| 127 | + |
| 128 | + # Returns solution |
| 129 | + return solution_array |
0 commit comments