This article demonstrates a way to check if the Schwarzschild metrc satisfies the Einstein equation using a Python library "SymPy". In general, in order to examine the Einstein equation, one needs to compute various objects, for instance, partial differentials of the spacetime metric, the Christoffel symbols, Riemann curvature tensors, Ricci tensors and so on. It will be of great benefit if you could use your computer for such symbolic calculations and a Python's library "SymPy" is such a one.
The following article describes some basic usage for SymPy:
This article mainly takes a look into 4-dimensional case, but also 5-dim, and without showing the code, 6-dim. cases as well. It is an advantage of using computer that you can extend the situation easily.
- (Pseudo-)Riemannian Geometry for 4-dimensional Spacetime
- Schwarzschild Sol. in 4D
- Schwarzschild Sol. in 5D
- Schwarzschild Sol. in 6D
(Pseudo-)Riemannian Geometry for 4-dimensional Spacetime
Hereafter, a pair of the same indices appearing in the same term on lower/upper is to be summed over 0 to 3 unless otherwise mentioned (Einstein convention).
Coordinates
A coordinate system
is implemented in SymPy as
import sympy as sp sp.var('t, r, theta, phi') xi = sp.Matrix([ [t],[r],[theta],[phi] ])
for the later convenience to extend, let D be the dimension of spacetime:
D = len(xi)
Spacetime Metric
The spacetime metric associated with the coordinate system defines an invariant distance via
Since the metric is a 2nd rank tensor, it can be represented as a matirx
Here assume the metric is given in the following form
That is, their non-trivial components read
where is a function of and its expression shall be determined by the Einstein equation later. The metric is input by
f = sp.Function('f')(r) g = sp.Matrix([ [-f, 0, 0, 0], [0, 1/f, 0, 0], [0, 0, r**2, 0], [0, 0, 0, r**2*sp.sin(theta)**2] ])
The metric inverse that satisfies is obtained by
ginv = g.inv()
Christoffel Symbols
The Christoffel symbols which specifies the Levi-Civita connection is given by
which can be computed by
def Gamma(k,i,j): gm = 0 for n in range(D): gm = gm + sp.Rational(1,2)*ginv[k,n]*(g[n,i].diff(xi[j])\ +g[n,j].diff(xi[i])-g[i,j].diff(xi[n])) return gm
for example
Gamma(1,3,3)
gives
Riemann Curvature Tensor
Riemann curvature is defined by
def R(i,j,k,l): rm = Gamma(i,l,j).diff(xi[k]) - Gamma(i,k,j).diff(xi[l]) for n in range(D): rm = rm + Gamma(n,l,j)*Gamma(i,k,n) - Gamma(n,k,j)*Gamma(i,l,n) return rm
for instance
R(1,3,1,3)
shows
Ricci Tensor
Ricci tensor is defined by
which shall be computed by
def Ricc(j,k): ric = 0 for n in range(D): ric = ric + R(n,j,n,k) return ric
Since this is a 2nd-rank tensor, let it be represented as a matrix
RiccMat = sp.Matrix([ [Ricc(0,0), Ricc(0,1), Ricc(0,2), Ricc(0,3)], [Ricc(1,0), Ricc(1,1), Ricc(1,2), Ricc(1,3)], [Ricc(2,0), Ricc(2,1), Ricc(2,2), Ricc(2,3)], [Ricc(3,0), Ricc(3,1), Ricc(3,2), Ricc(3,3)] ]) sp.simplify(RiccMat)
then one shall find
Ricci Scalar
Ricci scalar is an invariant given by
R = sp.simplify((ginv*RiccMat).trace()) R
results in
Schwarzschild Sol. in 4D
Einstein Equation
The fundamental equation for determining the spacetime metric is the Einstein equation
where no matter-fields neither cosmological constant is assumed. The equation requires for the unknown function to satisfy
Since the first equation automatically follows from the second, only the second equation is to be considered:
whose solution is easily found as
where is a constant. The vacuum solution to the Einstein equation given by this function is known as the Schwarzschild solution. One of the feature of this solution is that it shows a singularity at whose radius is called Schwarzschild radius.
Schwarzschild Sol. in 5D
Let it apply the same calculation to 5-dim. spacetime with coordinate system whose metric shall take the form
%reset import sympy as sp sp.var('t, r, theta, phi, psi') xi = sp.Matrix([ [t],[r],[theta],[phi],[psi] ]) D = len(xi) f = sp.Function('f')(r) g = sp.Matrix([ [-f, 0, 0, 0, 0], [0, 1/f, 0, 0, 0], [0, 0, r**2, 0, 0], [0, 0, 0, r**2*sp.sin(theta)**2, 0], [0, 0, 0, 0, r**2*sp.sin(theta)**2*sp.sin(phi)**2] ]) ginv = g.inv() def Gamma(k,i,j): gm = 0 for n in range(D): gm = gm + sp.Rational(1,2)*ginv[k,n]*(g[n,i].diff(xi[j])\ +g[n,j].diff(xi[i])-g[i,j].diff(xi[n])) return gm def R(i,j,k,l): rm = Gamma(i,l,j).diff(xi[k]) - Gamma(i,k,j).diff(xi[l]) for n in range(D): rm = rm + Gamma(n,l,j)*Gamma(i,k,n) - Gamma(n,k,j)*Gamma(i,l,n) return rm def Ricc(j,k): ric = 0 for n in range(D): ric = ric + R(n,j,n,k) return ric RiccMat = sp.Matrix([ [Ricc(0,0), Ricc(0,1), Ricc(0,2), Ricc(0,3), Ricc(0,4)], [Ricc(1,0), Ricc(1,1), Ricc(1,2), Ricc(1,3), Ricc(1,4)], [Ricc(2,0), Ricc(2,1), Ricc(2,2), Ricc(2,3), Ricc(2,4)], [Ricc(3,0), Ricc(3,1), Ricc(3,2), Ricc(3,3), Ricc(3,4)], [Ricc(4,0), Ricc(4,1), Ricc(4,2), Ricc(4,3), Ricc(4,4)] ]) R = sp.simplify((ginv*RiccMat).trace()) GMat = sp.simplify(RiccMat - sp.Rational(1,2)*g*R) GMat
shows the Einstein tensor is
The Einstein equation imposes
on the function . This case as well it reduces to a single equation
which is solved by
where is a constant of integration. The metric specified by this
is called 5-dimensional Schwarzschild metric.
Schwarzschild Sol. in 6D
It shall be straightforward to extend the previous analysis to the case of 6-dimensional spacetime with
The Einstein equation requires to enjoy
which is satisfied by
and the corresponding metric is the 6-dimensional Schwarzschild metric.
Now, can you guess how it will be for n-dimensional case??
Keywords: Python, SymPy, Riemannian geometry, General theory of relativity