Skip to content

Commit fae9bc3

Browse files
committed
Formats ORCA method and basis set strings
Normalizes method strings to ORCA-friendly labels and addresses the wb97xd deprecation by suggesting alternatives. Formats basis set strings to ORCA formatting (e.g., def2tzvp -> def2-TZVP). Fixed the opt and fine opt keywords to be more inline with 5.0.4 - 6.0.0
1 parent 741fa26 commit fae9bc3

1 file changed

Lines changed: 51 additions & 5 deletions

File tree

arc/job/adapters/orca.py

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,52 @@
3232

3333
logger = get_logger()
3434

35+
ORCA_METHOD_ALIASES = {
36+
'wb97x-d3': 'wb97x-d3',
37+
'wb97xd3': 'wb97x-d3',
38+
}
39+
40+
41+
def _format_orca_method(method: str) -> str:
42+
"""
43+
Convert ARC method names to ORCA-friendly labels when needed.
44+
"""
45+
if not method:
46+
return method
47+
if method.lower() == 'wb97xd':
48+
logger.warning('ORCA does not support wb97xd; use wb97x or wb97x-d3. '
49+
'wb97xd3 will be normalized to wb97x-d3.')
50+
return ORCA_METHOD_ALIASES.get(method.lower(), method)
51+
52+
53+
def _format_orca_basis_token(token: str) -> str:
54+
"""
55+
Convert def2 basis tokens to ORCA formatting (e.g., def2tzvp -> def2-TZVP).
56+
"""
57+
if not token:
58+
return token
59+
parts = token.split('/')
60+
base = parts[0]
61+
if base.lower().startswith('def2'):
62+
base_rest = base[4:]
63+
if base_rest.startswith('-'):
64+
base_rest = base_rest[1:]
65+
if base_rest:
66+
base = f"def2-{base_rest.lower()}"
67+
if len(parts) > 1:
68+
parts = [base] + [part.lower() for part in parts[1:]]
69+
return '/'.join(parts)
70+
return base
71+
72+
73+
def _format_orca_basis(basis: str) -> str:
74+
"""
75+
Convert basis strings to ORCA-friendly labels where applicable.
76+
"""
77+
if not basis:
78+
return basis
79+
return ' '.join(_format_orca_basis_token(token) for token in basis.split())
80+
3581
default_job_settings, global_ess_settings, input_filenames, output_filenames, servers, submit_filenames = \
3682
settings['default_job_settings'], settings['global_ess_settings'], settings['input_filenames'], \
3783
settings['output_filenames'], settings['servers'], settings['submit_filenames']
@@ -219,13 +265,13 @@ def write_input_file(self) -> None:
219265
'keywords',
220266
]:
221267
input_dict[key] = ''
222-
input_dict['auxiliary_basis'] = self.level.auxiliary_basis or ''
223-
input_dict['basis'] = self.level.basis or ''
268+
input_dict['auxiliary_basis'] = _format_orca_basis(self.level.auxiliary_basis or '')
269+
input_dict['basis'] = _format_orca_basis(self.level.basis or '')
224270
input_dict['charge'] = self.charge
225271
input_dict['cpus'] = self.cpu_cores
226272
input_dict['label'] = self.species_label
227273
input_dict['memory'] = self.input_file_memory
228-
input_dict['method'] = self.level.method
274+
input_dict['method'] = _format_orca_method(self.level.method)
229275
input_dict['multiplicity'] = self.multiplicity
230276
input_dict['xyz'] = xyz_to_str(self.xyz)
231277

@@ -241,9 +287,9 @@ def write_input_file(self) -> None:
241287
input_dict['method_class'] = 'KS'
242288
# DFT grid must be the same for both opt and freq
243289
if self.fine:
244-
self.add_to_args(val='Grid6 NoFinalGrid', key1='keyword')
290+
self.add_to_args(val='defgrid3', key1='keyword')
245291
else:
246-
self.add_to_args(val='Grid5 NoFinalGrid', key1='keyword')
292+
self.add_to_args(val='defgrid2', key1='keyword')
247293
elif self.level.method_type == 'wavefunction':
248294
input_dict['method_class'] = 'HF'
249295
if 'dlpno' in self.level.method:

0 commit comments

Comments
 (0)