Skip to content

Commit

Permalink
Update LMAXMIX logic + test
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhorton committed Sep 16, 2021
1 parent 08e289f commit 932d9da
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
29 changes: 17 additions & 12 deletions pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,22 +544,27 @@ def incar(self) -> Incar:
else:
incar[k] = v
has_u = hubbard_u and sum(incar["LDAUU"]) > 0
if has_u:
# modify LMAXMIX if LSDA+U and you have d or f electrons
# note that if the user explicitly sets LMAXMIX in settings it will
# override this logic.
if "LMAXMIX" not in settings.keys():
# contains f-electrons
if any(el.Z > 56 for el in structure.composition):
incar["LMAXMIX"] = 6
# contains d-electrons
elif any(el.Z > 20 for el in structure.composition):
incar["LMAXMIX"] = 4
else:
if not has_u:
for key in list(incar.keys()):
if key.startswith("LDAU"):
del incar[key]

# Modify LMAXMIX if you have d or f electrons present.
# Note that if the user explicitly sets LMAXMIX in settings it will
# override this logic.
# Previously, this was only set if Hubbard U was enabled as per the
# VASP manual but following an investigation it was determined that
# this would lead to a significant difference between SCF -> NonSCF
# even without Hubbard U enabled. Thanks to Andrew Rosen for
# investigating and reporting.
if "LMAXMIX" not in settings.keys():
# contains f-electrons
if any(el.Z > 56 for el in structure.composition):
incar["LMAXMIX"] = 6
# contains d-electrons
elif any(el.Z > 20 for el in structure.composition):
incar["LMAXMIX"] = 4

if self.constrain_total_magmom:
nupdown = sum([mag if abs(mag) > 0.6 else 0 for mag in incar["MAGMOM"]])
incar["NUPDOWN"] = nupdown
Expand Down
3 changes: 3 additions & 0 deletions pymatgen/io/vasp/tests/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ def test_hubbard_off_and_ediff_override(self):
p = MPRelaxSet(self.structure, user_incar_settings={"LDAU": False, "EDIFF": 1e-10})
self.assertNotIn("LDAUU", p.incar)
self.assertEqual(p.incar["EDIFF"], 1e-10)
# after testing, we have determined LMAXMIX should still be 4 for d-block
# even if U is turned off (thanks Andrew Rosen for reporting)
self.assertEqual(p.incar["LMAXMIX"], 4)

def test_write_input(self):
self.mitset.write_input(".", make_dir_if_not_present=True)
Expand Down

0 comments on commit 932d9da

Please sign in to comment.