# Code for general Einstein field equations with diagonal metric anzatc

    Basic definitions
{t,r,\theta,\phi}::Coordinate.
{\mu,\nu,\rho,\tau,\sigma,\lambda,\alpha,\beta,\tau,\gamma}::Indices(values={t,r,\theta,\phi}, position=fixed).
\partial{#}::PartialDerivative.
F::Depends(r).
G::Depends(r).

Metric definition
g_{\mu\nu}::Metric.
g^{\mu\nu}::InverseMetric.
g_{\mu\nu}::Symmetric.
g_{\mu\nu}::Diagonal.
g := { g_{t t} = -exp(F(r)),
g_{r r} = exp(G(r)),
g_{\theta\theta} = r**2,
g_{\phi\phi}=r**2 \sin(\theta)**2
}.
complete(g, $g^{\mu\nu}$);

Christofel f second kind
Christoffel2nd := \Gamma^{\tau}_{\mu\nu} = 1/2 g^{\tau\rho} (
\partial_{\mu}{g_{\nu\rho}}
+ \partial_{\nu}{g_{\mu\rho}}
- \partial_{\rho}{g_{\mu\nu}}
);
substitute(Christoffel2nd,g)
evaluate(Christoffel2nd, g, rhsonly=True);

Rieman tensor
Riemann := R^{\rho}_{\mu\tau\nu} = \partial_{\tau}{\Gamma^{\rho}_{\nu\mu}}
- \partial_{\nu}{\Gamma^{\rho}_{\tau\mu}}
+ \Gamma^{\rho}_{\tau\sigma}\Gamma^{\sigma}_{\nu\mu}
- \Gamma^{\rho}_{\nu\sigma}\Gamma^{\sigma}_{\tau\mu}.
substitute( Riemann, Christoffel2nd)
evaluate(Riemann,g,rhsonly=True)
lRieman := R_{\alpha\beta\mu\nu} = g_{\sigma\alpha}R^{\sigma}_{\beta\mu\nu};
substitute( lRieman, Riemann)
evaluate( lRieman, g, rhsonly=True )

Ricci tensor and scalar
RicciT := R_{\mu\nu} = g^{\alpha\beta} R_{\beta\mu\alpha\nu};
substitute( RicciT, lRieman)
evaluate( RicciT, g, rhsonly=True );
RicciS := R = g^{\mu\nu}R_{\mu\nu};
substitute( RicciS, RicciT )
evaluate( RicciS, g, rhsonly=True );

Einstein tensor
Einstein := G_{\mu\nu} = R_{\mu\nu} - 1/2 g_{\mu\nu} R;
substitute( Einstein, RicciT )
substitute( Einstein, RicciS )
evaluate( Einstein, g, rhsonly=True);

The F and G dependecies is working sometime as it is, sometimes I need to place explicitly argument of r in the functions F(r) and G(r) instead only F and G in the metric definition

If metric is written with e**{F} not exp(F), it produces strange log(e) but this seems to happen because of sympy

Ricc tensor, the phi phi and theta theta components are fine, but there is additional 6r^-2 term in the rr component, tt seems fine. In both cases the numerical coefficients seem oddlu off some even multiple

The ricci scalar has some 5r\partial_r G(r), and whit this "5" in front of it seems very off.

In some cases the Einstein tensor is evaluated in some cases it is failing with, some SyntaxError: unexpected character after line continuation character (, line ) and tracebacks it to python3.6 suympy_parser.py eval_expr and parse_exprr. Very odd. since it happens when I change some of the expresions in the metric and nothing on Cadabra code

Those problems remain despite restarting kernele and ec.t

I am using version 2.2.0 build private date 2018-08-07, which is from

Components of the tensors

Great post... very complete, and detailed discussion. Thank you for the report, and also Thanks to Kasper for the quick solution!

Thanks for reporting this. The main issue is a bug in computing dependencies of expressions like exp(F(r)), which fail to figure out that this depends on r. I have just pushed a fix to github which solves this (your notebook then reproduces the Ricci tensor/scalar results in that PDF file).