In this article, using Python, what is needed in general relativity ・ ** Calculation of various tensors including weighing $ g_ {\ mu \ nu} $ ** ・ ** Simple calculation of Einstein equation ** Introduce how to do.
** [Reference] ** For computing related to tensor analysis and algebra in general relativity, Heinicke, C., et.al.- Computer Algebra in Gravity Korolkova, A., et.al.- Tensor computations in computer algebra systems There are some affordable Review papers such as, so please refer to them as appropriate. Also, for a similar study using SageMath, Gourgoulhon, E., et.al. - Symbolic tensor calculus on manifolds Etc. are known.
GraviPy is a module for tensor calculation that runs on Python3.
By collaborating with SymPy, which specializes in algebraic symbol processing, a stress-free tensor calculation environment is realized on Python.
Download the GraviPy module including SymPy according to the following GraviPy, Tensor Calculus Package for General Relativity (Version 0.1.0) (2014) (Access date: November 26, 2019)
You can actually use pip,
python
$ pip install GraviPy
If there is no problem, it will be installed. SymPy should be installed at the same time if the Python environment is ver.3.7 or higher.
Use GraviPy to derive the Schwarzschild solution from the Schwarzschild metric.
The sign of the metric is $ (+,-,-,-) $ according to MTW, and the line element is determined as follows.
g_{\mu\nu}=\left[\begin{array}{cccc}
\Big( 1- \frac{2M}{r} \Big) & 0 & 0 & 0 \\
0 & -\Big( 1- \frac{2M}{r} \Big)^{-1} & 0 & 0 \\
0 & 0 & -r^2 & 0 \\
0 & 0 & 0 & -r^2sin^2\theta
\end{array}\right].
Here, the four-dimensional coordinate $ (t, r, \ theta, \ phi) $ is taken as the coordinate system, and $ M $ is defined as the black hole mass. The Schwarzschild metric shows a singularity at $ r = 2M $ in the radial direction, which is known as the so-called "event horizon".
Let's derive the Schwarzschild solution from the above $ g_ {\ mu \ nu} $. Use GraviPy to calculate according to the following process.
First, let's define space-time. Take
GR.py
#!/usr/bin/env python3
from gravipy import *
from gravipy import tensorial as ten
from sympy import *
import inspect
# Coordinates (\ chi is the four - vector of coordinates )
t, r, theta, phi, M = symbols('t , r , theta , phi , M ')
x = ten.Coordinates('\chi',[t, r, theta, phi])
Here, the first argument '\ chi'
often.Coordinates ()
specifies that the second argument is a four-vector. Also, the reason why it is set to ten. ~
Is that this Coordinates ()
does not work unless it explicitly refers to the tensorial
.
After that, the tensors that appear will be referred to by ten. ~
.
Next, let's define the metric $ g_ {\ mu \ nu} $. The Schwarzschild metric described above may be described as follows.
GR.py
#Continued
# Metric tensor
Metric = diag((1 -2* M / r ) , -1/(1 -2* M / r ) , -r **2 , -r **2* sin( theta ) **2)
g = ten.MetricTensor('g', x , Metric )
Here, the output result of g = ten.MetricTensor ('g', x, Metric)
is
Metric
#Or
g(ten.All,ten.All)
It can be displayed with, and it becomes as follows.
g_{\mu\nu}=
\displaystyle \left[\begin{matrix}- 2M/r + 1 & 0 & 0 & 0\\0 & \displaystyle- \frac{1}{- 2M/r + 1} & 0 & 0\\0 & 0 & - r^{2} & 0\\0 & 0 & 0 & - r^{2} \sin^{2}{\left(\theta \right)}\end{matrix}\right]
Although there are some differences in the expression, the previous definition is accurately reflected. For example, when referring to the radial component $ g_ {rr} = g_ {11} $
g(1,1)
Then, it can be obtained for each element as follows.
g_{11}=- \frac{1}{\displaystyle- \frac{2M}{r} + 1}
Next, let's calculate the Christoffel symbol $ \ Gamma ^ \ mu {} _ {\ nu \ rho} $ based on $ g_ {\ mu \ nu} $.
GR.py
#Continued
# Christoffel symbol
Ga = ten.Christoffel('Ga', g )
Ga
is the Christoffel symbol for $ g_ {\ mu \ nu} $. Christoffel is a tensor on the 3rd floor, so if you limit it to $ \ mu = 0 $, you will get the following tensor on the 2nd floor.
\Gamma^{ 0}{}_{\nu\rho}=
\left[
\begin{matrix}
0 & \frac{M}{r^{2}} & 0 & 0 \\
\frac{M}{r^{2}} & 0 & 0 & 0 \\
0 & 0 & 0 & 0\\
0 & 0 & 0 & 0
\end{matrix}\right]
To get all the ingredients
Ga(ten.All,ten.All,ten.All)
You can do it as
\displaystyle
\Gamma^\mu{}_{\nu\rho}=
\left[\begin{matrix}\left[\begin{matrix}0 & \frac{M}{r^{2}} & 0 & 0\\\frac{M}{r^{2}} & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right] & \left[\begin{matrix}- \frac{M}{r^{2}} & 0 & 0 & 0\\0 & \frac{M}{\left(2 M - r\right)^{2}} & 0 & 0\\0 & 0 & r & 0\\0 & 0 & 0 & r \sin^{2}{\left(\theta \right)}\end{matrix}\right] & \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & - r & 0\\0 & - r & 0 & 0\\0 & 0 & 0 & \frac{r^{2} \sin{\left(2 \theta \right)}}{2}\end{matrix}\right] & \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & - r \sin^{2}{\left(\theta \right)}\\0 & 0 & 0 & - \frac{r^{2} \sin{\left(2 \theta \right)}}{2}\\0 & - r \sin^{2}{\left(\theta \right)} & - \frac{r^{2} \sin{\left(2 \theta \right)}}{2} & 0\end{matrix}\right]\end{matrix}\right]
Will be. Since it is a third-order tensor, it can be formally obtained as a "one-dimensional array of two-dimensional array" (= a form in which the elements of the one-dimensional array are two-dimensional arrays).
Next, calculate the Ricci curvature. (This name comes from the mathematician Ricci.)
# Ricci tensor
Ri = ten.Ricci ('Ri ', g )
# Display all compon
Ri(ten.All,ten.All)
The Ricci tensor in the Schwarzschild metric drops all components to zero.
R_{\mu\nu}=
\displaystyle \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right]
Of course, this is a special thing, in the Schwarzschild metric formula.
Finally, let's output the Einstein tensor using the Ricci tensor.
# Einstein tensor
G = ten.Einstein ('G', Ri )
G(ten.All,ten.All)
Result is,
G_{\mu\nu}=
\displaystyle \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right]
It has become. This result is the assumption of the Schwarzschild solution, ** vacuum condition **
The GraviPy tutorial has been released, and I referred to the following.
https://github.com/wojciechczaja/GraviPy
Also, the SymPy support page is below.
[https://docs.sympy.org/dev/index.html] (https://docs.sympy.org/dev/index.html)
Recommended Posts