Skip to content

Commit

Permalink
Added new method to thermo class which calls all internal methods to …
Browse files Browse the repository at this point in the history
…calculate adsorabe thermochemistry
  • Loading branch information
tdprice-858 committed Dec 9, 2024
1 parent 9c530bd commit 5b15962
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions pynta/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ def _get_vibrational_thermo(self):

return

def fit_NASA(self):
def _fit_NASA(self):
'''I have not yet check the math on all this stuff from Goldsmith group'''
R = self.R
heat_capacity = self.Cp
Expand Down Expand Up @@ -846,7 +846,7 @@ def fit_NASA(self):
return

# Print output in cti format
def format_RMG_output(self, index):
def _format_RMG_output(self, index):
line = '\n'
line += 'entry(\n index = %s,\n' % (index)
line += f' label = "{self.name}",\n'
Expand All @@ -869,6 +869,60 @@ def format_RMG_output(self, index):

return

def temp_corrections(self, index=0):
# call the subroutine for the translational and vibrational partition functions
_get_translation_thermo(self)
_get_vibrational_thermo(self)

# Atom corrections from Thermochemistry chapter by Ruscic and Bross
# Page 75 of DOI = https://doi.org/10.1016/B978-0-444-64087-1.00001-2
h_correction = 4.234 # kJ/mol. enthalpy_H(298) - enthalpy_H(0)
c_correction = 1.051 # kJ/mol. enthalpy_C(298) - enthalpy_C(0)
n_correction = 4.335 # kJ/mol. enthalpy_N(298) - enthalpy_N(0)
o_correction = 4.340 # kJ/mol. enthalpy_O(298) - enthalpy_O(0)

# Still not certain why these are needed. Need to read book
self.heat_of_formation_correction = 0.0
self.heat_of_formation_correction += self.composition['H'] * h_correction
self.heat_of_formation_correction += self.composition['C'] * c_correction
self.heat_of_formation_correction += self.composition['N'] * n_correction
self.heat_of_formation_correction += self.composition['O'] * o_correction

# note that the partition function is the production of the individual terms,
# whereas the thermodynamic properties are additive
self.Q = self.Q_trans * self.Q_vib
self.S = self.S_trans + self.S_vib
self.dH = self.dH_trans + self.dH_vib
self.Cp = self.Cp_trans + self.Cv_vib # see comments in each section regarding Cp vs Cv
self.heat_of_formation_298K = self.heat_of_formation_0K + self.dH[
0] - self.heat_of_formation_correction
self.H = self.heat_of_formation_298K + self.dH - self.dH[0]

print(self.heat_of_formation_298K)
print(self.H[0])
# This writes H_298, S_298 and appropriate indices of Cp to file (preparation for computing adsorption corrections)
g = open("thermodata_adsorbates.py", 'a+')
g.write(
'[' + str(self.name) + ', Cpdata:, ' + str(self.Cp[np.where(temperature == 300)] * 239.0057)[
1:-1] + ', ' + str(
self.Cp[np.where(temperature == 400)] * 239.0057)[1:-1] + ', ' + str(
self.Cp[np.where(temperature == 500)] * 239.0057)[1:-1] + ', ' + str(
self.Cp[np.where(temperature == 600)] * 239.0057)[1:-1] + ', ' + str(
self.Cp[np.where(temperature == 800)] * 239.0057)[1:-1] + ', ' + str(
self.Cp[np.where(temperature == 1000)] * 239.0057)[1:-1] + ', ' + str(
self.Cp[np.where(temperature == 1500)] * 239.0057)[
1:-1] + ', ' + ",'cal/(mol*K)', H298, " + str(
self.H[0] * 0.2390057) + ", 'kcal/mol', S298, " + str(
self.S[0] * 239.0057) + ", 'cal/(mol*K)']")
g.write('\n')
g.close()

# now that we've computed the thermo properties, go ahead and fit them to a NASA polynomial
_fit_NASA(self)
# format_output(molecule)
_format_RMG_output(self, index)
return




Expand Down

0 comments on commit 5b15962

Please sign in to comment.