Skip to content

Commit

Permalink
Origin data audit (#696)
Browse files Browse the repository at this point in the history
* Add origin data to elasticity

* Fix elascity origins

* Typo fix

* Fix electronic structure origins

* Fix summary origins

* Fix mypy

* Fix es origins

* More es fixes

* ES test fix

* Origins key fix
  • Loading branch information
munrojm committed Apr 10, 2023
1 parent a452bb0 commit 2682d3d
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 154 deletions.
18 changes: 13 additions & 5 deletions emmet-builders/emmet/builders/materials/elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def ensure_index(self):
self.elasticity.ensure_index("material_id")
self.elasticity.ensure_index("last_updated")

def get_items(self,) -> Generator[Tuple[str, Dict[str, str], List[Dict]], None, None]:
def get_items(
self,
) -> Generator[Tuple[str, Dict[str, str], List[Dict]], None, None]:
"""
Gets all items to process into elasticity docs.
Expand All @@ -93,7 +95,6 @@ def get_items(self,) -> Generator[Tuple[str, Dict[str, str], List[Dict]], None,
query = self.query.copy()

for i, doc in enumerate(cursor):

material_id = doc["material_id"]
calc_types = {str(k): v for k, v in doc["calc_types"].items()}

Expand All @@ -106,6 +107,7 @@ def get_items(self,) -> Generator[Tuple[str, Dict[str, str], List[Dict]], None,
"output",
"orig_inputs",
"completed_at",
"last_updated",
"transmuter",
"task_id",
"dir_name",
Expand Down Expand Up @@ -172,12 +174,14 @@ def process_item(self, item: Tuple[MPID, Dict[str, str], List[Dict]]) -> Union[D
stresses = []
deform_task_ids = []
deform_dir_names = []
deform_last_updated = []
for doc in final_deform:
deforms.append(Deformation(doc["transmuter"]["transformation_params"][0]["deformation"]))
# -0.1 to convert to GPa from kBar and s
stresses.append(-0.1 * Stress(doc["output"]["stress"]))
deform_task_ids.append(doc["task_id"])
deform_dir_names.append(doc["dir_name"])
deform_last_updated.append(doc["last_updated"])

elasticity_doc = ElasticityDoc.from_deformations_and_stresses(
structure=Structure.from_dict(final_opt["output"]["structure"]),
Expand All @@ -186,6 +190,7 @@ def process_item(self, item: Tuple[MPID, Dict[str, str], List[Dict]]) -> Union[D
stresses=stresses,
deformation_task_ids=deform_task_ids,
deformation_dir_names=deform_dir_names,
deform_last_updated=deform_last_updated,
equilibrium_stress=-0.1 * Stress(final_opt["output"]["stress"]),
optimization_task_id=final_opt["task_id"],
optimization_dir_name=final_opt["dir_name"],
Expand All @@ -208,7 +213,9 @@ def update_targets(self, items: List[Dict]):


def filter_opt_tasks(
tasks: List[Dict], calc_types: Dict[str, str], target_calc_type: str = CalcType.GGA_Structure_Optimization,
tasks: List[Dict],
calc_types: Dict[str, str],
target_calc_type: str = CalcType.GGA_Structure_Optimization,
) -> List[Dict]:
"""
Filter optimization tasks, by
Expand All @@ -220,7 +227,9 @@ def filter_opt_tasks(


def filter_deform_tasks(
tasks: List[Dict], calc_types: Dict[str, str], target_calc_type: str = CalcType.GGA_Deformation,
tasks: List[Dict],
calc_types: Dict[str, str],
target_calc_type: str = CalcType.GGA_Deformation,
) -> List[Dict]:
"""
Filter deformation tasks, by
Expand Down Expand Up @@ -326,7 +335,6 @@ def filter_deform_tasks_by_time(tasks: List[Dict], deform_comp_tol: float = 1e-5
mapping = TensorMapping(tol=deform_comp_tol, tensors=[], values=[])

for doc in tasks:

# assume only one deformation, should be checked in `filter_deform_tasks()`
deform = doc["transmuter"]["transformation_params"][0]["deformation"]

Expand Down

0 comments on commit 2682d3d

Please sign in to comment.