Skip to content

Commit 9b3fe8c

Browse files
committed
Fix to ensure r2SCAN entries would not be ignored in mixing scheme correction
1 parent 928a0f0 commit 9b3fe8c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/pymatgen/entries/mixing_scheme.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ class MaterialsProjectDFTMixingScheme(Compatibility):
4040
may lead to unexpected results.
4141
4242
This is the scheme used by the Materials Project to generate Phase Diagrams containing
43-
a mixture of GGA(+U) and R2SCAN calculations. However in principle it can be used to
43+
a mixture of GGA(+U) and r2SCAN calculations. However in principle it can be used to
4444
mix energies from any two functionals.
4545
"""
4646

4747
def __init__(
4848
self,
4949
structure_matcher: StructureMatcher | None = None,
5050
run_type_1: str = "GGA(+U)",
51-
run_type_2: str = "R2SCAN",
51+
run_type_2: str = "r2SCAN",
5252
compat_1: (Compatibility | None) = MaterialsProject2020Compatibility(), # noqa: B008
5353
compat_2: Compatibility | None = None,
5454
fuzzy_matching: bool = True,
@@ -64,7 +64,7 @@ def __init__(
6464
run_type_1: The first DFT run_type. Typically this is the majority or run type or
6565
the "base case" onto which the other calculations are referenced. Valid choices
6666
are any run_type recognized by Vasprun.run_type, such as "LDA", "GGA", "GGA+U",
67-
"PBEsol", "SCAN", or "R2SCAN". The class will ignore any entries that have a
67+
"PBEsol", "SCAN", or "r2SCAN". The class will ignore any entries that have a
6868
run_type different than run_type_1 or run_type_2.
6969
7070
The list of run_type_1 entries provided to process_entries MUST form a complete
@@ -103,8 +103,10 @@ def __init__(
103103
raise ValueError(f"run_type_1={run_type_2=}. The mixing scheme is meaningless unless run_types different")
104104
self.run_type_1 = run_type_1
105105
self.run_type_2 = run_type_2
106-
self.valid_rtypes_1 = ["GGA", "GGA+U"] if self.run_type_1 == "GGA(+U)" else [self.run_type_1]
107-
self.valid_rtypes_2 = ["GGA", "GGA+U"] if self.run_type_2 == "GGA(+U)" else [self.run_type_2]
106+
"""Valid run_type, allowing for archive R2SCAN entries"""
107+
valid_rtype_dict = {"GGA(+U)": ["GGA", "GGA+U"], "R2SCAN": ["r2SCAN", "R2SCAN"]}
108+
self.valid_rtypes_1 = valid_rtype_dict.get(run_type_1.upper(), [self.run_type_1])
109+
self.valid_rtypes_2 = valid_rtype_dict.get(run_type_2.upper(), [self.run_type_2])
108110

109111
self.compat_1 = compat_1
110112
self.compat_2 = compat_2
@@ -253,7 +255,7 @@ def process_entries(
253255

254256
def get_adjustments(self, entry, mixing_state_data: pd.DataFrame | None = None):
255257
"""Get the corrections applied to a particular entry. Note that get_adjustments is not
256-
intended to be called directly in the R2SCAN mixing scheme. Call process_entries instead,
258+
intended to be called directly in the r2SCAN mixing scheme. Call process_entries instead,
257259
and it will pass the required arguments to get_adjustments.
258260
259261
Args:
@@ -326,7 +328,7 @@ def get_adjustments(self, entry, mixing_state_data: pd.DataFrame | None = None):
326328
# For run_type_2 entries, there is no correction
327329
return adjustments
328330

329-
# Discard GGA ground states whose structures already exist in R2SCAN.
331+
# Discard GGA ground states whose structures already exist in r2SCAN.
330332
df_slice = mixing_state_data[(mixing_state_data["entry_id_1"] == entry.entry_id)]
331333

332334
if df_slice["entry_id_2"].notna().item():
@@ -344,8 +346,8 @@ def get_adjustments(self, entry, mixing_state_data: pd.DataFrame | None = None):
344346
f"because there is a matching {self.run_type_2} material."
345347
)
346348

347-
# If a GGA is not present in R2SCAN, correct its energy to give the same
348-
# e_above_hull on the R2SCAN hull that it would have on the GGA hull
349+
# If a GGA is not present in r2SCAN, correct its energy to give the same
350+
# e_above_hull on the r2SCAN hull that it would have on the GGA hull
349351
hull_energy_1 = df_slice["hull_energy_1"].iloc[0]
350352
hull_energy_2 = df_slice["hull_energy_2"].iloc[0]
351353
correction = (hull_energy_2 - hull_energy_1) * entry.composition.num_atoms

0 commit comments

Comments
 (0)