diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 74a330347..7b69a55f1 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -310,6 +310,7 @@ cdef extern from "cantera/kinetics/Reaction.h" namespace "Cantera": CxxChebyshevRate rate cdef cppclass CxxCoverageDependency "Cantera::CoverageDependency": + CxxCoverageDependency(double, double, double) double a double E double m diff --git a/interfaces/cython/cantera/reaction.pyx b/interfaces/cython/cantera/reaction.pyx index 3f01d2325..1f1e94269 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -399,17 +399,6 @@ cdef class ChebyshevReaction(Reaction): r.rate = CxxChebyshevRate(Tmin, Tmax, Pmin, Pmax, data) -cdef class CoverageDependency: - cdef public double a - cdef public double m - cdef public double E - - def __init__(self, a, m, E): - self.a = a - self.m = m - self.E = E - - cdef class InterfaceReaction(ElementaryReaction): reaction_type = INTERFACE_RXN @@ -419,19 +408,32 @@ cdef class InterfaceReaction(ElementaryReaction): deps = {} cdef pair[string,CxxCoverageDependency] item for item in r.coverage_deps: - deps[pystr(item.first)] = CoverageDependency( - item.second.a, item.second.m, item.second.E * gas_constant) + deps[pystr(item.first)] = (item.second.a, item.second.m, + item.second.E * gas_constant) return deps + def __set__(self, deps): + cdef CxxInterfaceReaction* r = self.reaction + r.coverage_deps.clear() + cdef str species + for species, D in deps.items(): + r.coverage_deps[stringify(species)] = CxxCoverageDependency( + D[0], D[2] / gas_constant, D[1]) property is_sticking_coefficient: def __get__(self): cdef CxxInterfaceReaction* r = self.reaction return r.is_sticking_coefficient + def __set__(self, stick): + cdef CxxInterfaceReaction* r = self.reaction + r.is_sticking_coefficient = stick property sticking_species: def __get__(self): cdef CxxInterfaceReaction* r = self.reaction return pystr(r.sticking_species) + def __set__(self, species): + cdef CxxInterfaceReaction* r = self.reaction + r.sticking_species = stringify(species) cdef Reaction wrapReaction(shared_ptr[CxxReaction] reaction): diff --git a/interfaces/cython/cantera/test/test_kinetics.py b/interfaces/cython/cantera/test/test_kinetics.py index 4525c93e1..c4a830069 100644 --- a/interfaces/cython/cantera/test/test_kinetics.py +++ b/interfaces/cython/cantera/test/test_kinetics.py @@ -743,3 +743,29 @@ class TestReaction(utilities.CanteraTest): gas1.forward_rate_constants[4]) self.assertNear(gas2.net_rates_of_progress[0], gas1.net_rates_of_progress[4]) + + def test_interface(self): + surf_species = ct.Species.listFromFile('ptcombust.xml') + gas = ct.Solution('ptcombust.xml', 'gas') + surf1 = ct.Interface('ptcombust.xml', 'Pt_surf', [gas]) + r1 = ct.InterfaceReaction() + r1.reactants = 'H(S):2' + r1.products = 'H2:1, PT(S):2' + r1.rate = ct.Arrhenius(3.7e20, 0, 67.4e6) + r1.coverage_deps = {'H(S)': (0, 0, -6e6)} + + self.assertNear(r1.coverage_deps['H(S)'][2], -6e6) + + surf2 = ct.Interface(thermo='Surface', species=surf_species, + kinetics='interface', reactions=[r1], phases=[gas]) + + surf2.site_density = surf1.site_density + surf1.coverages = surf2.coverages = 'PT(S):0.7, H(S):0.3' + gas.TP = surf2.TP = surf1.TP + + for T in [300, 500, 1500]: + gas.TP = surf1.TP = surf2.TP = T, 5*ct.one_atm + self.assertNear(surf1.forward_rate_constants[1], + surf2.forward_rate_constants[0]) + self.assertNear(surf1.net_rates_of_progress[1], + surf2.net_rates_of_progress[0])