[Python] Add setters for InterfaceReaction properties
This commit is contained in:
parent
4022e408af
commit
dd62e6061e
3 changed files with 42 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = <CxxInterfaceReaction*>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 = <CxxInterfaceReaction*>self.reaction
|
||||
return r.is_sticking_coefficient
|
||||
def __set__(self, stick):
|
||||
cdef CxxInterfaceReaction* r = <CxxInterfaceReaction*>self.reaction
|
||||
r.is_sticking_coefficient = stick
|
||||
|
||||
property sticking_species:
|
||||
def __get__(self):
|
||||
cdef CxxInterfaceReaction* r = <CxxInterfaceReaction*>self.reaction
|
||||
return pystr(r.sticking_species)
|
||||
def __set__(self, species):
|
||||
cdef CxxInterfaceReaction* r = <CxxInterfaceReaction*>self.reaction
|
||||
r.sticking_species = stringify(species)
|
||||
|
||||
|
||||
cdef Reaction wrapReaction(shared_ptr[CxxReaction] reaction):
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue