CHE 492 HW 9 Fawaz Alsaiede

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Homework #9

November 30, 2021


CHE 492 - Computer Methods in Chemical Engineering - Dr. Jason Bara
By: Fawaz Alsaiede

1. Question 1:

1.1. Objective:
The first topic asks us to determine the rate constants 𝑘1 , 𝑘2 and 𝑘3 of the given reaction sets
1, 2 and 3 respectively. MATLAB is used to simulate the variation of the concentrations of the
chemical species with time showing the disappearance of reactants and formation of products
simultaneously until the required concentration is reached after 250 s.

1.2. Methods:
In order to simulate the variation of the concentration of the chemical species, the following
equations were used and implemented into MATLAB as can be seen below:

𝑑[𝐶2 𝐻6 ]
−𝑘1 [𝐶2 𝐻6 ] − 𝑘2 [𝐶2 𝐻6 ][𝐻2 ] − 𝑘3 [𝐶2 𝐻6 ][𝐶2 𝐻4 ] = −
𝑑𝑡

𝑑[𝐻2 ]
𝑘1 [𝐶2 𝐻6 ] − 𝑘2 [𝐶2 𝐻6 ][𝐻2 ] = −
𝑑𝑡

𝑑[𝐶2 𝐻4 ]
𝑘1 [𝐶2 𝐻6 ] − 𝑘3 [𝐶2 𝐻6 ][𝐶2 𝐻4 ] = −
𝑑𝑡

𝑑[𝐶𝐻4 ]
𝑘2 [𝐶2 𝐻6 ][𝐻2 ] + 𝑘3 [𝐶2 𝐻6 ][𝐶2 𝐻4 ] = −
𝑑𝑡

𝑑[𝐶3 𝐻6 ]
𝑘3 [𝐶2 𝐻6 ][𝐻2 ] = −
𝑑𝑡

The rate constants were defined as k1, k2 and k3 in MATLAB and the equations found
above were defined in matrix form f where columns 1 through 5 represented the variation of
the concentrations of 𝐶2 𝐻6, 𝐻2 , 𝐶2 𝐻4, 𝐶3 𝐻6, and 𝐶𝐻4 respectively. The initial concentrations
of the chemical species were set as presented in the problem statement. Finally, the
concentrations of 𝐶2 𝐻6, 𝐶2 𝐻4 and 𝐶3 𝐻6 were plotted as a function of time. The final values of
the concentrations were evaluated and the values of k1, k2 and k3 were regulated using
trial and error method in order to obtain a close enough solution. The full MATALAB script
of the code used to evaluate the value of the rate constants can be found in Appendix A.

1
1.3. Results:
Running the MATLAB script for several trials, I started by tweaking the value of k3 which
was equal to k2 since the concentration of 𝐶3 𝐻6 was as a function of k3 only and arrived at
a value of k3 = k2 = 0.00044 where the concentration of 𝐶3 𝐻6 after 250 sec was equal to
0.25 mol/L. I moved on to try changing the value of k1 since the concentration of 𝐶2 𝐻4 was
dependent on it and found it to be around 0.0025 where the concentration of 𝐶2 𝐻4 was equal
to 1.5 mol/L after 250 sec. Figure 1 below shows the variation of the concentrations of 𝐶2 𝐻6,
𝐶2 𝐻4 and 𝐶3 𝐻6 as a function of time where k1, k2 and k3 were configured to obtain the
required final composition.

Figure 1. The variation of the concentrations of 𝐶2 𝐻6, 𝐶2 𝐻4 and 𝐶3 𝐻6 as a function of time


Figure 1 shows variation of the concentrations of 𝐶2 𝐻6, 𝐶2 𝐻4 and 𝐶3 𝐻6 as a function of time
where 𝐶2 𝐻6 is plotted in blue, 𝐶2 𝐻4 is plotted in red and 𝐶3 𝐻6 is plotted in yellow. One must
𝑚𝑜𝑙 𝑚𝑜𝑙
note that after 250 sec time intervals, [𝐶2 𝐻4 ] = 1.5 𝐿
and [𝐶3 𝐻6 ] = 0.25 𝐿
where the
respective rate constants are k1= 0.0025 and k3 = k2 = 0.00044.

