We will rederive the equations from General Theory of Relativity, chapter 18, by Dirac. They describe a spherically symmetric solution to the Einstein's equation in vacuum.
We will not try to solve the resulting equations.
This version of the notebook uses functions that explicitly calculate the Christoffel symbols, hence the work is coordinate-system-dependent.
Import the necessary modules.
from sympy.diffgeom import *
TP = TensorProduct
Define a 4D manifold with a patch and a coordinate chart on which we will work.
m = Manifold('Schwarzschild', 4)
p = Patch('origin', m)
cs = CoordSystem('spherical', p, ['t', 'r', 'theta', 'phi'])
m, p, cs
Prepare the variables containing the scalar fields and the 1-form fields.
t, r, theta, phi = cs.coord_functions()
t, r, theta, phi
dt, dr, dtheta, dphi = cs.base_oneforms()
dt, dr, dtheta, dphi
The most general spherically-symmetric metric has the following form.
metric = exp(2*f(r))*TP(dt, dt) - exp(2*g(r))*TP(dr, dr) - r**2*TP(dtheta, dtheta) - r**2*sin(theta)**2*TP(dphi, dphi)
metric
The matrix $M$ representing the two-form as a bilinear map $V,U\to V^tMU$ over the column vectors $V$ and $U$ in the canonical basis of the chosen coordinate system is:
twoform_to_matrix(metric)
Now we will calculate the components in the same basis of the Ricci tensor.
ricci = metric_to_Ricci_components(metric)
ricci = [[simplify(ricci[i][j])
for j in range(4)] for i in range(4)]
The diagonal components give the equations we are interested in.
ricci[0][0]
ricci[1][1]
ricci[2][2]
ricci[3][3]
The off-diagonal components are zero.
all(ricci[i][j]==0 for i in range(4) for j in range(4) if i!=j)
True
For completeness we can also check out the Christoffel symbol of 2nd kind. We will print only the non-zero components, and only one of the symmetric components (symmetric in the last two indices).
ch_2nd = metric_to_Christoffel_2nd(metric)
filt = [((i,j,k), simplify(ch_2nd[i][j][k]))
for i in range(4) for j in range(4) for k in range(j,4)
if ch_2nd[i][j][k]!=0]
filt[0:3]
filt[3:6]
filt[6:9]
We can also confirm that the Christoffel symbol is symmetric.
all([ch_2nd[k][i][j] == ch_2nd[k][j][i] for k in range(4) for i in range(4) for j in range(4)])
True