Skip to content

Commit

Permalink
Fix to ensure r2SCAN entries would not be ignored in mixing scheme co…
Browse files Browse the repository at this point in the history
…rrection
  • Loading branch information
peikai committed Jan 20, 2025
1 parent 928a0f0 commit 9b3fe8c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/pymatgen/entries/mixing_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ class MaterialsProjectDFTMixingScheme(Compatibility):
may lead to unexpected results.
This is the scheme used by the Materials Project to generate Phase Diagrams containing
a mixture of GGA(+U) and R2SCAN calculations. However in principle it can be used to
a mixture of GGA(+U) and r2SCAN calculations. However in principle it can be used to
mix energies from any two functionals.
"""

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

self.compat_1 = compat_1
self.compat_2 = compat_2
Expand Down Expand Up @@ -253,7 +255,7 @@ def process_entries(

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

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

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

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

0 comments on commit 9b3fe8c

Please sign in to comment.