Plug Flow Reactor Module Using Matlab
Plug Flow Reactor Module Using Matlab
The primary Matlab program for simulating a plug flow reactor is called: plugr1.
Before it is executed, a data file must be constructed that holds compound property
data as well as the reactor parameters. The FORTRAN program: start403a facilitates
the construction of such a file. In addition, a Matlab program must be written that
specifies the reaction kinetics. We will show how these programs are used in a
simulation of a plug flow reactor using data that was given in the 1995 ammonia plant
design for CENG 404.
First we construct the a compound data file. The name used for the file is arbitrary,
but htscomp was chosen in this example.
stationnm%start403a
Copyright 1997 Rice University
All rights reserved
Give the name used for your data file. It stores
compound property data and reaction rates.
The name should be no more than 16 characters long.
htscomp
<-- The file name used for the data
If your compound data file already exists, and you
do not want to change it, reply: y
better!
<-- Our program agrees.
gas shift:
CO + H2O -> CO2 + H2
Now we will set up a second file to hold the parameters associated with the
reactor. Again the name is arbitrary, but we will chhose: htsreact.
Give the name of your reactor data file,
it should be no more than 16 characters long.
htsreact
Give a title for your simulation.
It will be used on your plots.
High Temp. Shift
Give the name of your reaction rate file.
ratehts2
<-- The file ratehts2.m must
be stored
If the reaction fluid is a liquid, reply: y.
<-- Our reactor fluid is a vapor
number
number
number
number
number
The compound data file: htscomp created by this process is quite long and contains a
lot of property data that is not required in the plug flow simulator. Here is a partial
listing of the file.
6
1
6
hydrogen
methane
nitrogen
carbon monoxide
carbon dioxide
water
6
1
6
H2
CH4
N2
CO
CO2
H2O
6
1
6
1
2
3
4
5
6
Aabc
1
2
2.016
16.043
28.013
28.010
44.010
18.015
6
3
12.784
13.584
6
1
232.32
968.13
8.0800
-3.7200
Here is where we omit some of the data in the file. Note that the data for some
compounds are missing; such as the melting point for the fifth compound and the
specific heats for all solids except water as seen in:
TmpK
1
2
3
4
6
cpl
1
2
3
4
5
6
cps
6
cpv
1
2
3
4
5
6
critP
1
2
3
4
5
6
critT
1
2
3
4
5
6
critZ
1
2
3
6
13.960
90.650
63.150
68.050
273.15
6
58.866
-5.7070
14.714
14.967
11.042
18.296
6
-2.4167
6
17.630
38.380
29.410
29.000
19.020
34.040
6
1315.2
4640.7
3398.4
3498.6
7380.5
22109.
6
33.191
191.06
126.27
132.95
304.20
647.30
6
0.30400
0.28900
0.29100
4
5
6
1
-0.23069
1.0256
2.2026
2.1440
1.1595
0.47211
1
1
0.24405
6
1
0.67000E-01
-0.73660E-01
-0.30100E-02
0.24900E-02
0.79620E-01
-0.96500E-02
6
1
-0.80421E-01 0.13777E-02
-0.16656E-02 -0.19750E-04
-0.35214E-01 0.17996E-03
-0.32470E-01 0.15804E-03
-0.72313E-02 0.15501E-04
-0.13387E-02 0.13142E-05
-0.77632E-03
0.15743E-05
4
5
6
dHComb
1
2
4
stoic
1
2
0.29400
0.27400
0.23000
6
-241.80
-802.31
-283.00
2
3.00
1.00
6
2
-1.00
0.00
1
0.00
0.00
1.00
-1.00
0.00
1.00
-1.00
-1.00
The last set of data is the stoichiometric array that defines the two reactions.
The reactor data file: htsreact created by use of start403a is short and may be listed in
its entirety. You can recognize most of the answers given to prompts in the session
with start403a.
data file
Now we must create a Matlab program that can be used to specify the reaction
kinetics. We said it would be called ratehts2, so we must put a file called that with the
Matlab appendage: ".m" in our Matlab path. Here is the file by that name used in our
simulation:
Note that the comments in the function show exactly how the rates are calculated.
Executing plugr2
Before we can execute the plug flow simulator in Matlab, we must make sure that
Matlab can find:
1. the compound data file
2. the reactor data file and
3. the kinetic rate program.
If you have stored the kinetic in your Matlab directory or another place which is in
Matlab's search path, this program will be found. The data files (in our
example htscomp and htsreact) may have to be moved to a directory that is searched
by Matlab. An even more serious problem can occur if you have multiple copies of
either of the files or the program. In the case of the kinetic program, you may want to
use the Matlab whichcommand to make sure Matlab will find the version of program
that you desire. Unfortunately, this command can not be used to see what data file will
be found. The plugr2 program:
prints the names of the compounds,
lists the reactions and
shows that name you gave to your simulation.
You should make sure that this information is unique so you can tell that you are using
the correct data.
Here is our simulation executed in the Matlab Command Window:
>>plugr2
Copyright 1997 Rice University
All rights reserved
If you have not run the FORTRAN program start403a to
produce a compound data file, do so before you go on.
You may also want to use the same program to produce
a file of operating data for your system.
If you have an operating data file, you should give
that file name in response to the following prompt:
Note the white line around the file name that was selected, make sure it is there;
otherwise the file may not really be selected. You may then click on the Done button.
How many streams will there be?0
Here are your compounds' names:
hydrogen
methane
nitrogen
carbon monoxide
carbon dioxide
water
Here are your reactions:
CH4 + H2O --> 3 H2 + CO
CO + H2O --> H2 + CO2
High Temp. Shift
Would you like to see a table or plot or stop?
I chose first to see a table of data and specified with the following menu that it should
be molfractions of the gas.
Length m
0
0.0781
0.7031
1.3281
1.9531
2.5781
3.2031
Mole Fractions
H2
CH4
0.3050
0.1000
0.3054
0.1000
0.3092
0.1000
0.3133
0.1000
0.3179
0.1000
0.3229
0.1000
0.3284
0.1000
N2
0.1500
0.1500
0.1500
0.1500
0.1500
0.1500
0.1500
CO
0.0980
0.0976
0.0938
0.0897
0.0851
0.0801
0.0746
CO2
0.0400
0.0404
0.0442
0.0483
0.0529
0.0579
0.0634
H2O
0.3070
0.3066
0.3028
0.2987
0.2941
0.2891
0.2836
3.8281
4.4531
5.0781
5.7031
6.3281
6.9531
7.5781
8.2031
8.8281
9.4531
10.0000
0.3344
0.3409
0.3477
0.3546
0.3612
0.3670
0.3717
0.3751
0.3774
0.3789
0.3797
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1500
0.1500
0.1500
0.1500
0.1500
0.1500
0.1500
0.1500
0.1500
0.1500
0.1500
0.0686
0.0621
0.0553
0.0484
0.0418
0.0360
0.0313
0.0279
0.0256
0.0241
0.0233
0.0694
0.0759
0.0827
0.0896
0.0962
0.1020
0.1067
0.1101
0.1124
0.1139
0.1147
0.2776
0.2711
0.2643
0.2574
0.2508
0.2450
0.2403
0.2369
0.2346
0.2331
0.2323
After choosing to either see a table or plot results, you have eight items to choose
from:
1. Mass Fractions of the compounds,
2. Mol Fraction of the compounds,
3. Molar flow rate of the compounds,
4. Temperature of the gas,
5. Gas Velocity,
6. Gas Density,
7. Average molecular weight of the gas,
8. Total molar flow of the gas.
Note that in making a new run to simulate similar conditions, it may not be necessary
to execute start403a to create your reactor data file. The file may be readily edited to
change one or more pieces of data. You should be careful to give your new simulation
a distinct name so that you can tell in the Matlab run, what data was used.