Skip to content

Commit 373ae3a

Browse files
authored
Merge branch 'main' into gbd
2 parents 62623d5 + ebc1bb1 commit 373ae3a

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

mp_api/client/mprester.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -783,17 +783,22 @@ def get_entries(
783783

784784
def get_pourbaix_entries(
785785
self,
786-
chemsys: str | list,
786+
chemsys: str | list[str] | list[ComputedEntry | ComputedStructureEntry],
787787
solid_compat="MaterialsProject2020Compatibility",
788788
use_gibbs: Literal[300] | None = None,
789789
):
790790
"""A helper function to get all entries necessary to generate
791791
a Pourbaix diagram from the rest interface.
792792
793793
Args:
794-
chemsys (str or [str]): Chemical system string comprising element
794+
chemsys (str or [str] or Computed(Structure)Entry):
795+
Chemical system string comprising element
795796
symbols separated by dashes, e.g., "Li-Fe-O" or List of element
796797
symbols, e.g., ["Li", "Fe", "O"].
798+
799+
Can also be a list of Computed(Structure)Entry objects to allow
800+
for adding extra calculation data to the Pourbaix Diagram.
801+
If this is set, the chemsys will be inferred from the entries.
797802
solid_compat: Compatibility scheme used to pre-process solid DFT energies prior
798803
to applying aqueous energy adjustments. May be passed as a class (e.g.
799804
MaterialsProject2020Compatibility) or an instance
@@ -816,6 +821,27 @@ def get_pourbaix_entries(
816821
)
817822
from pymatgen.entries.computed_entries import ComputedEntry
818823

824+
thermo_types = ["GGA_GGA+U"]
825+
user_entries: list[ComputedEntry | ComputedStructureEntry] = []
826+
if isinstance(chemsys, list) and all(
827+
isinstance(v, ComputedEntry | ComputedStructureEntry) for v in chemsys
828+
):
829+
user_entries = [ce.copy() for ce in chemsys]
830+
831+
elements = set()
832+
for entry in user_entries:
833+
elements.update(entry.elements)
834+
chemsys = [ele.name for ele in elements]
835+
836+
user_run_types = set(
837+
[
838+
entry.parameters.get("run_type", "unknown").lower()
839+
for entry in user_entries
840+
]
841+
)
842+
if any("r2scan" in rt for rt in user_run_types):
843+
thermo_types = ["GGA_GGA+U_R2SCAN"]
844+
819845
if solid_compat == "MaterialsProjectCompatibility":
820846
solid_compat = MaterialsProjectCompatibility()
821847
elif solid_compat == "MaterialsProject2020Compatibility":
@@ -851,9 +877,13 @@ def get_pourbaix_entries(
851877
# TODO - would be great if the commented line below would work
852878
# However for some reason you cannot process GibbsComputedStructureEntry with
853879
# MaterialsProjectAqueousCompatibility
854-
ion_ref_entries = self.get_entries_in_chemsys(
855-
list([str(e) for e in ion_ref_elts] + ["O", "H"]),
856-
# use_gibbs=use_gibbs
880+
ion_ref_entries = (
881+
self.get_entries_in_chemsys(
882+
list([str(e) for e in ion_ref_elts] + ["O", "H"]),
883+
additional_criteria={"thermo_types": thermo_types}
884+
# use_gibbs=use_gibbs
885+
)
886+
+ user_entries
857887
)
858888

859889
# suppress the warning about supplying the required energies; they will be calculated from the

mp_api/client/routes/materials/robocrys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def search(
1515
self,
1616
keywords: list[str],
1717
num_chunks: int | None = None,
18-
chunk_size: int | None = 100,
18+
chunk_size: int | None = 1000,
1919
):
2020
"""Search text generated from Robocrystallographer.
2121

0 commit comments

Comments
 (0)