Skip to content

Commit

Permalink
enforce KSPACING cap in MPScanRelaxSet
Browse files Browse the repository at this point in the history
  • Loading branch information
rkingsbury committed Jun 22, 2021
1 parent 3384478 commit 9f113be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pymatgen/io/vasp/sets.py
Expand Up @@ -962,8 +962,10 @@ def __init__(self, structure, bandgap=0, **kwargs):
rmin = 25.22 - 2.87 * bandgap # Eq. 25
kspacing = 2 * np.pi * 1.0265 / (rmin - 1.0183) # Eq. 29
# cap the KSPACING at a max of 0.44, per internal benchmarking
kspacing = min(0.44, kspacing)
updates["KSPACING"] = kspacing
if 0.22 < kspacing < 0.44:
updates["KSPACING"] = kspacing
else:
updates["KSPACING"] = 0.44
updates["ISMEAR"] = -5
updates["SIGMA"] = 0.05

Expand Down
10 changes: 10 additions & 0 deletions pymatgen/io/vasp/tests/test_sets.py
Expand Up @@ -1283,6 +1283,16 @@ def test_nonmetal(self):
self.assertEqual(incar["ISMEAR"], -5)
self.assertEqual(incar["SIGMA"], 0.05)

def test_kspacing_cap(self):
# Test that KSPACING is capped at 0.44 for insulators
file_path = self.TEST_FILES_DIR / "POSCAR.O2"
struct = Poscar.from_file(file_path, check_for_POTCAR=False).structure
scan_nonmetal_set = MPScanRelaxSet(struct, bandgap=10)
incar = scan_nonmetal_set.incar
self.assertAlmostEqual(incar["KSPACING"], 0.44, places=5)
self.assertEqual(incar["ISMEAR"], -5)
self.assertEqual(incar["SIGMA"], 0.05)

def test_incar_overrides(self):
# use 'user_incar_settings' to override the KSPACING, ISMEAR, and SIGMA
# parameters that MPScanSet normally determines
Expand Down

0 comments on commit 9f113be

Please sign in to comment.