def testThermoRestart(self): """ Restart tests for the :class:`rmg.thermo.ThermoGAData`, :class:`rmg.thermo.ThermoWilhoitData`, and :class:`rmg.thermo.ThermoNASAData` classes. """ import rmg.thermo as thermo # Create thermoGAData0 = thermo.ThermoGAData(H298=-3.08, S298=64.27, Cp=[12.28, 14.34, 16.30, 18.05, 20.92, 23.08, 26.39], comment='acetyl') thermoWilhoitData0 = thermo.convertGAtoWilhoit(thermoGAData0, 6, 1, False) thermoNASAData0 = thermo.convertWilhoitToNASA(thermoWilhoitData0) # Pickle f = open('test.pkl', 'wb'); cPickle.dump(thermoGAData0, f) cPickle.dump(thermoWilhoitData0, f) cPickle.dump(thermoNASAData0, f) f.close() # Unpickle f = open('test.pkl', 'rb') thermoGAData = cPickle.load(f) thermoWilhoitData = cPickle.load(f) thermoNASAData = cPickle.load(f) f.close() # Compare self.assertTrue(thermoGAData0.equals(thermoGAData)) self.assertTrue(thermoWilhoitData0.equals(thermoWilhoitData)) self.assertTrue(thermoNASAData0.equals(thermoNASAData))
def testOxygenFromGA(self): """Check conversion of GA values for molecular oxygen to NASA form """ oxygen = structure.Structure(SMILES='O=O') oxygen.updateAtomTypes() GAthermoData = species.getThermoData(oxygen,thermoClass=thermo.ThermoGAData) WilhoitData = thermo.convertGAtoWilhoit(GAthermoData, atoms=2, rotors=0, linear=True) print WilhoitData NASAthermoData = thermo.convertWilhoitToNASA(WilhoitData)
def testEntropy(self): """Check the Wilhoit S matches the GA S for propane. Uses Propane as a test-case. atoms=11, rotors=2, linear=False """ propane = structure.Structure(SMILES='CCC') propane.updateAtomTypes() GAthermoData = species.getThermoData(propane,thermoClass=thermo.ThermoGAData) WilhoitData = thermo.convertGAtoWilhoit(GAthermoData, atoms=11, rotors=2, linear=False) Tlist = thermo.ThermoGAData.CpTlist # just check at defined data points for T in Tlist: ga = GAthermoData.getEntropy(T) wil = WilhoitData.getEntropy(T) err = abs(ga-wil) limit = 4.0 # J/mol/K self.assertTrue(err<limit,"GA (%.1f) and Wilhoit (%.1f) differ by more than %s J/mol/K at %dK"%(ga,wil,limit,T))
def testEnthalpy(self): """Check the Wilhoit H matches the GA H for propane. Uses Propane as a test-case. atoms=11, rotors=2, linear=False """ propane = structure.Structure(SMILES='CCC') propane.updateAtomTypes() GAthermoData = species.getThermoData(propane,thermoClass=thermo.ThermoGAData) WilhoitData = thermo.convertGAtoWilhoit(GAthermoData, atoms=11, rotors=2, linear=False) Tlist = thermo.ThermoGAData.CpTlist # just check at defined data points for T in Tlist: ga = GAthermoData.getEnthalpy(T) wil = WilhoitData.getEnthalpy(T) err = abs(ga-wil) limit = 2000.0 # J/mol # the wilhoit should be more accurate then trapezoid integration of GA, so wouldn't want them to be exactly the same self.assertTrue(err<limit,"GA (%.1f) and Wilhoit (%.1f) differ by more than %s J/mol at %dK"%(ga,wil,limit,T))
def testHeatCapacity(self): """Check the NASA Cp matches the GA Cp for propane. Uses Propane as a test-case. atoms=11, rotors=2, linear=False """ propane = structure.Structure(SMILES='CCC') propane.updateAtomTypes() GAthermoData = species.getThermoData(propane,thermoClass=thermo.ThermoGAData) WilhoitData = thermo.convertGAtoWilhoit(GAthermoData, atoms=11, rotors=2, linear=False) NASAthermoData = thermo.convertWilhoitToNASA(WilhoitData) Tlist = thermo.ThermoGAData.CpTlist # just check at defined data points for T in Tlist: ga = GAthermoData.getHeatCapacity(T) nasa = NASAthermoData.getHeatCapacity(T) err = abs(ga-nasa) limit = 10.0 # J/mol/K self.assertTrue(err<limit,"GA (%.1f) and NASA (%.1f) differ by more than %s J/mol/K at %dK"%(ga,nasa,limit,T))
def testOxygenFromGA2(self): """Check conversion of current GA values for molecular oxygen to Wilhoit form This is an attempt to test a discrepancy between results on Greg's Windows computer (same in both C- and pure-python modes) and Josh's Linux computer (C-mode) Discrepancy could be during the numerically intensive step (which this tests) or the computation of the group values (which a unit test below tests) """ #the following values come from Greg's Windows computer; Josh's scaled result for thermoWilhoitData is thermo.ThermoWilhoitData(3.5,4.5,-2.343,32.54,-79.26,47.75,8951,-18.19, B=0.5) GAthermoData = thermo.ThermoGAData(H298=0.0, S298=205.026767175, Cp=[29.288, 30.208480000000002, 31.128960000000003, 32.007600000000004, 33.764880000000005, 34.936399999999999, 36.484480000000005], index="+1096+++0+1096+++0") WilhoitData = thermo.convertGAtoWilhoit(GAthermoData, atoms=2, rotors=0, linear=True) limit = 0.01 #relative error limit (0.01=1%) a0e = -0.9324 a0re = abs(WilhoitData.a0-a0e)/abs(a0e) self.assertTrue(a0re<limit,"Actual (%.8f) and expected (%.8f) differ by more than %s"%(WilhoitData.a0,a0e,limit*a0e)) a1e = 26.18 a1re = abs(WilhoitData.a1-a1e)/abs(a1e) self.assertTrue(a1re<limit,"Actual (%.8f) and expected (%.8f) differ by more than %s"%(WilhoitData.a1,a1e,limit*a1e)) a2e = -70.47 a2re = abs(WilhoitData.a2-a2e)/abs(a2e) self.assertTrue(a2re<limit,"Actual (%.8f) and expected (%.8f) differ by more than %s"%(WilhoitData.a2,a2e,limit*a2e)) a3e = 44.12 a3re = abs(WilhoitData.a3-a3e)/abs(a3e) self.assertTrue(a3re<limit,"Actual (%.8f) and expected (%.8f) differ by more than %s"%(WilhoitData.a3,a3e,limit*a3e))
def testWilhoitCreated(self): """Can we make Wilhoit polynomial data""" GAthermoData = thermo.ThermoGAData(0, 0, [10, 20, 30, 40, 60, 80, 130.0]) WilhoitData = thermo.convertGAtoWilhoit(GAthermoData, atoms=2, rotors=0, linear=True ) self.assertTrue(isinstance(WilhoitData,thermo.ThermoWilhoitData),"Didn't make ThermoWilhoitData instance") self.assertTrue(isinstance(WilhoitData,thermo.ThermoData),"Didn't make any kind of ThermoData instance")