70 views

Skip to first unread message

Jan 18, 2023, 10:34:04 AM1/18/23

to xAct Tensor Computer Algebra

Hi everyone, I'm new to Mathematica so I'm aware I may have committed some atrocious crimes in writing my code.

Basically, I need to study the Einstein tensor for a metric (that i called "improvedmetric") in order to compute the energy-momentum tensor. The problem is that it takes a very very long time for my computer to compute the Einstein tensor, therefore I can never work on it since I'm always stuck at the last line of the code (I'm gonna write it at the end of my message). Have I done something wrong? Is there a clever way to speed up the computation?

I already tried to compute the Ricci tensor and the scalar curvature separately: in this case the computation actually works, but when I try to calculate the Einstein tensor by using its definition, I get a huge monster that I can never get to simplify.

Thank you all in advance!

<< xAct`xCoba`

$Info = False;

$CVVerbose = False;

$PrePrint = ScreenDollarIndices;

indices = Join[{a},

Table[ToExpression[StringJoin["a", ToString[j]]], {j, 1, 20}]

]

DefManifold[M, 4, indices]

DefMetric[-1, g[-a1, -a2], CD, PrintAs -> "g"]

DefChart[chart, M, {0, 1, 2, 3}, {t[], r[], \[Theta][], \[Phi][]}]

DefScalarFunction[F]

DefConstantSymbol[Mass, PrintAs -> "M"]

DefConstantSymbol[Rotation, PrintAs -> "a"]

Delta = r[]^2*F[r[]] + Rotation^2

f = 1/2*r[]^2*(1 - F[r[]])

Psi = r[]^2 + Rotation^2 Cos[\[Theta][]]^2

Sigma = (r[]^2 + Rotation^2)^2 - Rotation^2*Delta*Sin[\[Theta][]]^2

improvedmetric = {

{1 - 2 f/Psi, 0, 0,

4*Rotation*f*Sin[\[Theta][]]^2/Psi}, {0, -Psi/Delta, 0, 0}, {0,

0, -Psi^2, 0}, {4*Rotation*f*Sin[\[Theta][]]^2/Psi, 0,

0, -Sigma*Sin[\[Theta][]]^2/Psi}

}

MetricInBasis[g, -chart, improvedmetric] // TableForm

MetricCompute[g, chart, "Einstein"[-1, -1], CVSimplify -> Simplify]

$Info = False;

$CVVerbose = False;

$PrePrint = ScreenDollarIndices;

indices = Join[{a},

Table[ToExpression[StringJoin["a", ToString[j]]], {j, 1, 20}]

]

DefManifold[M, 4, indices]

DefMetric[-1, g[-a1, -a2], CD, PrintAs -> "g"]

DefChart[chart, M, {0, 1, 2, 3}, {t[], r[], \[Theta][], \[Phi][]}]

DefScalarFunction[F]

DefConstantSymbol[Mass, PrintAs -> "M"]

DefConstantSymbol[Rotation, PrintAs -> "a"]

Delta = r[]^2*F[r[]] + Rotation^2

f = 1/2*r[]^2*(1 - F[r[]])

Psi = r[]^2 + Rotation^2 Cos[\[Theta][]]^2

Sigma = (r[]^2 + Rotation^2)^2 - Rotation^2*Delta*Sin[\[Theta][]]^2

improvedmetric = {

{1 - 2 f/Psi, 0, 0,

4*Rotation*f*Sin[\[Theta][]]^2/Psi}, {0, -Psi/Delta, 0, 0}, {0,

0, -Psi^2, 0}, {4*Rotation*f*Sin[\[Theta][]]^2/Psi, 0,

0, -Sigma*Sin[\[Theta][]]^2/Psi}

}

MetricInBasis[g, -chart, improvedmetric] // TableForm

MetricCompute[g, chart, "Einstein"[-1, -1], CVSimplify -> Simplify]

Jan 18, 2023, 11:13:08 AM1/18/23

to xAct Tensor Computer Algebra

Hi,

The computation of the Einstein tensor is fast. It's the simplification that takes very long. To see this, change the simplification function to do nothing:

In[19]:= MetricCompute[g, chart, "Einstein"[-1, -1], CVSimplify -> Identity] // AbsoluteTiming

Out[19]= {0.132989, Null}

Out[19]= {0.132989, Null}

It took 0.13 seconds to compute everything, with no simplification. Hence the entries of the tensors will be large. For example the 00 component of the Einstein tensor takes about 1 MB:

In[26]:= EinsteinCD[{0, -chart}, {0, -chart}] // ToValues // ByteCount

Out[26]= 1066200

In[26]:= EinsteinCD[{0, -chart}, {0, -chart}] // ToValues // ByteCount

Out[26]= 1066200

Simplify can get that down to a 0.28MB in 34 seconds in my computer:

In[25]:= EinsteinCD[{0, -chart}, {0, -chart}] // ToValues // Simplify //ByteCount // AbsoluteTiming

Out[25]= {34.2689, 284544}

In[25]:= EinsteinCD[{0, -chart}, {0, -chart}] // ToValues // Simplify //ByteCount // AbsoluteTiming

Out[25]= {34.2689, 284544}

So this is a question of balance: choosing a more powerful simplification function (say Together or Simplify) will simplify the initial steps of the computations (which helps in later steps), but will make the last steps rather slow. Choosing no intermediate simplification will be fast, but you will have to simplify everything at the end. For complicated cases, I think the latter method is more useful, because it gives you more control on how to simplify things manually.

Cheers,

Jose.

Jan 19, 2023, 9:30:18 AM1/19/23

to xAct Tensor Computer Algebra

Thank you so much, it was really helpful!

I guess I will have to deal with my little monster tensor then, at least for a little bit.

Have a good day!

Giorgia

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu