Skip to content

Fix read_orca_hess silently returning energy=0.0 for ordinary jobs - #108

Merged
galjos merged 2 commits into
mainfrom
fix-orca-energy-parsing
Jul 8, 2026
Merged

Fix read_orca_hess silently returning energy=0.0 for ordinary jobs#108
galjos merged 2 commits into
mainfrom
fix-orca-energy-parsing

Conversation

@galjos

@galjos galjos commented Jul 8, 2026

Copy link
Copy Markdown
Member

Found by running a real ORCA 6.1.1 calculation (water, HF/STO-3G, Freq) — the first time this reader (added in #99) was tested against genuine ORCA output rather than a hand-written synthetic .hess.

The bug

$act_energy in the .hess file is 0.000000 for an ordinary geometry-optimization + frequency job. Confirmed from the real file: $act_atom/$act_coord are also 0 — these three fields together describe the active point of a relaxed surface scan, and ORCA only populates them meaningfully for scan jobs. A plain .hess carries no reliable electronic energy at all.

read_orca_hess treated $act_energy as the energy unconditionally, so a real-world .hess (without an explicit energy= override) silently returned 0.0 Hartree instead of the true SCF/DFT energy — wrong thermochemistry, no error. My original synthetic test fixture had a plausible fake nonzero $act_energy, which is exactly why this went undetected.

The fix

Prefer the companion <basename>.property.txt file ORCA writes alongside every .hess ($Single_Point_Data / &FinalEnergy — ORCA's own machine-readable output, verified against the real file to match the .out log's "FINAL SINGLE POINT ENERGY" to full precision). Fall back to a nonzero $act_energy (genuine relaxed-scan use). Otherwise None — same contract as before, still requires an explicit energy= from the caller.

Verification

Captured the real water_freq.hess + water_freq.property.txt from that ORCA run and committed them as test fixtures (tests/data/calculator/orca/). New tests: exact energy match against real output, full orca_thermo end-to-end (entropy lands at 45.06 cal/mol/K — right at the well-known experimental value for gas-phase water), a direct regression test for the exact bug (literal 0.0 $act_energy without a property file → None, not 0.0), property-file-wins-over-act_energy, and the property-file-present-but-empty fallback. All 18 tests in the file pass, full suite passes (371 passed, 12 skipped — the skips are pre-existing, DFTB+/xtb-binary-gated), 100% patch coverage on orca.py.

Closes #107

Verified against a real ORCA 6.1.1 calculation (water, HF/STO-3G, Freq):
$act_energy in the .hess file is 0.000000 for an ordinary geometry
optimization + frequency job. It is a relaxed-surface-scan field
(alongside $act_atom/$act_coord, both 0 here too) that ORCA only
populates meaningfully for scan jobs, so a plain .hess carries no
reliable electronic energy for the common case.

read_orca_hess previously treated $act_energy as the energy unconditionally,
so a real ORCA .hess (without an explicit energy= override) silently
returned 0.0 Hartree instead of the true SCF/DFT energy -- wrong
thermochemistry with no error. The bug went undetected because the
existing test fixture was a hand-written synthetic .hess with a
plausible nonzero $act_energy.

Fix: prefer the companion <basename>.property.txt file ORCA writes
alongside the .hess ($Single_Point_Data / &FinalEnergy, its own
machine-readable output); fall back to a nonzero $act_energy (for
relaxed-scan use); otherwise None (unchanged contract, still requires an
explicit energy= from the caller).

Add the real captured water_freq.hess + water_freq.property.txt as test
fixtures and a regression test reproducing the exact bug (a literal 0.0
$act_energy without a property file must not be read as a real energy).

Closes #107
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.27%. Comparing base (3c30da7) to head (49702b8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
+ Coverage   97.25%   97.27%   +0.02%     
==========================================
  Files          31       31              
  Lines        1895     1910      +15     
==========================================
+ Hits         1843     1858      +15     
  Misses         52       52              
Flag Coverage Δ
unittests 97.27% <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.

Review nit: the docstring and the 'no energy' error still described the
old (incorrect) $act_energy-only model. Point at the companion
.property.txt file instead.
@galjos
galjos merged commit bcb49f1 into main Jul 8, 2026
5 checks passed
@galjos
galjos deleted the fix-orca-energy-parsing branch July 8, 2026 10:15
galjos added a commit that referenced this pull request Jul 8, 2026
Small docs-only addition following the ORCA/Gaussian/Turbomole
real-software validation work (#108, #110, #112): a brief note in the
QM-import usage section stating that `orca_thermo`/`cclib_thermo` are
validated against genuine program output, and that unparseable files
raise `TSValueError` rather than an arbitrary parser exception.

Verified by building the docs locally and visually checking the rendered
note (Furo's styled admonition) in the browser. No code changes.
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.

read_orca_hess silently returns energy=0.0 for ordinary (non-scan) jobs

1 participant