diff --git a/dpdata/qe/scf.py b/dpdata/qe/scf.py index 7b6a70aa..341261d2 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): diff --git a/tests/test_qe_pw_scf_energy_bug.py b/tests/test_qe_pw_scf_energy_bug.py index b66ce924..a513dc7c 100644 --- a/tests/test_qe_pw_scf_energy_bug.py +++ b/tests/test_qe_pw_scf_energy_bug.py @@ -8,7 +8,7 @@ class TestPWSCFSinglePointEnergy: def test_energy(self): ref_energy = -296.08379065679094669 - self.assertAlmostEqual(self.system_al.data["energies"][0], ref_energy) + self.assertAlmostEqual(self.system_al.data["energies"][0] / ref_energy, 1.0) class TestPWSCFLabeledOutput(unittest.TestCase, TestPWSCFSinglePointEnergy):