This notebook shows how you can do component computations in Cadabra. It is a translation of the Cadabra notebook https://cadabra.science/notebooks/schwarzschild.html to Jupyter.
The first thing we always need to do is to declare the coordinates used, and the names of the indices.
In [1]:
{r,t,\phi,\theta}::Coordinate;
{\mu,\nu,\rho,\sigma,\lambda,\kappa,\chi,\gamma}::Indices(values={t,r,\phi,\theta}, position=fixed);
\partial{#}::PartialDerivative;
g_{\mu\nu}::Metric.
g^{\mu\nu}::InverseMetric.
Out[1]:
Out[1]:
Out[1]:
Below is the Schwarzschild metric in standard coordinates. Note how the components are given in terms of substitution rules, and how the inverse metric is computed. The \algo{complete} algorithm adds the rules for the inverse metric to the rules for the metric.
In [2]:
ss:= { g_{t t} = -(1-2 M/r),
g_{r r} = 1/(1-2 M/r),
g_{\theta\theta} = r**2,
g_{\phi\phi}=r**2 \sin(\theta)**2
}.
complete(ss, $g^{\mu\nu}$);
Out[2]:
We can now compute the Christoffel symbols. We give Cadabra the expression for the
Christoffel symbols in terms of the metric, and then evaluate the components of the
metric using the evaluate
algorithm.
In [3]:
ch:= \Gamma^{\mu}_{\nu\rho} = 1/2 g^{\mu\sigma} (
\partial_{\rho}{g_{\nu\sigma}}
+\partial_{\nu}{g_{\rho\sigma}}
-\partial_{\sigma}{g_{\nu\rho}} ):
evaluate(ch, ss, rhsonly=True);
Out[3]:
Out[3]:
Continuing from here we can compute the Riemann tensor components. Again, we start
by giving this tensor in terms of the Christoffel symbols. We then subsitute the
Christoffel symbols just found, and work out any remaining component substitions using
evaluate
(the computation takes a few seconds, essentially because of the round
trips through Sympy).
In [4]:
rm:= R^{\rho}_{\sigma\mu\nu} = \partial_{\mu}{\Gamma^{\rho}_{\nu\sigma}}
-\partial_{\nu}{\Gamma^{\rho}_{\mu\sigma}}
+\Gamma^{\rho}_{\mu\lambda} \Gamma^{\lambda}_{\nu\sigma}
-\Gamma^{\rho}_{\nu\lambda} \Gamma^{\lambda}_{\mu\sigma};
Out[4]:
In [5]:
substitute(rm, ch)
evaluate(rm, ss, rhsonly=True);
Out[5]:
The Ricci tensor should of course vanish as the Schwarzschild solution is a vacuum solution. Following the same logic as above, this is easily verified:
In [6]:
rc:= R_{\sigma\nu} = R^{\rho}_{\sigma\rho\nu};
substitute(rc, rm)
evaluate(rc, ss, rhsonly=True);
Out[6]:
Out[6]:
More interesting is the Kretschmann scalar.
In [7]:
K:= K = R^{\mu}_{\nu\rho\sigma} R^{\lambda}_{\kappa\gamma\chi}
g_{\mu\lambda} g^{\nu\kappa} g^{\rho\gamma} g^{\sigma\chi};
Out[7]:
In [8]:
substitute(K, rm)
evaluate(K, ss, rhsonly=True);
Out[8]:
This shows that $r=0$ is a true singularity.
In [ ]: