Skip to content

Commit 47e73c5

Browse files
committed
Warn if 'year' is specified on non-Arkane levels
The 'year' attribute is only consumed when part of arkane_level_of_theory for database matching. This adds a warning if it is specified for other job levels (e.g., sp_level, opt_level) where it is currently ignored.
1 parent 33f5046 commit 47e73c5

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

arc/main.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ def __init__(self,
406406
self.job_types['opt'] = True # Run the optimizations, self.fine_only will make sure that they are fine.
407407

408408
self.set_levels_of_theory() # All level of theories should be Level types after this call.
409+
self._warn_year_on_non_arkane_levels()
409410
if self.thermo_adapter == 'arkane':
410411
self.check_arkane_level_of_theory()
411412

@@ -1155,6 +1156,20 @@ def process_level_of_theory(self):
11551156

11561157
self.level_of_theory = '' # Reset the level_of_theory argument to avoid conflicts upon restarting ARC.
11571158

1159+
def _warn_year_on_non_arkane_levels(self):
1160+
"""
1161+
Warn if ``year`` was specified on any Level other than ``arkane_level_of_theory``.
1162+
The ``year`` attribute only affects Arkane database matching and is ignored elsewhere.
1163+
"""
1164+
for attr_name in ('sp_level', 'opt_level', 'freq_level', 'scan_level', 'irc_level',
1165+
'conformer_opt_level', 'conformer_sp_level', 'orbitals_level'):
1166+
level = getattr(self, attr_name, None)
1167+
if isinstance(level, Level) and level.year is not None:
1168+
logger.warning(
1169+
f'The "year" attribute on {attr_name} ({level.simple()}) has no effect. '
1170+
f'Year is only used for Arkane database matching via arkane_level_of_theory.'
1171+
)
1172+
11581173
def check_arkane_level_of_theory(self):
11591174
"""
11601175
Check that the level of theory has AEC in Arkane.

arc/main_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,23 @@ def test_determine_model_chemistry_for_job_types(self):
340340
self.assertEqual(arc14.freq_level.simple(), 'pm6')
341341
self.assertEqual(arc14.sp_level.simple(), 'amber')
342342

343+
# Test explicit year in arkane_level_of_theory dictionary
344+
arc15 = ARC(project='test',
345+
sp_level='wb97xd/def2tzvp',
346+
opt_level='wb97xd/def2tzvp',
347+
arkane_level_of_theory={'method': 'wb97xd', 'basis': 'def2tzvp', 'year': 2023},
348+
bac_type=None,
349+
calc_freq_factor=False, compute_thermo=False)
350+
self.assertEqual(arc15.arkane_level_of_theory.year, 2023)
351+
352+
# Test warning when year is specified on sp_level instead of arkane_level_of_theory
353+
with self.assertLogs('arc', level='WARNING') as cm:
354+
ARC(project='test',
355+
sp_level={'method': 'wb97xd', 'basis': 'def2tzvp', 'year': 2023},
356+
opt_level='wb97xd/def2tzvp',
357+
calc_freq_factor=False, compute_thermo=False)
358+
self.assertTrue(any('year' in msg and 'sp_level' in msg for msg in cm.output))
359+
343360
def test_determine_unique_species_labels(self):
344361
"""Test the determine_unique_species_labels method"""
345362
spc0 = ARCSpecies(label='spc0', smiles='CC', compute_thermo=False)

0 commit comments

Comments
 (0)