MCPcopy Create free account
hub / github.com/SZAILAB/MaterialDFT-Demo / _parse_stress

Method _parse_stress

src/materialdft/backends/cpp_core.py:691–715  ·  view source on GitHub ↗
(self, output: dict[str, Any])

Source from the content-addressed store, hash-verified

689 return forces
690
691 def _parse_stress(self, output: dict[str, Any]) -> list[list[float]] | None:
692 stress_raw = output.get("stress_kbar")
693 if stress_raw is None:
694 return None
695 if not (
696 isinstance(stress_raw, list)
697 and len(stress_raw) == 3
698 and all(isinstance(row, list) and len(row) == 3 for row in stress_raw)
699 ):
700 raise BackendExecutionError(
701 "cpp_core output stress_kbar must be a 3x3 matrix when provided",
702 "RUNTIME_ERROR",
703 "POSTPROCESS",
704 )
705 stress: list[list[float]] = []
706 for row in stress_raw:
707 try:
708 stress.append([float(row[0]), float(row[1]), float(row[2])])
709 except (TypeError, ValueError) as exc:
710 raise BackendExecutionError(
711 "cpp_core output stress_kbar must contain numeric values",
712 "RUNTIME_ERROR",
713 "POSTPROCESS",
714 ) from exc
715 return stress
716
717 def _convert_stress_to_vasp_convention(self, output: dict[str, Any]) -> None:
718 if output.get("stress_convention") != "positive_tensile_fd_dE_deps":

Callers 1

Calls 1

Tested by

no test coverage detected