Dear professor Gianluca Gorni:
Thank you very much for your help, now my problem is almost solved!
I slightly modified the code received to allow for the following options:
1) non-numeric scalar symbols like "s0" or "s1[t,x]":
scalarQ[S_] := TrueQ[TensorRank[S] === 0];
2) Identities for Dot and TensorProduct combinations, taken from Lebedev (2003):
myDot[T_, S_] /; scalarQ[S] :> T*S
myDot[TensorProduct[T1_, T2_], T3_] :>
TensorProduct[T1, myDot[T2, T3]]
myDot[T1_, TensorProduct[T2_, T3_]] :>
TensorProduct[myDot[T1, T2], T3],
3) Divergence of a Tensor product. For this, I applied the product rule:
myDiv[TensorProduct[T1_, T2_], x_] :>
TensorProduct[myDiv[T1, x], T2] + myDot[T1, myGrad[T2, x]],
4) Finally, to allow for constant functions, I added the conditions:
yDiv[T_, x_] /; FreeQ[T, x] :> 0
myGrad[T_, x_] /; FreeQ[T, x] :> 0
My main doubt is the item nÂș3, as I cannot find an explicit published reference. The best I could find was this entry in a physics forum (coincidentally, the fluid mechanics problem involved is the same I have):
Fluid dynamics - divergence of a tensor product
The derivation offered there seems right, but maybe I am wrong.
Finally, I am attaching the full notebook (with the continuum mechanics problem included). Please tell me if there is some mistake there.
References:
Lebedev, Leonid P, and Michael J Cloud. Tensor Analysis, World Scientific Publishing Company, 2003
Attachments: