To resolve the v2 issue please follow up on that original thread and let me know what you did after my reply there.
For your current issue, you are thinking about things the wrong way. I'll show you how I would do these kind of problems, then maybe it clicks.
Your problem is about a tensor $Z$ with components $Z^{\rho}{}_{\eta}$ which is given by some particular expression in terms of other tensors. You then want to build another expression, which involves products of your $Z$ tensor with itself (and possibly others). You then want to write out the $Z$s in that new expression in terms of the other, more basic tensors.
So the starting point should be a Cadabra expression, let's call it Zrule
, which says how the components of $Z$ are related to the other tensor components. Something like
{\tau,\eta,\rho,\lambda}::Indices(position=fixed).
Zrule:= Z^{\rho}_{\eta} = u^{\rho} u_{\eta};
(I have used a vastly simpler expression than in your problem just to make this answer easier to read; the logic remains the same though). You now have an object Zrule
, which tells Cadabra how components of $Z$ can be converted to components of $u$. Important: the Zrule
itself is not a tensor, it is the name of an expression which involves tensor components. Call it banana
if you like, to make this more clear.
Now you make an expression which is built from $Z$, e.g. the ${\rm tr}(Z.Z)$ you mentioned:
ex:= Z^{\rho}_{\eta} Z^{\eta}_{\rho};
Cadabra will display this as $Z^{\rho}{}_{\eta} Z^{\eta}{}_{\rho}$. Not in terms of $u$, because you did not ask for that yet. You can get the expression in terms of $u$ by substituting the $Z$ components using the Zrule
,
substitute(_, Zrule); # in cadabra v2
@substitute!(%){ @(Zrule) } # in cadabra v1
This will produce $u^\rho u_\eta u^\eta u_\rho$. If you ask to display ex
again (by typing ex;
) you will see that the ex
object has now been replaced by the expression in terms of $u$ above.
Does that make it more clear? Main lesson: do not think in terms of the left-hand sides of :=
lines as being tensors themselves. The left-hand sides of :=
lines are names of expressions. Names do not carry indices. Call them after your favourite fruits or pets animals if you get confused.
Hope this helps.