Skip to content

Commit

Permalink
Merge pull request ReactionMechanismGenerator#2658 from sevyharris/th…
Browse files Browse the repository at this point in the history
…ermo_allzeros_identical

add check for all zeros in thermo comparison
  • Loading branch information
hwpang authored May 10, 2024
2 parents 2753ed8 + 4cd90fb commit 6a5ebf4
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions rmgpy/thermo/model.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,18 @@ cdef class HeatCapacityModel(RMGObject):

Tdata = [300,400,500,600,800,1000,1500,2000]
for T in Tdata:
if not (0.8 < self.get_heat_capacity(T) / other.get_heat_capacity(T) < 1.25):
# Do exact comparison in addition to relative in case both are zero (surface site)
if self.get_heat_capacity(T) != other.get_heat_capacity(T) and \
not (0.8 < self.get_heat_capacity(T) / other.get_heat_capacity(T) < 1.25):
return False
elif not (0.8 < self.get_enthalpy(T) / other.get_enthalpy(T) < 1.25):
elif self.get_enthalpy(T) != other.get_enthalpy(T) and \
not (0.8 < self.get_enthalpy(T) / other.get_enthalpy(T) < 1.25):
return False
elif not (0.8 < self.get_entropy(T) / other.get_entropy(T) < 1.25):
elif self.get_entropy(T) != other.get_entropy(T) and \
not (0.8 < self.get_entropy(T) / other.get_entropy(T) < 1.25):
return False
elif not (0.8 < self.get_free_energy(T) / other.get_free_energy(T) < 1.25):
elif self.get_free_energy(T) != other.get_free_energy(T) and \
not (0.8 < self.get_free_energy(T) / other.get_free_energy(T) < 1.25):
return False

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

Tdata = [300,400,500,600,800,1000,1500,2000]
for T in Tdata:
if not (0.95 < self.get_heat_capacity(T) / other.get_heat_capacity(T) < 1.05):
# Do exact comparison in addition to relative in case both are zero (surface site)
if self.get_heat_capacity(T) != other.get_heat_capacity(T) and \
not (0.95 < self.get_heat_capacity(T) / other.get_heat_capacity(T) < 1.05):
return False
elif not (0.95 < self.get_enthalpy(T) / other.get_enthalpy(T) < 1.05):
elif self.get_enthalpy(T) != other.get_enthalpy(T) and \
not (0.95 < self.get_enthalpy(T) / other.get_enthalpy(T) < 1.05):
return False
elif not (0.95 < self.get_entropy(T) / other.get_entropy(T) < 1.05):
elif self.get_entropy(T) != other.get_entropy(T) and \
not (0.95 < self.get_entropy(T) / other.get_entropy(T) < 1.05):
return False
elif not (0.95 < self.get_free_energy(T) / other.get_free_energy(T) < 1.05):
elif self.get_free_energy(T) != other.get_free_energy(T) and \
not (0.95 < self.get_free_energy(T) / other.get_free_energy(T) < 1.05):
return False

return True
Expand Down

0 comments on commit 6a5ebf4

Please sign in to comment.