Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VASP setting for the dftd4 vdW functional and extend PBE_64 support. #3967

Merged
merged 7 commits into from
Aug 24, 2024
27 changes: 17 additions & 10 deletions src/pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class VaspInputSet(InputGenerator, abc.ABC):
atomic species are grouped together.
user_potcar_functional (str): Functional to use. Default (None) is to use the
functional in the config dictionary. Valid values: "PBE", "PBE_52",
"PBE_54", "LDA", "LDA_52", "LDA_54", "PW91", "LDA_US", "PW91_US".
"PBE_54", "PBE_64", "LDA", "LDA_52", "LDA_54", "PW91", "LDA_US", "PW91_US".
force_gamma (bool): Force gamma centered kpoint generation. Default (False) is
to use the Automatic Density kpoint scheme, which will use the Gamma
centered generation scheme for hexagonal cells, and Monkhorst-Pack otherwise.
Expand Down Expand Up @@ -1281,7 +1281,7 @@ class MPScanRelaxSet(VaspInputSet):

2. Meta-GGA calculations require POTCAR files that include
information on the kinetic energy density of the core-electrons,
i.e. "PBE_52" or "PBE_54". Make sure the POTCARs include the
i.e. "PBE_52", "PBE_54" or "PBE_64". Make sure the POTCARs include the
following lines (see VASP wiki for more details):

$ grep kinetic POTCAR
Expand Down Expand Up @@ -1322,7 +1322,7 @@ class MPScanRelaxSet(VaspInputSet):
user_potcar_functional: UserPotcarFunctional = "PBE_54"
auto_ismear: bool = True
CONFIG = _load_yaml_config("MPSCANRelaxSet")
_valid_potcars: Sequence[str] | None = ("PBE_52", "PBE_54")
_valid_potcars: Sequence[str] | None = ("PBE_52", "PBE_54", "PBE_64")

def __post_init__(self) -> None:
super().__post_init__()
Expand Down Expand Up @@ -2295,13 +2295,13 @@ class MVLRelax52Set(VaspInputSet):

Args:
structure (Structure): input structure.
user_potcar_functional (str): choose from "PBE_52" and "PBE_54".
user_potcar_functional (str): choose from "PBE_52", "PBE_54" and "PBE_64".
**kwargs: Other kwargs supported by VaspInputSet.
"""

user_potcar_functional: UserPotcarFunctional = "PBE_52"
CONFIG = _load_yaml_config("MVLRelax52Set")
_valid_potcars: Sequence[str] | None = ("PBE_52", "PBE_54")
_valid_potcars: Sequence[str] | None = ("PBE_52", "PBE_54", "PBE_64")


class MITNEBSet(VaspInputSet):
Expand Down Expand Up @@ -2635,7 +2635,7 @@ class MVLScanRelaxSet(VaspInputSet):

2. Meta-GGA calculations require POTCAR files that include
information on the kinetic energy density of the core-electrons,
i.e. "PBE_52" or "PBE_54". Make sure the POTCAR including the
i.e. "PBE_52", "PBE_54" or "PBE_64". Make sure the POTCAR including the
following lines (see VASP wiki for more details):

$ grep kinetic POTCAR
Expand All @@ -2652,13 +2652,13 @@ class MVLScanRelaxSet(VaspInputSet):
"""

user_potcar_functional: UserPotcarFunctional = "PBE_52"
_valid_potcars: Sequence[str] | None = ("PBE_52", "PBE_54")
_valid_potcars: Sequence[str] | None = ("PBE_52", "PBE_54", "PBE_64")
CONFIG = MPRelaxSet.CONFIG

def __post_init__(self) -> None:
super().__post_init__()
if self.user_potcar_functional not in {"PBE_52", "PBE_54"}:
raise ValueError("SCAN calculations require PBE_52 or PBE_54!")
if self.user_potcar_functional not in {"PBE_52", "PBE_54", "PBE_64"}:
raise ValueError("SCAN calculations require PBE_52, PBE_54, or PBE_64!")

