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
26 changes: 21 additions & 5 deletions arc/job/adapters/mockter.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ def __init__(self,
self.command = 'mockter'
self.url = ''

if species is None:
raise ValueError('Cannot execute Mockter without an ARCSpecies object.')
if species is None and reactions is None:
raise ValueError('Cannot execute Mockter without an ARCSpecies or an ARCReaction object.')

_initialize_adapter(obj=self,
is_ts=False,
Expand Down Expand Up @@ -178,7 +178,7 @@ def write_input_file(self) -> None:
input_dict['memory'] = self.input_file_memory
input_dict['method'] = self.level.method
input_dict['multiplicity'] = self.multiplicity
input_dict['xyz'] = xyz_to_str(self.xyz)
input_dict['xyz'] = xyz_to_str(self.get_mock_xyz())
input_dict['job_type'] = self.job_type
input_dict['memory'] = self.input_file_memory

Expand Down Expand Up @@ -238,7 +238,23 @@ def set_input_file_memory(self) -> None:
Set the input_file_memory attribute.
"""
self.input_file_memory = self.job_memory_gb


def get_mock_xyz(self) -> Optional[dict]:
"""
Get the xyz coordinates for the mock job.
"""
if self.xyz is not None:
return self.xyz
if self.species is not None and len(self.species):
return self.species[0].get_xyz()
if self.reactions is not None and len(self.reactions):
ts_xyz_str = ''
reactants, _ = self.reactions[0].get_reactants_and_products()
for r in reactants:
ts_xyz_str += xyz_to_str(r.get_xyz()) + '\n'
return str_to_xyz(ts_xyz_str)
return None

Comment thread
OfirSimhi1612 marked this conversation as resolved.
def execute_incore(self):
"""
Execute a job incore.
Expand All @@ -250,7 +266,7 @@ def execute_incore(self):
if self.species[0].is_ts:
freqs[0] = -500
output = {'adapter': 'mockter',
'xyz': input['xyz'],
'xyz': xyz,
'sp': e_elect,
'T1': 0.0002,
'freqs': freqs,
Expand Down
40 changes: 38 additions & 2 deletions arc/job/adapters/mockter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from arc.common import ARC_PATH, read_yaml_file
from arc.job.adapters.mockter import MockAdapter
from arc.level import Level
from arc.reaction.reaction import ARCReaction
from arc.settings.settings import input_filenames, output_filenames
from arc.species import ARCSpecies

Expand Down Expand Up @@ -47,6 +48,16 @@ def setUpClass(cls):
species=[ARCSpecies(label='spc3', xyz=['O 0 0 1\nH 0 0 0\nH 1 0 0'], is_ts=True)],
testing=True,
)
cls.job_4 = MockAdapter(job_type='tsg',
level=Level(method='mock)', basis='cc-pVmockZ'),
project='test',
project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_MockAdapter_4'),
reactions=[ARCReaction(r_species=[ARCSpecies(label='O', smiles='[O]'),
ARCSpecies(label='CCC', smiles='CCC')],
p_species=[ARCSpecies(label='OH', smiles='[OH]'),
ARCSpecies(label='CCCyl', smiles='[CH2]CC')])],
testing=True,
)

def test_set_cpu_and_mem(self):
"""Test assigning number of cpu's and memory"""
Expand Down Expand Up @@ -109,6 +120,31 @@ def test_write_input_file(self):
'H 1.00000000 0.00000000 0.00000000'}
self.assertEqual(content_3, job_3_expected_input_file)

def test_get_mock_xyz(self):
"""Test getting the xyz coordinates from the mock input file"""
self.job_1.write_input_file()
xyz = self.job_1.get_mock_xyz()
expected_xyz = ((0.0, 0.0, 1.0),)
self.assertEqual(xyz['coords'], expected_xyz)

self.job_4.write_input_file()
xyz = self.job_4.get_mock_xyz()
expected_xyz = {'coords': ((0.0, 0.0, 0.0),
(-1.23638885, -0.31576286, 0.08035856),
(-0.01951084, 0.58603214, 0.20011967),
(1.25111292, -0.12649245, -0.23138091),
(-1.1299088, -1.20421894, 0.71100631),
(-1.38117893, -0.64405306, -0.95389019),
(-2.13745897, 0.21915243, 0.39632612),
(-0.16491381, 1.47886657, -0.41803363),
(0.08498971, 0.92174781, 1.23780143),
(1.43621378, -1.00896698, 0.38941334),
(1.1849428, -0.44879975, -1.27548267),
(2.11210099, 0.5424951, -0.13623803)),
'isotopes': (16, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1),
'symbols': ('O', 'C', 'C', 'C', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H')}
self.assertEqual(xyz, expected_xyz)

def test_executing_mockter(self):
"""Test executing mockter"""
self.job_1.execute()
Expand All @@ -118,7 +154,7 @@ def test_executing_mockter(self):

self.job_2.execute()
output = read_yaml_file(os.path.join(self.job_2.local_path, output_filenames[self.job_2.job_adapter]))
self.assertEqual(output['xyz'], 'O 0.00000000 0.00000000 1.00000000')
self.assertEqual(output['xyz'], {'coords': ((0.0, 0.0, 1.0),), 'isotopes': (16,), 'symbols': ('O',)})

self.job_3.execute()
output = read_yaml_file(os.path.join(self.job_3.local_path, output_filenames[self.job_3.job_adapter]))
Expand All @@ -131,7 +167,7 @@ def tearDownClass(cls):
A function that is run ONCE after all unit tests in this class.
Delete all project directories created during these unit tests
"""
for folder in ['test_MockAdapter_1', 'test_MockAdapter_2', 'test_MockAdapter_3']:
for folder in ['test_MockAdapter_1', 'test_MockAdapter_2', 'test_MockAdapter_3', 'test_MockAdapter_4']:
shutil.rmtree(os.path.join(ARC_PATH, 'arc', 'testing', folder), ignore_errors=True)


Expand Down
3 changes: 2 additions & 1 deletion arc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,8 @@ def spawn_ts_jobs(self):
if method in all_families_ts_adapters or \
(rxn.family is not None
and rxn.family in list(ts_adapters_by_rmg_family.keys())
and method in ts_adapters_by_rmg_family[rxn.family]):
and method in ts_adapters_by_rmg_family[rxn.family]) \
or 'mock' in method:
self.run_job(job_type='tsg',
job_adapter=method,
reactions=[rxn],
Expand Down
Loading