1.4. Discussion
The results obtained were close enough, however, we didn’t obtain the exact solution towards
this problem where accuracy may be crucial in configuring such a chemical production facility
ensuring its safe and efficient operation. Further development can be implemented into the
MATLAB script implements several approach methods which could get us as close as possible
to the exact solution saving us time and rigid calculations.

2
2. Question 2:
2.1. Objective:
The second question investigates an alkyne’s complete combustion reaction as well as its wet
and dry basis combustion gases. A MATLAB code is used to evaluate these combustion
parameters.

2.2. Methods:
First, I commenced by requesting the alkyne’s name from the user. I used an if conditional
to warn the user to input an alkyne containing carbon and hydrogen only. I defined two
parameters x and y which represent the number of carbon and hydrogen atoms respectively.
I then used case and switch conditional statements in order to create cases for the type
of hydrocarbon entered and extract its corresponding molecular formula. I moved on to define
the complete combustion reaction of hydrocarbons as follows:
𝑦 𝑦
𝐶𝑥 𝐻𝑦 + (𝑥 + ) 𝑂2 → 𝑥𝐶𝑂2 + 𝑂2
4 2
I then used the fprintf function to display the complete combustion reaction of the
hydrocarbon and converted the amount of oxygen used into the stoichiometric air ratio where
oxygen forms 21% of air composition. Finally, I calculated the dry and wet basis of combustion
gases where the dry basis constitutes of carbon dioxide only whereas the wet basis constitutes
of carbon dioxide and water. The full MATALAB script can be found in Appendix B.

2.3. Results:
After running the MATLAB script, I had to check for the variables Dry_basis and
Wet_Basis as well as the balanced overall chemical combustion reaction. I ran the
MATLAB script for several test runs varying the input as the user would do and the code
performed greatly where it gave the corresponding outputs when the inputs were valid and an
error message otherwise. Figures 2 and 3 below represent a valid and invalid input cases
respectively.

Enter chemical formula or name: Ethyne


Chemical Name: ethyne
Molecular formula: C2H2
Balanced overall reaction:
2C2H2 + 5O2 = 4CO2 + 2H2O
Amount of stoichiometric air = 11.9048 moles
Dry Basis = 2 CO2 or 100 percent CO2
Wet Basis = 2 CO2 or 0.666667 percentage CO2 1 H2O or
0.333333 percentage H2O

Figure 2. MATLAB output results for a valid input hydrocarbon name

3
Enter chemical formula or name: ethene
Error using Question2 (line 69)
Check your input and the correct spelling

Figure 3. MATLAB output results showing an error message for an invalid input
hydrocarbon name

Figure 2 above shows the results of a valid input ethyne into MATLAB whereas Figure 3
displays an error message for the user for an invalid input ethene.

2.4. Discussion:
This script helps the user to save time and effort performing hydrocarbon (alkynes in
our case) combustion calculations as well derivations of the overall combustion
equation. Further development can be implemented into this code by adding a library
of alkanes and alkenes which would definitely render it more beneficial for chemical
engineers. Finally similar codes may be developed which can be used by chemical
engineers.

4
3. New Question:

Write a MATLAB code to help the user perform gas release conditions and calculations form
a chemical facility taking into account the release model, stack height, temperature, pressure
and wind speed.

5
Appendix A
A.1: Full script used to evaluate the value of the chemical reaction’s
rate constants.

A.1: Full script used to evaluate the value of the chemical reaction’s rate constants:
k1 = 0.00215; % set rate
constant k1
k2 = 0.00019; % set rate
constant k2
k3 = 0.00019; % set rate
constant k3
f = @(t,y)[-k1*y(1) - k2*y(1)*y(2) - k3*y(1)*y(3); k1*y(1) - k3*y(1)*y(2);
k1*y(1) - k2*y(1)*y(3); k2*y(1)*y(3) + k3*y(1)*y(2); k3*y(1)*y(2)]; %
define differential equations
tspan = [0 250]; % set interval
of integration
% set initial conditions for reactants
Ao = 4; % C2H6 at t=0
Bo = 0; % H2 at t=0
Co = 0; % C2H4 at t=0
Do = 0; % C3H6 at t=0
Eo = 0; % CH4 at t=0
y0 = [Ao; Bo; Co; Do; Eo]; % set vector of
initial values
[t, y] = ode45(f,tspan,y0); % call
integrator
plot(t,y(:,1),'-o',t,y(:,3),'-o',t,y(:,4),'-o') %Plot A, C, D
vs time

