Exemple #1
0
def getThermoData(struct, thermoClass=thermo.ThermoNASAData): # ThermoGAData
	"""
	Get the thermodynamic data associated with `structure` by looking in the
	loaded thermodynamic database.

	`thermoClass` is the class of thermo object you want returning; default
	is :class:`ThermoNASAData`
	"""
	import constants
	import math

	GAthermoData = thermoDatabase.getThermoData(struct)

	# Correct entropy for symmetry number
	struct.calculateSymmetryNumber()
	GAthermoData.S298 -= constants.R * math.log(struct.symmetryNumber)

	logging.debug('Group-additivity thermo data: %s' % GAthermoData)

	if thermoClass == thermo.ThermoGAData:
		return GAthermoData  # return here because Wilhoit conversion not wanted

	# Convert to Wilhoit
	rotors = struct.calculateNumberOfRotors()
	atoms = len(struct.atoms())
	linear = struct.isLinear()
	WilhoitData = thermo.convertGAtoWilhoit(GAthermoData,atoms,rotors,linear)

	logging.debug('Wilhoit thermo data: %s' % WilhoitData)

	if thermoClass == thermo.ThermoWilhoitData:
		return WilhoitData

	# Convert to NASA
	NASAthermoData = thermo.convertWilhoitToNASA(WilhoitData)

	logging.debug('NASA thermo data: %s' % NASAthermoData)

	# compute the error for the entire conversion, printing it as info or warning (if it is sufficiently high)
	rmsErr = NASAthermoData.rmsErr(GAthermoData)
	if(rmsErr > 0.35):
	    logging.warning("Poor overall GA-to-NASA fit: Overall RMS error in heat capacity fit = %.3f*R." % (rmsErr))
	else:
	    logging.debug("Overall RMS error in heat capacity fit = %.3f*R" % (rmsErr))

	if thermoClass == thermo.ThermoNASAData:
		return NASAthermoData

	# Still not returned?
	raise Exception("Cannot convert themo data into class %r"%(required_class))
Exemple #2
0
def getThermoData(struct, required_class=thermo.ThermoNASAData): # ThermoGAData
	"""
	Get the thermodynamic data associated with `structure` by looking in the
	loaded thermodynamic database.

	`required_class` is the class of thermo object you want returning; default
	is :class:`ThermoNASAData`
	"""
	import constants
	import math

	GAthermoData = thermoDatabase.getThermoData(struct)

	# Correct entropy for symmetry number
	struct.calculateSymmetryNumber()
	GAthermoData.S298 -= constants.R * math.log(struct.symmetryNumber)

	if required_class==thermo.ThermoGAData:
		return GAthermoData  # return here because Wilhoit conversion not wanted

	# Convert to Wilhoit
	rotors = struct.calculateNumberOfRotors()
	atoms = len(struct.atoms())
	linear = struct.isLinear()
	WilhoitData = thermo.convertGAtoWilhoit(GAthermoData,atoms,rotors,linear)

	if required_class==thermo.ThermoWilhoitData:
		return WilhoitData

	# Convert to NASA
	NASAthermoData = thermo.convertWilhoitToNASA(WilhoitData)

	if required_class==thermo.ThermoNASAData:
		return NASAthermoData

	# Still not returned?
	raise Exception("Cannot convert themo data into class %r"%(required_class))