How to speed up the calculation for the Ricci tensor of an 11-dimensional metric

243 views
Skip to first unread message

Vasil Dimitrov

unread,
Nov 8, 2021, 9:34:56 AM11/8/21
to xAct Tensor Computer Algebra
Hello,

I have a hard calculation to do that I have performed successfully in 7 dimensions, but when I try to do an analogous calculation in 11 dimensions things become impossibly slow. I realize that the Riemann tensor in D=11 has 1210 non-zero out of a total of 11^4 components, so it is expected to be slow, but how do I speed up my calculation? Here is part of my code, the full code is attached as a notebook, the problem arises in section 6 of the notebook:

Define the manifold:

<< xAct`xTerior`
xAct`xCoba`$LargeComponentSize = 3000;
$PrePrint = ScreenDollarIndices;
$DefInfoQ = $UndefInfoQ = $CVVerbose = False;
$CVSimplify = Together;
DefManifold[man, 11, {a, b, c, d, e, f, h, i, j, k, l}]

Define chart:

DefChart[bh11, man, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {t[],
  r[], \[Theta][], \[Psi][], \[Phi][], x[],
  y[], \[Alpha][], \[Beta][], \[Phi]1[], \[Phi]2[]},
 FormatBasis -> {"Partials", "Differentials"}]
DefConstantSymbol@{f0, g0, r0, m, \[Epsilon], p, q, g, L, z, \[Lambda]1, \[Lambda]2};
DefScalarFunction /@ {U, \[CapitalLambda], \[CapitalOmega], Att,
   A\[Sigma]3, \[Nu]1, \[Nu]2, \[Nu]3, \[CapitalDelta], U11};
$Assumptions =
  And[t[] \[Element] Reals, r0 > 0, r[] > r0, \[Pi] > \[Theta][] > 0,
   4 \[Pi] > \[Phi][] > 0, 2 \[Pi] > \[Psi][] > 0,
   x[] \[Element] Reals,
   y[] \[Element] Reals, \[Pi] > \[Alpha][] > 0, \[Pi]/2 > \[Beta][] >
     0, 1 > z > 0, m > 0, \[Epsilon] \[Element] Reals, L > 0, f0 > 0,
   g0 > 0];

Define metric and covariant derivative:

[Some trivial code to setup the metric matrix omitted]
metmatrix =
  CoefficientArrays[
      ds2, {dt, dr, d\[Theta], d\[Psi], d\[Phi], dxx, dy, d\[Alpha],
       d\[Beta], d\[Phi]1, d\[Phi]2}, "Symmetric" -> True][[3]] //
    Normal // Simplify;
metbh11 =
  CTensor[metmatrix /. {t -> t[],
     r -> r[], \[Theta] -> \[Theta][], \[Psi] -> \[Psi][], \[Phi] -> \
\[Phi][], x -> x[],
     y -> y[], \[Alpha] -> \[Alpha][], \[Beta] -> \[Beta][], \[Phi]1 \
-> \[Phi]1[], \[Phi]2 -> \[Phi]2[]}, {-bh11, -bh11}];
SetCMetric[metbh11, bh11, SignatureOfMetric -> {10, 1, 0}]
cdbh11 = CovDOfMetric[metbh11];

Trying to calculate Ricci (impossibly slow, left it overnight, it got stuck on finding Riemann[-1,-1,-1,1] with no error messages, just moves very slowly):

MetricCompute[metbh11, bh11, "Ricci"[-1, -1],
  Verbose -> True, Parallelize -> True] // AbsoluteTiming

Thoughts:

I carry a bunch of constant symbols throughout the whole calculation: f0, g0, r0, m, \[Epsilon], p, q, g, L, z, \[Lambda]1, \[Lambda]2. I tried giving them numerical values beforehand, but this only makes things slower (even cdbh11 takes much longer to compute that way), I guess carrying numbers with many decimals after the comma is hard.

Raising indices is hard. I noticed the following: I have a tensor G[-a,-b,-c,-d]. Asking for G[-a,-b,c,d] is way slower than asking for metbh11[c,i]metbh11[d,j]G[-a,-b,-i,-j].

Questions:

1/ Is everything with my code ok in the sense, I am slowing it down artificially somewhere?

2/ Is there a way in xAct to work with sparse arrays https://reference.wolfram.com/language/ref/SparseArray.html when doing xCoba calculations?

3/ If the calculation is just slow and that's life I plan to put it on a cluster. Is there a way to tell xAct to make use of GPU resources for faster matrix operations?

Thank you so much, to everyone involved, for making such an expansive and amazing package!

Vasko
7D_eom.nb

Jose

unread,
Nov 15, 2021, 12:21:17 AM11/15/21
to xAct Tensor Computer Algebra
Hi,

This notebook is too large for me to analyze. And the example you provided in text is not complete (the definition of ds2 is not given), so I cannot run it and see why it's slow.

MetricCompute is careful with avoiding repeated computation, i.e. it does not compute components of Riemann that are given by symmetry from other components already computed.

In general, when working with metrics of complicated algebraic structure, the main source of slowness is typically the use of simplification functions. As the computation progresses from the metric to its first derivatives and then second derivatives, the expressions tend to grow and you may spend much time just trying to simplify the results. Perhaps you can try to use more powerful simplification functions in the first steps (say up to the computation of Christoffel) and then use less powerful (or none at all) simplification functions later for curvature computations. I see you also use assumptions, which may make simplification even harder, because there are more rules to try.

For large cases, also try to avoid automatic raising or lowering of indices. Keep tensor indices in their original positions and perform only strictly necessary computations. Large computations must be guided.

I'd recommend not to use reals and use random integers instead. There is no problem in having many decimals after the comma (it's all machine reals anyway),  but by using reals there are never exact cancellations. If something is always exact zero for arbitrary integer values of the constants, then it's probably truly zero, but the same cannot be said using finite precision reals.

It may also be useful to turn on progress messages:

$CVVerbose = True
$xCobaCacheVerbose = True

or locally Verbose->True in MetricCompute.

In relation to your explicit questions:

1) Your code is quite large and I didn't read it carefully, but I didn't see anything obviously wrong.

2) No, xCoba does not handle sparse arrays in any special way. It does, however, use symmetries internally, especially via MetricCompute.

3) I see you already use Parallelize. There is no special support for GPUs.

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