[Go to previous section: 1.3| Go
to next section: 1.5]
[ Go to CENG301 Homepage
| CENG301 Notes Table of Contents]
The text spends some time on the problems associated with linearly
dependent sets of reactions. We will look at ways to use the
driver program to simplify the process. The
equations in Example Problem 3.21 in Reklaitis are shown to include
only two independent reactions in the session:
Using start301, set the compound names and formulae, molecular
weights, and reaction coefficients.
It should include the names:
Compound # Name 1 methane 2 carbon dioxide 3 carbon monoxide 4 hydrogen 5 water
For this example, we choose (1) New Session, and since we only wish to use names, formulae and molecular weights, we choose Mass Balances Only from the second menu. Then we set our data:
Input the name of your new file: test The output file name is: test Input the number of compounds: 5 The number of compounds is: 5 Enter the name of compound # 1: methane Enter the name of compound # 2: CO2 Enter the name of compound # 3: carbon monoxide Enter the name of compound # 4: hydrogen Enter the name of compound # 5: H2O Enter the number of reactions: 4 ..... Enter the coefficients for each compound in reaction # 1 CH4 CO2 CO H2 H2O -1 -1 2 2 0 Enter the coefficients for each compound in reaction # 2 CH4 CO2 CO H2 H2O 0 1 -1 1 -1 Enter the coefficients for each compound in reaction # 3 CH4 CO2 CO H2 H2O -1 0 1 3 -1 Enter the coefficients for each compound in reaction # 4 CH4 CO2 CO H2 H2O -1 1 0 4 -2 Here are your compounds' formulae and names: No. Formula Name ---------------------------------------- 1 CH4 methane 2 CO2 carbon dioxide 3 CO carbon monoxide 4 H2 hydrogen 5 H2O water Here are your reactions: ---------------------------------------- 1) CH4 + CO2 --> 2CO + 2H2 2) CO + H2O --> CO2 + H2 3) CH4 + H2O --> CO + 3H2 4) CH4 + 2H2O --> CO2 + 4H2 Enter the number of streams: 0 The variables for your compounds have now been created, you may continue, or come back later and reload the same data.
Our stoic array now lists just as it did in the test file:
>> stoic stoic = -1 -1 2 2 0 0 1 -1 1 -1 -1 0 1 3 -1 -1 1 0 4 -2
Thus we have set stoic to represent the equations shown in
the example. If we are only interested in the number of independent
reactions, we can invoke the rank function to
determine it:
>> rank(stoic) ans = 2
There are two. If we want to do more than that, we can diagonalize
the matrix. The driver function can be used for
this. All we need to do is to operate on stoic to eliminate
the non-zero elements to the left of the main diagonal of the matrix.
Note that the procedure given in section 3.3.2 in Reklaitis is
similar to the procedure using stoic and
driver, except that (in Reklaitis) the
stoichiometric coefficients for a single reaction is a column vector,
not a row vector, and non-zero elements are eliminated to the right
of the main diagonal.
We will store the result given by driver in the
matrix stind. It should contain the stoichiometric array in
which each equation represented is trivially independent of the rest
since each involves one compound that none of the rest do.
>> driver(stoic) Give the space for each number to print in 10 Give the number of decimal points 5 Here is your matrix row/col 1 2 3 4 5 1 -1.00000 -1.00000 2.00000 2.00000 0.00000 2 0.00000 1.00000 -1.00000 1.00000 -1.00000 3 -1.00000 0.00000 1.00000 3.00000 -1.00000 4 -1.00000 1.00000 0.00000 4.00000 -2.00000 --------------------------------------------------------- Choice Reply --------------------------------------------------------- Add multiple of row to another a Interchange rows r Divide row by a constant d Stop s --------------------------------------------------------- enter the letter of your choice d give the row to work on 1 enter the constant to divide by -1 Here is your matrix row/col 1 2 3 4 5 1 1.00000 1.00000 -2.00000 -2.00000 0.00000 2 0.00000 1.00000 -1.00000 1.00000 -1.00000 3 -1.00000 0.00000 1.00000 3.00000 -1.00000 4 -1.00000 1.00000 0.00000 4.00000 -2.00000 ---------------------------------------------------------- Choice Reply ---------------------------------------------------------- Add multiple of row to another a Interchange rows r Divide row by a constant d Stop s ---------------------------------------------------------- enter the letter of your choice a give the row to be added. 1 what is the row to add it to? 3 what should the first row be multiplied by? 1 Here is your matrix row/col 1 2 3 4 5 1 1.00000 1.00000 -2.00000 -2.00000 0.00000 2 0.00000 1.00000 -1.00000 1.00000 -1.00000 3 0.00000 1.00000 -1.00000 1.00000 -1.00000 4 -1.00000 1.00000 0.00000 4.00000 -2.00000
Note that the term "first row" refers to the "row to be added." Now
we have eliminated the negative one in the third row as we can see in
this listing of the matrix. We can repeat the operation of adding row
1 to row 4 to eliminate the negative one there. Then we can turn our
attention to the second column and see what happens when we eliminate
the ones in the third and fourth rows. After doing so, we finally get
to:
Here is your matrix row/col 1 2 3 4 5 1 1.00000 0.00000 -1.00000 -3.00000 1.00000 2 0.00000 1.00000 -1.00000 1.00000 -1.00000 3 0.00000 0.00000 0.00000 0.00000 0.00000 4 0.00000 0.00000 0.00000 0.00000 0.00000 --------------------------------------------------------- Choice Reply --------------------------------------------------------- Add multiple of row to another a Interchange rows r Divide row by a constant d Stop s --------------------------------------------------------- enter the letter of your choice s ans = 1 0 -1 -3 1 0 1 -1 1 -1 0 0 0 0 0 0 0 0 0 0 >> stind=ans;
Now we see there are only two independent equations. Let's look at
the two equations our procedure gave us. The matrix returned by
driver was shown in the last part of our session. It is the matrix
that gives stoichiometric coefficients for the reactions. Thus to use
chemeqs to list the reactions, we have to pick out
the first two rows.
>> st=stind(1:2,:) st1 = 1 0 -1 -3 1 0 1 -1 1 -1 >> chemeqs(st,form) ans = CO + 3H2 --> CH4 + H2O CO + H2O --> CO2 + H2
That gives two possible linearly independent equations. There are
other possible equations that you could get using the same
driver program.