Skip to content

Commit

Permalink
updating 'rotconsts' ref to be compatible with cclib v1.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBNEU committed Mar 20, 2024
1 parent 68737dc commit a798966
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
21 changes: 14 additions & 7 deletions rmgpy/qm/molecule.py
Expand Up @@ -409,18 +409,25 @@ def parse(self):
parser.logger.setLevel(
logging.ERROR
) # cf. http://cclib.sourceforge.net/wiki/index.php/Using_cclib#Additional_information
parser.rotcons = (
[]
) # 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()

# for bacwards compatibility with cclib <1.6
if not hasattr(cclib_data, "rotconsts"):
# this hack required because rotconsts not part of a default cclib data object
parser.rotconsts = (

Check warning on line 419 in rmgpy/qm/molecule.py

View check run for this annotation

Codecov / codecov/patch

rmgpy/qm/molecule.py#L419

Added line #L419 was not covered by tests
[]
) # give it an attribute and it won't delete it, leaving it on the parser object

cclib_data.rotconsts = (

Check warning on line 423 in rmgpy/qm/molecule.py

View check run for this annotation

Codecov / codecov/patch

rmgpy/qm/molecule.py#L423

Added line #L423 was not covered by tests
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')

Check warning on line 104 in rmgpy/qm/qmdata.py

View check run for this annotation

Codecov / codecov/patch

rmgpy/qm/qmdata.py#L104

Added line #L104 was not covered by tests

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

Expand Down

0 comments on commit a798966

Please sign in to comment.