@property
def incar_updates(self) -> dict[str, Any]:
Expand Down Expand Up @@ -2708,12 +2708,19 @@ class LobsterSet(VaspInputSet):
user_potcar_functional: UserPotcarFunctional = "PBE_54"

CONFIG = MPRelaxSet.CONFIG
_valid_potcars: Sequence[str] | None = ("PBE_52", "PBE_54")
_valid_potcars: Sequence[str] | None = ("PBE_52", "PBE_54", "PBE_64")

def __post_init__(self) -> None:
super().__post_init__()
warnings.warn("Make sure that all parameters are okay! This is a brand new implementation.")

if self.user_potcar_functional in ["PBE_52", "PBE_64"]:
warnings.warn(
f"Using {self.user_potcar_functional} POTCARs with basis functions generated for PBE_54 POTCARs. "
"Basis functions for elements with obsoleted, updated or newly added POTCARs in "
f"{self.user_potcar_functional} will not be available and may cause errors or inaccuracies.",
BadInputSetWarning,
)
if self.isym not in {-1, 0}:
raise ValueError("Lobster cannot digest WAVEFUNCTIONS with symmetry. isym must be -1 or 0")
if self.ismear not in {-5, 0}:
Expand Down
2 changes: 2 additions & 0 deletions src/pymatgen/io/vasp/vdW_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ dftd3:
IVDW: 11
dftd3-bj:
IVDW: 12
dftd4:
IVDW: 13
ts:
IVDW: 2
ts-hirshfeld:
Expand Down
10 changes: 5 additions & 5 deletions tests/io/vasp/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_sets_changed(self):
"PBE64Base.yaml": "3434c918c17706feae397d0852f2224e771db94d7e4c988039e8658e66d87494",
"MPRelaxSet.yaml": "c9b0a519588fb3709509a9f9964632692584905e2961a0fe2e5f657561913083",
"MITRelaxSet.yaml": "0b4bec619fa860dac648584853c3b3d5407e4148a85d0e95024fbd1dc315669d",
"vdW_parameters.yaml": "977c226a1b44831382e772a464aecb7f6297c98d7efc9190f8c18e0b73be2666",
"vdW_parameters.yaml": "7d2599a855533865335a313c043b6f89e03fc2633c88b6bc721723d94cc862bd",
"MatPESStaticSet.yaml": "4ec60ad4bbbb9a756f1b3fea8ca4eab8fc767d8f6a67332e7af3908c910fd7c5",
"MPAbsorptionSet.yaml": "e49cd0ab87864f1c244e9b5ceb4703243116ec1fbb8958a374ddff07f7a5625c",
"PBE54Base.yaml": "cdffe123eca8b19354554b60a7f8de9b8776caac9e1da2bd2a0516b7bfac8634",
Expand Down Expand Up @@ -1676,7 +1676,7 @@ def test_potcar(self):
assert input_set.potcar.functional == "PBE_52"

with pytest.raises(
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54', 'PBE_64'\)"
):
MVLScanRelaxSet(self.struct, user_potcar_functional="PBE")

Expand All @@ -1687,7 +1687,7 @@ def test_potcar(self):
# assert test_potcar_set_1.potcar.functional == "PBE_54"
#
# with pytest.raises(
# ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
# ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54', 'PBE_64'\)"
# ):
# self.set(self.struct, user_potcar_functional="PBE")
#
Expand Down Expand Up @@ -1806,7 +1806,7 @@ def test_potcar(self):
assert input_set.potcar.functional == "PBE_54"

with pytest.raises(
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54', 'PBE_64'\)"
):
MPScanRelaxSet(self.struct, user_potcar_functional="PBE")

Expand Down Expand Up @@ -1976,7 +1976,7 @@ def test_potcar(self):
assert test_potcar_set_1.potcar.functional == "PBE_52"

with pytest.raises(
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54', 'PBE_64'\)"
):
self.set(self.struct, user_potcar_functional="PBE")

Expand Down