Request for assistance

55 views
Skip to first unread message

Eran Lavi

unread,
Apr 28, 2025, 8:56:06 AMApr 28
to xAct Tensor Computer Algebra
Hi
I have attached the code I used to find the tensor components. What I get is an answer that does not present the variables and constant, and does not run on the entire tensor.
Please tell me what mistake I am making?

<< xAct`xTensor`

(*Define manifold and chart*)
DefManifold[M, 4, {a, b, c, d}];
DefChart[cM, M, {t, r, \[Theta], \[Phi]}];

(*Define metric*)
DefMetric[-1, g[-a, -b], CD, {";", "\[Del]"}, PrintAs -> "g"];

(*Define metric components (Kerr-like)*)
DefMetricComponents[
  g[-a, -b], {{-(r^2 - (2  G  M  r)/c^2 + a^2  Cos[\[Theta]]^2)/(r^2 +
         a^2  Cos[\[Theta]]^2)  c^2, 0,
    0, -(a  Sin[\[Theta]]^2  (2  G  M  r)/c)/(r^2 +
       a^2  Cos[\[Theta]]^2)}, {0, (r^2 +
       a^2  Cos[\[Theta]]^2)/(r^2 - (2  G  M  r)/c^2 + a^2), 0,
    0}, {0, 0, r^2 + a^2  Cos[\[Theta]]^2,
    0}, {-(a  Sin[\[Theta]]^2  (2  G  M  r)/c)/(r^2 +
       a^2  Cos[\[Theta]]^2), 0,
    0, ((r^2 + a^2)^2 -
       a^2  (r^2 - (2  G  M  r)/c^2 +
          a^2)  Sin[\[Theta]]^2)  Sin[\[Theta]]^2/(r^2 +
        a^2  Cos[\[Theta]]^2)}}];

(*Define tensors*)
DefTensor[F[-a, -b], M, Antisymmetric[{-a, -b}]];
DefTensor[T[-a, -b], M, Symmetric[{-a, -b}]];

(*Define F_ab components directly*)
FcompRules = {F[__] :> 0, F[-t, -r] -> (M  G)/(c  r^2),
   F[-r, -t] -> -(M  G)/(c  r^2)};

(*Apply component substitution before raising indices*)
FwithComponents = F[-a, -b] /. FcompRules;
FUp2 := Raise[FwithComponents, g, 2];
FUpAll := Raise[FwithComponents, g, All];

(*Define stress-energy tensor*)
K = c^2/G;
Texpr = K  (FwithComponents[-a, -c]  FUp2[-b, -c] - (1/
        4)  g[-a, -b]  FwithComponents[-c, -d]  FUpAll[-c, -d]);

(*Build 4x4 matrix of components*)
coords = {t, r, \[Theta], \[Phi]};
Tmatrix =
  Table[Simplify[
    ComponentValue[Texpr, {coords[[i]], coords[[j]]}]], {i, 1, 4}, {j,
     1, 4}];

(*Display neatly*)
MatrixForm[Tmatrix]
xTensor T_.nb

Juan Margalef

unread,
Apr 28, 2025, 1:52:06 PMApr 28
to xAct Tensor Computer Algebra
Hi Eran.

I am afraid there are several mistakes. 

1. The use of components requires the package xCoba. Use << xAct`xCoba` (which loads automatically xTensor and the rest of the important packages). I think you should read the documentation xCobaDoc.nb to get a better idea of the syntax used in this package (CTensor, SetCMetric, and related functions). 

2. The constants must be declared with something like:

DefConstantSymbol /@ {cc, G, m, aa};

Notice that you cannot use "c" or "a" as constants since they are already defined as indices. 

3. The coordinates are scalars and then require a pair of empty brackets:

DefChart[cM, M, {1, 2, 3, 4}, {t[], r[], \[Theta][], \[Phi][]}] 

Notice that every coordinate expression that you write must include the empty brackets.

Hopefully, with these comments, you can get what you want. If not, don't hesitate to ask again.

Good luck!
Reply all
Reply to author
Forward
0 new messages