xCoba, the Riemann tensor and ToValues

1,037 views
Skip to first unread message

Daan Janssen

unread,
Apr 20, 2021, 9:41:54 AM4/20/21
to xAct Tensor Computer Algebra
Hey everyone,
I am relatively new to Mathematica and especially xtensor/xcoba, but even though I am very happy that these packages exist and already make my life much easier, I am running in to a couple of problems. One of them, is that in the calculations I am doing, terms like

RiemannCD[-c, a, b, -d] RiemannCD[-e, -a, -b, -f]

appear. If I want to evaluate these in a certain coordinate basis, the Riemann tensor with unconventional placings of indices are not calculated by MetricCompute and hence TaValues does not work here, see below a more concrete example. What is the best way to overcome this? This is not the only problem I run into during my calculations, but overcoming this would already help a lot.
--
Concrete example code:
<< xAct`xTensor`
<< xAct`xCoba`

DefManifold[M, 4, IndexRange[a, f]]
DefMetric[-1, metric[-a, -b], CD, PrintAs -> "g"]

(*Define spherically symmetric metric in quasi-conformal coordinates*)

DefChart[quasconf, M, {0, 1, 2, 3}, {t[],
  r[], \[CurlyTheta][], \[CurlyPhi][]}, ChartColor -> Red]
DefScalarFunction[\[Alpha]]
DefScalarFunction[\[Beta]]

met = {{-Exp[2 (\[Alpha][t[], r[]] + \[Beta][t[], r[]])], -Exp[
     2*\[Beta][t[], r[]]], 0, 0}, {-Exp[2*\[Beta][t[], r[]]], 0, 0,
   0}, {0, 0, Exp[2*\[Beta][t[], r[]]] r[]^2, 0}, {0, 0, 0,
   Exp[2*\[Beta][t[], r[]]] r[]^2 *Sin[\[CurlyTheta][]]^2}}

MetricInBasis[metric, -quasconf, met]
MetricCompute[metric, quasconf, All]

RiemannCD[{0, -quasconf}, a,  b, {0, -quasconf}] RiemannCD[{0, -quasconf}, -a, -b, {0, \
-quasconf}] // ToBasis[quasconf] // TraceBasisDummy // ToValues
--
In the output the second Riemann tensor is evaluated, but the first is not. Is there a way to force both Riemann tensors into a form where they are both evaluated? (In this example I wrote the expression to be evaluated by hand, but in my actual code they are generated by applying functions like SortCovDs etc to an expression.)

Best regards,
Daan Janssen

Jose

unread,
Apr 20, 2021, 4:44:30 PM4/20/21
to xAct Tensor Computer Algebra
Hi,

xCoba currently has two alternative ways things. For computations like yours I recommend to use only the CTensor framework, without using ToValues and friends. This is what I'd do:

Load xCoba (which automatically loads xTensor):

   << xAct`xCoba`

Define a manifold and a chart. No need to define a symbol metric (no need to use DefMetric):

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

   DefChart[quasconf, M, {0, 1, 2, 3}, {t[], r[], \[CurlyTheta][], \[CurlyPhi][]}, ChartColor -> Red]

Specify your metric as a CTensor object:

   DefScalarFunction[\[Alpha]]
   DefScalarFunction[\[Beta]]

   met = CTensor[{
     {-Exp[2 (\[Alpha][t[], r[]] + \[Beta][t[], r[]])], -Exp[2*\[Beta][t[], r[]]], 0, 0},
     {-Exp[2*\[Beta][t[], r[]]], 0, 0, 0},
     {0, 0, Exp[2*\[Beta][t[], r[]]] r[]^2, 0},
     {0, 0, 0, Exp[2*\[Beta][t[], r[]]] r[]^2*Sin[\[CurlyTheta][]]^2}
    }, {-quasconf, -quasconf}];

Precompute everything about this metric:

   MetricCompute[met, quasconf, All]

Declare that this metric will be used to raise and lower indices when needed (this is the main step you were missing):

   SetCMetric[met, quasconf, SignatureOfMetric -> {3, 1, 0}]

Now you can get all objects associated to that metric. For example the Levi-Civita connection (you can use this object as usual with CD[-a][ctensor], etc):

   CD = LC[met];

The Riemann tensor of that connection:

   RiemannCD = Riemann[CD];

Now compute the scalar you want. Note that no ToBasis/TraceDummy/ToValues calls are needed:

   RiemannCD[{0, -quasconf}, a, b, {0, -quasconf}] RiemannCD[{0, -quasconf}, -a, -b, {0, -quasconf}] // Simplify

Cheers,
Jose.

Daan Janssen

unread,
Apr 21, 2021, 6:21:14 AM4/21/21
to xAct Tensor Computer Algebra
Hey Jose, thanks for your speedy answer.

I had also considered this method, but the problem is that for the way I actually derive the quantities that I want to evaluate, this method is not so feasible I feel. In particular I need to find a Taylor expansion (in some coordinate system) of geodesic distances (denoted by \sigma) to 6th order. In order to calculate these quantities I first need covariant derivatives of this geodesic distances in a coincidence limit, which can be derived from a differential equation defining the geodesic distance.

I currently do this in the way described below (here I give the third order term, the sixth order is just repeating the same idea, though I should mention that the problematic terms for ToValues only start appearing at 5th order). The main problem is that when replacing CD by a precalculated levi civita connection as you suggest, block 5 of the calculations below already slows down a lot, let alone if I need to take even more derivatives to go to 6th order. Also, I'm not so sure if your suggestions jives very well with the rules I use here. I will try to make it work, but if you have any suggestions on how to sort these issues out, the are very welcome.

Many thanks for your time,
Daan

---
(*\[Sigma] denotes half the geodesic distance, i.e. the Synge world function (say from some fixed point p)*)
DefTensor[\[Sigma][], M]

(*CD[-a][\[Sigma]]=0 at point p (lowest order contribution in covariant Taylor series is quadratic)*)
\[Sigma]c1rule =
 MakeRule[{CD[-a][\[Sigma][]],0},
   MetricOn -> {a, b}, ContractMetrics -> True][[1]]

(*CD[-a][CD[-b][\[Sigma][]]]=metric[-a,-b] at point p*)
\[Sigma]c2rule =
 MakeRule[{CD[-a][CD[-b][\[Sigma][]]], metric[-a, -b]},
   MetricOn -> {a, b}, ContractMetrics -> True][[1]]

(*Calculate CD[-c][CD[-b][CD[-a][\[Sigma][]]]] at point p from diff. eq. 2\[Sigma][]==metric[a,b]CD[-a][\[Sigma][]]CD[-b][\[Sigma][]]*)
(*Define placeholder for bookkeeping*)
DefTensor[\[Sigma]c3[-a, -b, -c], M]

(*Take three derivatives of defining diff eq*)
0 == Module[{a, b, c, e, f},  CD[-c][CD[-b][CD[-a][metric[e, f] CD[-e][\[Sigma][]] CD[-f][\[Sigma][]]/2 - \[Sigma][]]]]] // SortCovDs

(*Apply rules CD[-a][CD[-b][\[Sigma][]]]=metric[-a,-b] and CD[-a][\[Sigma]]=0 while CD[-c][CD[-b][CD[-a][\[Sigma][]]]] remains untouched*)
\[Sigma]3expr = % /. MakeRule[{CD[-c][CD[-b][CD[-a][\[Sigma][]]]], \[Sigma]c3[-a, -b, -c]}, MetricOn -> {a, b, c}, ContractMetrics -> True] /. \[Sigma]c2rule /. \[Sigma]c1rule /. MakeRule[{\[Sigma]c3[-a, -b, -c], CD[-c][CD[-b][CD[-a][\[Sigma][]]]]}, MetricOn -> {a, b, c}, ContractMetrics -> True] // Simplification // SortCovDs

(*Solve for CD[-c][CD[-b][CD[-a][\[Sigma][]]]] at p*)
\[Sigma]c3rule = SolveTensors[\[Sigma]3expr, CD[-c_][CD[-b_][CD[-a_][\[Sigma][]]]]][[1]][[1]]

Jose

unread,
Apr 21, 2021, 10:27:59 PM4/21/21
to xAct Tensor Computer Algebra
Hi,

The new problem you pose seems quite a lot more involved than the original one in the previous email. I can only give some general advice:

In situations like this, in which one eventually finds large expressions, I'd recommend to guide all computations, step by step. For example your original expression was RiemannCD[{0, -Q}, a,  b, {0, -Q}] RiemannCD[{0, -Q}, -a, -b, {0, -Q}] (with Q your quasconf) and you seemed to expect that xCoba would automatically raise and lower indices of the Riemann tensors. This can be automated with SetCMetric, but if the metric is complicated then it's better to perform those contractions manually, so that you have full control on when each operation is performed, and how much simplification is applied after each step. It is also better to keep all indices of all tensors in their original positions, not absorbing metric factors, because then you can eventually replace symbolic metrics g[-a, -b] with explicit objects CTensor[...][-a, -b], etc. Hence try to construct rules that do not require the use of MetricOn and ContractMetrics.

Cheers,
Jose.
Reply all
Reply to author
Forward
0 new messages