I have recently been using the Pourbaix tools in Pymatgen and the Materials Project API to generate Pourbaix diagrams and compute decomposition energies for various chemical systems. It seems to me that the Pymatgen code can, quite easily, be adapted to make use of the GGA(+U)/r2SCAN mixing scheme implemented in the MaterialsProjectDFTMixingScheme
class. However, I’ve noticed that the API does not currently support this mixing scheme directly, and the Pourbaix app on the Materials Project website also does not use it (https://next-gen.materialsproject.org/pourbaix).
My question is therefore: is it valid to use the GGA(+U)/r2SCAN mixing scheme in the Pourbaix tools with the ionic reference data (ionic fits)?
The method of correcting the DFT energies via the experimental data seems to me to be entirely valid to use in combination with the GGA(+U)/r2SCAN mixing:
https://journals.aps.org/prb/abstract/10.1103/PhysRevB.85.235438
I came across a similar question in a previous discussion (r2SCAN data for constructing Pourbaix diagram), but it appears that the answer there was more focused on phase diagrams specifically, rather than Pourbaix diagrams.
from pymatgen.entries.compatibility import Compatibility
from pymatgen.entries.compatibility import MaterialsProject2020Compatibility, MaterialsProjectAqueousCompatibility
from pymatgen.entries.mixing_scheme import MaterialsProjectDFTMixingScheme
from pymatgen.analysis.structure_matcher import StructureMatcher
from pymatgen.core.ion import Ion
from mp_api.client import MPRester
import itertools
class SafeCompatibilityWrapper(Compatibility):
def __init__(self, compat):
self.compat = compat
def process_entries(self, entries, clean=True, inplace=True, **kwargs):
return self.compat.process_entries(entries, clean=clean, inplace=inplace)
def get_adjustments(self, entries, clean=True, inplace=True, **kwargs):
return self.compat.get_adjustments(entries, clean=clean, inplace=inplace)
mpr = MPRester('MY_API_KEY')
chemsys = 'relevant chemsys'
ion_data = mpr.get_ion_reference_data_for_chemsys(chemsys)
ion_ref_comps = [
Ion.from_formula(d["data"]["RefSolid"]).composition for d in ion_data
]
ion_ref_elts = set(
itertools.chain.from_iterable(i.elements for i in ion_ref_comps)
)
gga_entries = mpr.get_entries_in_chemsys(
list([str(e) for e in ion_ref_elts] + ["O", "H"])
)
r2scan_entries = mpr.get_entries_in_chemsys(
list([str(e) for e in ion_ref_elts] + ["O", "H"]),
additional_criteria = {"thermo_types": ["R2SCAN"]}
)
all_entries = gga_entries + r2scan_entries
structure_matcher = StructureMatcher()
compat2020 = MaterialsProject2020Compatibility(check_potcar=False)
compat = SafeCompatibilityWrapper(
MaterialsProjectDFTMixingScheme(
structure_matcher = structure_matcher,
run_type_1 = "GGA(+U)",
run_type_2 = "r2SCAN",
compat_1 = compat2020,
compat_2 = None,
fuzzy_matching = True,
check_potcar = False
)
)
aq_compat = MaterialsProjectAqueousCompatibility(solid_compat=compat)
processed_all_entries = aq_compat.process_entries(all_entries)
# Convert to pbx_entries
# make PourbaixDiagrams etc.