Cutlip Cutli p and Shacham: Probl Problem em Solving in Chemi Chemical cal and Biochem Biochemical ical Engineering Engineering
Chapter 2
Basic Principles and Calculations
Cheng-Liang Chen
P SE
LABORATORY
Department of Chemical Engineering National TAIWAN University
Chen CL
1
Molar Volume and Compressibility Factor from van der Waals Equation Concepts Utilized: Use of the van der Waals equation of state to calculate
molar volume and compressibility factor for a gas. Numerical Methods: Solution of a single nonlinear algebraic equation. Problem Statement:
The ideal gas law can represent the pressure-volume-temperature (PVT) relationship of gases only at low (near atmospheric) pressures. For higher pressures more complex equations of state should be used. The calculation of the molar volume and the compressibility factor using complex equations of state typically requires a numerical solution when the pressure and temperature are specified. The van der Waals equation of state is given by a P + 2 (V − b) = RT V 2 2 27 R T c RT c a= , b = 64 P c 8P c
Where P = pressure in atm, V = molar volume in liters/g-mol, T = temperature in K, R= gas constant (R ( R = 0.08206 atm-liter/g-mol K), T c = critical
Chen CL
2
temperature (405 (405..5 K for ammonia), P c = critical pressure (111 (111..3 atm for ammonia). Reduced pressure and the compressibility factor are defined as P P r = P c
P V Z = RT
(a) Calcul Calculate ate the mol molaar vol volume ume and com comp press ressibi ibilit lityy fac facto torr fo forr gas gaseou eouss amm ammoni oniaa at a pressure P = 56 atm and a temperature T = 450 K using the van der Waals equation of state. (b) Repeat the calculations calculations for the following following reduced pressures: pressures: P r = 1, 2, 4, 10 10,, 20 20.. (c) Ho How w does the compressib compressibilit ilityy factor vary vary as a function of P r? Solution:
A function of volume, f f ((V V )), is defined and setting it to zero.
a f ((V f V )) = P + 2 (V − b) − RT V MATLAB has equation solvers such as fzero (in all versions) and fsolve (in the
optimization Toolbox). To use the solvers one must define f f ((V V )) as a
Chen CL
3
MATLAB function. An example of a function is the following NLEfun(V). All statements following % are ignored by MATLAB. The semi-colons prevent the
values from being printed while the program is being executed. function P2_01A_CCL % Section 2.1, Pages 15,16 clear, clc, format short g, format compact disp(’For gaseous ammonia (Pc = 111.3 atm, Tc = 405.5 K) ’) disp(’When P = 56 atm, T = 450.0 K ’) disp(’Molar volumn by ideal gas law (L/g-mol) is ’) Videal = (0.08206 * 450) / 56; disp(Videal) disp(’ ’) disp(’Problem: find volume by Van Der Waals Eq. ’) Vguess = input(’ Please enter initial guess: ’); disp(’ ’) disp(’Variable value at the initial estimate’); disp([’Unknown=’ num2str(Vguess) ’Func.=’ num2str(NLEfun(Vguess))]); Vsolv=fzero(@NLEfun,Vguess); disp(’ ’) disp(’ Variable values at the solution’); disp([’Unknown=’ num2str(Vsolv) ’Function=’ num2str(NLEfun(Vsolv))]);
Chen CL
disp(’ ’) disp(’ Compressibility factor Z = V(Van Dea Waals)/V(ideal) is Z = Vsolv / Videal; disp(Z) % %- - - - - - - - - - - - - - - - - - - - - function fV = NLEfun(V); P = 56; R = .08206; T = 450; Tc = 405.5; Pc = 111.3; Pr = P / P c; a = 27 * R ^ 2 * Tc ^ 2 / Pc / 64; b = R * Tc / (8 * Pc); Z = P * V / (R * T); fV = (P+a/(V^2))*(V-b)-(R*T);
4
’);
Chen CL
5
For gaseous ammonia (Pc = 111.3 atm, Tc = 405.5 K) When P = 56 atm, T = 450.0 K Molar volume by ideal gas law (L/g-mol) is 0.65941 Problem:
find volume by Van Der Waals Eq. Please enter initial guess: 0.5
Variable value at the initial estimate Unknown value = 0.5 Function Value = -3.2533 Variable values at the solution Unknown value = 0.57489 Function Value = 0 Compressibility factor Z = V(Van Dea Waals)/V(ideal) is 0.87183
Chen CL
6
function P2_01B_CCL % Section 2.1, Pages 15,16 clear, clc, format short g, format compact repeat = 1; while repeat disp(’ ’) disp(’For gaseous ammonia (Pc = 111.3 atm, Tc = 405.5 K) ’) disp(’Problem: find volume by Van Der Waals Eq. at given Pr value’ Pr = input(’ Please enter Pr value: ’); disp(’At given Pr, and T = 450.0 K ’) disp(’Molar volume by ideal gas law (L/g-mol) is ’) Videal = (0.08206 * 450) / (111.3*Pr); disp(Videal) disp(’ ’) Vguess = input(’ Enter initial guess of V(Pr; Van Der Waals) disp(’ ’) disp(’Variable value at the initial estimate’); disp([’Unkn=’ num2str(Vguess) ’ Func=’ num2str(NLEfun(Vguess,Pr))]); Vsolv = fzero(@(Vguess) NLEfun(Vguess,Pr),Vguess); disp(’ ’) disp(’ Variable values at the solution’); disp([’ Unkn=’ num2str(Vsolv) ’ Func.=’ num2str(NLEfun(Vsolv,Pr))]);
Chen CL
7
disp(’ disp (’ ’) disp di sp(’ (’ Co Comp mpre ress ssib ibil ilit ity y fa fact ctor or Z = V( V(Va Van n De Dea a Wa Waal als) s)/V /V(i (ide deal al) ) ’) ’); ; Z = Vso solv lv / Vi Vide deal al; ; disp(Z) repe re peat at = in inpu put( t(’\ ’\n\ n\n n Re Repe peat at th the e ca calc lcul ulat atio ions ns: : 0 (N (No) o), , 1 (y (yes es)) )) ? ’ end
Chen CL
8
Molar Volume and Compressibility Factor from Redlich-Kwong Equation Concepts Utilized: Use of the Redlich-Kwong equation of state to calculate
molar volume and compressibility factor for a gas. Numerical Methods: Solution of a single nonlinear algebraic equation. Problem Statement:
The Redlich-Kwong equation of state is given by RT a √ − P = (V − b) V V ((V + b) T 5/2 R2T c a = 0.42747 P c RT c b = 0.08664 P c
Solution:
Chen CL
9
function P2_02 function P2_02A_CCL A_CCL % Se Sect ctio ion n 2. 2.2, 2, Pa Page ge 19 clea cl ear, r, cl clc, c, fo form rmat at sh shor ort t g, fo form rmat at co comp mpac act t disp di sp(’ (’Fo For r ga gase seou ous s am ammo moni nia a (P (Pc c = 11 111. 1.3 3 at atm, m, Tc = 40 405. 5.5 5 K) ’) disp(’When P = 56 atm, T = 450.0 K ’) dis di sp( p(’M ’Mol olar ar volu volume me by ideal ideal gas gas law (L/g (L/g-m -mol ol) ) is ’) Vid Vi dea eal l = (0 (0. .08 0820 206 6 * 45 450) 0) / 56 56; ; disp(Videal) disp di sp(’ (’ ’) disp di sp(’ (’Pr Prob oble lem: m: fi find nd vo volu lume me by Re Redl dlic ichh-Kw Kwon ong g Eq Eq. . ’) Vguess = input(’ Please enter initial guess: ’); disp di sp(’ (’ ’) disp(’ dis p(’Var Variab iable le val value ue at the ini initia tial l est estima imate’ te’); ); disp([’Unk disp( [’Unkn=’ n=’ num2s num2str(Vg tr(Vguess) uess) ’ Func. Func.=’ =’ num2s num2str(NL tr(NLEfun( Efun(Vgues Vguess))]) s))]); ; Vsolv=fzero(@NLEfun,Vguess); disp di sp(’ (’ ’) disp di sp(’ (’ Va Vari riab able le va valu lues es at th the e so solu luti tion on’) ’); ; disp([ dis p([’Un ’Unkn= kn=’ ’ num num2st 2str(V r(Vsol solv) v) ’ Fun Func.= c.=’ ’ num num2st 2str(N r(NLEf LEfun( un(Vso Vsolv) lv))]) )]); ; disp di sp(’ (’ ’) disp di sp(’ (’ Co Comp mpre ress ssib ibil ilit ity y fa fact ctor or Z = V( V(Re Redl dlic ich h Kw Kwon ong) g)/V /V(i (ide deal al) ) is ’) ’); ; Z = Vsolv / Videal; disp(Z)
Chen CL
% %- - - - - - - - - - - - - - - - - - - - - function fV = NLEfun(V); P = 56; R = .08206; T = 450; Tc = 405.5; Pc = 111.3; Pr = P / P c; a = 0.42747*R^2*Tc^(5/2)/Pc; b = 0.08664* R * Tc / Pc; Z = P * V / (R * T); fV = (P + a/(V*(V+b)*sqrt(T)) )*(V-b)-(R*T);
10
Chen CL
11
For gaseous ammonia (Pc = 111.3 atm, Tc = 405.5 K) When P = 56 atm, T = 450.0 K Molar volume by ideal gas law (L/g-mol) is 0.65941 Problem:
find volume by Redlich-Kwong Eq. Please enter initial guess: 0.5
Variable value at the initial estimate Unknown value = 0.5 Function Value = -3.0991 Variable values at the solution Unknown value = 0.5698 Function Value = 0 Compressibility factor Z = V(Redlich Kwong)/V(ideal) is 0.86411
Chen CL
12
function P2_02B_CCL % Section 2.2, Page 19 clear, clc, format short g, format compact repeat = 1; while repeat disp(’ ’) disp(’For gaseous ammonia (Pc = 111.3 atm, Tc = 405.5 K) ’) disp(’Problem: find volume by Redlich Kwong Eq. at given Pr value’ Pr = input(’ Please enter Pr value: ’); disp(’At given Pr, and T = 450.0 K ’) disp(’Molar volume by ideal gas law (L/g-mol) is ’) Videal = (0.08206 * 450) / (111.3*Pr); disp(Videal) disp(’ ’) Vguess = input(’ Enter initial guess of V(Pr; Van Der Waals): disp(’ ’) disp(’Variable value at the initial estimate’); disp([’Unkn=’ num2str(Vguess) ’ Func.= ’ num2str(NLEfun(Vguess,Pr)) Vsolv = fzero(@(Vguess) NLEfun(Vguess,Pr),Vguess); disp(’ ’) disp(’ Variable values at the solution’); disp([’ Unkn=’ num2str(Vsolv) ’ Func.=’ num2str(NLEfun(Vsolv,Pr))]
Chen CL
13
disp(’ ’) disp(’ Compressibility factor Z = V(Redlich Kwong)/V(ideal) ’); Z = Vsolv / Videal; disp(Z) repeat = input(’\n\n Repeat the calculations: 0 (No), 1 (yes))? ’); end
Chen CL
14
Stoichiometric Calculations for Biological Reactions Concepts Utilized: Use of elemental balances to calculate the stoichiometric
coefficients using respiratory quotient, RQ, in general biological reactions. Numerical Methods: Solution of a system of linear equations. Problem Statement:
A simplified biological conversion reaction can be written for a carbohydrate reacting with oxygen and ammonia to form cellular material and only water and carbon dioxide products as CH mOn + aO2 + bNH 3 → cCH αOβ N δ + dH 2O + eCO2
(2-10)
Thus the reactant carbohydrate and the product of cellular material contain only one gram atom of carbon. When complete elemental analyses of the carbohydrate reactant and the cellular product are known, the elemental balances can be written as Carbon Balance: 1 = c+e Hydrogen Balance: m + 3b = cα + 2d Oxygen Balance: n + 2a = cβ + d + 2e Nitrogen Balance:
b = cδ
Chen CL
15
This is a system of four linear equations with five unknowns and may be completely defined adding an additional relationship between the unknowns. The respiratory quotient, RQ, is defined as RQ =
e a
and this equation can be added to the above system equations. (a) Glucose substrate, C 6H 1206, reacts with oxygen and ammonia to form a bacteria, CH 2O0.27N 0.25, water, and carbon dioxide with a respiratory quotient of 1.5. What are the stoichiometric coefficients for this reaction when it is written in the form of Equation (2-10)? (b) Repeat the calculations for part (a) with a respiratory quotient of 2.0. (c) Repeat the calculations of part (a) when benzoic acid substrate, C 6H 5COOH , forms the same bacteria under anaerobic conditions where there is no gaseous oxygen present.
Chen CL
16
Solution:
It is first necessary to express glucose in the form of Equation (2-10) as C 1H 2O1. The respiratory quotient can be written as 1.5a = e The problem then become a system of linear equations, where m = 2, n = 1, α = 2, β = 0.27, and δ = 0.25 as shown below. c+e=1 3b − 2c − 2d = −2 2a − 0.27c − d − 2e = −1 b − 0.25c = 0 1.5a − e = 0
Chen CL
function P2_03A_CCL clear, clc, format short g, format compact A=[0 0 1 0 1 0 3 -2 -2 0 x = 2 0 -.27 -1 -2 0 1 -.25 0 0 1.5 0 0 0 -1]; b=[ 1 -2 -1 0 0]; x = inv(A)*b
17
0.23165 0.16313 0.65253 0.59217 0.34747
(= (= (= (= (=
a) b) c) d) e)
Chen CL
18
Steady-State Material Balances on A Separation Train Concepts Utilized:
Material balances on a steady-state process with no recycle. Numerical Methods:
Solution of simultaneous linear equations. Problem Statement:
Paraxylene, styrene, toluene, and benzene are to be separated with the array of distillation columns shown in below. (a) Calculate the molar flow rates of D1, D2, B1, and B2. (b) Reduce the original feed flow rate to the first column in turn for each one of the components by first 1%, then 2%, and calculate the corresponding flow rates of D1, B1, D2, and B2. Explain your results. (c) Determine molar flow rates and compositions of streams B and D for part (a).
Chen CL
19
Solution:
Material balances on individual components yield Xylene: 0.07D1 + 0.18B1 + 0.15D2 + 0.24B2 Styrene: 0.04D1 + 0.24B1 + 0.10D2 + 0.65B2 Toluene: 0.54D1 + 0.42B1 + 0.54D2 + 0.l0B2 Benzene: 0.35D1 + 0.16B1 + 0.21D2 + 0.01B2 function P2_04A_CCL clear, clc, format short g, format compact A=[.07 .18 .15 .24 x = .04 .24 .1 .65 .54 .42 .54 .1 .35 .16 .21 .01]; b=[10.5 17.5 28 14]; x = inv(A)*b
= = = =
0.15 × 70 0.25 × 70 0.40 × 70 0.20 × 70
26.25 17.5 8.75 17.5
Chen CL
20
Fitting Models by Least Squares inputs = xi1, xi2, · · · , xip (y1
;
(y2 ..
;
(yn
;
output = yi,
x11, x12, · · · , x1 p)
(1st observation data)
x21, x22, · · · , x2 p) ..
(2nd observation data)
xn1, xn2, · · · , xnp)
(nth observation data)
y = β 1x1 + β 2x2 + · · · + β px p
⇒
i = 1, . . . , n
(linear model)
y1 = β 1x11 + β 2x12 + · · · + β px1 p + 1 y2 = β 1x21 + β 2x22 + · · · + β px2 p + 2 .. .. yn
= β 1xn1 + β 2xn2 + · · · + β pxnp + n
nth obs
nth model output, yˆn
error
Chen CL
21
Fitting Models by Least Squares n
f =
i2 =
yi
β
∗
= 0
ˆ =β
∗
n
ˆ1 yixi1 = β
i=1 n
ˆ1 yixi2 = β ..
..
..
n
i=1
∂f ∂ β2 n
i=1 n i=1
i=1
β j xij
(SSE)
j =1
find β 1, · · · , β p to minimize SSE ?
Q: ∂f ∂ β1
2
p
n
i=1
− ··· ··· ··· ···
i=1 n
ˆ1 yixip = β
i=1
β
∗
ˆ =β
∂f ∂ β p
=0
∗
β
∗
ˆ =β
=0
∗
n
ˆ2 xi1xi1 + β
n
xi1xi2 +
ˆ p + β
i=1 n
ˆ2 xi2xi1 + β
i=1 n
xi2xi2 +
ˆ p + β
i=1
i=1
n
n
ˆ2 xipxi1 + β
xipxi2 +
i=1
xi1xip
ˆ p + β
i=1
xi2xip
xipxip
Chen CL
22
Fitting Models by Least Squares n
⇒ Q: how to find β ˆ , · · · , β ˆ p? (to minimize 1
y1 y2 ..
yn
obs.s
=
x11 x12 x21 x22 .. .. xn1 xn2
x1 p
···
xnp
..
x2 p ..
model outputs
ˆ + Y = X β
··· ···
i2 = T )
i=1
β 1 β 2 ..
β p
1
+
2 ..
n
error
f = T = (Y − X β )T (Y − X β ) (SSE)
∂f ˆ = = X T Y − X T X β ˆ ∂ β β ˆ = (X T X ) 1X T Y β −
0
Chen CL
23
Fitting Polynomials by Least Squares y = β 0 + β 1x + β 2x2 + · · · + β px p
y1 y2 ..
yn
obs.s
=
1 x1 x21 2 2
1 x2 x .. .. ..
1 xn x2n
x p1
···
x pn
p
x2
..
model outputs
ˆ + Y = X β
··· ···
(polynomial)
β 0 β 1 β 2 .. β p
1
+
2 ..
n
error
f = T = (Y − X β )T (Y − X β ) (SSE)
∂f ˆ = = X T Y − X T X β ˆ ∂ β β ˆ = (X T X ) 1X T Y β −
0
Chen CL
24
Fitting Polynomials and correlation Equations to Vapor Pressure Data Concepts Utilized:
Use of polynomials, the Clapeyron equation, and the Riedel equation to correlate vapor pressure versus temperature data. Numerical Methods:
Regression of polynomials of various degrees and linear regression of correlation equations with variable transformations. Problem Statement:
The following table presents data of vapor pressure versus temperature for benzene. Some design calculations require these data to be correlated accurately by algebraic equations.
Vapor Pressure of Benzene (Ambrose) Temp. (K)
Pressure (Pa)
Temp (K)
Pressure (Pa)
290.08
8634.0
353.47
102040.0
302.39
15388.0
356.19
110850.0
311.19
22484.0
358.87
120140.0
318.69
30464.0
362.29
132780.0
325.1
38953.0
365.23
144530.0
330.54
47571.0
367.90
155800.0
334.89
55511.0
370.53
167600.0
338.94
63815.0
373.15
180060.0
342.95
72985.0
375.84
193530.0
346.24
81275.0
378.52
207940.0
349.91
91346.0
381.32
223440.0
Chen CL
25
A simple polynomial is often used as an empirical correlation equation. This can be written in general form as P (x) = a0 + a1x + a2x2 + . . . + anxn where a0, . . . , an are parameters, also called coefficients, to be determined by regression and n is the degree of the polynomial. Typically the degree of the polynomial is selected that gives the best data correlation when using a least-squares objective function. The Clapeyron equation is given by log(P ) = A +
B T
where T is the absolute temperature in K and both A and B are the parameters of the equation that are typically determined by regression. The Riedel equation has the form log(P ) = A +
B + C log(T ) + DT β T
Chen CL
26
where T is the absolute temperature in K and A, B, C , and D are parameters determined by regression. β in the above equation is an integer exponent that is typically set to a value of 2. (a) Correlate the data with polynomials of different degrees by assuming that the absolute temperature in K is the independent variab and P in Pa is the dependent variable. Determine the degree of polynomial fits the data best. (b) Correlate the data using the Clapeyron equation. (c) Correlate the data using the Riedel equation. (d) Discuss which of the preceding correlations best represents the given data set. Solution:
To obtain the polynomials that represent the data of P (dependent variable) versus data of T K (independent variable). P (calc) = a0 + a1T K + a2T K 2 + a3T K 3 + a4T K 4
Chen CL
27
The least squares objective function: N
i=1
The variance:
P (obs) − P (calc)
N
σ2 =
i=1
2
P (obs) − P (calc) N − (n + 1)
2
function P2_05A_CCL clear, clc,format short g, format compact prob_title = ([’ VP Correlation for Benzene’]); ind_var_name= [’\bf Temp. (K)’]; dep_var_name= [’\bf Vapor Pressure (Pa) ’]; xyData=[ 290.08 8634.0 302.39 15388.0 311.19 22484.0 318.69 30464.0 325.1 38953.0 330.54 47571.0 334.89 55511.0
Chen CL
28
338.94 63815.0 342.95 72985.0 346.24 81275.0 349.91 91346.0 353.47 102040.0 356.19 110850.0 358.87 120140.0 362.29 132780.0 365.23 144530.0 367.9 155800.0 370.53 167600.0 373.15 180060.0 375.84 193530.0 378.52 207940.0 381.32 223440.0]; x = xyData(:,1); y = xyData(:,2); [m,n] = size(x); freeparm=input(’ Input 1 if there is a free parameter, 0 otherwise degree =input(’ Enter the degree of the polynomial ’); [Beta, ycal, ConfInt, Var, R2, n] = PolyReg(x,y,degree,freeparm); disp([’ Results,’ prob_title]);
Chen CL
Res=[]; for i=0:n-1 if freeparm==0; ii=i+1; else ii=i; end Res=[Res; ii Beta(i+1) ConfInt(i+1)]; end disp(’ Parameter No. Beta Conf_int’); disp(Res); disp([’ Variance ’, num2str(Var)]); disp([’ Correlation Coefficient ’, num2str(R2)]); % %Plot of experimental and calculated data % for i=1:m index(i)=i; end subplot(2,1,1) plot(x,ycal, ’r-’,x,y,’b+’,’LineWidth’,2) % plot(index,ycal, ’r-’,index,y,’b+’,’LineWidth’,2) set(gca,’FontSize’,14,’Linewidth’,2) title([’\bf Cal./Exp. data ’ prob_title],’FontSize’,12) xlabel([’\bf Exp. Temperature’],’FontSize’,14) % xlabel([’\bf Point No.’],’FontSize’,14)
29
Chen CL
30
ylabel([dep_var_name],’FontSize’,14) %pause subplot(2,1,2) plot(y,y-ycal,’*’,’LineWidth’,2) % residual plot set(gca,’FontSize’,14,’Linewidth’,2) title([’\bf Residual plot, ’ prob_title],’FontSize’,12) xlabel([dep_var_name ’\bf (measured)’],’FontSize’,14) ylabel(’\bf Residual’,’FontSize’,14) %pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [Beta,ycal,ConfInt,Var,R2,n]=PolyReg(x,y,degree,freeparm) tdistr95=[12.7062 4.3027 3.1824 2.7764 2.5706 2.4469 2.3646 2.306... 2.2622 2.2281 2.2010 2.1788 2.1604 2.1448 2.1315 2.1199... 2.1098 2.1009 2.0930 2.0860 2.0796 2.0739 2.0687 2.0639... 2.0595 2.0555 2.0518 2.0484 2.0452 2.0423 2.0395 2.0369... 2.0345 2.0322 2.0301 2.0281 2.0262 2.0244 2.0227 2.0211... 2.0195 2.0181 2.0167 2.0154 2.0141]; % 95 % prob t-distr. if freeparm==1 n=degree+1; else n=degree;
Chen CL
31
end m=size(x,1); for i=1:m for j=1:n if freeparm==1 p=j-1; else p=j; end X(i,j)=x(i)^p; %Calculate powers of the independent variable and put end end Beta=X\y; % Solve X’Beta = Y using QR decomposition ycal=X*Beta; % Calculated dependent variable values Var=sum((y-ycal)’*(y-ycal))/(m-n); % variance if (m-n)>45 t=2.07824-0.0017893*(m-n)+0.000008089*(m-n)^2; else t=tdistr95(m-n); end A=X’*X; Ainv=A\eye(size(A)); %Calculate the inverse of the X’X matrix
Chen CL
32
for i=1:n ConfInt(i,1)=t*sqrt(Var*Ainv(i,i)); %confidence intervals end ymean=mean(y); R2=(ycal-ymean)’*(ycal-ymean)/((y-ymean)’*(y-ymean));%linear corr
Input 1 if there is a free parameter, 0 otherwise 1 Enter the degree of the polynomial 3 Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.249753e-023. > In P2_05A_CCL>PolyReg at 99 In P2_05A_CCL at 33 Results, VP Correlation for Benzene Parameter No. Beta Conf_int 0 -4.2472e+006 2.0326e+005 1 44001 1820.2 2 -153.46 5.414 3 0.18046 0.0053493 Variance 36161.6487 Correlation Coefficient 0.99999
Chen CL
33
Chen CL
34
Mean Heat Capacity of n-Propane Concepts Utilized:
Calculation of mean heat capacity from heat capacity versus temperature data. Numerical Methods:
Regression of polynomials of various degrees to data and integration of fitted polynomials between definite limits. Problem Statement:
The mean heat capacity (C p) between two temperatures T ref and T can be calculated by
T
C p =
T ref
C p dT (T − T ref )
Use the data in Table to complete the empty boxes in the column for the mean heat capacity of n-propane. Use 25oC (298.15K) as T ref . Solution:
No. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Heat Capacity of Gaseous Propane C p C p Temp. (K) kJ/kg-mol·K kJ/kg-mol·K 50. 34.16 100. 41.30 150. 48.79 200. 56.07 273.15 68.74 300. 73.93 400. 94.01 500. 112.59 600. 128.70 700. 142.67 800. 154.77 900. 163.35 1000. 174.60 1100. 182.67 1200. 189.74 1300. 195.85 1400. 201.21 1500. 205.89
Chen CL
function P2_07A clear, clc,format short g, format compact xyData=[ 50 34.16 100 41.3 150 48.79 200 56.07 273.15 68.74 300 73.93 400 94.01 500 112.59 600 128.7 700 142.67 800 154.77 900 163.35 1000 174.6 1100 182.67
35
1200 189.74 1300 195.85 1400 201.21 1500 205.89]; T_K = xyData(:,1); Cp = xyData(:,2); Tref = 298.15; Cpref= spline(T_K,Cp,Tref); T_K = [Tref;T_K(6:end)]; Cp = [Cpref; Cp(6:end)]; Cpav = cumtrapz(T_K,Cp); for i=2:14 Cpav(i)=Cpav(i)/(T_K(i)-Tref); end disp(’Temp.(K) Cpav (kJ/kg-mol-K)’); disp([T_K(2:end) Cpav(2:end)])
Chen CL
Temp. (K) 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500
36
Cpav (kJ/kg-mol-K) 73.748 83.784 93.453 102.46 110.73 118.3 125.07 131.33 137.23 142.66 147.66 152.28 156.54
Chen CL
37
Gas Volume Calculations Using Various Equations of State Concepts Utilized: Gas volume calculations using the ideal gas, van der Waals,
Soave-Redlich-Kwong, Peng-Robinson, and Beattie-Bridgeman equations of state. Numerical Methods: Solution of a single nonlinear algebraic equation. Problem Statement:
It is proposed to use a steel tank to store carbon dioxide at 300 K. The tank is 2.5 m3 in volume, and the maximum pressure it can safely withstand is 100 atm. (a) Determine the maximum number of moles of CO2 that can be stored in the tank using the equations of state which are discussed in the text that follows. (b) Assuming that the Beattie-Bridgeman equation is the most accurate, what is the percent error in the calculated number of moles using the other correlations? (c) Repeat (b) for different values of T r (T /T c) and P r (P/P c). How do the accuracies of the different correlations change with T r and P r ?
Chen CL
38
Ideal Gas P V = RT RT αa − Soave-Redlich-Kwong P = (V − b) V (V + b) R2 T c2 a = 0.42747 P c b = 0.08664
−
2
α =
1 + m(l
T/Tc)
RT c P c
m = 0.48508 + 1.55171ω − 0.1561ω 2 T c = 304.2 K,) P c = 72.9 atm for CO2) Peng-Robinson
ω = the acentric factor (0.225 for CO2) RT a(T ) P = − (V − b) V (V + b) + b(V − b) R2 T c2 a = 0.45724 P c α(T ) b = 0.0778 α =
Beattie-Bridgeman
− 1 + k(l
T/Tc)
2
RT c P c
k = 0.37464 + 1.54226ω − 0.26992ω 2 RT β γ δ P = + 2+ 3+ 4 V V V V Rc β = RT B0 − A0 − 2 T RcB0 RcB0b γ = RT B0b + A0a − δ = T 2 T 2
Chen CL
39
For CO2, A0 = 5.0065; a = 0.07132; B0 = 0.10476; b = 0.07235; and c = 66.0 × 104. Solution:
One solution to this problem is to find the volume of 1 mole of CO2 at the specified temperature and pressure for each equation of state and then calculate the moles in the 2.5 m3 volume of the tank. The first equation of state (ideal) can be solved directly. In order to be consistent with the rest of the equations, this one can be rewritten as an implicit expression f (V ) = P V − RT
Chen CL
40
function P2_09A1 clear, clc, format short g, format compact xguess = 0.505 ; disp(’Variable values at the initial estimate’); disp([’ Unkn’ num2str(xguess) ’ Func.’ num2str(NLEfun(xguess))]); xsolv=fzero(@NLEfun,xguess); disp(’ Variable values at the solution’); disp([’ Unkn’ num2str(xsolv) ’ Func.’ num2str(NLEfun(xsolv))]); %- - - - - - - - - - - - - - - - - - - - - function fV = NLEfun(V); Variable values at the initial estimate P = 100; Unknown value 0.505 Function Value 2 R = .08206; Variable values at the solution T = 300; Unknown value 0.24618 Function Value nmoles = 2.5 * 1000 / V; fV = P * V - (R * T);
Chen CL
41
function P2_09A2 clear, clc, format short g, format compact xguess = 0.505 ; disp(’Variable values at the initial estimate’); disp([’ Unkn’ num2str(xguess) ’ Func.’ num2str(NLEfun(xguess))]); xsolv=fzero(@NLEfun,xguess); disp(’ Variable values at the solution’); disp([’ Unkn’ num2str(xsolv) ’ Func.’ num2str(NLEfun(xsolv))]); %- - - - - - - - - - - - - - - - - - - - - function fV = NLEfun(V); Variable values at the initial estimate P = 100; Unknown value 0.505 Function Value 2 R = .08206; Variable values at the solution T = 300; Unknown value 0.079572 Function Valu nmoles = 2.5 * 1000 / V; Tc = 304.2; Pc = 72.9; a = 27 * R ^ 2 * Tc ^ 2 / (Pc * 64); b = R * Tc / (8 * Pc); fV = (P + a / (V * V)) * (V - b) - (R * T);
Chen CL
42
Bubble Point Calculation for An Ideal Binary Mixture Concepts Utilized: Calculation of bubble point in an ideal binary mixture. Numerical Methods: Solution of a single nonlinear algebraic equation. Problem Statement:
(a) Calculate the bubble point temperature and equilibrium composition associated with a liquid mixture of 10 mol% n-pentane and 90 mol% n-hexane at 1 atm. (b) Repeat the calculations for liquid mixtures containing 0 mol% up to 100 mol% of n-pentane. (c) Plot the bubble point temperature and mol% of n-pentane in the vapor phase as a function of the mol% in the liquid phase. The vapor pressure of n-pentane, P A , in mm Hg can be calculated from the Antoine equation: 1064.63 log(P A) = 6.85221 − T + 232.0
Chen CL
43
where T is the temperature in oC. The vapor pressure of n-hexane, P B , in mm Hg can be calculated from the Antoine equation: log(P B ) = 6.87776 −
1171.53 T + 224.366
Solution:
At the bubble point, the sum of the partial vapor pressures of the components must equal the total pressure, which in this case is 1 atm or 760 mm of Hg. Denoting xA as the mole fraction of n-pentane in the liquid mixture and xB as the mole fraction of n-hexane, the nonlinear equation to be solved for the bubble point temperature is given by f (T bp) = xAP A + xB P B − 760 At the solution, f (T bp) should become very small, f (T bp) ≈ 0. The vapor phase mole fraction of n-pentane, yA, and the mole fraction of n-hexane, yB , can be calculated from Raoult’s law given by the equations yA = xAP A /760
yB = xB P B /760
Chen CL
44
It is important to note that the bubble point can also be considered as the temperature at which the individual mole fractions in the gas phase sum to 1.0 for the given liquid phase composition. Thus this problem can alternately be solved by solving the nonlinear equation given next as an alternate. f (T bp) = yA + yB − 1
Chen CL
45
function P2_10A clear, clc, format short g, format compact xguess = 49.5 ; disp(’Variable values at the initial estimate’); disp([’ Unkn’ num2str(xguess) ’ Func.’ num2str(NLEfun(xguess))]); xsolv=fzero(@NLEfun,xguess); disp(’ Variable values at the solution’); disp([’ Unkn’ num2str(xsolv) ’ Func.’ num2str(NLEfun(xsolv))]); %- - - - - - - - - - - - - - - - - - - - - function fTbp = NLEfun(Tbp); xA = .1; PA = 10 ^ (6.85221 - (1064.63 / (Tbp + 232))); PB = 10 ^ (6.87776 - (1171.53 / (224.366 + Tbp))); Variable values at the initial estimate xB = 1 - x A; Unknown value 49.5 Function Value -2 yA = xA * PA / 760; Variable values at the solution yB = xB * PB / 760; Function Value fTbp = xA * PA + xB * PB - 760;Unknown value 63.6645
Chen CL
46
Adiabatic Flame Temperature in Combustion
Concepts Utilized: Material and energy balances on an adiabatic system and
calculation of adiabatic flame temperature. Numerical Methods: Solution of a single nonlinear algebraic equation and use
of logical variable during solution. Problem Statement:
When natural gas is burned with air, the maximum temperature that can be reached (theoretically) is the adiabatic flame temperature (AFT). This temperature depends mainly on the composition of the natural gas and the amount of air used in the burner. Natural gas consists mainly of methane, ethane, and nitrogen. The composition is different for natural gas found in various locations. Determine the AFT for the following conditions, and plot the AFT as a function of mol% CH 4 and the stoichiometric molar air to fuel ratio. The composition of natural gas is given below. The air-to-fuel ratios vary between 0.5 to 2.0. it can be assumed that the air and natural gas enter the burner at room temperature and atmospheric pressure. What composition and air-to-fuel ratio
Chen CL
47
leads to the highest AFT? Composition of Natural Gas: CH 4 C 2H 6 N 2
65 ∼ 95 mol% 3 ∼ 33 mol% 2 mol%
The molar heat capacity of the reactants and the combustion products can be calculated from the equation C p = α + βT + γT 2 where T is in K and C p is in cal/g-mol·K. The constants of this equation for the different components are shown in Table as given by Smith and Van Ness. The heat of combustion is −212798 cal/g-mol for CH 4 and −72820 cal/g-mol for C 2H 6, as reported by Henley. Assume that both the air and the natural gas enter at the temperature of 298 K and that the N 2 content of the natural gas is always 2.0 mol%. Air is 21 mol%O2.
Chen CL
48
Molar Heat Capacity of Gases α
β × 103
γ × 106
CH 4
3.381
18.044
-4.30
C 2H 6
2.247
38.201
-11.049
CO2
6.214
10.396
-3.545
H 2O
7.256
2.298
0.283
O2
6.148
3.102
-0.923
N 2
6.524
1.25
-0.001
Solution:
The stoichiometric equations are CH 4 + 2O2 C 2H 6 + 72 O2
−→ −→
CO2 + 2H 2O 2CO2 + 3H 2O
The actual to theoretical molar air-to-fuel ratio can be denoted by x with the inlet mole fractions of CH 4 and C 2H 6 denoted by y and z, respectively. For 1 mol of natural gas, there would be 0.02 mol N 2, y mol CH 4, and z mol C 2H 6. Therefore, the total moles of air required to react completely with the 1 mol of
Chen CL
49
natural gas would be given by (2y + [7/2]z)/0.21. Material balances for the different compounds using a 1 mol natural gas basis are shown in Table for both fuel-rich (x < 1) and fuel-lean (x > 1) situations. Material Balance on the Reacting Species Moles in the product (x < 1)
Moles in the product (x < 1)
Expression
For y = 0.75
Expression
For y = 0.75
y(1 − x)
0.75(1 − x)
0
0
0
0
CO2
(y + 2z)x
1.21x
y + 2z
1.21
H 2O
(2y + 3z)x
2y + 3z
2.19
CH 4 C 2H 6
O2
z(1 − x)
0
0.23(1 − x) 2.19x 0
− 2y + 72 z (x
1)
2.305(x − 1)
N 2 0.02 + 3.76x 2y + 72 z 0.02 + 8.67x 0.02 + 3.76x 2y + 72 z 0.02 + 8.67x
Since both the gas and the air enter at 298 K, this temperature can be used as a reference for enthalpy calculations. The enthalpy change for the product gases from T = 298 K up to the adiabatic flame temperature T f can be calculated from
Chen CL
50
the following expression: 6
6
6
1 1 ∆H P = αini(T f − 298) + β ini(T f 2 − 2982) + γ ini(T f 3 − 2983) 2 i=1 3 i=1 i=1
where ∆H P is the enthalpy change per mole of natural gas fed, and ni is the number of moles of the different compounds, as shown in the above Table. For x < 1 the general energy balance can be written as f (T f ) = −212798xy − 372820xz + ∆H P = 0 For x > 1 the same equation can be used with the value x =1. function P2_13 clear, clc, format short g, format compact xguess = 2000. ; disp(’Variable values at the initial estimate’); disp([’ Unkn’ num2str(xguess) ’ Func.’ num2str(NLEfun(xguess))]); xsolv=fzero(@NLEfun,xguess); disp(’ Variable values at the solution’); disp([’ Unkn’ num2str(xsolv) ’ Func.’ num2str(NLEfun(xsolv))]);
Chen CL
%- - - - - - - - - - - - - - - - - - - - - function fT = NLEfun(T); y = .75; x = .5; z = 1 - y - .02; if (x < 1) CH4 = y * (1 - x); else CH4 = 0; end if (x < 1) C2H6 = z * (1 - x); else C2H6 = 0; end if (x < 1) CO2 = (y + 2 * z) * x; else CO2 = y + 2 * z; end if (x < 1) H2O = (2 * y + 3 * z) * x;
51
Chen CL
else H2O = 2 * y + 3 * z; end N2 = .02 + 3.76 * (2 * y + 7 * z / 2) * x; alp = 3.381*CH4+2.247*C2H6+6.214*CO2+7.256*H2O+6.524*N2; bet = 18.044*CH4+38.201*C2H6+10.396*CO2+2.298*H2O+1.25*N2; gam = -4.3*CH4-(11.049*C2H6)-(3.545*CO2)+.283*H2O-(.001*N2); H0 = alp*298+bet*.001*298*298 / 2+gam*10 ^ -6*298 ^ 3 / 3; Hf = alp*T+bet*.001*T ^ 2 / 2+gam*.000001*T ^ 3 / 3; fT = 212798*y*x+372820*z*x+H0 - Hf; Variable values at the initial estimate Unknown value 2000 Function Value 14679.6191 Variable values at the solution Unknown value 2197.9949 Function Value 1.35e-011
52
Chen CL
53
Usteady-State Mixing in A Tank Concepts Utilized: Unsteady-state material balances. Numerical Methods: Solution of simultaneous ordinary differential equations. Problem Statement:
A large tank is used for removing a small amount of settling solid particles (impurities) from brine in a steady-state process. Normally, a single input stream of brine (20% salt by weight) is pumped into the tank at the rate of 10 kg/min and a single output stream is pumped from the tank at the same flow rate. Normal operation keeps the level constant with the total mass in the tank at 1000 kg which is well below the maximum tank capacity. At a particular time (t = 0) an operator accidentally opens a valve, which causes pure water to flow continuously into the tank at the rate of 10 kg/min (in addition to the brine feed), and the level in the tank begins to rise. Determine the amount of both water and salt in the tank as a function of time during the first hour after the pure water valve has been opened. Assume that the outlet flow rate from the tank does not change and the contents of the tank are well mixed at all times.
Chen CL
54
Solution:
A mass balance on the total mass in the tank yields Accumulation = Input − Output dM = 10 + 10 − 1 0 = 1 0 dt where M is the mass in kg. A mass balance on the salt in the tank yields
dS S = 10(0.2) − 10 dt M
S = 2 − 10 M
where S is the weight of salt in the tank in kg. Note that S/M represents the mass fraction of salt that is leaving the tank at any time t. This is also the mass fraction of salt within the tank since the tank is well mixed. Thus both M and S are functions of time for this problem. At t = 0, the initial conditions are that M = 1000 kg and S = 200 since the brine contains 20% salt by mass. function P2_14_CCL clear, clc, format short g, format compact tspan = [0 60.]; % Range for the independent variable y0 = [1000.; 200.]; % Initial values for the dependent variables
Chen CL
55
disp(’ Variable values at the initial point ’); disp([’ t = ’ num2str(tspan(1))]); disp(’ y dy/dt ’); disp([y0 ODEfun(tspan(1),y0)]); [t,y]=ode45(@ODEfun,tspan,y0); for i=1:size(y,2) disp([’ Solution for dependent variable y’ int2str(i)]); disp([’ t y’ int2str(i)]); disp([t y(:,i)]); plot(t,y(:,i),’LineWidth’,2); set(gca,’FontSize’,14,’Linewidth’,2) title([’\bf Plot of dependent variable y’ int2str(i)],’FontSize’, xlabel(’\bf Independent variable (t)’,’FontSize’,14); ylabel([’\bf Dependent variable y’ int2str(i)],’FontSize’,14); if i < size(y,2) disp(’* Pause **** Please press any key to continue ... ’) pause end end %- - - - - - - - - - - - - - - - - - - - - function dYfuncvecdt = ODEfun(t,Yfuncvec); M = Yfuncvec(1);
Chen CL
S = Yfuncvec(2); SaltPC = 100 * S / M; dMdt = 10; dSdt = 2 - (10 * S / M); dYfuncvecdt = [dMdt; dSdt];
56
Chen CL
57
Heat Exchange in A Series of Tanks Concepts Utilized: Unsteady-state energy balances and dynamic response of
well-mixed heated tanks in series. Numerical Methods: Solution of simultaneous first order ordinary differential
equations. Problem Statement:
Three tanks in sequence are used to preheat a multicomponent oil solution before it is fed to a distillation column for separation. Each tank is initially filled with 1000 kg of oil at 20oC. Saturated steam at a temperature of 250oC condenses within coils immersed in each tank. The oil is fed into the first tank at the rate of 100 kg/min and overflows into the second and the third tanks at the same flow rate. The temperature of the oil fed to the first tank is 20oC. The tanks are well mixed so that the temperature inside the tanks is uniform, and the outlet stream
Chen CL
58
temperature is the temperature within the tank. The heat capacity, C p , of the oil is 2.0 kJ/kg·oC. For a particular tank, the rate at which heat is transferred to the oil from the steam coil is given by the expression Q = U A(T steam − T ) where U A is the product of the heat transfer coefficient and the area of the coil. U A = 10kJ/minoC for each tank T = temperature of the oil in the tank in oC Q = rate of heat transferred in kJ/min (a) Determine the steady-state temperatures in all three tanks. What time interval will be required for T 3 to reach 99% of this steady-state value during startup? (b) After operation at steady state, the oil feed is stopped for three hours. What are the highest temperatures that the oil in each tank will reach during this period? (c) After three hours the oil feed is restored. How long will it take to achieve 101% of steady state value for T 3? Will all steady-state temperatures be the same as before in part (a)?
Chen CL
59
Solution:
Energy balances should be made on each of the individual tanks. In these balances, the mass flow rate to each tank will remain at the same fixed value. Thus W = W 1 = W 2 = W 3. The mass in each tank will be assumed constant as the tank volume and oil density are assumed to be constant. Thus M = M 1 = M 2 = M 3. For the first tank, the energy balance can be expressed by Accumulation = Input − Output dT 1 M C p = W C pT 0 + U A(T steam − T 1) − W C pT 1 dt Note that the unsteady-state mass balance is not needed for tank 1 or any other tanks since the mass in each tank does not change with time. The preceding differential equation can be rearranged and explicitly solved for the derivative,
Chen CL
60
which is the usual format for numerical solution
Similarly,
dT 1 dt dT 2 dt dT 3 dt
= [W C p(T 0 − T 1) + U A(T steam − T 1)] M C p = [W C p(T 1 − T 2) + U A(T steam − T 2)] M C p = [W C p(T 2 − T 3) + U A(T steam − T 3)] M C p
function P2_16A_CCL clear, clc, format short g, format compact tspan = [0 200.]; % Range for the independent variable y0 = [20.; 20.; 20.]; % Initial values for the dependent variables disp(’ Variable values at the initial point ’); disp([’ t = ’ num2str(tspan(1))]); disp(’ y dy/dt ’); disp([y0 ODEfun(tspan(1),y0)]); [t,y]=ode45(@ODEfun,tspan,y0); for i=1:size(y,2) disp([’ Solution for dependent variable y’ int2str(i)]); disp([’ t y’ int2str(i)]); disp([t y(:,i)]);
Chen CL
61
plot(t,y(:,i),’LineWidth’,2); set(gca,’FontSize’,14,’Linewidth’,2) title([’\bf Plot of dependent variable y’ int2str(i)],’FontSize’, xlabel(’\bf Independent variable (t)’,’FontSize’,14); ylabel([’\bf Dependent variable y’ int2str(i)],’FontSize’,14); if i < size(y,2) disp(’* Pause **** Please press any key to continue ... ’) pause end end %- - - - - - - - - - - - - - - - - - - - - function dYfuncvecdt = ODEfun(t,Yfuncvec); T1 = Yfuncvec(1); T2 = Yfuncvec(2); T3 = Yfuncvec(3); W = 100; Cp = 2; T0 = 20; UA = 10; Tsteam = 250; M = 1000; dT1dt = (W * Cp * (T0 - T1) + UA * (Tsteam - T1)) / (M * Cp);
Chen CL
dT2dt = (W * Cp * (T1 - T2) + UA * (Tsteam - T2)) / (M * Cp); dT3dt = (W * Cp * (T2 - T3) + UA * (Tsteam - T3)) / (M * Cp); dYfuncvecdt = [dT1dt; dT2dt; dT3dt];
62