Skip to content

Commit f04ffdc

Browse files
committed
Updated thermo
1 parent 32a1850 commit f04ffdc

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

molecule/thermo/model.pyx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,18 @@ cdef class HeatCapacityModel(RMGObject):
163163

164164
Tdata = [300,400,500,600,800,1000,1500,2000]
165165
for T in Tdata:
166-
if not (0.8 < self.get_heat_capacity(T) / other.get_heat_capacity(T) < 1.25):
166+
# Do exact comparison in addition to relative in case both are zero (surface site)
167+
if self.get_heat_capacity(T) != other.get_heat_capacity(T) and \
168+
not (0.8 < self.get_heat_capacity(T) / other.get_heat_capacity(T) < 1.25):
167169
return False
168-
elif not (0.8 < self.get_enthalpy(T) / other.get_enthalpy(T) < 1.25):
170+
elif self.get_enthalpy(T) != other.get_enthalpy(T) and \
171+
not (0.8 < self.get_enthalpy(T) / other.get_enthalpy(T) < 1.25):
169172
return False
170-
elif not (0.8 < self.get_entropy(T) / other.get_entropy(T) < 1.25):
173+
elif self.get_entropy(T) != other.get_entropy(T) and \
174+
not (0.8 < self.get_entropy(T) / other.get_entropy(T) < 1.25):
171175
return False
172-
elif not (0.8 < self.get_free_energy(T) / other.get_free_energy(T) < 1.25):
176+
elif self.get_free_energy(T) != other.get_free_energy(T) and \
177+
not (0.8 < self.get_free_energy(T) / other.get_free_energy(T) < 1.25):
173178
return False
174179

175180
return True
@@ -185,13 +190,18 @@ cdef class HeatCapacityModel(RMGObject):
185190

186191
Tdata = [300,400,500,600,800,1000,1500,2000]
187192
for T in Tdata:
188-
if not (0.95 < self.get_heat_capacity(T) / other.get_heat_capacity(T) < 1.05):
193+
# Do exact comparison in addition to relative in case both are zero (surface site)
194+
if self.get_heat_capacity(T) != other.get_heat_capacity(T) and \
195+
not (0.95 < self.get_heat_capacity(T) / other.get_heat_capacity(T) < 1.05):
189196
return False
190-
elif not (0.95 < self.get_enthalpy(T) / other.get_enthalpy(T) < 1.05):
197+
elif self.get_enthalpy(T) != other.get_enthalpy(T) and \
198+
not (0.95 < self.get_enthalpy(T) / other.get_enthalpy(T) < 1.05):
191199
return False
192-
elif not (0.95 < self.get_entropy(T) / other.get_entropy(T) < 1.05):
200+
elif self.get_entropy(T) != other.get_entropy(T) and \
201+
not (0.95 < self.get_entropy(T) / other.get_entropy(T) < 1.05):
193202
return False
194-
elif not (0.95 < self.get_free_energy(T) / other.get_free_energy(T) < 1.05):
203+
elif self.get_free_energy(T) != other.get_free_energy(T) and \
204+
not (0.95 < self.get_free_energy(T) / other.get_free_energy(T) < 1.05):
195205
return False
196206

197207
return True

molecule/thermo/thermoengine.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#from molecule.statmech import Conformer
3838
from molecule.thermo import Wilhoit, NASA, ThermoData
3939
from molecule.molecule import Molecule
40+
from molecule.molecule.fragment import Fragment
4041

4142

4243
def process_thermo_data(spc, thermo0, thermo_class=NASA, solvent_name=''):
@@ -69,7 +70,7 @@ def process_thermo_data(spc, thermo0, thermo_class=NASA, solvent_name=''):
6970
# correction is added to the entropy and enthalpy
7071
wilhoit.S0.value_si = (wilhoit.S0.value_si + solvation_correction.entropy)
7172
wilhoit.H0.value_si = (wilhoit.H0.value_si + solvation_correction.enthalpy)
72-
wilhoit.comment += ' + Solvation correction with {} as solvent and solute estimated using {}'.format(solvent_name, solute_data.comment)
73+
wilhoit.comment += f' + Solvation correction (H={solvation_correction.enthalpy/1e3:+.0f}kJ/mol;S={solvation_correction.entropy:+.0f}J/mol/K) with {solvent_name} as solvent and solute estimated using {solute_data.comment}'
7374

7475
# Compute E0 by extrapolation to 0 K
7576
# if spc.conformer is None:
@@ -157,7 +158,7 @@ def evaluator(spc, solvent_name=''):
157158
"""
158159
logging.debug("Evaluating spc %s ", spc)
159160

160-
if isinstance(spc.molecule[0], Molecule):
161+
if not isinstance(spc.molecule[0], Fragment):
161162
spc.generate_resonance_structures()
162163
thermo = generate_thermo_data(spc, solvent_name=solvent_name)
163164
else:

molecule/thermo/wilhoit.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ cdef class Wilhoit(HeatCapacityModel):
273273

274274
# What remains is to fit the polynomial coefficients (a0, a1, a2, a3)
275275
# This can be done directly - no iteration required
276-
A = np.empty((Cpdata.shape[0],4), np.float64)
277-
b = np.empty(Cpdata.shape[0], np.float64)
276+
A = np.empty((Cpdata.shape[0],4), float)
277+
b = np.empty(Cpdata.shape[0], float)
278278
for i in range(Cpdata.shape[0]):
279279
y = Tdata[i] / (Tdata[i] + B)
280280
for j in range(4):

0 commit comments

Comments
 (0)