** DefTensor: Defining tensor ChristoffelCDPDcoords[i,-j,-k].** DefTensor: Defining weight +2 density Detgcoords[]. Determinant.
<< xAct`xCoba`;DefManifold[\[CapitalSigma], 3, {i, j, k, l, m, n, s, t, u, v}];
DefMetric[1, g[-i, -j], CD, SymbolOfCovD -> {";", "\[Del]"}, WeightedWithBasis -> AIndex];
DefChart[Spher, \[CapitalSigma], {1, 2, 3}, {r[], \[Theta][], \[Phi][]}];$PrePrint = ScreenDollarIndices;MetricInBasis[g, -Spher, {{1, 0, 0}, {0, r[]^2, 0}, {0, 0,r[]^2 Sin[\[Theta][]]^2}}];MetricCompute[g, Spher, All];
DefConstantSymbol[X];DefConstantSymbol[Y];DefConstantSymbol[Z];DefTensor[V[i], \[CapitalSigma]];AllComponentValues[V[{i, Spher}], {Z Cos[\[Theta][]] + Sin[\[Theta][]] (X Cos[\[Phi][]] + Y Sin[\[Phi][]]), ( X Cos[\[Theta][]] Cos[\[Phi][]] - Z Sin[\[Theta][]] + Y Cos[\[Theta][]] Sin[\[Phi][]])/r[], ( Csc[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]]))/r[]}]
In[34]:= ToBasis[Spher][CD[-j][V[i]]]
Out[34]= xAct`xTensor`Basis[-k, {i, Spher}] CD[{-j, -Spher}][V[k]]
In[35]:= ComponentArray[%]Out[35]= {{xAct`xTensor`Basis[-i, {1, Spher}] CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {1, Spher}] CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {1, Spher}] CD[{3, -Spher}][V[i]]}, {xAct`xTensor`Basis[-i, {2, Spher}] CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {2, Spher}] CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {2, Spher}] CD[{3, -Spher}][V[i]]}, {xAct`xTensor`Basis[-i, {3, Spher}] CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {3, Spher}] CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {3, Spher}] CD[{3, -Spher}][V[i]]}}
1/18/20 12:37:28 In[36]:= ToBasis[Spher][%]1/18/20 12:37:28 Out[36]= {{xAct`xTensor`Basis[{-i, -Spher}, {1, Spher}] ChristoffelCDPDSpher[{i, Spher}, {1, -Spher}, {-j, -Spher}] V[{j, Spher}] + xAct`xTensor`Basis[{-i, -Spher}, {1, Spher}] CD[{1, -Spher}][V[{i, Spher}]] , ETC...
In[37]:= TraceBasisDummy[%]
Out[37]= {{ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {1, -Spher}] V[{1, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {2, -Spher}] V[{2, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {3, -Spher}] V[{3, Spher}] + CD[{1, -Spher}][V[{1, Spher}]], ETC...In[39]:= ToValues[%] // SimplifyOut[39]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
In[41]:= ToValues[ ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {1, -Spher}] V[{1, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {2, -Spher}] V[{2, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {3, -Spher}] V[{3, Spher}]]
ToValues[CD[{3, -Spher}][V[{1, Spher}]]]
Out[41]= -Sin[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]])Out[42]= Sin[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]])
Thank you so much Jose, you're so awesome for still supporting xAct so keenly!
Your answer made me wonder whether I've been using xCoba right... I usually first attribute values to tensor components in a certain basis, then write a tensorial expression I want to calculate, then set all the indices to that basis, apply tracebasisdummy to expand the contracted indices, apply componentarray if there are uncontracted indices, and ToValues will usually finally give me the answer.But have I been doing this right? It looks like I might have only been calculating covariant derivatives of tensor components, instead of components of covariant derivatives!Let me write here a minimal working example: spherical coordinates in 3D<< xAct`xCoba`;DefManifold[\[CapitalSigma], 3, {i, j, k, l, m, n, s, t, u, v}];DefMetric[1, g[-i, -j], CD, SymbolOfCovD -> {";", "\[Del]"}, WeightedWithBasis -> AIndex];DefChart[Spher, \[CapitalSigma], {1, 2, 3}, {r[], \[Theta][], \[Phi][]}];$PrePrint = ScreenDollarIndices;MetricInBasis[g, -Spher, {{1, 0, 0}, {0, r[]^2, 0}, {0, 0,r[]^2 Sin[\[Theta][]]^2}}];MetricCompute[g, Spher, All];so I have the flat Euclidean metric in spherical coordinates. Now I define a vector which, in Cartesian coordinates, would have constant components X Y and Z, but in spherical coordinates has nonconstant components:DefConstantSymbol[X];DefConstantSymbol[Y];DefConstantSymbol[Z];DefTensor[V[i], \[CapitalSigma]];AllComponentValues[V[{i, Spher}], {Z Cos[\[Theta][]] + Sin[\[Theta][]] (X Cos[\[Phi][]] + Y Sin[\[Phi][]]), ( X Cos[\[Theta][]] Cos[\[Phi][]] - Z Sin[\[Theta][]] + Y Cos[\[Theta][]] Sin[\[Phi][]])/r[], ( Csc[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]]))/r[]}]This guy has to have zero covariant derivatives. Calculating all the components of the covariant derivative in my way I get:In[34]:= ToBasis[Spher][CD[-j][V[i]]]Out[34]= xAct`xTensor`Basis[-k, {i, Spher}] CD[{-j, -Spher}][V[k]]here it projected the k component of V, who is inside CD, onto the i-th component of the Spher coordinate system. The component of CD is already in the Spher coordinate system.
Now let's make a matrix with the choices of components i and j:In[35]:= ComponentArray[%]Out[35]= {{xAct`xTensor`Basis[-i, {1, Spher}] CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {1, Spher}] CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {1, Spher}] CD[{3, -Spher}][V[i]]}, {xAct`xTensor`Basis[-i, {2, Spher}] CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {2, Spher}] CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {2, Spher}] CD[{3, -Spher}][V[i]]}, {xAct`xTensor`Basis[-i, {3, Spher}] CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {3, Spher}] CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {3, Spher}] CD[{3, -Spher}][V[i]]}}(sorry for the long expression). Now, running ToValues now does nothing, because there is still a saturated abstract index i which is not in any particular coordinate system. So I put it in the basis Spher (and this might be a misstep, I suppose?):
1/18/20 12:37:28 In[36]:= ToBasis[Spher][%]1/18/20 12:37:28 Out[36]= {{xAct`xTensor`Basis[{-i, -Spher}, {1, Spher}] ChristoffelCDPDSpher[{i, Spher}, {1, -Spher}, {-j, -Spher}] V[{j, Spher}] + xAct`xTensor`Basis[{-i, -Spher}, {1, Spher}] CD[{1, -Spher}][V[{i, Spher}]] , ETC...so you see what I get? It's a Christoffell symbol saturated with V, plus a CD of V. The above expression would be correct if there was a partial derivative instead of CD.
Now I expand the saturated indices, and apply ToValues:In[37]:= TraceBasisDummy[%]Out[37]= {{ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {1, -Spher}] V[{1, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {2, -Spher}] V[{2, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {3, -Spher}] V[{3, Spher}] + CD[{1, -Spher}][V[{1, Spher}]], ETC...In[39]:= ToValues[%] // SimplifyOut[39]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}The result is correct! I don't understand what's going on...
If I ToValues separately one of the Christhoffel terms and the corresponding CD term I get:In[41]:= ToValues[ ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {1, -Spher}] V[{1, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {2, -Spher}] V[{2, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {3, -Spher}] V[{3, Spher}]]ToValues[CD[{3, -Spher}][V[{1, Spher}]]]Out[41]= -Sin[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]])Out[42]= Sin[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]])I get equal and opposite nonzero values, as it should be if the derivative was PD and not CD.
I'm clearly missing something basic here... can you help?