Calculation of permutation in tensor of rank 4

189 Views Asked by At

I am trying to compute the symmetric part of a 4th order tensor $A_{ijkl}$

From a previous post (Symmetric Part of Product of 2 tank 2 tensors), I saw that I need to compute the permutations of $A_{ijkl}$ (4!=24 permutations).

I would like to know if anyone can give some hints on how to compute these permutations.

If $$A_{ij}=\begin{bmatrix} 1 &0 &0 \\ 0 &1 &0 \\ 0 & 0 &1 \end{bmatrix}\quad\text{and}\quad A_{kl}=\begin{bmatrix} 1 &0 &0 \\ 0 &1 &0 \\ 0 & 0 &1 \end{bmatrix}$$

Then

$$A_{ijkl}=\begin{bmatrix} 1 &0 &0 \\ 0 &1 &0 \\ 0 & 0 &1 \end{bmatrix} \begin{bmatrix} 1 &0 &0 \\ 0 &1 &0 \\ 0 & 0 &1 \end{bmatrix} \\ = \begin{bmatrix} 1.& 0.& 0.& 0.& 1.& 0.& 0.& 0.& 1. \\ 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 1.& 0.& 0.& 0.& 1.& 0.& 0.& 0.& 1.\\ 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 1.& 0.& 0.& 0.& 1.& 0.& 0.& 0.& 1.\\ \end{bmatrix} $$

How can I compute the remainder, e.g., $A_{ikjl},A_{jikl}, A_{lkij}, \ldots$

Kind Regards!

2

There are 2 best solutions below

5
On

Your $2$ dimensional array is constructed by taking $M_{(i,j),(k,l)} = A_{ijkl}$, where the tuples $(i,j)$ and $(k,l)$ are ordered lexicographically. At least, that is what I suspect.

Likewise, the corresponding array for $A_{ikjl}$ would be found by taking $M_{(i,k),(j,l)} = A_{ijkl}$. In particular, we have $$ A_{ikjl} = \left[\begin{array}{ccc|ccc|ccc} 1 & 0 & 0 & 0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0&0\\ 0&0&1&0&0&0&0&0&0\\ \hline 0&0&0&1&0&0&0&0&0\\ 0&0&0&0&1&0&0&0&0\\ 0&0&0&0&0&1&0&0&0\\ \hline 0&0&0&0&0&0&1&0&0\\ 0&0&0&0&0&0&0&1&0\\ 0&0&0&0&0&0&0&0&1 \end{array}\right]. $$ In the above, the "blocks" of each column correspond to $k=1,2,3$, and the blocks of each row correspond to $l = 1,2,3$.

For example: to get the $5,7$ entry in the above array, note that the $5$th tuple in $\{1,2,3\}^2$ is $(2,2)$, and the $7$th tuple is $(3,1)$. So, the number in the $5,7$ spot corresponds to $i=2,k=2,j=3,l=1$. That is, we have $A_{23} \cdot A_{21} = 0 \cdot 0 = 0$.

Note that by the symmetry of the $2 \times 2$ arrays $A_{ij}$ and $A_{kl}$, switching $i$ and $j$ and switching $k$ and $l$ do not change the resulting permuted tensor. For instance, we will have $A_{ikjl} = A_{jkil}$, and $A_{ikjl} = A_{iljk}$. Similarly, making the simultaneous switch $i \leftrightarrow k,j \leftrightarrow l$ does not change the resulting permuted tensor, so that $A_{ikjl} = A_{kilj}$.

I hope that helps.


An alternative approach: note that $A_{ij} = \sum_{i,j = 1}^3 \delta_{ij} e_i \otimes e_j = \sum_i e_i \otimes e_i$. Similarly, $A_{kl} = \sum_{k=1}^3 e_k \otimes e_k$. With that, we have $$ A_{ijkl} = \sum_{i,k = 1}^3 (e_i \otimes e_i) \otimes (e_k \otimes e_k) = \sum_{i,k = 1}^3 e_i \otimes e_i \otimes e_k \otimes e_k. $$ Note that each permutation corresponds to a reordering of this product. For instance, $$ A_{ikjl} = \sum_{i,k=1}^3 e_i \otimes e_k \otimes e_i \otimes e_k. $$


Note that each permutation will yield either the original matrix from your post, the matrix $A_{ikjl}$ in this answer above, or the matrix $$ A_{kjil} = \left[\begin{array}{ccc|ccc|ccc} 1 & 0 & 0 & 0&0&0&0&0&0\\ 0&0&0&1&0&0&0&0&0\\ 0&0&0&0&0&0&1&0&0\\ \hline 0&1&0&0&0&0&0&0&0\\ 0&0&0&0&1&0&0&0&0\\ 0&0&0&0&0&0&0&1&0\\ \hline 0&0&1&0&0&0&0&0&0\\ 0&0&0&0&0&1&0&0&0\\ 0&0&0&0&0&0&0&0&1 \end{array}\right] $$

0
On

Solved in python with:

import numpy as np
from itertools import permutations
# create a 2nd order tensor
a=np.eye(3)
a[0][0]=2
a[0][-1]=3
a[-1][-1]=4
# create a 2nd order tensor
b=np.eye(3)

# Function that will permutate the indices 
def permutation(str1,tmp):
    store=np.zeros([3,3,3,3]) # variable to store the results
    
    #function to split the string with the indices
    def split(word): 
       return [char for char in word]
                
    
    a,b,c,d=split(str1) # gets indices from string

    
    for i in [0,1,2]:
        for j in [0,1,2]:
            for k in [0,1,2]:
                for l in [0,1,2]:
                    store[i,j,k,l]=tmp[vars()[a],vars()[b],vars()[c],vars()[d]]
    return store
                
                
result=np.einsum('ij,kl->ijkl',a,b) # gets the result of A_ij*B_kl = P_ijkl 




permutation_set=[''.join(p) for p in permutations('ijkl')] # generate a list of permutations with the indices ijkl

for p in permutation_set:

    permutation_wanted=np.einsum(p,result) # permutates the result for the with the intended permutation with the funciton einsum
    
    check=permutation(p,result) # gets the permutation with the permutation function defined above
    print("Current permutation is: %s" %(p))
    if(np.count_nonzero(check-permutation_wanted)==0):
        # if the difference between check and permutation_wanted is 0 (all the elements are equal)
        print("Script is working")
    else:
        print("Script is not working!")