Skip to content

Commit

Permalink
add comment TT side
Browse files Browse the repository at this point in the history
  • Loading branch information
alchem0x2A committed Nov 1, 2024
1 parent dcfc960 commit ad58f57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 13 additions & 2 deletions sparc/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*")
Expand Down Expand Up @@ -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
Expand All @@ -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 = {}

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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"]
Expand Down
3 changes: 2 additions & 1 deletion sparc/sparc_parsers/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ad58f57

Please sign in to comment.