I want to calculate the divergence of a rank-2 tensor field $$\nabla \cdot T$$ defined on the surface of a sphere in spherical coordinates. As an example, let the field be given as follows :

import numpy as np

LAT = 100
LONG = 100

tensor_field = np.array([np.random.rand(LAT,LONG) for i in range(9)])

here, each one of the 9 entries corresponds to one component in spherical coordinates of the rank-2 tensor.

If it were a rank-1 tensor field (a vector field), I could brute force my way by manually converting each component to Cartesian basis, and calculate the divergence as done in this answer.

Is there a simpler way for higher rank tensor fields?

  • $\begingroup$ Welcome to Scicomp! Have you checked: en.wikipedia.org/wiki/… ? $\endgroup$
    – MPIchael
    Commented Jan 22 at 9:50
  • $\begingroup$ Have you tried to write down the contraction of the covariant derivative with the tensor in index notation? $\endgroup$
    – Bort
    Commented Jan 24 at 17:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.