First of all, note that you'll need to use xCoba
to do any calculations in terms of coordinate components. From the xTensor documentation page:
xTensor does not perform component calculations. Use the companion package xCoba.
In xCoba
, you need to define a "chart" on your manifold with the coordinates you're using, and explicitly call DefScalarFunction
for the functions you're going to be using. For example, here's how you'd define a flat FRW metric:
<< xAct`xCoba`
(* Define the manifold *)
DefManifold[M, 4, IndexRange[a, n]]
(* Define coordinates on a chart of M *)
DefChart[ch, M, {0, 1, 2, 3}, {t[], x[], y[], z[]}, ChartColor -> Blue]
(* Define aa (the scale factor) to be a scalar function of one or more coordinates *)
DefScalarFunction[aa]
(* Create the metric tensor in terms of its coordinate components *)
met = CTensor[DiagonalMatrix[{-1, aa[t[]]^2, aa[t[]]^2, aa[t[]]^2}], {-ch, -ch}];
(* Set this metric to be the metric of the manifold on the chart ch *)
SetCMetric[met, ch, SignatureOfMetric -> {3, 1, 0}]
(* Define the covariant derivative operator *)
cd = CovDOfMetric[met];
(* Calculate various curvature tensors and cache *)
MetricCompute[met, ch, All]
(* Display Kretschmann invariant *)
Kretschmann[cd][]
Out[] = (12 (aa'[t[]]^4 + aa[t[]]^2 (aa'')[t[]]^2))/aa[t[]]^4
The Gauss-Bonnet invariant is not automatically computed by MetricCompute
, but you could easily define it in terms of the appropriate contractions.
Note that none of this is terribly clear in the main xCobaDoc.nb
file that's linked to on the main xCoba page. However, when you download and install the package, there should be a file called xCobaDoc2.nb
in the Documentation directory that gives a lot more detail on how to use CTensor
to define coordinate tensors, with some helpful examples. That's how I personally figured out how to use the package...