materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.52k stars 864 forks source link

How to transform elastic constants after a change of basis with the help of pymatgen? #4139

Closed hongyi-zhao closed 1 week ago

hongyi-zhao commented 1 week ago

Hi there,

I have a question about transforming elastic constants when changing the basis/coordinate system. Does pymatgen provide functionality for this kind of transformation?

Specifically, I want to:

  1. Take a 6x6 elastic constant matrix in Voigt notation
  2. Apply a basis transformation
  3. Get the transformed elastic constants in the new basis

Is there a built-in method to do this in pymatgen? If not, what would be the recommended way to implement this?

Thanks in advance! Zhao

P.S.:

The following things seem to have something to do with this problem:

  1. https://pymatgen.org/pymatgen.core.html#pymatgen.core.operations.SymmOp.transform_tensor

  2. https://github.com/materialsproject/pymatgen/blob/0e65d35ae0b1df964639a48067b1a525979eec84/src/pymatgen/core/tensors.py#L406

But the documentation link shown here is outdated:

image

hongyi-zhao commented 1 week ago

Based on the related documentation here and here, I got the following solution based on the method here in order to demonstrate some of the methodology conventions of simulating elasticity calculations adopted by the materials project. The details and parameter settings of the vasp calculations may not necessarily be consistent, so the final results cannot be directly and accurately compared with those in the Materials Project database.

In the following test, we use the cif structure file from the legacy database to prepare the POSCAR, as shown below:

# Steps to do the test, using Si_mp-149_primitive.cif as an example:
# Use your python venv accordingly:
$ pyenv shell datasci 
$ python struct2conv.py -i Si_mp-149_primitive.cif -o Si_mp-149_conventional_standard.vasp
$ mkdir Si_mp-149_conventional_standard && cd Si_mp-149_conventional_standard
$ ln -sfr ../Si_mp-149_conventional_standard.vasp POSCAR
$ (echo 101; echo DC)|vaspkit
$ (echo 102; echo 2; echo 0.03)|vaspkit

# Comment out the `NPAR` tag in INCAR and run the vasp calculation:
$ mpirun -n 16 vasp_std

# Extract the elastic tensor
$ echo 203 |vaspkit

# Convert elastic tensor to IEEE format
$ python ../elastic2ieee.py

All related necessary files and scripts are as follows:

elastic2ieee.zip

See below for the related discussions and tools: