MCPcopy Create free account
hub / github.com/Cantera/cantera / test_with_surface

Method test_with_surface

test/python/test_reactor.py:2992–3075  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2990 assert r1.heat_rate == approx(Qext + Qwall)
2991
2992 def test_with_surface(self):
2993 phase_defs = """
2994 units: {length: cm, quantity: mol, activation-energy: J/mol}
2995 phases:
2996 - name: gas
2997 thermo: ideal-gas
2998 species:
2999 - gri30.yaml/species: [H2, H2O, H2O2, O2]
3000 kinetics: gas
3001 reactions:
3002 - gri30.yaml/reactions: declared-species
3003 skip-undeclared-third-bodies: true
3004 - name: Pt_surf
3005 thermo: ideal-surface
3006 species:
3007 - ptcombust.yaml/species: [PT(S), H(S), H2O(S), OH(S), O(S)]
3008 kinetics: surface
3009 reactions: [ptcombust.yaml/reactions: declared-species]
3010 site-density: 3e-09
3011 """
3012
3013 gas = ct.Solution(yaml=phase_defs, name="gas")
3014 surf = ct.Interface(yaml=phase_defs, name="Pt_surf", adjacent=[gas])
3015 gas.TPX = 800, 0.01*ct.one_atm, "H2:2.0, O2:1.0"
3016 surf.TP = 800, 0.01*ct.one_atm
3017 surf.coverages = {"H(S)": 1.0} # dummy values to be replaced by delegate
3018
3019 kHs = surf.species_index("H(S)")
3020 kPts = surf.species_index("PT(S)")
3021 kH2 = gas.species_index("H2")
3022 kO2 = gas.species_index("O2")
3023 class SurfReactor(ct.ExtensibleIdealGasReactor):
3024 def replace_eval_surfaces(self, LHS, RHS, sdot):
3025 site_density = self.surfaces[0].kinetics.site_density
3026 sdot[:] = 0.0
3027 LHS[:] = 1.0
3028 RHS[:] = 0.0
3029 C = self.thermo.concentrations
3030 theta = self.surfaces[0].coverages
3031
3032 # Replace actual reactions with simple absorption of H2 -> H(S)
3033 rop = 1e-4 * C[kH2] * theta[kPts]
3034 RHS[kHs] = 2 * rop / site_density
3035 RHS[kPts] = - 2 * rop / site_density
3036 sdot[kH2] = - rop * self.surfaces[0].area
3037
3038 def replace_get_surface_initial_conditions(self, y):
3039 y[:] = 0
3040 y[kPts] = 1
3041
3042 def replace_update_surface_state(self, y):
3043 # this is the same thing the original method does
3044 self.surfaces[0].coverages = y
3045
3046 r1 = SurfReactor(gas)
3047 r1.volume = 1e-6 # 1 cm^3
3048 r1.energy_enabled = False
3049 rsurf = ct.ReactorSurface(surf, A=0.01)

Callers

nothing calls this directly

Calls 8

stepMethod · 0.95
advanceMethod · 0.95
SurfReactorClass · 0.85
SolutionMethod · 0.80
InterfaceMethod · 0.80
ReactorSurfaceMethod · 0.80
installMethod · 0.45
ReactorNetMethod · 0.45

Tested by

no test coverage detected