This contraction is used for spin-orbit correction in non-local
contribution to stresses.
Symmetric gxa1, gxa2 are stored as 11 22 33 32 31 21;
gmet(3,3) is symmetric but stored fully (9 elements);
Output rank2c is not symmetric but since
$rank2c_{gxa1,gxa2}(a,b)=conjg(rank2c_{gxa2,gxa1}(b,a))$
it is stored as 11 22 33 32 31 21.
rank2c(1,1), rank2c(2,2), rank3c(3,3) are not needed;
They are not calculated.
rank2c(a,b)=3 conjg(gxa1(i,a)) gmet(i,j) gxa2(j,b)

rank2(6)=2*Re[contraction] given by
2*Re[(15/2)*r3(a,i,j)*r3(b,j,i)-3*r1(i)*r3(a,b,i)-(3/2)*r1(a)*r1(b)]
where r3(a,i,j)=gmet(j,k) gxa(a,i,k) and r1(a)=gmet(i,j) gxa(i,j,a).
rank2 is stored in the compressed form 11 22 33 32 31 21.

m_contract/metcon [ Functions ]

Carries out specialized metric tensor contractions needed for
l=0,1,2,3 nonlocal Kleinman-Bylander pseudopotential operation.
Full advantage is taken of the full permutational symmetry of these
tensors.

m_contract/metcon_so [ Functions ]

Carries out specialized metric tensor contractions needed for
l=0,1,2,3 nonlocal Kleinman-Bylander pseudopotential operation
in the spin-orbit case.
Full advantage is taken of the full permutational symmetry of these tensors.

INPUTS

rank=0,1,2, or 3 = rank of input tensor aa
gmet(3,3)=metric tensor (array is symmetric but stored as 3x3)
amet(3,3)=real or imaginary part of one spin matrix element of the
"spin metric" tensor
aa(2,(rank+1)*(rank+2)/2)=unique elements of complex input tensor

OUTPUT

bb(2,(rank+1)*(rank+2)/2)=unique elements of complex output tensor

NOTES

All tensors are stored in a compressed storage mode defined below;
input and output conform to this scheme.
When tensor elements occur repeatedly due to symmetry, the
WEIGHT IS INCLUDED in the output tensor element to simplify later
contractions with other tensors of the same rank and form, i.e. the
next contraction is then simply a dot product over the unique elements.
Definitions of the contractions:
rank=0: bb=0
rank=1: bb(i)= $amet(i,l) aa(l)$ (3 elements in, 3 elements out)
rank=2: bb(i,j)= $[3 gmet(i,l) amet(j,m)] aa(l,m)$
(6 elements in, 6 elements out)
rank=3: bb(i,j,k)= $[{15 \over 2} g(i,l) g(j,m) a(k,n) - {3 \over 2} g(i,j) g(l,m) a(k,n)] aa(l,m,n)$
(10 elements in, 10 elements out)
In this rank 3 case, the second term is NOT symmetric in all
permutations of i,j,k, but the final tensor b(ijk) may be
symmetrized over all permutations because it will be
contracted with a completely symmetric tensor.
The compressed storage scheme is based on storing
a symmetric 3x3 matrix as
(1 . .)
(6 2 .)
(5 4 3)
which leads to the following mappings for all ranks
where the compressed storage index is to the right of the arrow:
rank=0 1->1 (only a scalar)
rank=1 1->1 2->2 3->3 (standard vector, no compression)
rank=2 11->1 22->2 33->3 32->4 31->5 21->6
weights 1 1 1 2 2 2
rank=3 111->1 221->2 331->3 321->4 311->5 211->6 222->7 332->8 322->9 333->10
weights 1 3 3 6 3 3 1 3 3 1