Skip to content

Commit a896980

Browse files
committed
Merge pull request #212 from connie/thermoGroups
Fixing thermo group corrections for cyclics
2 parents 82e60c6 + 5b292eb commit a896980

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

rmgpy/data/thermo.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ def estimateThermoViaGroupAdditivity(self, molecule):
878878
return self.estimateRadicalThermoViaHBI(molecule, self.estimateThermoViaGroupAdditivity )
879879

880880
else: # non-radical species
881+
cyclic = molecule.isCyclic()
881882
# Generate estimate of thermodynamics
882883
for atom in molecule.atoms:
883884
# Iterate over heavy (non-hydrogen) atoms
@@ -891,9 +892,10 @@ def estimateThermoViaGroupAdditivity(self, molecule):
891892
logging.error(molecule.toAdjacencyList())
892893
raise
893894
# Correct for gauche and 1,5- interactions
894-
try:
895-
self.__addGroupThermoData(thermoData, self.groups['gauche'], molecule, {'*':atom})
896-
except KeyError: pass
895+
if not cyclic:
896+
try:
897+
self.__addGroupThermoData(thermoData, self.groups['gauche'], molecule, {'*':atom})
898+
except KeyError: pass
897899
try:
898900
self.__addGroupThermoData(thermoData, self.groups['int15'], molecule, {'*':atom})
899901
except KeyError: pass
@@ -904,7 +906,7 @@ def estimateThermoViaGroupAdditivity(self, molecule):
904906
# Do ring corrections separately because we only want to match
905907
# each ring one time
906908

907-
if molecule.isCyclic():
909+
if cyclic:
908910
if molecule.getAllPolycyclicVertices():
909911
# If the molecule has fused ring atoms, this implies that we are dealing
910912
# with a polycyclic ring system, for which separate ring strain corrections may not
@@ -923,21 +925,14 @@ def estimateThermoViaGroupAdditivity(self, molecule):
923925
for ring in rings:
924926
# Make a temporary structure containing only the atoms in the ring
925927
# NB. if any of the ring corrections depend on ligands not in the ring, they will not be found!
926-
ringCorrection = None
927-
for atom in ring:
928+
try:
929+
self.__addGroupThermoData(thermoData, self.groups['ring'], molecule, {})
930+
except KeyError:
931+
logging.error("Couldn't find in ring database:")
932+
logging.error(ring)
933+
logging.error(ring.toAdjacencyList())
934+
raise
928935

929-
try:
930-
correction = self.__addGroupThermoData(None, self.groups['ring'], molecule, {'*':atom})
931-
except KeyError:
932-
logging.error("Couldn't find in ring database:")
933-
logging.error(ring)
934-
logging.error(ring.toAdjacencyList())
935-
raise
936-
937-
if ringCorrection is None or ringCorrection.H298.value_si < correction.H298.value_si:
938-
ringCorrection = correction
939-
940-
self.__addThermoData(thermoData, ringCorrection)
941936

942937
# Correct entropy for symmetry number
943938
molecule.calculateSymmetryNumber()
@@ -994,12 +989,12 @@ def __addGroupThermoData(self, thermoData, database, molecule, atom):
994989
data.comment = '{0}({1})'.format(database.label, comment)
995990

996991
# This code prints the hierarchy of the found node; useful for debugging
997-
#result = ''
998-
#while node is not None:
999-
# result = ' -> ' + node + result
1000-
# node = database.tree.parent[node]
1001-
#print result[4:]
1002-
992+
# result = ''
993+
# while node is not None:
994+
# result = ' -> ' + node.label + result
995+
# node = node.parent
996+
# print result[4:]
997+
1003998
if thermoData is None:
1004999
return data
10051000
else:

0 commit comments

Comments
 (0)