Skip to content

Commit

Permalink
Consistently use T=298. K for fitting and evaluating Blowers-Masel ra…
Browse files Browse the repository at this point in the history
…tes.

Closes #1748
  • Loading branch information
rwest authored and ssun30 committed Sep 19, 2024
1 parent d0f7092 commit 1102c0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions rmgpy/data/kinetics/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -3658,13 +3658,13 @@ def cross_validate(self, folds=5, template_rxn_map=None, test_rxn_inds=None, T=1
if kinetics.E0.value_si < 0.0 or len(L) == 1:
kinetics = average_kinetics([r.kinetics for r in L])
else:
kinetics = kinetics.to_arrhenius(rxn.get_enthalpy_of_reaction(298.0))
kinetics = kinetics.to_arrhenius(rxn.get_enthalpy_of_reaction(298.))
else:
kinetics = ArrheniusChargeTransferBM().fit_to_reactions(L, recipe=self.forward_recipe.actions)
if kinetics.E0.value_si < 0.0 or len(L) == 1:
kinetics = average_kinetics([r.kinetics for r in L])
else:
kinetics = kinetics.to_arrhenius_charge_transfer(rxn.get_enthalpy_of_reaction(298.0))
kinetics = kinetics.to_arrhenius_charge_transfer(rxn.get_enthalpy_of_reaction(298.))

k = kinetics.get_rate_coefficient(T)
errors[rxn] = np.log(k / krxn)
Expand Down Expand Up @@ -4596,15 +4596,15 @@ def _make_rule(rr):
dlnks = np.array([
np.log(
arr().fit_to_reactions(rs[list(set(range(len(rs))) - {i})], recipe=recipe)
.to_arrhenius(rxn.get_enthalpy_of_reaction(Tref))
.to_arrhenius(rxn.get_enthalpy_of_reaction(298.))
.get_rate_coefficient(T=Tref) / rxn.get_rate_coefficient(T=Tref)
) for i, rxn in enumerate(rs)
]) # 1) fit to set of reactions without the current reaction (k) 2) compute log(kfit/kactual) at Tref
else: # SurfaceChargeTransfer or ArrheniusChargeTransfer
dlnks = np.array([
np.log(
arr().fit_to_reactions(rs[list(set(range(len(rs))) - {i})], recipe=recipe)
.to_arrhenius_charge_transfer(rxn.get_enthalpy_of_reaction(Tref))
.to_arrhenius_charge_transfer(rxn.get_enthalpy_of_reaction(298.))
.get_rate_coefficient(T=Tref) / rxn.get_rate_coefficient(T=Tref)
) for i, rxn in enumerate(rs)
]) # 1) fit to set of reactions without the current reaction (k) 2) compute log(kfit/kactual) at Tref
Expand Down
10 changes: 5 additions & 5 deletions rmgpy/kinetics/arrhenius.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ cdef class ArrheniusBM(KineticsModel):
"""
Return the rate coefficient in the appropriate combination of m^3,
mol, and s at temperature `T` in K and enthalpy of reaction `dHrxn`
in J/mol.
in J/mol, evaluated at 298 K.
"""
cdef double A, n, Ea
Ea = self.get_activation_energy(dHrxn)
Expand All @@ -570,7 +570,7 @@ cdef class ArrheniusBM(KineticsModel):
cpdef double get_activation_energy(self, double dHrxn) except -1:
"""
Return the activation energy in J/mol corresponding to the given
enthalpy of reaction `dHrxn` in J/mol.
enthalpy of reaction `dHrxn` in J/mol, evaluated at 298 K.
"""
cdef double w0, E0
E0 = self._E0.value_si
Expand All @@ -586,7 +586,8 @@ cdef class ArrheniusBM(KineticsModel):
cpdef Arrhenius to_arrhenius(self, double dHrxn):
"""
Return an :class:`Arrhenius` instance of the kinetics model using the
given enthalpy of reaction `dHrxn` to determine the activation energy.
given enthalpy of reaction `dHrxn` (in J/mol, evaluated at 298 K)
to determine the activation energy.
"""
return Arrhenius(
A=self.A,
Expand Down Expand Up @@ -615,7 +616,6 @@ cdef class ArrheniusBM(KineticsModel):
w0 = sum(w0s) / len(w0s)

if len(rxns) == 1:
T = 1000.0
rxn = rxns[0]
dHrxn = rxn.get_enthalpy_of_reaction(298.0)
A = rxn.kinetics.A.value_si
Expand All @@ -632,7 +632,7 @@ cdef class ArrheniusBM(KineticsModel):
self.Tmin = rxn.kinetics.Tmin
self.Tmax = rxn.kinetics.Tmax
self.solute = None
self.comment = 'Fitted to {0} reaction at temperature: {1} K'.format(len(rxns), T)
self.comment = 'Fitted to 1 reaction.'
else:
# define optimization function
def kfcn(xs, lnA, n, E0):
Expand Down

0 comments on commit 1102c0b

Please sign in to comment.