Skip to content

Commit

Permalink
deduce software - irc
Browse files Browse the repository at this point in the history
If user has both software available for IRC,  it will use go with preferred order

level tests update
  • Loading branch information
calvinp0 committed Feb 11, 2024
1 parent 7f05059 commit 4242e28
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
9 changes: 7 additions & 2 deletions arc/level.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,15 @@ def deduce_software(self,
f'levels_ess is:\n{levels_ess}')
self.software = 'gaussian'


# QChem & Gaussian for IRC jobs
if job_type == 'irc':
if 'qchem' in supported_ess:
preferred_ess_order_for_irc = ['gaussian', 'qchem']

if 'qchem' in supported_ess and 'gaussian' in supported_ess:
# Use preferred order if both are available
relevant_software = get_ordered_intersection_of_two_lists(preferred_ess_order_for_irc, supported_ess)
self.software = relevant_software[0]
elif 'qchem' in supported_ess:
self.software = 'qchem'
elif 'gaussian' in supported_ess:
self.software = 'gaussian'
Expand Down
33 changes: 32 additions & 1 deletion arc/level_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os
import unittest
from unittest.mock import patch

from arkane.modelchem import LevelOfTheory

Expand Down Expand Up @@ -45,7 +46,7 @@ def test_deduce_software(self):
self.assertEqual(Level(method='B3LYP', basis='6-311g+(d,f)').software, 'gaussian')
level_3 = Level(method='B3LYP', basis='6-311g+(d,f)')
level_3.deduce_software(job_type='irc')
self.assertEqual(level_3.software, 'qchem')
self.assertEqual(level_3.software, 'gaussian')
self.assertEqual(Level(method='DLPNO-CCSD(T)', basis='def2-tzvp').software, 'orca')
self.assertEqual(Level(method='PM6').software, 'gaussian')
self.assertEqual(Level(method='HF').software, 'gaussian')
Expand All @@ -61,6 +62,36 @@ def test_deduce_software(self):
self.assertEqual(Level(method='new', basis='new', args={'keywords': {'general': 'iop(99/33=1)'}}).software,
'gaussian')

@patch('arc.level.supported_ess', new=['qchem', 'gaussian'])
def test_deduce_software_irc_with_both(self):
"""Test deducing software for IRC job when both qchem and gaussian are supported."""
level = Level(method='B3LYP', basis='6-311g+(d,f)')
level.deduce_software(job_type='irc')
self.assertEqual(level.software, 'gaussian') # gaussian is also available

@patch('arc.level.supported_ess', new=['qchem'])
def test_deduce_software_irc_with_only_gaussian(self):
"""Test deducing software for IRC job when only gaussian is supported."""
level = Level(method='B3LYP', basis='6-311g+(d,f)')
level.deduce_software(job_type='irc')
self.assertEqual(level.software, 'qchem') # Only qchem is available

@patch('arc.level.supported_ess', new=[])
def test_deduce_software_value_errors(self):
"""Test various ValueError scenarios in deduce_software."""
test_cases = [
('onedmin', None, 'onedmin'),
('orbitals', None, 'qchem'),
('composite', 'B3LYP', 'gaussian'),
('irc', None, 'qchem or gaussian')
]

for job_type, method, missing_software in test_cases:
with self.subTest(job_type=job_type, method=method, missing_software=missing_software):
level = Level(method=method or 'B3LYP', basis='6-311g+(d,f)' if not method else None)
with self.assertRaises(ValueError):
level.deduce_software(job_type=job_type)

def test_lower(self):
"""Test the Level.lower() method"""
level = Level(method='B3LYP',
Expand Down

0 comments on commit 4242e28

Please sign in to comment.