SSCHAcode / python-sscha

The python implementation of the Stochastic Self-Consistent Harmonic Approximation (SSCHA).
GNU General Public License v3.0
55 stars 21 forks source link

wrong units in Phonons.load_phonopy() #167

Open kw600 opened 1 year ago

kw600 commented 1 year ago

Dear developers,

I just want to give contribution on this function. There is a warning saying that "This subroutine is not tested yet, use it with care." I do find the unit in this function is incorrect. For example, phonopy use angstron as the distance unit and this is the same as the SSCHA so the line like self.structure.coords[:,:] = np.array(coords) BOHR_TO_ANGSTROM should be changed into self.structure.coords[:,:] = np.array(coords) 1. (Angstram to Angstram). Also, phonopy uses ev/A2 as the unit for force constants and the default one in SSCHA is Ry/bohr2. The following line needs to be changed from dynq = GetDynQFromFCSupercell(fc, np.array(q_tot), self.structure, superstruct, itau) to fc = fc/(RY_TO_EV*A_TO_BOHR**2) dynq = GetDynQFromFCSupercell(fc, np.array(q_tot), self.structure, superstruct, itau) In this way the units for both distance and force constants are correct and this function works correctly.

Best wishes, Kang

kw600 commented 1 year ago

I just tested the gamma point for this function and it works. Unfortunately, I realize it breaks down when there is more than 1 q point. Still needs further testing.

mesonepigreco commented 1 year ago

Hi, thanks for the issue; there are some methods to deal with phonopy inside Methods.py

For example, you can also try the function:

CC.Methods.sscha_phonons_from_phonopy

In our implementation, there is a mismatch in the atom ordering inside the supercell between phonopy and the generate_supercell method, causing the supercell's error. Simply swapping the atoms correctly in the load_phonopy should solve it; someone was working on it, but it has been a while since I received news about it.