Skip to content

Commit 19f88c0

Browse files
committed
add check_potcar: bool = True to MaterialsProjectDFTMixingScheme
1 parent c008776 commit 19f88c0

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

pymatgen/entries/mixing_scheme.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def __init__(
5454
compat_1: Compatibility | None = MaterialsProject2020Compatibility(), # noqa: B008
5555
compat_2: Compatibility | None = None,
5656
fuzzy_matching: bool = True,
57-
):
57+
check_potcar: bool = True,
58+
) -> None:
5859
"""
5960
Instantiate the mixing scheme. The init method creates a generator class that
6061
contains relevant settings (e.g., StructureMatcher instance, Compatibility settings
@@ -93,29 +94,28 @@ def __init__(
9394
space group are all identical. If there are multiple materials of run_type_2
9495
that satisfy these criteria, the one with lowest energy is considered to
9596
match.
97+
check_potcar: Whether to perform additional checks to ensure that the POTCARs
98+
used for the run_type_1 and run_type_2 calculations are the same. This is
99+
useful for ensuring that the mixing scheme is not used on calculations that
100+
used different POTCARs, which can lead to unphysical results. Defaults to True.
101+
Has no effect if neither compat_1 nor compat_2 have a check_potcar attribute.
96102
"""
97103
self.name = "MP DFT mixing scheme"
98104
self.structure_matcher = structure_matcher or StructureMatcher()
99105
if run_type_1 == run_type_2:
100-
raise ValueError(
101-
f"You specified the same run_type {run_type_1} for both run_type_1 and run_type_2. "
102-
"The mixing scheme is meaningless unless run_type_1 and run_type_2 are different"
103-
)
106+
raise ValueError(f"run_type_1={run_type_2=}. The mixing scheme is meaningless unless run_types different")
104107
self.run_type_1 = run_type_1
105108
self.run_type_2 = run_type_2
106-
if self.run_type_1 == "GGA(+U)":
107-
self.valid_rtypes_1 = ["GGA", "GGA+U"]
108-
else:
109-
self.valid_rtypes_1 = [self.run_type_1]
110-
111-
if self.run_type_2 == "GGA(+U)":
112-
self.valid_rtypes_2 = ["GGA", "GGA+U"]
113-
else:
114-
self.valid_rtypes_2 = [self.run_type_2]
109+
self.valid_rtypes_1 = ["GGA", "GGA+U"] if self.run_type_1 == "GGA(+U)" else [self.run_type_1]
110+
self.valid_rtypes_2 = ["GGA", "GGA+U"] if self.run_type_2 == "GGA(+U)" else [self.run_type_2]
115111

116112
self.compat_1 = compat_1
117113
self.compat_2 = compat_2
118114
self.fuzzy_matching = fuzzy_matching
115+
self.check_potcar = check_potcar
116+
for compat in (self.compat_1, self.compat_2):
117+
if hasattr(compat, "check_potcar"):
118+
compat.check_potcar = check_potcar # type: ignore[union-attr]
119119

120120
def process_entries(
121121
self,

0 commit comments

Comments
 (0)