I am trying to write a small python script which will symmetrize an elastic tensor based on rotational symmetry of the space group. I started with this link and created a new python script as below.
I started with cubic elastic constants in Voigt form and expected to get same results as input. But the final result shows C12=C14 which is not correct. What might I be doing wrong?
from pymatgen.core import Structure, Lattice
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
import numpy as np
from pymatgen.analysis.elasticity.elastic import ElasticTensor
structure = Structure.from_spacegroup(
"Fm-3m", Lattice.cubic(1.0), ["element"], [[0, 0, 0]])
sga = SpacegroupAnalyzer(SpacegroupAnalyzer(structure).find_primitive())
ops_list = sga.get_symmetry_operations(cartesian=True)
ops_rotation_list = [op.rotation_matrix for op in ops_list]
C = np.array([[271.64, 141.6, 141.6,0,0,0],
[141.6,271.64,141.6,0,0,0],
[141.6,141.6,271.64,0,0,0],
[0,0,0,105.18,0,0],
[0,0,0,0,105.18,0],
[0,0,0,0,0,105.18]])
C_prime_sum = 0
CC = ElasticTensor(ElasticTensor.from_voigt(C).symmetrized)
for idx, op in enumerate(ops_rotation_list):
# perform the 4th order tensor rotation.
C_prime = ElasticTensor(
np.einsum('im,jn,mnop,ok,pl', op, op, CC, op.T, op.T), tol=1e-5)
C_prime_sum += C_prime
C_prime = C_prime_sum / (idx + 1)
A=C_prime.voigt
Expected output (Same as input matrix C)
C = np.array([[271.64, 141.6, 141.6,0,0,0],
[141.6,271.64,141.6,0,0,0],
[141.6,141.6,271.64,0,0,0],
[0,0,0,105.18,0,0],
[0,0,0,0,105.18,0],
[0,0,0,0,0,105.18]])
current output (Which is not correct)
[[271.64 117.32 117.32 0. 0. 0. ]
[117.32 271.64 117.32 0. 0. 0. ]
[117.32 117.32 271.64 0. 0. 0. ]
[ 0. 0. 0. 117.32 0. 0. ]
[ 0. 0. 0. 0. 117.32 0. ]
[ 0. 0. 0. 0. 0. 117.32]]