Skip to content

Conversation

@manvirsingh01
Copy link

@manvirsingh01 manvirsingh01 commented Jan 23, 2026

Fix ORCA file handling error in CondensedConceptualDFT.from_file()

This PR fixes #57, where ORCA-generated .wfn and .mkl files caused a runtime crash when loaded using CondensedConceptualDFT.from_file().

Issue

ORCA output files do not include total energy information. However, get_dict_energy() assumed molecule.energy was always present, leading to the following error:

TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

Solution

  • Added explicit validation in get_dict_energy() to check whether molecule.energy is None
  • Raises a clear and user-friendly ValueError explaining the limitation
  • Guides users to prefer .fchk files or alternative conversion workflows
  • Added a dedicated test case to cover this scenario

Changes

  • chemtools/toolbox/utils.py: Added energy availability validation
  • chemtools/toolbox/test/test_utils.py: Added regression test for missing energy data

Testing

  • Syntax and static checks passed
  • Full test suite requires the optional horton dependency

- Added validation in get_dict_energy() to check if molecule.energy is None
- Raises clear ValueError with guidance for users using ORCA files (.wfn, .mkl)
- Added test case for the new validation
- ORCA files don't contain total energy, so users are directed to use .fchk files
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.

1 participant