MATLAB Code
Introduction: “Petrochemical Processing”
Diethanolamine (DEA) is extensively used in the gas processing
industry for removing acid gases such as carbon dioxide and
hydrogen sulfide from light hydrocarbons. DEA's popularity is based
on several factors: energy savings compared with certain other
solvents; high affinity for acid gases; fair resistance to
degradation. Degradation is defined as the irreversible
transformation of DEA into undesirable compounds. The principal
degradation compounds were found to be
3-(hydroxyethyl)-2-oxazolidone (HEOD),
N,N,N-tris(hydroxyethyl)ethylenediamine (THEED), and
N,N-bis(hydroxyethyl)-piperazine (BHEP).[1]
In this problem we will investigate a simplified chemical kinetic mechanism for degradation of DEA dissolved in water, using the compartment model framework introduced in our class presentation entitled, “Introduction to Modeling III: Systems of Population Equations and Compartment Models.”
Consider the following compartment model for the degradation of DEA:
[1] Kennard, M.L. and Meisen, A., “Mechanisms and Kinetics of Diethanolamine Degradation”, Industrial & Engineering Chemistry Fundamentals, 1985, 24, 129-140.
Situation:
DEA dissociates (degrades) into HEOD at a rate of 1.67% per hour, as indicated by the d1 pathway in the compartment diagram. DEA also dissociates into THEED at a rate of 2.56% per hour, as indicated by the d2pathway. Finally, THEED degrades into BHEP at a rate of 6.33% per hour, as indicated by the d3 pathway.
Note #1: In Chemistry the term “mass fraction” is commonly used to refer to the fraction of a solution that is a given chemical. So saying “a 0.65 mass fraction” means that within the solution, 65% is the given chemical. A 0.0 mass fraction means that the chemical is NOT present. This term is used so that chemists do not have to worry about the volume or quantity of the whole solution.
Note #2: DEA simultaneously dissociates into two different products, and thus, it “dies twice”, so to speak. The overall “death rate” for DEA is therefore the sum of its two, individual dissociation rates. HOWEVER, both HEOD and THEED receive immigrants from DEA at rates corresponding to the rate (d1 or d2) that points into their respective compartments!
Problem: Write a SINGLE MATLAB program that solves ALL 4 of the below questions in response to the above situation. YES all 4 questions below must be answered and displayed as a SINGLE and to be able to answer the following questions:
HINT: To put more than one line on a plot, you can use the following command. This example plots arrays A/B/C/D, you would use the array names that you build in the code. MATLAB will change the color of each line as it prepares the plot. I suggest to use the "1:length(A)" so that you don't have to count the size of the A Array:
plot(1:length(A),A, 1:length(B),B, 1:length(C),C, 1:length(D),D)
legend('A','B','C','D')
CODE:
%Petrochemical Processing
% intialisation the given at t = 0hour; index starts from (1)
DEA(1) = 0.65;
HEOD(1) = 0; THEED(1) = 0; BHEP(1) = 0;
d1 = 0.0167; % 1.67%/hour DEA to HEOD
d2 = 0.0256; % 2.56%/hour DEA to THEED
d3 = 0.0633; % 6.33%/hour THEED to BHEP
for t=2:121
HEOD(t) = HEOD(t-1) + DEA(t-1)*(d1);
THEED(t) = THEED(t-1) + DEA(t-1)*(d2);
DEA(t) = DEA(t-1)*(1-d1-d2);
BHEP(t) = BHEP(t-1) + THEED(t)*(d3);
THEED(t) = THEED(t)*(1-d3);
end
%Q1
c = 33 + 1; % 33rd hour
fprintf('33 hours: DEA %6.4f HEOD %6.4f THEED %6.4f BHEP %6.4f
\n',DEA(c), HEOD(c), THEED(c), BHEP(c));
%Q2
c = 100 + 1; % 100th hour
fprintf('100 hours: DEA %6.4f HEOD %6.4f THEED %6.4f BHEP %6.4f
\n',DEA(c), HEOD(c), THEED(c), BHEP(c));
%Q3 plot the three graphs
t = 1:121;
figure
hold on
plot(t,DEA,t,HEOD,t,THEED,t,BHEP)
xlabel('Hours')
ylabel('Mass Fraction')
legend('DEA','HEOD','THEED','BHEP')
%Q4 toal mass fraction at 120th hour
c = 121;
fprintf('Total Mass fraction at 120th Hour: %6.4f \n',DEA(c) +
HEOD(c) + THEED(c) + BHEP(c))
SCREENSHOT
PLOT AND OUTPUT
Please go through above code and screenshots and if you have any doubts then message me.
Give me a thumbs up. Thanks.
MATLAB Code Introduction: “Petrochemical Processing” Diethanolamine (DEA) is extensively used in the gas processing industry for removing acid gases such as carbon dioxide and hydrogen sulfide from li...