From 8028a06b080f46349f1fe2d662fc59d073850e3f Mon Sep 17 00:00:00 2001 From: Han Wang Date: Thu, 19 Sep 2024 20:15:24 +0800 Subject: [PATCH] fix: qe/pw/scf unit conversion is now consistent with qe/cp/traj --- dpdata/qe/scf.py | 10 +++++++--- tests/test_qe_pw_scf.py | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dpdata/qe/scf.py b/dpdata/qe/scf.py index c2530b7c..6d0043bc 100755 --- a/dpdata/qe/scf.py +++ b/dpdata/qe/scf.py @@ -7,9 +7,13 @@ from dpdata.utils import open_file -ry2ev = 13.605693009 -bohr2ang = 0.52917721067 -kbar2evperang3 = 1e3 / 1.602176621e6 +from .traj import ( + kbar2evperang3, + ry2ev, +) +from .traj import ( + length_convert as bohr2ang, +) _QE_BLOCK_KEYWORDS = [ "ATOMIC_SPECIES", diff --git a/tests/test_qe_pw_scf.py b/tests/test_qe_pw_scf.py index a38e2d05..7fe803b9 100644 --- a/tests/test_qe_pw_scf.py +++ b/tests/test_qe_pw_scf.py @@ -161,11 +161,11 @@ def test_virial(self): def test_energy(self): ref_energy = -219.74425946528794 - self.assertAlmostEqual(self.system_ch4.data["energies"][0], ref_energy) + self.assertAlmostEqual(self.system_ch4.data["energies"][0] / ref_energy, 1.0) ref_energy = -30007.651851226798 - self.assertAlmostEqual(self.system_h2o.data["energies"][0], ref_energy) + self.assertAlmostEqual(self.system_h2o.data["energies"][0] / ref_energy, 1.0) ref_energy = -219.7153691367526562 - self.assertAlmostEqual(self.system_ch4_2.data["energies"][0], ref_energy) + self.assertAlmostEqual(self.system_ch4_2.data["energies"][0] / ref_energy, 1.0) class TestPWSCFLabeledOutput(unittest.TestCase, TestPWSCFSinglePointEnergy):