Skip to content
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
5 changes: 5 additions & 0 deletions arc/species/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class ARCSpecies(object):
multi_species: (str): The multi-species set this species belongs to. Used for running a set of species
simultaneously in a single ESS input file.
symmetry_number (int): The external symmetry number of the species, calculated from mol_list.
index (int): An optional index for the species.
"""

def __init__(self,
Expand Down Expand Up @@ -366,6 +367,7 @@ def __init__(self,
self.project_directory = project_directory
self.label = label
self.symmetry_number = None
self.index = None

if species_dict is not None:
# Reading from a dictionary (it's possible that the dict contains only a 'yml_path' argument, check first)
Expand Down Expand Up @@ -678,6 +680,8 @@ def as_dict(self,
species_dict['arkane_file'] = self.arkane_file
if not self.consider_all_diastereomers:
species_dict['consider_all_diastereomers'] = self.consider_all_diastereomers
if self.index is not None:
species_dict['index'] = self.index
if self.is_ts:
if len(self.ts_guesses):
species_dict['ts_guesses'] = [tsg.as_dict() for tsg in self.ts_guesses]
Expand Down Expand Up @@ -827,6 +831,7 @@ def from_dict(self, species_dict):
self.ts_conf_spawned = species_dict['ts_conf_spawned'] if 'ts_conf_spawned' in species_dict \
else False if self.is_ts else None
self.adjlist = species_dict['adjlist'] if 'adjlist' in species_dict else None
self.index = species_dict['index'] if 'index' in species_dict else None
if self.is_ts:
self.ts_number = species_dict['ts_number'] if 'ts_number' in species_dict else None
self.ts_guesses_exhausted = species_dict['ts_guesses_exhausted'] if 'ts_guesses_exhausted' in species_dict else False
Expand Down
14 changes: 14 additions & 0 deletions arc/species/species_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2767,6 +2767,20 @@ def test_hash(self):
self.assertEqual(len(s), 2)
self.assertIn(self.spc1, s)

def test_species_indexing(self):
"""Test species indexing in ARCSpecies."""
spc_a = ARCSpecies(label='spc_a', smiles='C')
spc_b = ARCSpecies(label='spc_b', smiles='CC')
spc_c = ARCSpecies(label='spc_c', smiles='CCC')

species_list = [spc_a, spc_b, spc_c]
for index, spc in enumerate(species_list):
spc.index = index

self.assertEqual(spc_a.index, 0)
self.assertEqual(spc_b.index, 1)
self.assertEqual(spc_c.index, 2)


class TestTSGuess(unittest.TestCase):
"""
Expand Down
Loading