Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin data audit #696

Merged
merged 10 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading