Skip to content

Commit 4b88c41

Browse files
author
Shyue Ping Ong
committed
Logic fixes and doc =updates for MatPESSet.
1 parent e4792d1 commit 4b88c41

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

pymatgen/io/vasp/sets.py

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
11
"""
2-
This module defines the VaspInputSet abstract base class and a concrete
3-
implementation for the parameters developed and tested by the core team
4-
of pymatgen, including the Materials Virtual Lab, Materials Project and the MIT
5-
high throughput project. The basic concept behind an input set is to specify
6-
a scheme to generate a consistent set of VASP inputs from a structure
7-
without further user intervention. This ensures comparability across
8-
runs.
2+
This module defines the VaspInputSet abstract base class and a concrete implementation for the parameters developed
3+
and tested by the core team of pymatgen, including the Materials Virtual Lab, Materials Project and the MIT high
4+
throughput project. The basic concept behind an input set is to specify a scheme to generate a consistent set of VASP
5+
inputs from a structure without further user intervention. This ensures comparability across runs.
96
107
Read the following carefully before implementing new input sets:
118
12-
1. 99% of what needs to be done can be done by specifying user_incar_settings
13-
to override some of the defaults of various input sets. Unless there is an
14-
extremely good reason to add a new set, DO NOT add one. E.g., if you want
9+
1. 99% of what needs to be done can be done by specifying user_incar_settings to override some of the defaults of
10+
various input sets. Unless there is an extremely good reason to add a new set, DO NOT add one. E.g., if you want
1511
to turn the Hubbard U off, just set "LDAU": False as a user_incar_setting.
16-
2. All derivative input sets should inherit from one of the usual MPRelaxSet or
17-
MITRelaxSet, and proper superclass delegation should be used where possible.
18-
In particular, you are not supposed to implement your own as_dict or
19-
from_dict for derivative sets unless you know what you are doing.
20-
Improper overriding the as_dict and from_dict protocols is the major
21-
cause of implementation headaches. If you need an example, look at how the
22-
MPStaticSet or MPNonSCFSets are constructed.
12+
2. All derivative input sets should inherit from one of the usual MPRelaxSet or MITRelaxSet, and proper superclass
13+
delegation should be used where possible. In particular, you are not supposed to implement your own as_dict or
14+
from_dict for derivative sets unless you know what you are doing. Improper overriding the as_dict and from_dict
15+
protocols is the major cause of implementation headaches. If you need an example, look at how the MPStaticSet or
16+
MPNonSCFSets are constructed.
2317
2418
The above are recommendations. The following are UNBREAKABLE rules:
2519
26-
1. All input sets must take in a structure or list of structures as the first
27-
argument.
28-
2. user_incar_settings, user_kpoints_settings and user_<whatever>_settings are
29-
ABSOLUTE. Any new sets you implement must obey this. If a user wants to
30-
override your settings, you assume he knows what he is doing. Do not
31-
magically override user supplied settings. You can issue a warning if you
32-
think the user is wrong.
33-
3. All input sets must save all supplied args and kwargs as instance variables.
34-
E.g., self.my_arg = my_arg and self.kwargs = kwargs in the __init__. This
35-
ensures the as_dict and from_dict work correctly.
20+
1. All input sets must take in a structure or list of structures as the first argument.
21+
2. user_incar_settings, user_kpoints_settings and user_<whatever>_settings are ABSOLUTE. Any new sets you implement
22+
must obey this. If a user wants to override your settings, you assume he knows what he is doing. Do not
23+
magically override user supplied settings. You can issue a warning if you think the user is wrong.
24+
3. All input sets must save all supplied args and kwargs as instance variables. E.g., self.my_arg = my_arg and
25+
self.kwargs = kwargs in the __init__. This ensures the as_dict and from_dict work correctly.
3626
"""
3727

3828
from __future__ import annotations
@@ -1212,7 +1202,7 @@ class MatPESStaticSet(DictSet):
12121202
"""Creates input files for a MatPES static calculation.
12131203
12141204
The goal of MatPES is to generate PES data. This is a distinctly different from the objectives of the MP static
1215-
calculations, which aims to obtain primarily accurate energies and also electronic structure (DOS). For PES data,
1205+
calculations, which aims to obtain accurate energies and electronic structure (DOS) primarily. For PES data,
12161206
force accuracy (and to some extent, stress accuracy) is of paramount importance.
12171207
12181208
It should be noted that the default POTCAR versions have been updated to PBE_54, rather than the old PBE set used
@@ -1222,6 +1212,9 @@ class MatPESStaticSet(DictSet):
12221212

12231213
CONFIG = _load_yaml_config("MatPESStaticSet")
12241214

1215+
# These are parameters that we will inherit from any previous INCAR supplied. They are mostly parameters related
1216+
# to symmetry and convergence set by Custodian when errors are encountered in a previous run. Given that our goal
1217+
# is to have a strictly homogeneous PES data, all other parameters (e.g., ISMEAR, ALGO, etc.) are not inherited.
12251218
INHERITED_INCAR_PARAMS = (
12261219
"LPEAD",
12271220
"NGX",
@@ -1265,18 +1258,19 @@ def __init__(
12651258
super().__init__(structure, MatPESStaticSet.CONFIG, **kwargs)
12661259

12671260
if xc_functional.upper() == "R2SCAN":
1268-
self.user_incar_settings.setdefault("METAGGA", "R2SCAN")
1269-
self.user_incar_settings.setdefault("ALGO", "ALL")
1270-
self.user_incar_settings.setdefault("GGA", None)
1261+
self.user_incar_settings["METAGGA"] = "R2SCAN"
1262+
self.user_incar_settings["ALGO"] = "ALL"
12711263
elif xc_functional.upper() == "PBE+U":
1272-
self._config_dict["INCAR"]["LDAU"] = True
1264+
self.user_incar_settings["LDAU"] = True
12731265
elif xc_functional.upper() != "PBE":
12741266
raise ValueError(
12751267
f"{xc_functional} is not supported."
12761268
" The supported exchange-correlation functionals are PBE, PBE+U and R2SCAN."
12771269
)
12781270
if user_potcar_functional.upper() != "PBE_54":
1279-
raise UserWarning(f"POTCAR version ({user_potcar_functional}) is inconsistent with the recommended PBE_54.")
1271+
warnings.warn(
1272+
f"POTCAR version ({user_potcar_functional}) is inconsistent with the recommended PBE_54.", UserWarning
1273+
)
12801274

12811275
self.user_potcar_functional = user_potcar_functional.upper()
12821276

tests/io/vasp/test_sets.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,6 @@ def test_r2scan(self):
816816
scan = MatPESStaticSet(self.struct, xc_functional="R2SCAN")
817817
incar_scan = scan.incar
818818
assert incar_scan["METAGGA"] == "R2scan"
819-
assert incar_scan.get("GGA") is None
820819
assert incar_scan["ALGO"] == "All"
821820
assert incar_scan.get("LDAU") is None
822821
# test POTCAR files are default PBE_54 PSPs and functional

0 commit comments

Comments
 (0)