Skip to content

Add in-memory thermochemistry from PySCF results - #103

Merged
galjos merged 3 commits into
mainfrom
pyscf-thermo
Jul 7, 2026
Merged

Add in-memory thermochemistry from PySCF results#103
galjos merged 3 commits into
mainfrom
pyscf-thermo

Conversation

@galjos

@galjos galjos commented Jul 7, 2026

Copy link
Copy Markdown
Member

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

Add pyscf_thermo(mean_field, ...) which reads the geometry (Bohr ->
Angstrom) and energy (mf.e_tot) from a converged PySCF mean-field object
and runs the RRHO thermochemistry, taking vibrational frequencies directly
or deriving them from a Hessian via pyscf.hessian.thermo. Optional pyscf
extra; pyscf is imported lazily so the core install is unaffected.

Closes #102
@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.22%. Comparing base (09317c4) to head (bc26455).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #103      +/-   ##
==========================================
+ Coverage   97.19%   97.22%   +0.02%     
==========================================
  Files          30       30              
  Lines        1852     1872      +20     
==========================================
+ Hits         1800     1820      +20     
  Misses         52       52              
Flag Coverage Δ
unittests 97.22% <100.00%> (+0.02%) ⬆️

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.

galjos added 2 commits July 7, 2026 14:16
harmonic_analysis defaults to imaginary_freq=True (complex wavenumbers),
which np.real would flatten to ~0 and silently turn a saddle point into a
minimum. Pass imaginary_freq=False so imaginary modes are negative reals,
matching the other engines. Add a skippable real-pyscf test validating the
harmonic_analysis path returns the 3N-6 real vibrational modes for water.
Intercept the import itself instead of a sys.modules sentinel, which a
prior import of pyscf.hessian.thermo (e.g. the real integration test) would
defeat via the fromlist hasattr shortcut.
@galjos
galjos merged commit 88f3db1 into main Jul 7, 2026
5 checks passed
@galjos
galjos deleted the pyscf-thermo branch July 7, 2026 12:25
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.

In-memory thermochemistry from PySCF results

1 participant