Skip to content

Commit

Permalink
Added an option to specify the TS adapters in the input file (#657)
Browse files Browse the repository at this point in the history
Tests added
  • Loading branch information
naddeu committed May 17, 2023
2 parents 17f8512 + 6fe63bc commit c4df194
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
11 changes: 11 additions & 0 deletions arc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from arc.exceptions import InputError, SettingsError, SpeciesError
from arc.imports import settings
from arc.level import Level
from arc.job.factory import _registered_job_adapters
from arc.job.ssh import SSHClient
from arc.processor import process_arc_project
from arc.reaction import ARCReaction
Expand Down Expand Up @@ -153,6 +154,7 @@ class ARC(object):
output (dict, optional): Output dictionary with status and final QM file paths for all species.
Only used for restarting.
running_jobs (dict, optional): A dictionary of jobs submitted in a precious ARC instance, used for restarting.
ts_adapters (list, optional): Entries represent different TS adapters.
Attributes:
project (str): The project's name. Used for naming the working directory.
Expand Down Expand Up @@ -218,6 +220,7 @@ class ARC(object):
three_params (bool): Compute rate coefficients using the modified three-parameter Arrhenius equation
format (``True``) or classical two-parameter Arrhenius equation format (``False``).
trsh_ess_jobs (bool): Whether to attempt troubleshooting failed ESS jobs. Default is ``True``.
ts_adapters (list): Entries represent different TS adapters.
"""

def __init__(self,
Expand Down Expand Up @@ -263,6 +266,7 @@ def __init__(self,
thermo_adapter: str = 'Arkane',
three_params: bool = True,
trsh_ess_jobs: bool = True,
ts_adapters: List[str] = None,
ts_guess_level: Optional[Union[str, dict, Level]] = None,
verbose=logging.INFO,
):
Expand Down Expand Up @@ -315,6 +319,10 @@ def __init__(self,
self.bac_type = bac_type
self.arkane_level_of_theory = Level(repr=arkane_level_of_theory) if arkane_level_of_theory is not None else None
self.freq_scale_factor = freq_scale_factor
self.ts_adapters = ts_adapters
for ts_adapter in self.ts_adapters or list():
if ts_adapter.lower() not in _registered_job_adapters.keys():
raise InputError(f'Unknown TS adapter: "{ts_adapter}"')

# attributes related to level of theory specifications
self.level_of_theory = level_of_theory
Expand Down Expand Up @@ -465,6 +473,8 @@ def as_dict(self) -> dict:
restart_dict['conformer_level'] = self.conformer_level.as_dict()
if self.dont_gen_confs:
restart_dict['dont_gen_confs'] = self.dont_gen_confs
if self.ts_adapters:
restart_dict['ts_adapters'] = self.ts_adapters
restart_dict['e_confs'] = self.e_confs
restart_dict['ess_settings'] = self.ess_settings
if self.freq_level is not None:
Expand Down Expand Up @@ -581,6 +591,7 @@ def execute(self) -> dict:
dont_gen_confs=self.dont_gen_confs,
trsh_ess_jobs=self.trsh_ess_jobs,
fine_only=self.fine_only,
ts_adapters=self.ts_adapters,
)

save_yaml_file(path=os.path.join(self.project_directory, 'output', 'status.yml'), content=self.scheduler.output)
Expand Down
21 changes: 20 additions & 1 deletion arc/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_as_dict(self):
species=[spc1],
level_of_theory='ccsd(t)-f12/cc-pvdz-f12//b3lyp/6-311+g(3df,2p)',
three_params=False,
ts_adapters=['heuristics', 'AutoTST', 'GCN', 'xtb_gsm'],
)
arc0.freq_level.args['keyword']['general'] = 'scf=(NDump=30)'
restart_dict = arc0.as_dict()
Expand Down Expand Up @@ -160,7 +161,8 @@ def test_as_dict(self):
'multiplicity': 1,
'number_of_rotors': 0}],
'thermo_adapter': 'arkane',
'three_params': False}
'three_params': False,
'ts_adapters': ['heuristics', 'AutoTST', 'GCN', 'xtb_gsm']}
# import pprint # left intentionally for debugging
# print(pprint.pprint(restart_dict))
self.assertEqual(restart_dict, expected_dict)
Expand Down Expand Up @@ -475,6 +477,23 @@ def test_process_level_of_theory(self):
self.assertIsInstance(arc.opt_level, Level)
self.assertIsInstance(arc.freq_level, Level)

def test_unknown_ts_adapter(self):
"""
Tests that ARC raises an error when unknown TS adapters are given.
"""
spc1 = ARCSpecies(label='spc1',
smiles='CC',
compute_thermo=False,
)
with self.assertRaises(InputError):
arc0 = ARC(project='arc_test',
job_types=self.job_types1,
species=[spc1],
level_of_theory='ccsd(t)-f12/cc-pvdz-f12//b3lyp/6-311+g(3df,2p)',
three_params=False,
ts_adapters=['WRONG ADAPTER', 'AutoTST', 'GCN', 'xtb_gsm'],
)

@classmethod
def tearDownClass(cls):
"""
Expand Down
11 changes: 7 additions & 4 deletions arc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@
logger = get_logger()

LOWEST_MAJOR_TS_FREQ, HIGHEST_MAJOR_TS_FREQ, default_job_settings, \
default_job_types, rotor_scan_resolution, ts_adapters, max_rotor_trsh = \
default_job_types, rotor_scan_resolution, default_ts_adapters, max_rotor_trsh = \
settings['LOWEST_MAJOR_TS_FREQ'], settings['HIGHEST_MAJOR_TS_FREQ'], settings['default_job_settings'], \
settings['default_job_types'], settings['rotor_scan_resolution'], settings['ts_adapters'], settings['max_rotor_trsh']

ts_adapters = [ts_adapter.lower() for ts_adapter in ts_adapters]


class Scheduler(object):
"""
Expand Down Expand Up @@ -161,6 +159,7 @@ class Scheduler(object):
kinetics_adapter (str, optional): The statmech software to use for kinetic rate coefficient calculations.
freq_scale_factor (float, optional): The harmonic frequencies scaling factor.
trsh_ess_jobs (bool, optional): Whether to attempt troubleshooting failed ESS jobs. Default is ``True``.
ts_adapters (list, optional): Entries represent different TS adapters.
Attributes:
project (str): The project's name. Used for naming the working directory.
Expand Down Expand Up @@ -214,6 +213,7 @@ class Scheduler(object):
kinetics_adapter (str): The statmech software to use for kinetic rate coefficient calculations.
freq_scale_factor (float): The harmonic frequencies scaling factor.
trsh_ess_jobs (bool): Whether to attempt troubleshooting failed ESS jobs. Default is ``True``.
ts_adapters (list): Entries represent different TS adapters.
"""

def __init__(self,
Expand Down Expand Up @@ -247,6 +247,7 @@ def __init__(self,
trsh_ess_jobs: Optional[bool] = True,
kinetics_adapter: str = 'arkane',
freq_scale_factor: float = 1.0,
ts_adapters: List[str] = None,
) -> None:

self.project = project
Expand Down Expand Up @@ -275,6 +276,8 @@ def __init__(self,
self.trsh_ess_jobs = trsh_ess_jobs
self.kinetics_adapter = kinetics_adapter
self.freq_scale_factor = freq_scale_factor
self.ts_adapters = ts_adapters if ts_adapters is not None else default_ts_adapters
self.ts_adapters = [ts_adapter.lower() for ts_adapter in self.ts_adapters]
self.output = dict()

self.species_dict, self.rxn_dict = dict(), dict()
Expand Down Expand Up @@ -1474,7 +1477,7 @@ def spawn_ts_jobs(self):
else:
rxn.ts_species.tsg_spawned = True
tsg_index = 0
for method in ts_adapters:
for method in self.ts_adapters:
if method in all_families_ts_adapters or \
(rxn.family is not None
and rxn.family.label in list(ts_adapters_by_rmg_family.keys())
Expand Down

0 comments on commit c4df194

Please sign in to comment.