Skip to content

Commit

Permalink
added process_item for migration graph builder
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmshn committed May 4, 2021
1 parent 7dfba17 commit 65cc9f3
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions emmet-builders/emmet/builders/materials/electrodes.py
Expand Up @@ -18,6 +18,7 @@

from emmet.core.electrode import InsertionElectrodeDoc
from emmet.core.structure_group import StructureGroupDoc
from emmet.core.migration import MigrationGraphDoc
from emmet.core.utils import jsanitize

__author__ = "Jimmy Shen"
Expand Down Expand Up @@ -122,7 +123,9 @@ def update_targets(self, items: List):
class InsertionElectrodeBuilder(GroupedThermoDocsBuilder):
def get_items(self):
"""
Get items
Additional fields:
- working_ion: the name of the working ion
- working_ion_doc: the materials document for the working ion
"""

@lru_cache(1000)
Expand Down Expand Up @@ -198,4 +201,28 @@ def update_targets(self, items: List):

class MigrationGraphBuilder(InsertionElectrodeBuilder):
def process_item(self, item) -> Dict:
pass
if item["thermo_docs"] is None:
return None

self.logger.debug(
f"Working on {item['group_id']} with {len(item['thermo_docs'])}"
)

entries = [
tdoc_["entries"][tdoc_["energy_type"]] for tdoc_ in item["thermo_docs"]
]
entries = list(map(ComputedStructureEntry.from_dict, entries))

working_ion_entry = ComputedEntry.from_dict(
item["working_ion_doc"]["entries"][item["working_ion_doc"]["energy_type"]]
)
working_ion = working_ion_entry.composition.reduced_formula

struct = MigrationGraph.get_structure_from_entries(entries=entries, migrating_ion_entry=working_ion_entry)

mg_doc = MigrationGraphDoc.from_entries(entries=entries, working_ion_entry=working_ion_entry, ltol=item['ltol'],
stol=item['stol'],
angle_tol=item['angle_tol'],
symprec=item['symprec'])
d = mg_doc.dict()
return jsanitize(d)

0 comments on commit 65cc9f3

Please sign in to comment.