1A
Appendix B
B.1: Full script used to evaluate an alkyne’s complete combustion
reaction as well as its wet and dry basis combustion gases.

B.1: Full script used to evaluate an alkyne’s complete combustion reaction as well as its wet and dry
basis combustion gases:
clc
% Input = 'C4H6'; % Use single quotes
Input = input('Enter chemical formula or name: ', 's');
% Analyse the input
N = strlength(Input);
if N==4 % extract the stoichiometry
if Input(1)=='C'
disp('Chemical formula entered')
C = Input(1);
x = str2double(Input(2));
H = Input(3);
y = str2double(Input(4));
molecular_formula = Input;
Names = {'Ethyne','Propyne','Butyne','Pentyne',...
'Hexyne','Septyne','Octyne','Nonyne','Decyne'};
Chemical_Name = string(Names(1));
else
error('Check your input and the correct spelling')
end
else
Chemical_Name = lower(Input);
switch lower(Input)
case 'ethyne'
% Ethyne (C2H2)
molecular_formula = 'C2H2';
x = 2;
y = 2;
case 'propyne'
% Propyne (C3H4)
molecular_formula = 'C3H4';
x = 3;
y = 4;
case 'butyne'
% Butyne (C4H6)
molecular_formula = 'C4H6';
x = 4;
y = 6;
case 'pentyne'
% Pentyne (C5H8)
molecular_formula = 'C5H8';
x = 5;
y = 8;
case 'hexyne'
% Hexyne (C6H10)
molecular_formula = 'C6H10';
x = 6;
y = 10;
case 'septyne'
% septyne (C7H12)
1B
molecular_formula = 'C7H12';
x = 7;
y = 12;
case 'octyne'
% Octyne (C8H14)
molecular_formula = 'C8H14';
x = 8;
y = 14;
case 'nonyne'
% Nonyne(C9H16)
molecular_formula = 'C9H16';
x = 9;
y = 16;
case 'decyne'
% Decyne (C10H18)
molecular_formula = 'C10H18';
x = 10;
y = 18;
otherwise
error('Check your input and the correct spelling')
end
end

fprintf('Chemical Name: %s\n',Chemical_Name)


fprintf('Molecular formula: %s\n',molecular_formula)
%% Balanced Equation
fprintf('Balanced overall reaction:\n')
n_O2 = x+y/4;
n_CO2 = x;
n_H2O = y/2;

% if the coefficient of O2 is not a whole number, multiply all the


% coeffcients by 2
if floor(n_O2)==ceil(n_O2)
% Display the balanced chemical equation
fprintf('C%gH%g + %gO2 = %gCO2 + %gH2O\n',x,y,n_O2,n_CO2,n_H2O)
else
n_O2 = 2*n_O2;
n_CO2 = 2*n_CO2;
n_H2O = 2*n_H2O;
% Display the balanced chemical equation
fprintf('2C%gH%g + %gO2 = %gCO2 + %gH2O\n',x,y,n_O2,n_CO2,n_H2O)
end

%% amount of stoichiometric air


% 1 Litre of Air contains 21% of oxygen by volume
n_air = (x+y/4)/0.21;
Dry_basis = x;
Water_Composition = y/2;
fprintf('Amount of stoichiometric air = %g moles\n',n_air)
fprintf('Dry Basis = %g CO2 or 100 percent CO2\n',Dry_basis) %for a value of 100%
stochiometric mol ratio of CO2 formed
fprintf('Wet Basis = %g CO2 or %g percentage CO2\t %g H2O or %g percentage
H2O\n',Dry_basis, x/(x+y/2), Water_Composition, y/2/(x+y/2)) %for a value of 100%
stoichiometric mol ratio of CO2 and H2O formed

2B

You might also like