Skip to content

Commit

Permalink
Fix: qe/pw/scf unit conversion is not consistent with dpdata (#725)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a configuration file for sodium SCF calculations, enhancing
quantum mechanical simulations.
- Added a new test class to verify properties of sodium systems,
improving test coverage.

- **Bug Fixes**
- Improved logic for block extraction and stress block handling to
enhance robustness.

- **Tests**
- Updated energy validation method to use relative comparisons for more
accurate results.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Han Wang <[email protected]>
Co-authored-by: Han Wang <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 20, 2024
1 parent 2648d50 commit 482775f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions dpdata/qe/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_qe_pw_scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_qe_pw_scf_energy_bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 482775f

Please sign in to comment.