From fbd13a82c657e019d39a3fd0e9c2ab6094ec1226 Mon Sep 17 00:00:00 2001 From: Shyam D Date: Sat, 10 Jul 2021 10:01:17 -0700 Subject: [PATCH 1/4] reverse order of thermo processing --- emmet-builders/emmet/builders/vasp/thermo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/emmet-builders/emmet/builders/vasp/thermo.py b/emmet-builders/emmet/builders/vasp/thermo.py index 6428ffc2f9..d28aa23bbc 100644 --- a/emmet-builders/emmet/builders/vasp/thermo.py +++ b/emmet-builders/emmet/builders/vasp/thermo.py @@ -115,7 +115,9 @@ def get_items(self) -> Iterator[List[Dict]]: # Yield the chemical systems in order of increasing size # Will build them in a similar manner to fast Pourbaix - for chemsys in sorted(to_process_chemsys, key=lambda x: len(x.split("-"))): + for chemsys in sorted( + to_process_chemsys, key=lambda x: len(x.split("-")), reverse=True + ): entries = self.get_entries(chemsys) yield entries From dcc861e04e442e351886343dd4354d8eaf6dd1a7 Mon Sep 17 00:00:00 2001 From: Shyam D Date: Sat, 10 Jul 2021 10:10:32 -0700 Subject: [PATCH 2/4] add tests for deprecated material construction --- tests/emmet-core/vasp/test_materials.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/emmet-core/vasp/test_materials.py b/tests/emmet-core/vasp/test_materials.py index 33222945bf..ba2883dfe7 100644 --- a/tests/emmet-core/vasp/test_materials.py +++ b/tests/emmet-core/vasp/test_materials.py @@ -32,5 +32,18 @@ def test_make_mat(test_tasks): MaterialsDoc.from_tasks(bad_task_group, use_statics=False) +def test_make_deprecated_mat(test_tasks): + bad_task_group = [ + task for task in test_tasks if task.task_type != TaskType.Structure_Optimization + ] + + material = MaterialsDoc.construct_deprecated_material(bad_task_group) + + assert material.deprecated + assert material.formula_pretty == "Si" + assert len(material.task_ids) == 3 + assert material.entries is None + + def test_schema(): MaterialsDoc.schema() From 8e6743868028b095e703eea90c7b570535c8ae56 Mon Sep 17 00:00:00 2001 From: Shyam D Date: Sat, 10 Jul 2021 10:10:57 -0700 Subject: [PATCH 3/4] construct deprecated materials --- emmet-core/emmet/core/vasp/material.py | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/emmet-core/emmet/core/vasp/material.py b/emmet-core/emmet/core/vasp/material.py index c6a81f0e6d..a608ff3ffd 100644 --- a/emmet-core/emmet/core/vasp/material.py +++ b/emmet-core/emmet/core/vasp/material.py @@ -165,3 +165,61 @@ def _structure_eval(task: TaskDocument): origins=origins, entries=entries, ) + + @classmethod + def construct_deprecated_material( + cls, + task_group: List[TaskDocument], + ) -> "MaterialsDoc": + """ + Converts a group of tasks into a deprecated material + + Args: + task_group: List of task document + """ + if len(task_group) == 0: + raise Exception("Must have more than one task in the group.") + + # Metadata + last_updated = max(task.last_updated for task in task_group) + created_at = min(task.completed_at for task in task_group) + task_ids = list({task.task_id for task in task_group}) + + deprecated_tasks = {task.task_id for task in task_group} + run_types = {task.task_id: task.run_type for task in task_group} + task_types = {task.task_id: task.task_type for task in task_group} + calc_types = {task.task_id: task.calc_type for task in task_group} + + # Material ID + material_id = min([task.task_id for task in task_group]) + + # Choose any random structure for metadata + structure = SpacegroupAnalyzer( + task_group[0].output.structure, symprec=0.1 + ).get_conventional_standard_structure() + + # Initial Structures + initial_structures = [task.input.structure for task in task_group] + sm = StructureMatcher( + ltol=0.1, stol=0.1, angle_tol=0.1, scale=False, attempt_supercell=False + ) + initial_structures = [ + group[0] for group in sm.group_structures(initial_structures) + ] + + # Deprecated + deprecated = True + + return cls.from_structure( + structure=structure, + material_id=material_id, + last_updated=last_updated, + created_at=created_at, + task_ids=task_ids, + calc_types=calc_types, + run_types=run_types, + task_types=task_types, + initial_structures=initial_structures, + deprecated=deprecated, + deprecated_tasks=deprecated_tasks, + ) From c99bd0287183adc5f8866449deb0503f4dc06804 Mon Sep 17 00:00:00 2001 From: Shyam D Date: Mon, 12 Jul 2021 08:39:24 -0700 Subject: [PATCH 4/4] construct deprecated materials for failures --- emmet-builders/emmet/builders/vasp/materials.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emmet-builders/emmet/builders/vasp/materials.py b/emmet-builders/emmet/builders/vasp/materials.py index e9d95a347d..23de7cef0f 100644 --- a/emmet-builders/emmet/builders/vasp/materials.py +++ b/emmet-builders/emmet/builders/vasp/materials.py @@ -230,6 +230,8 @@ def process_item(self, items: List[Dict]) -> List[Dict]: f"No valid ids found among ids {failed_ids}. This can be the case if the required " "calculation types are missing from your tasks database." ) + materials.append(MaterialsDoc.construct_deprecated_material(tasks)) + self.logger.debug(f"Produced {len(materials)} materials for {formula}") return jsanitize([mat.dict() for mat in materials], allow_bson=True)