Perturbation theory in general relativity using xAct

Here is an example of how to do it.

We need xTensor and xCoba packages. First is made to work with abstract objects, whilst the second is for operations with explicitly specified metric and basis:

<< xAct`xTensor`
<< xAct`xCoba`(*Package*)

Then comes an example of how to define and get all the quantities for Kerr metric. In your case you will need to input other expressions into the metric.

In summary, we define the manifold, a chart and specify explicitly the metric:

$PrePrint = ScreenDollarIndices; (*Was needed for nice printouts*)
    $CVVerbose = False;
DefManifold[M4, 4,  {b, d, f, h, i, j, k, l, m, p, q, s}]; 
(*4d manifold called M4, indices to be used*)

DefChart[kerr, 
  M4, {1, 2, 3, 4}, {r[], θ[], φ[], t[]}, 
  BasisColor -> Green]; (*Chart called kerr, coordinate names*)

DefScalarFunction /@ {Δ, ρ};(*Auxiliary functions for metric*)
DefConstantSymbol /@ {M, a};

Δ = (r[])^2 - 2 M r[] + a^2;
ρ = ((r[])^2 + a^2 (Cos[θ[]])^2)^(1/2);
(*Explicit form for the auxiliary functions*)


DefMetric[-1, metricg[-i, -j], CD, PrintAs -> "g", 
 SymbolOfCovD -> {";","D"}](*Definition of the metric*)

MetricInBasis[metricg, -kerr, ( {
   {ρ^2/Δ, 0, 0, 0},
   {0, ρ^2, 0, 0},
   {0, 0, (((r[])^2 + a^2) + 
       2 a^2 M r[] ((Sin[θ[]])^2)/(ρ^2)) \
(Sin[θ[]])^2, -(2 a M r[] (Sin[θ[]])^2)/ρ^2},
   {0, 0, -(2 a M r[] (Sin[θ[]])^2)/ρ^2, -(1 - (2 M r[])/\
ρ^2)}
  } )]
(*Explicit form for the metric*)

MetricCompute[metricg, kerr, All]
(*Get all the quantities in kerr basis*)

After all this is done, you can use ToValues to get the explicit values of the quantities. For example: ToValues[metricg[{4, -kerr}, {4, -kerr}]. A good summary on how to access and manipulate the computed quantities is contained in xCoba documentation.

Hope this helps!

Edit 1: Here is a short summary of some relevant things which can be done with xCoba:

1) Metric compute prints out lots of lines, some of which state, which new quantities have been defined. For example, the above code prints:

** DefTensor: Defining symmetric Christoffel tensor ChristoffelPDkerr[b,-d,-f]. `

Now we can use the quantity ChristoffelCDPDkerr[{i, kerr}, {-k, -kerr}, {-j, -kerr}], which stands for Christoffel symbol in the natural basis (called kerr here) for natural covariant derivative.

2) Any geometric quantities can be contracted with each other, e.g. one can introduce a new vector field and contract it with $\Gamma^i_{kj}$:

DefTensor[Xg[i], {M4}];(*Define new tensor*)
Exp = ChristoffelCDPDkerr[{i,kerr}, {-k, -kerr}, {-j, -kerr}]Xg[{k, kerr}] Xg[{j, kerr}]] (*Make a new expression, which involves contractions, but has free indices too*)

3) And further it is possible manipulate, how one would like Exp to be, for example:

TraceBasisDummy[Exp]

will replace abstract indices to explicit ones, as in $a^\mu a_\mu=a^1a_1+a^2a_2 + ...$

Or, a free index can become a list of explicit ones:

TableOfComponents[Exp,kerr]

will change $a^\mu$ into $(a^1,a^2,...)$.

Or, finally, explicit quantities like $a^1$, if they were computed before (index position matters), can be replaced by their computed values:

ToValues[Exp]

4) New quantities may explicitly be defined as functions of coordinates for further use in 1-3) with AllComponentValues, e.g.AllComponentValues[Xg[{i,kerr}],{r[],(t[])^2,(r[])^(1/2),(r[])^(-1)}]

5) More things can generally be done with basis changes, but it is not very relevant here.


My suggestion would be to use xPert to generate the expressions in abstract indices. Once you have those then use xCoba to establish your metric in a particular chart, then you can expand your perturbative expression in the chosen coordinate basis according to the operations under the xCoba documentation. I have a slide show on how to do this sort of thing (not perturbations exactly, but once you have the expression for the tensors, it is easy to apply it) at the web site: http://www.madscitech.org/tensors.html, look for GR Calculations in Specific Bases using Mathematica.