Reducing computation time?

64 views
Skip to first unread message

Mario Herrero Valea

unread,
Feb 11, 2015, 4:22:16 AM2/11/15
to xa...@googlegroups.com
Hello everyone,

Recently I've been trying to perform a computation using xAct and a foliation decomposition of the metric and I'm finding that computation time is much much longer than I expected. In particular, I'm doing the following. First, I define the manifold and metric

DefManifold[M,4,{a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u,w,x,y,z}];
DefMetric[-1,gm[-a,-b],CD,PrintAs->"g"];
SetOptions[ContractMetric,AllowUpperDerivatives->True];

And afterwards, the elements necessary for the decomposition

DefTensor[n[a],M]; 
AutomaticRules[n,MakeRule[{n[a]n[-a],-1}]];
AutomaticRules[n,MakeRule[{gm[-a,-b]n[a]n[b],-1}]];
$ExtrinsicKSign=-1; 
$AccelerationSign=-1;
DefMetric[1,hm[-a,-b],sd,{"|","D"},InducedFrom->{gm,n},PrintAs->"h"];


Now, I introduce some simbols for defining differential operators

DefTensor[Deltat[],M,PrintAs->"\[CapitalDelta]t"];
IndexSetDelayed[Deltat[][expr_], LieD[n[a],CD][LieD[n[b],CD][expr]]];

DefTensor[Deltax[],M,PrintAs->\[CapitalDelta]x];
IndexSetDelayed[Deltax[][expr_], hm[r,s]ProjectWith[hm][CD[-r]@(ProjectWith[hm][CD[-s]@expr])]];

DefTensor[Deltax2[],M,PrintAs->\[CapitalDelta]x];
IndexSetDelayed[Deltax2[][expr_], hm[x,y]ProjectWith[hm][CD[-x]@(ProjectWith[hm][CD[-y]@expr])]];

And I'm trying to perform the following computation 

Dtf=Deltat[][f[]];
piece11=Deltax[][Dtf];
DtDxDtf=Deltat[][piece11];
one=Deltax2[][DtDxDtf];


I executed it during the night and it took more than 8 hours to give a result, which surprised me since it shouldn't be such a heavy computation. Does anyone know if there is any trick or strategy I can use to reduce computation time???

Thomas Bäckdahl

unread,
Feb 11, 2015, 7:16:53 AM2/11/15
to xa...@googlegroups.com
Hi Mario!

First, you had used f as an index (in DefManifold) but then used it as a scalar field.
I would suggest that you remove it from the list of indices, and define it as a tensor DefTensor[f[], M].

The main reason why it takes too long time, is because the problem quickly becomes huge. Already DtDxDf has 888 terms with many factors in each term. On top of that you apply two derivatives without simplifications, which by Leibniz rule gives huge expressions. So what you need to do is to make simplifications in each step. What these simplification steps are depends entirely on what you want your target expression to look like.

If you would like directional derivatives instead of n vectors outside, then I would recommend ContractDir. If you would like to translate the intrinsic metric hm to the full metric and the normal n, use ProjectorToMetric. If you would like to have the acceleration vector and second fundamental form instead of derivatives of n, you can use GradNormalToExtrinsicK. Whatever you decide to do, look at the intermediate expressions, and think about what kind of rules you could use to bring them into a form you would like to work with. You might also want to commute derivatives etc. Even though the problem does not seem that difficult at the surface, it is still quite hard unless you know exactly what to do in each step to keep the size down. xAct can handle reasonably large problems, but if you are not careful a single operation can take a reasonably sized expression, and make an enormous expression of it.

If you use IndexSetDelayed as you did, you don't really need to define Deltat as a tensor because it will never appear in any expression. If you want it as an operator you can for instance define it as an inert head.

DefInertHead[Deltat, PrintAs -> "\[CapitalDelta]t"];
DeltatRule =  IndexRuleDelayed[Deltat[expr_], ContractDir[LieD[n[a], CD][ContractDir[LieD[n[b], CD][expr], n]], n]];

Dtfeq = Deltat[f[]] == (Deltat[f[]] /. DeltatRule)

Regards
Thomas
--
You received this message because you are subscribed to the Google Groups "xAct Tensor Computer Algebra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xact+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mario Herrero Valea

unread,
Feb 11, 2015, 8:10:53 AM2/11/15
to xa...@googlegroups.com
Dear Thomas,

Thank you for your answer. The f[] in the final expressions was a typo when writing the code here. With respect to your other comments, I would prefer not to use directional derivatives because I want the final result in a form in which all derivatives action on f[] will be plain covariant derivatives. I will see if some of the other simplifications work.

For the moment, I've been able to reduce computation time by doing some intermediate simplifications using SameDummies and ToCanonical, but it still takes a huge amount of time even in a computing cluster (I guess this is because the program only uses a single core. Any chance of parallelizing it?).

Cheers,
Mario

Thomas Bäckdahl

unread,
Feb 11, 2015, 9:25:54 AM2/11/15
to xa...@googlegroups.com
Hi Mario!


If you convert to extrinsic curvature and acceleration, you can do simplification in each step, and get the computation time down to few minutes. See the attached file.
I don't know if this is what you want though.

Parallelization is possible, but difficult because all information about all tensors etc must be distributed to all subkernels. The automatic functions for this does not work well so you have to do it manually.  I.e. turn off the context distribution, load all packages on all kernels. Then you can define all manifolds, tensors etc on all kernels. When you have done that you can parallelize ToCanonical over the different terms of a sum, or whatever helps your calculation.

Regards
Thomas
MarioTest1.nb
Reply all
Reply to author
Forward
0 new messages