Merge pull request #427 from nicholascheng94/develop

Fix NAC correction for OpenMP
This commit is contained in:
Atsushi Togo 2024-09-13 19:29:05 +09:00 committed by GitHub
commit 29b1ecb132
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View File

@ -240,7 +240,7 @@ class QpointsPhonon:
self._eigenvalues = np.zeros((num_qpoints, num_band), dtype="double")
if phonoc.use_openmp():
dynmat = run_dynamical_matrix_solver_c(
self._dynamical_matrix, self._qpoints
self._dynamical_matrix, self._qpoints, self._nac_q_direction
)
eigenvectors = dynmat
elif self._with_eigenvectors:

View File

@ -6,7 +6,7 @@ from phonopy import Phonopy
from phonopy.units import VaspToTHz
def testQpoints(ph_nacl_nofcsym: Phonopy):
def test_Qpoints(ph_nacl_nofcsym: Phonopy):
"""Test phonon calculation at specific q-points by NaCl."""
phonon = ph_nacl_nofcsym
qpoints = [[0, 0, 0], [0, 0, 0.5]]
@ -18,3 +18,19 @@ def testQpoints(ph_nacl_nofcsym: Phonopy):
freqs = phonon.qpoints.frequencies[i] / VaspToTHz
np.testing.assert_allclose(dm_eigs, eigs)
np.testing.assert_allclose(freqs**2 * np.sign(freqs), eigs)
def test_Qpoints_with_NAC_qdirection(ph_nacl: Phonopy):
"""Test phonon calculation at specific q-points by NaCl."""
phonon = ph_nacl
qpoints = [[0, 0, 0]]
phonon.run_qpoints(qpoints)
freqs = phonon.get_qpoints_dict()["frequencies"]
np.testing.assert_allclose(
freqs, [[0, 0, 0, 4.61643516, 4.61643516, 4.61643516]], atol=1e-5
)
phonon.run_qpoints(qpoints, nac_q_direction=[1, 0, 0])
freqs = phonon.get_qpoints_dict()["frequencies"]
np.testing.assert_allclose(
freqs, [[0, 0, 0, 4.61643516, 4.61643516, 7.39632718]], atol=1e-5
)