Skip to content

Commit

Permalink
Load reaction correctly from an ARC restart (#688)
Browse files Browse the repository at this point in the history
When a species is loaded from an Artkane YAML file and has a different
label than in that file, it currently messes up the loading process of a
reaction from a restart file. Plus, another possible complication (in
addition or independently) is that a species label could be modified by
ARC for convenient folder naming.

Here we consider these two issues when loading species and reactions
from an ARC restart file
  • Loading branch information
alongd authored Aug 21, 2023
2 parents 8be4bf4 + d5d9c87 commit c6589c2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions arc/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ def from_dict(self,
self.r_species, self.p_species = list(), list()
for spc in species_list:
for r_spc_dict in reaction_dict['r_species']:
if spc.label == r_spc_dict['label']:
if r_spc_dict['label'] in [spc.label, spc.original_label]:
self.r_species.append(spc)
for p_spc_dict in reaction_dict['p_species']:
if spc.label == p_spc_dict['label']:
if p_spc_dict['label'] in [spc.label, spc.original_label]:
self.p_species.append(spc)
else:
self.r_species = [ARCSpecies(species_dict=r_dict) for r_dict in reaction_dict['r_species']] \
Expand Down
2 changes: 1 addition & 1 deletion arc/species/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def from_yml_file(self, label: str = None) -> bool:
# The data from the YAML file is loaded into the `species` argument of the `load_yaml` method in Arkane
yml_content = read_yaml_file(self.yml_path)
arkane_spc.load_yaml(path=self.yml_path, label=label, pdep=False)
self.label = label if label is not None else arkane_spc.label
self.label = label or self.label or arkane_spc.label
self.final_xyz = xyz_from_data(coords=arkane_spc.conformer.coordinates.value,
numbers=arkane_spc.conformer.number.value)
if 'mol' in yml_content:
Expand Down
3 changes: 2 additions & 1 deletion arc/species/species_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,8 @@ def tearDownClass(cls):
project_directory = os.path.join(ARC_PATH, 'Projects', project)
shutil.rmtree(project_directory, ignore_errors=True)

file_paths = [os.path.join(ARC_PATH, 'nul'), os.path.join(ARC_PATH, 'run.out')]
file_paths = [os.path.join(ARC_PATH, 'nul'), os.path.join(ARC_PATH, 'run.out'),
os.path.join(ARC_PATH, 'arc', 'species', 'nul'), os.path.join(ARC_PATH, 'arc', 'species', 'run.out')]
for file_path in file_paths:
if os.path.isfile(file_path):
os.remove(file_path)
Expand Down

0 comments on commit c6589c2

Please sign in to comment.