Note
Go to the end to download the full example code.
Plug flow reactor with surface chemistry#
This example simulates the partial oxidation of methane over a platinum catalyst in a
packed bed reactor. This example solves the DAE system directly, using the FlowReactor
class and the SUNDIALS IDA solver, in contrast to the approximation as a chain of
steady-state WSRs used in surf_pfr_chain.py.
Requires: cantera >= 3.0.0
Input Parameters#
tc = 800.0 # Temperature in Celsius
length = 0.3 * cm # Catalyst bed length
area = 1.0 * cm**2 # Catalyst bed area
cat_area_per_vol = 1000.0 / cm # Catalyst particle surface area per unit volume
velocity = 40.0 * cm / minute # gas velocity
porosity = 0.3 # Catalyst bed porosity
# input file containing the surface reaction mechanism
yaml_file = 'methane_pox_on_pt.yaml'
output_filename = 'surf_pfr2_output.csv'
t = tc + 273.15 # convert to Kelvin
# import the model and set the initial conditions
surf = ct.Interface(yaml_file, 'Pt_surf')
surf.TP = t, ct.one_atm
gas = surf.adjacent['gas']
gas.TPX = t, ct.one_atm, 'CH4:1, O2:1.5, AR:0.1'
mass_flow_rate = velocity * gas.density * area * porosity
# create a new reactor
r = ct.FlowReactor(gas)
r.area = area
r.surface_area_to_volume_ratio = cat_area_per_vol * porosity
r.mass_flow_rate = mass_flow_rate
r.energy_enabled = False
# Add the reacting surface to the reactor
rsurf = ct.ReactorSurface(surf, r)
sim = ct.ReactorNet([r])
output_data = []
n = 0
print(' distance X_CH4 X_H2 X_CO')
print(' {:10f} {:10f} {:10f} {:10f}'.format(
0, *r.thermo['CH4', 'H2', 'CO'].X))
while sim.distance < length:
dist = sim.distance * 1e3 # convert to mm
sim.step()
if n % 100 == 0 or (dist > 1 and n % 10 == 0):
print(' {:10f} {:10f} {:10f} {:10f}'.format(
dist, *r.thermo['CH4', 'H2', 'CO'].X))
n += 1
# write the gas mole fractions and surface coverages vs. distance
output_data.append(
[dist, r.T - 273.15, r.thermo.P / ct.one_atm]
+ list(r.thermo.X) # use r.thermo.X not gas.X
+ list(rsurf.kinetics.coverages) # use rsurf.kinetics.coverages not surf.coverages
)
with open(output_filename, 'w', newline="") as outfile:
writer = csv.writer(outfile)
writer.writerow(['Distance (mm)', 'T (C)', 'P (atm)'] +
gas.species_names + surf.species_names)
writer.writerows(output_data)
print("Results saved to '{0}'".format(output_filename))
distance X_CH4 X_H2 X_CO
0.000000 0.384615 0.000000 0.000000
0.000000 0.384615 0.000000 0.000000
0.000001 0.381787 0.001823 0.001722
0.000003 0.374725 0.005315 0.005324
0.000007 0.356415 0.010706 0.011553
0.000015 0.314843 0.013994 0.016728
0.000025 0.268139 0.012052 0.016012
0.000042 0.212235 0.007922 0.011658
0.000069 0.154969 0.004550 0.007885
0.000078 0.140157 0.003918 0.007684
0.000081 0.135070 0.003751 0.007908
0.000082 0.132721 0.003712 0.008144
0.000083 0.131891 0.003721 0.008278
0.000083 0.131589 0.003735 0.008344
0.000083 0.131353 0.003754 0.008408
0.000083 0.130949 0.003793 0.008530
0.000084 0.129624 0.003891 0.008948
0.000084 0.128246 0.003927 0.009369
0.000086 0.124836 0.003780 0.010285
0.000088 0.120254 0.003309 0.011195
0.000090 0.116936 0.002913 0.011639
0.000093 0.112453 0.002383 0.011993
0.000098 0.107403 0.001823 0.012116
0.000108 0.100820 0.001173 0.011944
0.000117 0.097224 0.000871 0.011732
0.000130 0.094601 0.000704 0.011538
0.000145 0.093388 0.000692 0.011440
0.000161 0.092837 0.000783 0.011396
0.000177 0.092601 0.000934 0.011378
0.000194 0.092469 0.001128 0.011370
0.000218 0.092350 0.001428 0.011366
0.000241 0.092261 0.001705 0.011364
0.000278 0.092126 0.002152 0.011362
0.000322 0.091975 0.002659 0.011362
0.000390 0.091754 0.003398 0.011364
0.000849 0.090472 0.007639 0.011422
0.001414 0.089168 0.011888 0.011550
0.003306 0.085679 0.022994 0.012147
0.007819 0.079696 0.041461 0.013752
0.015335 0.072811 0.062203 0.016109
0.037705 0.061173 0.096647 0.020707
0.104641 0.046834 0.137886 0.027575
0.175926 0.039804 0.157496 0.031550
0.436106 0.027963 0.189811 0.038958
1.013390 0.017867 0.216797 0.045843
1.117921 0.016864 0.219453 0.046552
1.184466 0.016252 0.221071 0.046988
1.244980 0.015730 0.222449 0.047360
1.300566 0.015278 0.223643 0.047684
1.356151 0.014813 0.224867 0.048017
1.501685 0.013721 0.227744 0.048805
1.683602 0.012606 0.230675 0.049615
1.865519 0.011638 0.233214 0.050321
2.110535 0.010486 0.236232 0.051168
2.322837 0.009680 0.238342 0.051765
2.575065 0.008772 0.240713 0.052439
2.935391 0.007752 0.243373 0.053201
Results saved to 'surf_pfr2_output.csv'
Total running time of the script: (0 minutes 0.291 seconds)