# About the direction of TENSOR

It’s about mp-568286, directions of the POSCAR and TENSOR are diffrent, seems that they have a 90 degree deviation, and I found many other materials’ data have the same problem.
Can you help me? Thanks!

TENSOR is
[879 -1 160 0 0 0
-1 6 -1 0 0 0
160 -1 879 0 0 0
0 0 0 2 0 0
0 0 0 0 360 0
0 0 0 0 0 1]

Hi lemon1256,

You can find the documentation of the elasticity calcs here, from those:

Different choices of lattice vectors with respect to a Cartesian coordinate system may lead to elastic tensors that look different from what might be expected. For example, for the hexagonal crystal system it is commonly stated that C11=C22C11=C22. However, this is true under the conditions that lattice vectors a1a1 and a2a2 are both in the basal plane, whereas a3a3 is orthogonal to the basal plane. Hence, the elastic tensor can only be completely specified when the lattice vectors are expressed in a given coordinate system. To avoid confusion, we present the elastic tensor in 2 ways. First, the elastic tensor is presented for the exact choice of lattice vectors as presented on the Materials Project webpage. This is consistent with the cif-file of the “conventional standard” structure, which can also be downloaded from the Materials Project webpage. Elastic tensors can also be expressed in a standard format according to the IEEE standard. The standardized IEEE-format specifies the precise choice of lattice vectors in a coordinate system and thereby unambiguously defines the components of the elastic tensor 1. In most cases, the elastic tensors in the POSCAR-format and the IEEE-format are identical. When the elastic tensor in POSCAR-format and IEEE-format are not identical however, they are related by a rotation. Note that IEEE tensors can be obtained using the get_ieee_tensor method for any of the subclasses of pymatgen.analysis.elasticity.tensors.TensorBase (which include ElasticTensor and PiezoTensor).

2 Likes

Thanks！ It helps me a lot!

Hi, Joseph Montoya,

(this is a part of the code)

But the some of the structures and TENSOR are still not matched(they still have like a 90 degree deviation). Could you please help me download mactched STRUCTURE and TENSOR? I will be very grateful.

By the way, I notice that some of the structure data is updated, so some of the structure and tensor are matched before the updating, but after updating they are not matched. It makes me a little bit confused.

Try the following code to modify a given structure such that it is in the IEEE standard (i. e. matched with the IEEE standard tensor). I haven’t extensively tested this, so use with care.

``````from pymatgen.core.tensors import Tensor
from pymatgen.core.operations import SymmOp

def get_ieee_structure(structure):
"""
Helper function to set a given structure according
to the IEEE standard.  Note that this does not
resize or reshape the cell (e. g. from primitive
to conventional, it simply rotates it
such that it has the same setting
"""
rot = Tensor.get_ieee_rotation(structure)
op = SymmOp.from_rotation_and_translation(rot)
new_struct = structure.copy()
new_struct.apply_operation(op)
return new_struct
``````

Note that if you’d prefer to modify the tensor, you should be able to apply the inverse rotation of `Tensor.get_ieee_rotation(structure)` to the tensor.

I notice this in:Announcement: changes to elastic tensor data :

“elastic_tensor_original” is now included in the API elasticity document, referring to the unsymmetrized, “POSCAR”-format tensor (i. e. corresponding to the conventional standard unit cell as generated by pymatgen).

Does it mean that elastic_tensor_original is matched with POSCAR in MP? If this is true, is there a method to download POSCAR in API? Right now， I can only find the keys: ‘final_structure’、‘structure’ and ‘initial_structure’, is there a key corresponding to POSCAR?

It means that the elastic tensor is matched to the POSCAR of the calculation, which is the one “corresponding to the conventional standard unit cell as generated by pymatgen.” This is not available via the API, but usually corresponds to the `final_structure` key (MP structures are occasionally re-grouped, and the primary structure as presented on a given material details page may not be that which was used to generate the input structure at the time of the calculation).
You will need to post-process the structures you retrieve from the API in order to match them to the tensors. You can do so with either the function I provided above (to rotate the structures so that the crystallographic axes are aligned with the IEEE standards, as the data corrsponding to the `elastic_tensor` key are), or you can generate the conventional unit cell using the corresponding pymatgen methods such that the structure corresponds to that which was used in the elastic tensor calculation (corresponding to the `elastic_tensor_original` key).