Skip to content

Commit 6b0a074

Browse files
committed
rmgpy.data.thermo.getAllThermoData once again returns a list of tuples.
This is currently required by the website. Hopefully this fixes the website without breaking anything else. Only getThermoDataFromLibraries and getThermoDataFromDepository return tuples. (What does getThermoDataFromDepository do? should it exist?)
1 parent 42eeeac commit 6b0a074

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

rmgpy/data/thermo.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,10 @@ def getThermoData(self, species):
604604
"""
605605
# Check the libraries in order first; return the first successful match
606606
thermoData = self.getThermoDataFromLibraries(species)
607-
if thermoData is None:
607+
if thermoData is not None:
608+
assert len(thermoData)==3, "thermoData should be a tuple at this point, eg. (thermoData, library, entry)"
609+
thermoData = thermoData[0]
610+
else:
608611
# Thermo not found in any loaded libraries, so estimate
609612
thermoData = self.getThermoDataFromGroups(species)
610613

@@ -631,7 +634,8 @@ def getThermoDataFromLibraries(self, species):
631634
for label in self.libraryOrder:
632635
thermoData = self.getThermoDataFromLibrary(species, self.libraries[label])
633636
if thermoData is not None:
634-
thermoData.comment = label
637+
assert len(thermoData) == 3, "thermoData should be a tuple at this point"
638+
thermoData[0].comment += label
635639
return thermoData
636640
return None
637641

@@ -657,7 +661,8 @@ def getAllThermoData(self, species):
657661
first, then the libraries (in order), and then the group additivity
658662
estimate. This method is useful for a generic search job.
659663
660-
Returns: a list of ThermoData
664+
Returns: a list of tuples (ThermoData, source, entry)
665+
(Source is a library or depository, or None)
661666
"""
662667
thermoDataList = []
663668
# Data from depository comes first
@@ -666,10 +671,13 @@ def getAllThermoData(self, species):
666671
for label in self.libraryOrder:
667672
data = self.getThermoDataFromLibrary(species, self.libraries[label])
668673
if data:
669-
data.comment = label
674+
assert len(data) == 3, "thermoData should be a tuple at this point"
675+
data[0].comment += label
670676
thermoDataList.append(data)
671677
# Last entry is always the estimate from group additivity
672-
thermoDataList.append(self.getThermoDataFromGroups(species))
678+
# Make it a tuple
679+
data = (self.getThermoDataFromGroups(species), None, None)
680+
thermoDataList.append(data)
673681

674682
# Return all of the resulting thermo parameters
675683
return thermoDataList
@@ -704,14 +712,14 @@ def getThermoDataFromLibrary(self, species, library):
704712
``None`` is returned. If no corresponding library is found, a
705713
:class:`DatabaseError` is raised.
706714
707-
Returns: ThermoData
715+
Returns a tuple: (ThermoData, library, entry) or None.
708716
"""
709717
for label, entry in library.entries.iteritems():
710718
for molecule in species.molecule:
711719
if molecule.isIsomorphic(entry.item) and entry.data is not None:
712720
thermoData = deepcopy(entry.data)
713721
self.findCp0andCpInf(species, thermoData)
714-
return thermoData
722+
return (thermoData, library, entry)
715723
return None
716724

717725
def getThermoDataFromGroups(self, species):
@@ -721,6 +729,9 @@ def getThermoDataFromGroups(self, species):
721729
additivity values. If no group additivity values are loaded, a
722730
:class:`DatabaseError` is raised.
723731
732+
The resonance isomer (molecule) with the lowest H298 is used, and as a side-effect
733+
the resonance isomers (items in `species.molecule` list) are sorted in ascending order.
734+
724735
Returns: ThermoData
725736
"""
726737
thermo = []

rmgpy/rmg/model.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,17 @@ def __reduce__(self):
7878

7979
def generateThermoData(self, database, thermoClass=NASA, quantumMechanics=None):
8080
"""
81-
Generates thermo data, using either QM or Database.
81+
Generates thermo data, first checking Libraries, then using either QM or Database.
8282
83-
If quantumMechanics is not None, it is aksed to calculate the thermo.
83+
If quantumMechanics is not None, it is asked to calculate the thermo.
8484
Failing that, the database is used.
8585
86-
The database enerates the thermo data for each structure (resonance isomer),
86+
The database generates the thermo data for each structure (resonance isomer),
8787
picks that with lowest H298 value.
8888
89-
It then calls :meth:`processThermoData`.
89+
It then calls :meth:`processThermoData`, to convert (via Wilhoit) to NASA
90+
and set the E0.
91+
9092
Result stored in `self.thermo` and returned.
9193
"""
9294
thermo0 = None
@@ -95,6 +97,8 @@ def generateThermoData(self, database, thermoClass=NASA, quantumMechanics=None):
9597

9698
if thermo0 is not None:
9799
logging.info("Found thermo for {0} in thermo library".format(self.label))
100+
assert len(thermo0) == 3, "thermo0 should be a tuple at this point: (thermoData, library, entry)"
101+
thermo0 = thermo0[0]
98102

99103
elif quantumMechanics:
100104
molecule = self.molecule[0]

0 commit comments

Comments
 (0)