Skip to content

Commit

Permalink
Merge pull request #164 from MichaelWolloch/Fix_IncorrectSmearingHandler
Browse files Browse the repository at this point in the history
Updated the check method in the IncorrectSmearingHandler class
  • Loading branch information
shyuep authored Feb 8, 2021
2 parents 64c4be6 + 5c54aa7 commit e0492bf
Show file tree
Hide file tree
Showing 10 changed files with 16,065 additions and 6 deletions.
15 changes: 9 additions & 6 deletions custodian/vasp/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,10 @@ def correct(self):

class IncorrectSmearingHandler(ErrorHandler):
"""
Check if a calculation is a metal (zero bandgap) but has been run with
ISMEAR=-5, which is only appropriate for semiconductors. If this occurs,
this handler will rerun the calculation using the smearing settings appropriate
for metals (ISMEAR=-2, SIGMA=0.2).
Check if a calculation is a metal (zero bandgap), has been run with
ISMEAR=-5, and is not a static calculation, which is only appropriate for
semiconductors. If this occurs, this handler will rerun the calculation
using the smearing settings appropriate for metals (ISMEAR=-2, SIGMA=0.2).
"""

is_monitor = False
Expand All @@ -930,8 +930,11 @@ def check(self):
"""
try:
v = Vasprun(self.output_filename)
# check whether bandgap is zero and tetrahedron smearing was used
if v.eigenvalue_band_properties[0] == 0 and v.incar.get("ISMEAR", 1) < 0:
# check whether bandgap is zero, tetrahedron smearing was used
# and relaxation is performed.
if (v.eigenvalue_band_properties[0] == 0 and
v.incar.get("ISMEAR", 1) < -3 and
v.incar.get("NSW", 0) > 1):
return True
except Exception:
pass
Expand Down
44 changes: 44 additions & 0 deletions custodian/vasp/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,50 @@ def tearDown(cls):
clean_dir()
os.chdir(cwd)

class IncorrectSmearingHandlerStaticTest(unittest.TestCase):
def setUp(cls):
if "PMG_VASP_PSP_DIR" not in os.environ:
os.environ["PMG_VASP_PSP_DIR"] = test_dir
os.chdir(test_dir)
subdir = os.path.join(test_dir, "static_smearing")
os.chdir(subdir)

shutil.copy("INCAR", "INCAR.orig")
shutil.copy("vasprun.xml", "vasprun.xml.orig")

def test_check_correct_scan_metal(self):
h = IncorrectSmearingHandler()
self.assertFalse(h.check())

@classmethod
def tearDown(cls):
shutil.move("INCAR.orig", "INCAR")
shutil.move("vasprun.xml.orig", "vasprun.xml")
clean_dir()
os.chdir(cwd)

class IncorrectSmearingHandlerFermiTest(unittest.TestCase):
def setUp(cls):
if "PMG_VASP_PSP_DIR" not in os.environ:
os.environ["PMG_VASP_PSP_DIR"] = test_dir
os.chdir(test_dir)
subdir = os.path.join(test_dir, "fermi_smearing")
os.chdir(subdir)

shutil.copy("INCAR", "INCAR.orig")
shutil.copy("vasprun.xml", "vasprun.xml.orig")

def test_check_correct_scan_metal(self):
h = IncorrectSmearingHandler()
self.assertFalse(h.check())

@classmethod
def tearDown(cls):
shutil.move("INCAR.orig", "INCAR")
shutil.move("vasprun.xml.orig", "vasprun.xml")
clean_dir()
os.chdir(cwd)


class ScanMetalHandlerTest(unittest.TestCase):
def setUp(cls):
Expand Down
26 changes: 26 additions & 0 deletions test_files/fermi_smearing/INCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ALGO = All
EDIFF = 1e-05
EDIFFG = -0.02
ENAUG = 1360
ENCUT = 680
IBRION = 2
ICHARG = 1
ISIF = 3
ISMEAR = -1
ISPIN = 2
KSPACING = 0.25
LAECHG = True
LASPH = True
LCHARG = True
LELF = True
LMIXTAU = True
LORBIT = 11
LREAL = Auto
LVTOT = True
LWAVE = False
MAGMOM = 1*0.6
METAGGA = R2scan
NELM = 200
NSW = 99
PREC = Accurate
SIGMA = 0.05
9 changes: 9 additions & 0 deletions test_files/fermi_smearing/POSCAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Al1
1.0
-0.000000 2.002523 2.002523
2.002523 -0.000000 2.002523
2.002523 2.002523 0.000000
Al
1
direct
-0.000000 0.000000 0.000000 Al
2,228 changes: 2,228 additions & 0 deletions test_files/fermi_smearing/POTCAR

Large diffs are not rendered by default.

Loading

0 comments on commit e0492bf

Please sign in to comment.