Skip to content

Import QM outputs (Gaussian, Turbomole, ORCA, ...) via cclib - #101

Merged
galjos merged 2 commits into
mainfrom
cclib-qm-import
Jul 7, 2026
Merged

Import QM outputs (Gaussian, Turbomole, ORCA, ...) via cclib#101
galjos merged 2 commits into
mainfrom
cclib-qm-import

Conversation

@galjos

@galjos galjos commented Jul 7, 2026

Copy link
Copy Markdown
Member

Consume DFT frequency calculations from many programs through cclib, which auto-detects the format — so Gaussian and Turbomole (and ORCA, Psi4, NWChem, …) are covered by one reader.

  • Optional qm extra (pip install thermoscreening[qm] → cclib). cclib is imported lazily, so import ThermoScreening, the core deps, and the conda-forge recipe are all unchanged; a clear error asks for the extra when it's missing.
  • read_cclib(path)(ase.Atoms, frequencies cm⁻¹, energy Hartree) using cclib's atomcoords (Å), vibfreqs (cm⁻¹) and the best available energy (ccenergiesmpenergiesscfenergies, converted eV → Hartree).
  • cclib_thermo(output_file, energy=None, ...) runs the RRHO thermochemistry via run_thermo (energy defaults to cclib's, overridable).

So reduction_potential(cclib_thermo("ox.log"), cclib_thermo("red.log")) works for a Gaussian (or Turbomole/ORCA/…) redox pair on DFT energetics.

Verified against cclib 1.8.1's documented units (atomcoords Å, vibfreqs cm⁻¹, scfenergies eV). Tested (parse + eV→Hartree, energy priority cc/mp/scf, unparseable/no-frequency/missing-dependency errors, end-to-end cclib_thermo + override + requires-energy). Docs + full patch coverage on the new code.

Closes #100

Add an optional `qm` extra (cclib) and a cclib-backed reader that consumes a
frequency calculation from any cclib-supported program (Gaussian, Turbomole,
ORCA, Psi4, NWChem, ...):

- read_cclib(path) -> (ase.Atoms, frequencies cm^-1, energy Hartree), using
  cclib's atomcoords (Angstrom), vibfreqs (cm^-1) and best available energy
  (ccenergies/mpenergies/scfenergies, converted eV -> Hartree).
- cclib_thermo(output_file, energy=None, ...) runs the RRHO thermochemistry
  via run_thermo (energy defaults to cclib's, overridable).

cclib is imported lazily, so the core install (and the conda-forge recipe) is
unchanged; a clear error asks for `thermoscreening[qm]` when it's absent.

Closes #100
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.19%. Comparing base (d405b01) to head (d32977a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #101      +/-   ##
==========================================
+ Coverage   97.12%   97.19%   +0.06%     
==========================================
  Files          29       30       +1     
  Lines        1811     1852      +41     
==========================================
+ Hits         1759     1800      +41     
  Misses         52       52              
Flag Coverage Δ
unittests 97.19% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cclib 2.0 is a breaking rearchitecture (data model / units); cap the qm
(and test) extra below it since the reader targets the 1.x model. Note in
read_cclib that cclib supplies only the real modes, so the geometry's
linearity classification must match the QM program's mode count.
@galjos
galjos merged commit 09317c4 into main Jul 7, 2026
5 checks passed
@galjos
galjos deleted the cclib-qm-import branch July 7, 2026 12:07
galjos added a commit that referenced this pull request Jul 7, 2026
PySCF is a Python library, so its results are in memory rather than a
file. This adds `pyscf_thermo(mean_field, ...)` to complete the
QM-import set (Gaussian/Turbomole/ORCA via cclib in #101; ORCA `.hess`
in #99).

- Reads the geometry (Bohr → Å) and energy (`mean_field.e_tot`) from a
converged PySCF mean-field object.
- Vibrational frequencies come from `frequencies=` (cm⁻¹) or are derived
from `hessian=` via `pyscf.hessian.thermo.harmonic_analysis`.
- Optional `pyscf` extra (`pip install thermoscreening[pyscf]`); **pyscf
is imported lazily** so the core install and conda-forge recipe are
unaffected, with a clear error when it's needed but missing.

So `reduction_potential(pyscf_thermo(mf_ox, hessian=h_ox),
pyscf_thermo(mf_red, hessian=h_red))` works for a PySCF redox pair.

Tested with a duck-typed fake mean field (no real pyscf needed):
frequencies path + energy-from-`e_tot`, energy override, the hessian
branch (helper mocked), the requires-frequencies-or-hessian error, and
the missing-pyscf error (forced via `sys.modules`). Docs + full patch
coverage.

Closes #102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import QM outputs (Gaussian, Turbomole, ORCA, ...) via cclib

1 participant