diff --git a/sparc/io.py b/sparc/io.py index eefc661..c682e46 100644 --- a/sparc/io.py +++ b/sparc/io.py @@ -331,6 +331,10 @@ def read_raw_results(self, include_all_files=False): Sets: self.raw_results (dict or List): the same as the return value + + #TODO: @TT 2024-11-01 allow accepting indices + #TODO: @TT last_image is a bad name, it should refer to the occurance of images + the same goes with num_calculations """ # Find the max output index out_files = self.directory.glob(f"{self.label}.out*") @@ -381,7 +385,8 @@ def read_raw_results(self, include_all_files=False): def _read_results_from_index(self, index, d_format="{:02d}"): """Read the results from one calculation index, and return a - single raw result dict + single raw result dict, e.g. for index=0 --> .static + and index=1 --> .static_01. Arguments: index (int): Index of image to return the results @@ -390,6 +395,8 @@ def _read_results_from_index(self, index, d_format="{:02d}"): Returns: dict: Results for single image + #TODO: @TT should we call index --> occurance? + """ results_dict = {} @@ -436,6 +443,8 @@ def convert_to_ase(self, index=-1, include_all_files=False, **kwargs): """ # Convert to images! + # TODO: @TT 2024-11-01 read_raw_results should implement a more + # robust behavior handling index, as it is the entry point for all rs = self.read_raw_results(include_all_files=include_all_files) if isinstance(rs, dict): raw_results = [rs] @@ -535,7 +544,9 @@ def _extract_static_results(self, raw_results, index=":"): partial_results["forces"] = static_results["forces"][self.resort] if "atomic_magnetization" in static_results: - partial_results["magmoms"] = static_results["atomic_magnetization"][self.resort] + partial_results["magmoms"] = static_results["atomic_magnetization"][ + self.resort + ] if "net_magnetization" in static_results: partial_results["magmom"] = static_results["net_magnetization"] diff --git a/sparc/sparc_parsers/static.py b/sparc/sparc_parsers/static.py index bba410d..9e0773c 100644 --- a/sparc/sparc_parsers/static.py +++ b/sparc/sparc_parsers/static.py @@ -27,7 +27,8 @@ def _read_static(fileobj): """ Read the .static file content - Each .static file should only host 1 or more images (is socket mode is enabled), but the output may vary + Each .static file should only host 1 or more images + (if socket mode is enabled), but the output may vary a lot depending on the flags (e.g. PRINT_ATOMS, PRINT_FORCES etc) """ contents = fileobj.read()