Skip to content

Commit 606bbe2

Browse files
committed
Support independent AEC and BAC keys in the QM corrections script
Updated the logic for retrieving QM corrections to handle separate keys for atom energy corrections (AEC) and bond additivity corrections (BAC). This ensures that corrections can be resolved independently if they are stored under different level-of-theory definitions in the RMG database. Key changes include: - Updated the script to process `aec_key` and `bac_key` independently. - Maintained backward compatibility by using `matched_key` as a fallback for `aec_key`. - Modified BAC retrieval to utilize the dedicated `bac_key`. Support backward compatibility for BAC keys in the QM corrections script Updated the logic for retrieving QM corrections to handle legacy input formats where atom and bond corrections are not defined as independent keys. Key changes include: - Maintained backward compatibility by using `matched_key` as a fallback for `bac_key`, mirroring the existing behavior for `aec_key`.
1 parent 602708a commit 606bbe2

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

arc/scripts/get_qm_corrections.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@ def _lot_from_string(lot_str):
4444
def main(input_path, output_path):
4545
"""Look up AEC and BAC for the given level of theory key."""
4646
params = read_yaml_file(input_path) or {}
47-
matched_key = params.get('matched_key')
4847
bac_type = params.get('bac_type')
4948

5049
result = {'aec': None, 'bac': None}
5150

52-
if not matched_key:
53-
save_yaml_file(output_path, result)
54-
return
51+
# Support both old format (single matched_key) and new format (separate aec_key/bac_key)
52+
aec_key = params.get('aec_key') or params.get('matched_key')
53+
bac_key = params.get('bac_key') or params.get('matched_key')
5554

56-
lot = _lot_from_string(matched_key)
55+
if aec_key:
56+
lot = _lot_from_string(aec_key)
57+
aec = atom_energies.get(lot)
58+
if aec is not None:
59+
result['aec'] = {str(k): float(v) for k, v in aec.items()}
5760

58-
aec = atom_energies.get(lot)
59-
if aec is not None:
60-
result['aec'] = {str(k): float(v) for k, v in aec.items()}
61-
62-
if bac_type in ('p', 'm'):
61+
if bac_key and bac_type in ('p', 'm'):
62+
bac_lot = _lot_from_string(bac_key)
6363
bac_dict = pbac if bac_type == 'p' else mbac
64-
bac = bac_dict.get(lot)
64+
bac = bac_dict.get(bac_lot)
6565
if bac is not None:
6666
result['bac'] = {str(k): float(v) for k, v in bac.items()}
6767

0 commit comments

Comments
 (0)