Skip to content

Commit 0585adc

Browse files
[BREAKING] Change default thermo type in get_entries_in_chemsys (#1074)
2 parents a08a927 + 9a863e6 commit 0585adc

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

mp_api/client/mprester.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
from mp_api.client.core.client import _DictLikeAccess
6060

61-
DEFAULT_THERMOTYPE_CRITERIA = {"thermo_types": ["GGA_GGA+U"]}
61+
DEFAULT_THERMOTYPE_CRITERIA = {"thermo_types": ["GGA_GGA+U_R2SCAN"]}
6262

6363
RESTER_LAYOUT = {
6464
"molecules/core": LazyImport(
@@ -1032,7 +1032,7 @@ def get_entries_in_chemsys(
10321032
compatible_only: bool = True,
10331033
property_data: list[str] | None = None,
10341034
conventional_unit_cell: bool = False,
1035-
additional_criteria: dict = DEFAULT_THERMOTYPE_CRITERIA,
1035+
additional_criteria: dict | None = None,
10361036
**kwargs,
10371037
) -> list[ComputedStructureEntry] | list[GibbsComputedStructureEntry]:
10381038
"""Helper method to get a list of ComputedEntries in a chemical system.
@@ -1091,6 +1091,17 @@ def get_entries_in_chemsys(
10911091
for els in itertools.combinations(elements_set, i + 1)
10921092
]
10931093

1094+
if additional_criteria is None:
1095+
warnings.warn(
1096+
"The default thermo type when retrieving entries has been changed from "
1097+
"the mixed/corrected PBE GGA and GGA+U hull (`thermo_type = GGA_GGA+U`) "
1098+
"to the joint PBE GGA / GGA+U / r2SCAN hull (`thermo_type = GGA_GGA+U_R2SCAN`). "
1099+
"To use the older behavior, call `get_entries_in_chemsys` with "
1100+
'`additional_criteria = {"thermo_types": ["GGA_GGA+U"]}`',
1101+
category=MPRestWarning,
1102+
stacklevel=2,
1103+
)
1104+
10941105
entries = self.get_entries(
10951106
all_chemsyses,
10961107
compatible_only=compatible_only,

tests/client/test_mprester.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,10 @@ def test_get_entries(self, mpr):
260260
def test_get_entries_in_chemsys(self, mpr):
261261
syms = ["Li", "Fe", "O"]
262262
syms2 = "Li-Fe-O"
263-
entries = mpr.get_entries_in_chemsys(syms)
263+
with pytest.warns(
264+
MPRestWarning, match="The default thermo type when retrieving entries"
265+
):
266+
entries = mpr.get_entries_in_chemsys(syms)
264267
entries2 = mpr.get_entries_in_chemsys(syms2)
265268
elements = {Element(sym) for sym in syms}
266269
for e in entries:
@@ -325,7 +328,9 @@ def test_get_pourbaix_entries(self, mpr):
325328
reason="`pip install mpcontribs-client` to use pourbaix functionality.",
326329
)
327330
def test_get_ion_entries(self, mpr):
328-
entries = mpr.get_entries_in_chemsys("Ti-O-H")
331+
entries = mpr.get_entries_in_chemsys(
332+
"Ti-O-H", additional_criteria={"thermo_types": ["GGA_GGA+U"]}
333+
)
329334
pd = PhaseDiagram(entries)
330335
ion_entry_data = mpr.get_ion_reference_data_for_chemsys("Ti-O-H")
331336
ion_entries = mpr.get_ion_entries(pd, ion_entry_data)
@@ -337,7 +342,9 @@ def test_get_ion_entries(self, mpr):
337342
assert len(bi_v_entry_data) == len(bi_data + v_data)
338343

339344
# test an incomplete phase diagram
340-
entries = mpr.get_entries_in_chemsys("Ti-O")
345+
entries = mpr.get_entries_in_chemsys(
346+
"Ti-O", additional_criteria={"thermo_types": ["GGA_GGA+U"]}
347+
)
341348
pd = PhaseDiagram(entries)
342349
with pytest.raises(ValueError, match="The phase diagram chemical system"):
343350
mpr.get_ion_entries(pd)
@@ -351,7 +358,8 @@ def test_get_ion_entries(self, mpr):
351358
itertools.chain.from_iterable(i.elements for i in ion_ref_comps)
352359
)
353360
ion_ref_entries = mpr.get_entries_in_chemsys(
354-
[*map(str, ion_ref_elts), "O", "H"]
361+
[*map(str, ion_ref_elts), "O", "H"],
362+
additional_criteria={"thermo_types": ["GGA_GGA+U"]},
355363
)
356364
mpc = MaterialsProjectAqueousCompatibility()
357365
ion_ref_entries = mpc.process_entries(ion_ref_entries)

0 commit comments

Comments
 (0)