Skip to content

Commit

Permalink
Conversion electrode builder query fix (#786)
Browse files Browse the repository at this point in the history
* Fix get items query in conversion electrode builder to ensure chemsys of working ion is included for retrieving phase diagrams

* Clean up: remove unnecessary .split() from chemsys list comp for get_items() query

* Bump pymatgen
  • Loading branch information
tsmathis committed Jul 20, 2023
1 parent 5cdb2f8 commit 9ee3f44
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions emmet-builders/emmet/builders/materials/electrodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,23 @@ def prechunk(self, number_splits: int) -> Iterator[Dict]:

def get_items(self):
"""
Get items. The phase diagrams are prefiltered by "thermo_type" or the functional.
Get items. Phase diagrams are filtered such that only PDs with chemical systems containing
the working ion and the specified "thermo_type", or functional, are chosen.
"""
q = dict(self.query)
q.update({"thermo_type": self.thermo_type})
for phase_diagram_doc in self.phase_diagram_store.query(q):

all_chemsys = self.phase_diagram_store.distinct("chemsys")

chemsys_w_wion = [c for c in all_chemsys if self.working_ion in c]

q = {
"$and": [
dict(self.query),
{"thermo_type": self.thermo_type},
{"chemsys": {"$in": chemsys_w_wion}},
]
}

for phase_diagram_doc in self.phase_diagram_store.query(criteria=q):
yield phase_diagram_doc

def process_item(self, item) -> Dict:
Expand Down

0 comments on commit 9ee3f44

Please sign in to comment.