I have started to learn about the xAct package to do some general relativistic calculations and whereas there might be other codes available, I would like to get my answer in terms of this package's codes. As the title suggests, this is a very basic question, but I am having a hard time to get the answer. I have installed the package and all its components properly, so there're no issues there.

I started with

<< xAct`xTensor`

<< xAct`xCoba`

<< xAct`xTras`

as I think these will be eventually needed. After that I am simply going ahead in the usual way to define the metric:

DefManifold[M, 4, IndexRange[a, q]]

DefMetric[-1, metric[-a, -b], CD, PrintAs -> "g"]


MatrixForm[fm = {
   {-E^(2 σ[z[]]), 0, 0, 0},
   {0, $N[z[]]^2 E^(2 σ[z[]]), 0, 0},
   {0, 0, R[z[]]^2  E^(2 σ[z[]]), 0},
   {0, 0, 0, R[z[]]^2 Sin[θ[]]^2 E^(2 σ[z[]])}

MetricInBasis[metric, -B, fm]

MetricCompute[metric, B, All, CVSimplify -> Simplify]

This defined the metric tensor and also assigns a basis vector. It also uses a particular matrix's elements as the metric tensor. So I have defined a given metric. The last input calculates several things together such as Riemann Tensor, Christoffel symbol and so on..

From here on, if I want I can compute Ricci scalar or any function of it. I can also e.g. find out what are the components of Riemann tensor e.g. But what I can't seem to compute is what is the value of $Rs=R_{abcd}R^{abcd}$ for this given metric.

I tried commands like

TensorValues[RiemannCD[-B, -B, -B, -B] RiemannCD[B, B, B, B]] // 


TensorValues[Rs] // ToBasis[B] // ToValues

but none of these are working. I also can't seem to find any such example anywhere!


1 Answer 1


The reason is that there is no chart defined on the manifold.

Manifold -> metric -> chart (B) -> MetricInBasis.

So before MetricInBasis, you need something like

DefChart[schwarzs, M, {0, 1, 2, 3}, {t[], r[], \[Theta][], \[Phi][]}, ChartColor -> Red],

Replace the Schwarzs with your actual coordinate system.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.