Skip to content

Commit 15ce6d5

Browse files
committed
Adding to_cantera_kinetics for ArrheniusBM class.
Cantera now has a BlowersMasel kinetics class. This requires Cantera > 2.6 As described in https://cantera.org/dev/python/kinetics.html#cantera.BlowersMaselRate the API may change suddenly on some versions.
1 parent b26129c commit 15ce6d5

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

rmgpy/kinetics/arrhenius.pyx

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,52 @@ cdef class ArrheniusBM(KineticsModel):
707707
"""
708708
self._A.value_si *= factor
709709

710+
def to_cantera_kinetics(self):
711+
"""
712+
Converts the RMG ArrheniusBM object to a cantera BlowersMaselRate.
713+
714+
BlowersMaselRate(A, b, Ea, W) where A is in units of m^3/kmol/s,
715+
b is dimensionless, and Ea and W are in J/kmol
716+
"""
717+
import cantera as ct
718+
719+
rate_units_conversion = {'1/s': 1,
720+
's^-1': 1,
721+
'm^3/(mol*s)': 1000,
722+
'm^6/(mol^2*s)': 1000000,
723+
'cm^3/(mol*s)': 1000,
724+
'cm^6/(mol^2*s)': 1000000,
725+
'm^3/(molecule*s)': 1000,
726+
'm^6/(molecule^2*s)': 1000000,
727+
'cm^3/(molecule*s)': 1000,
728+
'cm^6/(molecule^2*s)': 1000000,
729+
}
730+
731+
if self._T0.value_si != 1:
732+
A = self._A.value_si / (self._T0.value_si) ** self._n.value_si
733+
else:
734+
A = self._A.value_si
735+
736+
try:
737+
A *= rate_units_conversion[self._A.units] # convert from /mol to /kmol
738+
except KeyError:
739+
raise ValueError(f'ArrheniusBM A-factor units {self._A.units} not found among accepted '
740+
'units for converting to Cantera BlowersMaselRate object.')
741+
742+
b = self._n.value_si
743+
Ea = self._E0.value_si * 1000 # convert from J/mol to J/kmol
744+
w = self._w0.value_si * 1000 # convert from J/mol to J/kmol
745+
746+
return ct.BlowersMaselRate(A, b, Ea, w)
747+
710748
def set_cantera_kinetics(self, ct_reaction, species_list):
711749
"""
712-
Sets a cantera Reaction() object with the modified Arrhenius object
713-
converted to an Arrhenius form.
750+
Accepts a cantera Reaction object and sets its rate to a Cantera BlowersMaselRate object.
714751
"""
715-
raise NotImplementedError('set_cantera_kinetics() is not implemented for ArrheniusBM class kinetics.')
752+
import cantera as ct
753+
if not isinstance(ct_reaction.rate, ct.BlowersMaselRate):
754+
raise TypeError("ct_reaction must have a cantera BlowersMaselRate as the rate attribute")
755+
ct_reaction.rate = self.to_cantera_kinetics()
716756

717757
################################################################################
718758

0 commit comments

Comments
 (0)