Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating 'rotconsts' ref to be compatible with cclib v1.8+ #2639

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion environment.yml
Expand Up @@ -16,6 +16,7 @@
# made dependency list more explicit (@JacksonBurns).
# - October 16, 2023 Switched RDKit and descripatastorus to conda-forge,
# moved diffeqpy to pip and (temporarily) removed chemprop
# - April 17, 2024 Limit versions of cclib at advice of maintainers.
#
name: rmg_env
channels:
Expand Down Expand Up @@ -44,7 +45,8 @@ dependencies:
- coolprop
- cantera::cantera=2.6
- conda-forge::mopac
- conda-forge::cclib >=1.6.3,<1.8.0
# see https://github.com/ReactionMechanismGenerator/RMG-Py/pull/2639#issuecomment-2050292972
- conda-forge::cclib >=1.6.3,<2
- conda-forge::openbabel >= 3
- conda-forge::rdkit >=2022.09.1

Expand Down
27 changes: 18 additions & 9 deletions rmgpy/qm/molecule.py
Expand Up @@ -408,19 +408,28 @@ def parse(self):
parser = self.get_parser(self.output_file_path)
parser.logger.setLevel(
logging.ERROR
) # cf. http://cclib.sourceforge.net/wiki/index.php/Using_cclib#Additional_information
parser.rotcons = (
) # cf. https://cclib.github.io/index.html#how-to-use-cclib
parser.molmass = None # give it an attribute and it won't delete it, leaving it on the parser object
parser.rotcons = ( # for cclib < 1.8.0
[]
) # give it an attribute and it won't delete it, leaving it on the parser object
parser.molmass = None # give it an attribute and it won't delete it, leaving it on the parser object
cclib_data = parser.parse()
)
parser.rotconsts = ( # for cclib >= 1.8.0
[]
)
cclib_data = parser.parse() # fills in either parser.rotcons or parser.rotconsts but not both
assert bool(parser.rotconsts) != bool(parser.rotcons)
if parser.rotcons: # for cclib < 1.8.0
cclib_data.rotcons = (
parser.rotcons
)
else: # for cclib >= 1.8.0
cclib_data.rotconsts = (
parser.rotconsts
)
radical_number = self.molecule.get_radical_count()
cclib_data.rotcons = (
parser.rotcons
) # this hack required because rotcons not part of a default cclib data object
cclib_data.molmass = (
parser.molmass
) # this hack required because rotcons not part of a default cclib data object
) # this hack required because molmass is not part of a default cclib data object
qm_data = parse_cclib_data(
cclib_data, radical_number + 1
) # Should `radical_number+1` be `self.molecule.multiplicity` in the next line of code? It's the electronic ground state degeneracy.
Expand Down
6 changes: 5 additions & 1 deletion rmgpy/qm/qmdata.py
Expand Up @@ -98,7 +98,11 @@ def parse_cclib_data(cclib_data, ground_state_degeneracy):
molecular_mass = None
energy = (cclib_data.scfenergies[-1], 'eV/molecule')
atomic_numbers = cclib_data.atomnos
rotational_constants = (cclib_data.rotcons[-1], 'cm^-1')
if hasattr(cclib_data, 'rotconsts'):
rotational_constants = (cclib_data.rotconsts[-1], 'cm^-1')
else:
rotational_constants = (cclib_data.rotcons[-1], 'cm^-1')

atom_coords = (cclib_data.atomcoords[-1], 'angstrom')
frequencies = (cclib_data.vibfreqs, 'cm^-1')

Expand Down