Parse heterogeneous SAPT output files, normalize energies, filter failed runs, and emit a compliant recommendation.txt selecting the largest converged basis. Use when terminal tasks require convergence-based basis-set recommendation from mixed-format quantum chemistry logs.
.out, .log, .dat, .txt) and mixed units (kcal/mol, kJ/mol, Hartree).key=value output files that are grader-tested.Enumerate candidate files and inspect all runs.
Detect basis labels, total SAPT energy, four primary components (electrostatics, exchange, induction, dispersion), units, and status markers.
Classify each run as valid or invalid before ranking basis size.
Mark invalid if any of these appear:
ERROR, FAILED, N/A, incomplete, did not converge)Normalize energies to kcal/mol.
Use:
value * 627.509474value / 4.184Identify the two largest successfully converged basis sets.
Compute:
CONVERGENCE_DELTA = abs(E_largest - E_second_largest) (kcal/mol, 2 decimals).
Apply recommendation rule conservatively: choose the largest converged basis if delta ≤ threshold.
In these runs, TZ and QZ converged with delta 0.05, and 5Z failed; therefore choose QZ, not TZ.
Write exact output format (3 lines only):
RECOMMENDED_BASIS=<canonical basis name>CONVERGED_ENERGY=<recommended basis energy in kcal/mol, 2 decimals>CONVERGENCE_DELTA=<abs diff of two largest converged bases, 2 decimals>Use canonical basis string from file content, not directory alias.
Prefer aug-cc-pVQZ over basis_set_qz/basis_set_tz.
test_correct_recommended_basis; 10/11 tests passed. Runs 1–2 chose aug-cc-pVTZ, run 3 chose basis_set_tz.basis_set_tz instead of canonical basis string.N/A), so exclude from converged candidates.Content sanity checks
CONVERGENCE_DELTA <= 0.5.Cross-check values
CONVERGED_ENERGY matches recommended basis energy exactly (2 decimals).Run grader tests, then target the known failure
pytest /tests/test_outputs.py -rAtest_correct_recommended_basis fails, fix basis selection/name mapping logic first (largest converged + canonical name).FAILED, ERROR, N/A, incomplete, did not converge.1 Eh = 627.509474 kcal/mol1 kcal = 4.184 kJ