From 2bbcbd2b7944ddf78a50875ad61fd40a2ce79c1f Mon Sep 17 00:00:00 2001 From: Nicholas Cheng <33250303+nicholascheng94@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:27:16 +0800 Subject: [PATCH 1/2] Fix NAC correction for OpenMP --- phonopy/phonon/qpoints.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phonopy/phonon/qpoints.py b/phonopy/phonon/qpoints.py index 9a4f0479..ec891bb1 100644 --- a/phonopy/phonon/qpoints.py +++ b/phonopy/phonon/qpoints.py @@ -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: From ada5786f9e52ae364fff9794ae70c95c9b7a1a6f Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 13 Sep 2024 19:24:22 +0900 Subject: [PATCH 2/2] Add test for q-points mode at Gamma with q-direction --- test/phonon/test_qpoints.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/phonon/test_qpoints.py b/test/phonon/test_qpoints.py index b5064d97..07be8f9f 100644 --- a/test/phonon/test_qpoints.py +++ b/test/phonon/test_qpoints.py @@ -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 + )