Skip to content

Commit 80ab8b7

Browse files
authored
Merge pull request #2297 from arosen93/rosen-mixing
Add warning if LASPH != True for meta-GGA/hybrid/vdW/+U
2 parents 8a22390 + debcc75 commit 80ab8b7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

pymatgen/io/vasp/sets.py

+12
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,18 @@ def incar(self) -> Incar:
581581
elif any(el.Z > 20 for el in structure.composition):
582582
incar["LMAXMIX"] = 4
583583

584+
# Warn user about LASPH for +U, meta-GGAs, hybrids, and vdW-DF
585+
if not settings.get("LASPH", False) and (
586+
settings.get("METAGGA")
587+
or settings.get("LHFCALC", False)
588+
or settings.get("LDAU", False)
589+
or settings.get("LUSE_VDW", False)
590+
):
591+
warnings.warn(
592+
"LASPH = True should be set for +U, meta-GGAs, hybrids, and vdW-DFT",
593+
BadInputSetWarning,
594+
)
595+
584596
if self.constrain_total_magmom:
585597
nupdown = sum(mag if abs(mag) > 0.6 else 0 for mag in incar["MAGMOM"])
586598
if nupdown != round(nupdown):

pymatgen/io/vasp/tests/test_sets.py

+14
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,20 @@ def test_init(self):
520520
self.assertEqual(vis.incar["ENCUT"], 600)
521521
self.assertEqual(vis.kpoints.style, Kpoints.supported_modes.Monkhorst)
522522

523+
# Check warning if LASPH is set to False for meta-GGAs/hybrids/+U/vdW
524+
with pytest.warns(BadInputSetWarning, match=r"LASPH"):
525+
vis = MPStaticSet(vis.structure, user_incar_settings={"METAGGA": "M06L", "LASPH": False})
526+
vis.incar.items()
527+
with pytest.warns(BadInputSetWarning, match=r"LASPH"):
528+
vis = MPStaticSet(vis.structure, user_incar_settings={"LHFCALC": True, "LASPH": False})
529+
vis.incar.items()
530+
with pytest.warns(BadInputSetWarning, match=r"LASPH"):
531+
vis = MPStaticSet(vis.structure, user_incar_settings={"LDAU": True, "LASPH": False})
532+
vis.incar.items()
533+
with pytest.warns(BadInputSetWarning, match=r"LASPH"):
534+
vis = MPStaticSet(vis.structure, user_incar_settings={"LUSE_VDW": True, "LASPH": False})
535+
vis.incar.items()
536+
523537
non_prev_vis = MPStaticSet(vis.structure, user_incar_settings={"LORBIT": 12, "LWAVE": True})
524538
self.assertEqual(non_prev_vis.incar["NSW"], 0)
525539
# Check that the ENCUT and Kpoints style has NOT been inherited.

0 commit comments

Comments
 (0)