64
Cutlip and Shacham: Problem Solving in Chemical and Biochemical Engineering Chapter 2 Basic Principles and Calculations Cheng-Liang Chen PSE LABORATORY Department of Chemical Engineering National TAIWAN University

11 Basic Principles and Calculations

Embed Size (px)

Citation preview

Page 1: 11 Basic Principles and Calculations

Cutlip and Shacham: Problem Solving in Chemical and Biochemical Engineering

Chapter 2

Basic Principles and Calculations

Cheng-Liang Chen

PSELABORATORY

Department of Chemical EngineeringNational TAIWAN University

Page 2: 11 Basic Principles and Calculations

Chen CL 1

Molar Volume and Compressibility Factorfrom van der Waals Equation

Concepts Utilized: Use of the van der Waals equation of state to calculatemolar 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 higherpressures more complex equations of state should be used. The calculation of themolar volume and the compressibility factor using complex equations of statetypically requires a numerical solution when the pressure and temperature arespecified. The van der Waals equation of state is given by(

P +a

V 2

)(V − b) = RT

a =2764

(R2T 2

c

Pc

), b =

RTc

8Pc

Where P = pressure in atm, V = molar volume in liters/g-mol, T = temperaturein K, R= gas constant (R = 0.08206 atm-liter/g-mol K), Tc = critical

Page 3: 11 Basic Principles and Calculations

Chen CL 2

temperature (405.5 K for ammonia), Pc = critical pressure (111.3 atm forammonia). Reduced pressure and the compressibility factor are defined as

Pr =P

PcZ =

PV

RT

(a) Calculate the molar volume and compressibility factor for gaseous ammonia ata pressure P = 56 atm and a temperature T = 450 K using the van der Waalsequation of state.

(b) Repeat the calculations for the following reduced pressures: Pr = 1, 2, 4, 10, 20.

(c) How does the compressibility factor vary as a function of Pr?

Solution:A function of volume, f(V ), is defined and setting it to zero.

f(V ) =(P +

a

V 2

)(V − b)−RT

MATLAB has equation solvers such as fzero (in all versions) and fsolve (in theoptimization Toolbox). To use the solvers one must define f(V ) as a

Page 4: 11 Basic Principles and Calculations

Chen CL 3

MATLAB function. An example of a function is the following NLEfun(V). Allstatements following % are ignored by MATLAB. The semi-colons prevent thevalues from being printed while the program is being executed.

function P2_01A_CCL% Section 2.1, Pages 15,16clear, clc, format short g, format compactdisp(’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))]);

Page 5: 11 Basic Principles and Calculations

Chen CL 4

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 / Pc;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);

Page 6: 11 Basic Principles and Calculations

Chen CL 5

For gaseous ammonia (Pc = 111.3 atm, Tc = 405.5 K)When P = 56 atm, T = 450.0 KMolar 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 estimateUnknown value = 0.5 Function Value = -3.2533

Variable values at the solutionUnknown value = 0.57489 Function Value = 0

Compressibility factor Z = V(Van Dea Waals)/V(ideal) is0.87183

Page 7: 11 Basic Principles and Calculations

Chen CL 6

function P2_01B_CCL% Section 2.1, Pages 15,16clear, clc, format short g, format compactrepeat = 1;while repeatdisp(’ ’)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))]);

Page 8: 11 Basic Principles and Calculations

Chen CL 7

disp(’ ’)disp(’ Compressibility factor Z = V(Van Dea Waals)/V(ideal) ’);Z = Vsolv / Videal;disp(Z)repeat = input(’\n\n Repeat the calculations: 0 (No), 1 (yes)) ? ’);

end

Page 9: 11 Basic Principles and Calculations

Chen CL 8

Molar Volume and Compressibility Factorfrom Redlich-Kwong Equation

Concepts Utilized: Use of the Redlich-Kwong equation of state to calculatemolar 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

P =RT

(V − b)− a

V (V + b)√

T

a = 0.42747

(R2T

5/2c

Pc

)b = 0.08664

(RTc

Pc

)

Solution:

Page 10: 11 Basic Principles and Calculations

Chen CL 9

function P2_02A_CCL% Section 2.2, Page 19clear, clc, format short g, format compactdisp(’For gaseous ammonia (Pc = 111.3 atm, Tc = 405.5 K) ’)disp(’When P = 56 atm, T = 450.0 K ’)disp(’Molar volume by ideal gas law (L/g-mol) is ’)Videal = (0.08206 * 450) / 56;disp(Videal)disp(’ ’)disp(’Problem: find volume by Redlich-Kwong Eq. ’)Vguess = input(’ Please enter initial guess: ’);disp(’ ’)disp(’Variable value at the initial estimate’);disp([’Unkn=’ num2str(Vguess) ’ Func.=’ num2str(NLEfun(Vguess))]);Vsolv=fzero(@NLEfun,Vguess);disp(’ ’)disp(’ Variable values at the solution’);disp([’Unkn=’ num2str(Vsolv) ’ Func.=’ num2str(NLEfun(Vsolv))]);disp(’ ’)disp(’ Compressibility factor Z = V(Redlich Kwong)/V(ideal) is ’);Z = Vsolv / Videal;disp(Z)

Page 11: 11 Basic Principles and Calculations

Chen CL 10

%%- - - - - - - - - - - - - - - - - - - - - -function fV = NLEfun(V);P = 56;R = .08206;T = 450;Tc = 405.5;Pc = 111.3;Pr = P / Pc;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);

Page 12: 11 Basic Principles and Calculations

Chen CL 11

For gaseous ammonia (Pc = 111.3 atm, Tc = 405.5 K)When P = 56 atm, T = 450.0 KMolar 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 estimateUnknown value = 0.5 Function Value = -3.0991

Variable values at the solutionUnknown value = 0.5698 Function Value = 0

Compressibility factor Z = V(Redlich Kwong)/V(ideal) is0.86411

Page 13: 11 Basic Principles and Calculations

Chen CL 12

function P2_02B_CCL% Section 2.2, Page 19clear, clc, format short g, format compactrepeat = 1;while repeatdisp(’ ’)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))]);

Page 14: 11 Basic Principles and Calculations

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

Page 15: 11 Basic Principles and Calculations

Chen CL 14

Stoichiometric Calculations for Biological Reactions

Concepts Utilized: Use of elemental balances to calculate the stoichiometriccoefficients 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 carbohydratereacting with oxygen and ammonia to form cellular material and only water andcarbon dioxide products as

CHmOn + aO2 + bNH3→ cCHαOβNδ + dH2O + eCO2 (2-10)

Thus the reactant carbohydrate and the product of cellular material contain onlyone gram atom of carbon. When complete elemental analyses of the carbohydratereactant and the cellular product are known, the elemental balances can bewritten as

Carbon Balance: 1 = c + e

Hydrogen Balance: m + 3b = cα + 2d

Oxygen Balance: n + 2a = cβ + d + 2e

Nitrogen Balance: b = cδ

Page 16: 11 Basic Principles and Calculations

Chen CL 15

This is a system of four linear equations with five unknowns and may becompletely 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, C6H1206, reacts with oxygen and ammonia to form a bacteria,CH2O0.27N0.25, water, and carbon dioxide with a respiratory quotient of 1.5.What are the stoichiometric coefficients for this reaction when it is written inthe 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, C6H5COOH,forms the same bacteria under anaerobic conditions where there is no gaseousoxygen present.

Page 17: 11 Basic Principles and Calculations

Chen CL 16

Solution:It is first necessary to express glucose in the form of Equation (2-10) as C1H2O1.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 = 13b− 2c− 2d = −22a− 0.27c− d− 2e = −1b− 0.25c = 01.5a− e = 0

Page 18: 11 Basic Principles and Calculations

Chen CL 17

function P2_03A_CCLclear, clc, format short g, format compactA=[0 0 1 0 1

0 3 -2 -2 02 0 -.27 -1 -20 1 -.25 0 01.5 0 0 0 -1];

b=[ 1-2-100];

x = inv(A)*b

x =0.23165 (= a)0.16313 (= b)0.65253 (= c)0.59217 (= d)0.34747 (= e)

Page 19: 11 Basic Principles and Calculations

Chen CL 18

Steady-State Material Balanceson A Separation Train

Concepts Utilized:Material balances on a steady-stateprocess with no recycle.Numerical Methods:Solution of simultaneous linear equations.Problem Statement:Paraxylene, styrene, toluene, and benzeneare to be separated with the array ofdistillation 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 thecomponents by first 1%, then 2%, and calculate the corresponding flow rates ofD1, B1, D2, and B2. Explain your results.

(c) Determine molar flow rates and compositions of streams B and D for part (a).

Page 20: 11 Basic Principles and Calculations

Chen CL 19

Solution:Material balances on individual components yield

Xylene: 0.07D1 + 0.18B1 + 0.15D2 + 0.24B2 = 0.15× 70Styrene: 0.04D1 + 0.24B1 + 0.10D2 + 0.65B2 = 0.25× 70Toluene: 0.54D1 + 0.42B1 + 0.54D2 + 0.l0B2 = 0.40× 70Benzene: 0.35D1 + 0.16B1 + 0.21D2 + 0.01B2 = 0.20× 70

function P2_04A_CCLclear, clc, format short g, format compactA=[.07 .18 .15 .24

.04 .24 .1 .65

.54 .42 .54 .1

.35 .16 .21 .01];b=[10.5

17.52814];

x = inv(A)*b

x =26.2517.58.7517.5

Page 21: 11 Basic Principles and Calculations

Chen CL 20

Fitting Models by Least Squares

inputs = xi1, xi2, · · · , xip output = yi, i = 1, . . . , n

(y1 ; x11, x12, · · · , x1p) (1st observation data)

(y2 ; x21, x22, · · · , x2p) (2nd observation data)

... ...

(yn ; xn1, xn2, · · · , xnp) (nth observation data)

y = β1x1 + β2x2 + · · ·+ βpxp (linear model)

⇒ y1 = β1x11 + β2x12 + · · ·+ βpx1p + ε1

y2 = β1x21 + β2x22 + · · ·+ βpx2p + ε2... ...

yn︸︷︷︸nth obs

= β1xn1 + β2xn2 + · · ·+ βpxnp︸ ︷︷ ︸nth model output, yn

+ εn︸︷︷︸error

Page 22: 11 Basic Principles and Calculations

Chen CL 21

Fitting Models by Least Squares

f =n∑

i=1

εi2 =

n∑i=1

yi −p∑

j=1

βjxij

2

(SSE)

Q: find β1, · · · , βp to minimize SSE ?

∂f∂β1

∣∣∣β∗=β∗

= 0 ∂f∂β2

∣∣∣β∗=β∗

= 0 · · · ∂f∂βp

∣∣∣β∗=β∗

= 0n∑

i=1

yixi1 = β1

n∑i=1

xi1xi1 + β2

n∑i=1

xi1xi2 + · · ·+ βp

n∑i=1

xi1xip

n∑i=1

yixi2 = β1

n∑i=1

xi2xi1 + β2

n∑i=1

xi2xi2 + · · ·+ βp

n∑i=1

xi2xip

... ... ...n∑

i=1

yixip = β1

n∑i=1

xipxi1 + β2

n∑i=1

xipxi2 + · · ·+ βp

n∑i=1

xipxip

Page 23: 11 Basic Principles and Calculations

Chen CL 22

Fitting Models by Least Squares

⇒ Q: how to find β1, · · · , βp? (to minimizen∑

i=1

εi2 = εTε)

y1

y2

...

yn

︸ ︷︷ ︸obs.s

=

x11 x12 · · · x1p

x21 x22 · · · x2p

... ... ... ...

xn1 xn2 · · · xnp

β1

β2

...

βp

︸ ︷︷ ︸

model outputs

+

ε1

ε2...

εn

︸ ︷︷ ︸error

Y = Xβ + ε

f = εTε = (Y −Xβ)T (Y −Xβ) (SSE)

∂f

∂β

∣∣∣∣ ˆβ = XTY − XTXβ = 0

β = (XTX)−1XTY

Page 24: 11 Basic Principles and Calculations

Chen CL 23

Fitting Polynomials by Least Squaresy = β0 + β1x + β2x

2 + · · ·+ βpxp (polynomial)

y1

y2

...

yn

︸ ︷︷ ︸obs.s

=

1 x1 x2

1 · · · xp1

1 x2 x22 · · · xp

2

... ... ... ...

1 xn x2n · · · xp

n

β0

β1

β2

...

βp

︸ ︷︷ ︸

model outputs

+

ε1

ε2...

εn

︸ ︷︷ ︸error

Y = Xβ + ε

f = εTε = (Y −Xβ)T (Y −Xβ) (SSE)

∂f

∂β

∣∣∣∣ ˆβ = XTY − XTXβ = 0

β = (XTX)−1XTY

Page 25: 11 Basic Principles and Calculations

Chen CL 24

Fitting Polynomials and correlation Equationsto Vapor Pressure Data

Concepts Utilized:Use of polynomials, the Clapeyronequation, and the Riedel equationto correlate vapor pressure versustemperature data.Numerical Methods:Regression of polynomials of variousdegrees and linear regression ofcorrelation equations with variabletransformations.Problem Statement:The following table presents data ofvapor pressure versus temperature forbenzene. Some design calculationsrequire these data to be correlatedaccurately by algebraic equations.

Vapor Pressure of Benzene (Ambrose)

Temp. Pressure Temp Pressure(K) (Pa) (K) (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

Page 26: 11 Basic Principles and Calculations

Chen CL 25

A simple polynomial is often used as an empirical correlation equation. This canbe written in general form as

P (x) = a0 + a1x + a2x2 + . . . + anxn

where a0, . . . , an are parameters, also called coefficients, to be determined byregression and n is the degree of the polynomial. Typically the degree of thepolynomial is selected that gives the best data correlation when using aleast-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 parametersof the equation that are typically determined by regression.

The Riedel equation has the form

log(P ) = A +B

T+ C log(T ) + DT β

Page 27: 11 Basic Principles and Calculations

Chen CL 26

where T is the absolute temperature in K and A, B, C, and D are parametersdetermined by regression. β in the above equation is an integer exponent that istypically set to a value of 2.

(a) Correlate the data with polynomials of different degrees by assuming that theabsolute temperature in K is the independent variab and P in Pa is the dependentvariable. 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 TK (independent variable).

P(calc) = a0 + a1TK + a2TK2 + a3TK3 + a4TK4

Page 28: 11 Basic Principles and Calculations

Chen CL 27

The least squares objective function:

N∑i=1

(P(obs) − P(calc)

)2The variance:

σ2 =N∑

i=1

(P(obs) − P(calc)

)2N − (n + 1)

function P2_05A_CCLclear, clc,format short g, format compactprob_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.0311.19 22484.0318.69 30464.0325.1 38953.0330.54 47571.0334.89 55511.0

Page 29: 11 Basic Principles and Calculations

Chen CL 28

338.94 63815.0342.95 72985.0346.24 81275.0349.91 91346.0353.47 102040.0356.19 110850.0358.87 120140.0362.29 132780.0365.23 144530.0367.9 155800.0370.53 167600.0373.15 180060.0375.84 193530.0378.52 207940.0381.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]);

Page 30: 11 Basic Principles and Calculations

Chen CL 29

Res=[];for i=0:n-1

if freeparm==0; ii=i+1; else ii=i; endRes=[Res; ii Beta(i+1) ConfInt(i+1)];

enddisp(’ 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:mindex(i)=i;

endsubplot(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)

Page 31: 11 Basic Principles and Calculations

Chen CL 30

ylabel([dep_var_name],’FontSize’,14)%pausesubplot(2,1,2)plot(y,y-ycal,’*’,’LineWidth’,2) % residual plotset(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. values

if freeparm==1n=degree+1;

elsen=degree;

Page 32: 11 Basic Principles and Calculations

Chen CL 31

endm=size(x,1);for i=1:m

for j=1:nif freeparm==1

p=j-1;else

p=j;end

X(i,j)=x(i)^p; %Calculate powers of the independent variable and put them in the matrix Xend

endBeta=X\y; % Solve X’Beta = Y using QR decomposition

ycal=X*Beta; % Calculated dependent variable valuesVar=sum((y-ycal)’*(y-ycal))/(m-n); % variance

if (m-n)>45t=2.07824-0.0017893*(m-n)+0.000008089*(m-n)^2;

elset=tdistr95(m-n);

endA=X’*X;Ainv=A\eye(size(A)); %Calculate the inverse of the X’X matrix

Page 33: 11 Basic Principles and Calculations

Chen CL 32

for i=1:nConfInt(i,1)=t*sqrt(Var*Ainv(i,i)); %confidence intervals

endymean=mean(y);R2=(ycal-ymean)’*(ycal-ymean)/((y-ymean)’*(y-ymean));%linear correlation coefficient

Input 1 if there is a free parameter, 0 otherwise 1Enter the degree of the polynomial 3Warning: Matrix is close to singular or badly scaled.

Results may be inaccurate. RCOND = 9.249753e-023.> In P2_05A_CCL>PolyReg at 99In P2_05A_CCL at 33Results, VP Correlation for Benzene

Parameter No. Beta Conf_int0 -4.2472e+006 2.0326e+0051 44001 1820.22 -153.46 5.4143 0.18046 0.0053493

Variance 36161.6487Correlation Coefficient 0.99999

Page 34: 11 Basic Principles and Calculations

Chen CL 33

Page 35: 11 Basic Principles and Calculations

Chen CL 34

Mean Heat Capacity of n-Propane

Concepts Utilized:Calculation of mean heat capacity fromheat capacity versus temperature data.Numerical Methods:Regression of polynomials of variousdegrees to data and integration of fittedpolynomials between definite limits.Problem Statement:The mean heat capacity (Cp) betweentwo temperatures Tref and T can becalculated by

Cp =∫ T

Tref

CpdT/

(T − Tref)

Use the data in Table to complete theempty boxes in the column for the meanheat capacity of n-propane. Use 25oC(298.15K) as Tref.

Heat Capacity of Gaseous Propane

Temp. Cp CpNo. (K) kJ/kg-mol·K kJ/kg-mol·K

1 50. 34.162 100. 41.303 150. 48.794 200. 56.075 273.15 68.746 300. 73.937 400. 94.018 500. 112.599 600. 128.70

10 700. 142.6711 800. 154.7712 900. 163.3513 1000. 174.6014 1100. 182.6715 1200. 189.7416 1300. 195.8517 1400. 201.2118 1500. 205.89

Solution:

Page 36: 11 Basic Principles and Calculations

Chen CL 35

function P2_07Aclear, clc,format short g,format compactxyData=[ 50 34.16100 41.3150 48.79200 56.07273.15 68.74300 73.93400 94.01500 112.59600 128.7700 142.67800 154.77900 163.351000 174.61100 182.67

1200 189.741300 195.851400 201.211500 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);enddisp(’Temp.(K) Cpav (kJ/kg-mol-K)’);disp([T_K(2:end) Cpav(2:end)])

Page 37: 11 Basic Principles and Calculations

Chen CL 36

Temp. (K) Cpav (kJ/kg-mol-K)300 73.748400 83.784500 93.453600 102.46700 110.73800 118.3900 125.071000 131.331100 137.231200 142.661300 147.661400 152.281500 156.54

Page 38: 11 Basic Principles and Calculations

Chen CL 37

Gas Volume CalculationsUsing 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.5m3 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 thetank 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 isthe percent error in the calculated number of moles using the other correlations?

(c) Repeat (b) for different values of Tr (T/Tc) and Pr (P/Pc). How do theaccuracies of the different correlations change with Tr and Pr?

Page 39: 11 Basic Principles and Calculations

Chen CL 38

Ideal Gas PV = RT

Soave-Redlich-Kwong P =RT

(V − b)− αa

V (V + b)a = 0.42747

(R2T 2

cPc

)b = 0.08664

(RTcPc

)α =

[1 + m(l −

√T/Tc)

]2m = 0.48508 + 1.55171ω − 0.1561ω2

Tc = 304.2 K,) Pc = 72.9 atm for CO2)

ω = the acentric factor (0.225 for CO2)

Peng-Robinson P =RT

(V − b)− a(T )

V (V + b) + b(V − b)a = 0.45724

(R2T 2

cPc

)α(T ) b = 0.0778

(RTcPc

)α =

[1 + k(l −

√T/Tc)

]2k = 0.37464 + 1.54226ω − 0.26992ω2

Beattie-Bridgeman P =RT

V+

β

V 2+

γ

V 3+

δ

V 4

β = RTB0 −A0 −Rc

T 2

γ = RTB0b + A0a−RcB0

T 2δ =

RcB0b

T 2

Page 40: 11 Basic Principles and Calculations

Chen CL 39

For CO2, A0 = 5.0065; a = 0.07132; B0 = 0.10476; b = 0.07235; andc = 66.0× 104.

Solution:One solution to this problem is to find the volume of 1 mole of CO2 at thespecified temperature and pressure for each equation of state and then calculatethe moles in the 2.5 m3 volume of the tank. The first equation of state (ideal) canbe solved directly. In order to be consistent with the rest of the equations, thisone can be rewritten as an implicit expression

f(V ) = PV −RT

Page 41: 11 Basic Principles and Calculations

Chen CL 40

function P2_09A1clear, clc, format short g, format compactxguess = 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);P = 100;R = .08206;T = 300;nmoles = 2.5 * 1000 / V;fV = P * V - (R * T);

Variable values at the initial estimateUnknown value 0.505 Function Value 25.882Variable values at the solutionUnknown value 0.24618 Function Value 0

Page 42: 11 Basic Principles and Calculations

Chen CL 41

function P2_09A2clear, clc, format short g, format compactxguess = 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);P = 100;R = .08206;T = 300;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);

Variable values at the initial estimateUnknown value 0.505 Function Value 28.1373Variable values at the solutionUnknown value 0.079572 Function Value -7.8063e-016

Page 43: 11 Basic Principles and Calculations

Chen CL 42

Bubble Point Calculationfor 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 associatedwith 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 phaseas 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:

log(P ?A) = 6.85221− 1064.63

T + 232.0

Page 44: 11 Basic Principles and Calculations

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 componentsmust 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 themole fraction of n-hexane, the nonlinear equation to be solved for the bubble pointtemperature is given by

f(Tbp) = xAP ?A + xBP ?

B − 760

At the solution, f(Tbp) should become very small, f(Tbp) ≈ 0.

The vapor phase mole fraction of n-pentane, yA, and the mole fraction ofn-hexane, yB, can be calculated from Raoult’s law given by the equations

yA = xAP ?A/760 yB = xBP ?

B/760

Page 45: 11 Basic Principles and Calculations

Chen CL 44

It is important to note that the bubble point can also be considered as thetemperature at which the individual mole fractions in the gas phase sum to 1.0 forthe given liquid phase composition. Thus this problem can alternately be solvedby solving the nonlinear equation given next as an alternate.

f(Tbp) = yA + yB − 1

Page 46: 11 Basic Principles and Calculations

Chen CL 45

function P2_10Aclear, clc, format short g, format compactxguess = 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)));xB = 1 - xA;yA = xA * PA / 760;yB = xB * PB / 760;fTbp = xA * PA + xB * PB - 760;

Variable values at the initial estimateUnknown value 49.5 Function Value -284.145Variable values at the solutionUnknown value 63.6645 Function Value -2.372e-013

Page 47: 11 Basic Principles and Calculations

Chen CL 46

Adiabatic Flame Temperature in Combustion

Concepts Utilized: Material and energy balances on an adiabatic system andcalculation of adiabatic flame temperature.

Numerical Methods: Solution of a single nonlinear algebraic equation and useof logical variable during solution.

Problem Statement:When natural gas is burned with air, the maximum temperature that can bereached (theoretically) is the adiabatic flame temperature (AFT). Thistemperature depends mainly on the composition of the natural gas and theamount of air used in the burner. Natural gas consists mainly of methane, ethane,and nitrogen. The composition is different for natural gas found in variouslocations. Determine the AFT for the following conditions, and plot the AFT as afunction of mol% CH4 and the stoichiometric molar air to fuel ratio. Thecomposition of natural gas is given below. The air-to-fuel ratios vary between 0.5to 2.0. it can be assumed that the air and natural gas enter the burner at roomtemperature and atmospheric pressure. What composition and air-to-fuel ratio

Page 48: 11 Basic Principles and Calculations

Chen CL 47

leads to the highest AFT?

Composition of Natural Gas:

CH4 65 ∼ 95 mol%C2H6 3 ∼ 33 mol%

N2 2 mol%

The molar heat capacity of the reactants and the combustion products can becalculated 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. Theheat of combustion is −212798 cal/g-mol for CH4 and −72820 cal/g-mol forC2H6, as reported by Henley. Assume that both the air and the natural gas enterat the temperature of 298 K and that the N2 content of the natural gas is always2.0 mol%. Air is 21 mol%O2.

Page 49: 11 Basic Principles and Calculations

Chen CL 48

Molar Heat Capacity of Gases

α β × 103 γ × 106

CH4 3.381 18.044 -4.30

C2H6 2.247 38.201 -11.049

CO2 6.214 10.396 -3.545

H2O 7.256 2.298 0.283

O2 6.148 3.102 -0.923

N2 6.524 1.25 -0.001

Solution:The stoichiometric equations are

CH4 + 2O2 −→ CO2 + 2H2O

C2H6 + 72O2 −→ 2CO2 + 3H2O

The actual to theoretical molar air-to-fuel ratio can be denoted by x with the inletmole fractions of CH4 and C2H6 denoted by y and z, respectively. For 1 mol ofnatural gas, there would be 0.02 mol N2, y mol CH4, and z mol C2H6.Therefore, the total moles of air required to react completely with the 1 mol of

Page 50: 11 Basic Principles and Calculations

Chen CL 49

natural gas would be given by (2y + [7/2]z)/0.21. Material balances for thedifferent compounds using a 1 mol natural gas basis are shown in Table for bothfuel-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.75CH4 y(1− x) 0.75(1− x) 0 0

C2H6 z(1− x) 0.23(1− x) 0 0CO2 (y + 2z)x 1.21x y + 2z 1.21H2O (2y + 3z)x 2.19x 2y + 3z 2.19

O2 0 0(2y + 7

2z)(x− 1) 2.305(x− 1)

N2 0.02 + 3.76x(2y + 7

2z)

0.02 + 8.67x 0.02 + 3.76x(2y + 7

2z)

0.02 + 8.67x

Since both the gas and the air enter at 298 K, this temperature can be used as areference for enthalpy calculations. The enthalpy change for the product gasesfrom T = 298 K up to the adiabatic flame temperature Tf can be calculated from

Page 51: 11 Basic Principles and Calculations

Chen CL 50

the following expression:

∆HP =6∑

i=1

αini(Tf − 298) +12

6∑i=1

βini(T 2f − 2982) +

13

6∑i=1

γini(T 3f − 2983)

where ∆HP is the enthalpy change per mole of natural gas fed, and ni is thenumber of moles of the different compounds, as shown in the above Table.

For x < 1 the general energy balance can be written as

f(Tf) = −212798xy − 372820xz + ∆HP = 0

For x > 1 the same equation can be used with the value x =1.

function P2_13clear, clc, format short g, format compactxguess = 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))]);

Page 52: 11 Basic Principles and Calculations

Chen CL 51

%- - - - - - - - - - - - - - - - - - - - - -function fT = NLEfun(T);y = .75;x = .5;z = 1 - y - .02;if (x < 1)

CH4 = y * (1 - x);else

CH4 = 0;endif (x < 1)

C2H6 = z * (1 - x);else

C2H6 = 0;endif (x < 1)

CO2 = (y + 2 * z) * x;else

CO2 = y + 2 * z;endif (x < 1)

H2O = (2 * y + 3 * z) * x;

Page 53: 11 Basic Principles and Calculations

Chen CL 52

elseH2O = 2 * y + 3 * z;

endN2 = .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 estimateUnknown value 2000 Function Value 14679.6191Variable values at the solutionUnknown value 2197.9949 Function Value 1.35e-011

Page 54: 11 Basic Principles and Calculations

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 streamof brine (20% salt by weight) is pumped into the tank at the rate of 10 kg/minand 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 1000kg which is well below the maximum tank capacity.

At a particular time (t = 0) an operator accidentally opens a valve, which causespure water to flow continuously into the tank at the rate of 10 kg/min (inaddition 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 timeduring the first hour after the pure water valve has been opened. Assume that theoutlet flow rate from the tank does not change and the contents of the tank arewell mixed at all times.

Page 55: 11 Basic Principles and Calculations

Chen CL 54

Solution:A mass balance on the total mass in the tank yields

Accumulation = Input− OutputdM

dt= 10 + 10− 10 = 10

where M is the mass in kg. A mass balance on the salt in the tank yields

dS

dt= 10(0.2)− 10

(S

M

)= 2− 10

(S

M

)where S is the weight of salt in the tank in kg. Note that S/M represents themass fraction of salt that is leaving the tank at any time t. This is also the massfraction of salt within the tank since the tank is well mixed. Thus both M and Sare functions of time for this problem. At t = 0, the initial conditions are thatM = 1000 kg and S = 200 since the brine contains 20% salt by mass.

function P2_14_CCLclear, clc, format short g, format compacttspan = [0 60.]; % Range for the independent variabley0 = [1000.; 200.]; % Initial values for the dependent variables

Page 56: 11 Basic Principles and Calculations

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’,12);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

endend%- - - - - - - - - - - - - - - - - - - - - -function dYfuncvecdt = ODEfun(t,Yfuncvec);M = Yfuncvec(1);

Page 57: 11 Basic Principles and Calculations

Chen CL 56

S = Yfuncvec(2);SaltPC = 100 * S / M;dMdt = 10;dSdt = 2 - (10 * S / M);dYfuncvecdt = [dMdt; dSdt];

Page 58: 11 Basic Principles and Calculations

Chen CL 57

Heat Exchange in A Series of Tanks

Concepts Utilized: Unsteady-state energy balances and dynamic response ofwell-mixed heated tanks in series.

Numerical Methods: Solution of simultaneous first order ordinary differentialequations.

Problem Statement:

Three tanks in sequence are used to preheat a multicomponent oil solution beforeit is fed to a distillation column for separation. Each tank is initially filled with1000 kg of oil at 20oC. Saturated steam at a temperature of 250oC condenseswithin coils immersed in each tank. The oil is fed into the first tank at the rate of100 kg/min and overflows into the second and the third tanks at the same flowrate. The temperature of the oil fed to the first tank is 20oC. The tanks are wellmixed so that the temperature inside the tanks is uniform, and the outlet stream

Page 59: 11 Basic Principles and Calculations

Chen CL 58

temperature is the temperature within the tank. The heat capacity, Cp , of the oilis 2.0 kJ/kg·oC. For a particular tank, the rate at which heat is transferred to theoil from the steam coil is given by the expression

Q = UA(Tsteam − T )

where UA is the product of the heat transfer coefficient and the area of the coil.

UA = 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 intervalwill be required for T3 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 arethe 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 T3? Will all steady-state temperatures be the same asbefore in part (a)?

Page 60: 11 Basic Principles and Calculations

Chen CL 59

Solution:

Energy balances should be made on each of the individual tanks. In thesebalances, the mass flow rate to each tank will remain at the same fixed value.Thus W = W1 = W2 = W3. The mass in each tank will be assumed constant asthe tank volume and oil density are assumed to be constant. ThusM = M1 = M2 = M3. For the first tank, the energy balance can be expressed by

Accumulation = Input− Output

MCpdT1

dt= WCpT0 + UA(Tsteam − T1)−WCpT1

Note that the unsteady-state mass balance is not needed for tank 1 or any othertanks since the mass in each tank does not change with time. The precedingdifferential equation can be rearranged and explicitly solved for the derivative,

Page 61: 11 Basic Principles and Calculations

Chen CL 60

which is the usual format for numerical solution

dT1

dt= [WCp(T0 − T1) + UA(Tsteam − T1)]

/MCp

Similarly,dT2

dt= [WCp(T1 − T2) + UA(Tsteam − T2)]

/MCp

dT3

dt= [WCp(T2 − T3) + UA(Tsteam − T3)]

/MCp

function P2_16A_CCLclear, clc, format short g, format compacttspan = [0 200.]; % Range for the independent variabley0 = [20.; 20.; 20.]; % Initial values for the dependent variablesdisp(’ 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)]);

Page 62: 11 Basic Principles and Calculations

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’,12);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

endend%- - - - - - - - - - - - - - - - - - - - - -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);

Page 63: 11 Basic Principles and Calculations

Chen CL 62

dT2dt = (W * Cp * (T1 - T2) + UA * (Tsteam - T2)) / (M * Cp);dT3dt = (W * Cp * (T2 - T3) + UA * (Tsteam - T3)) / (M * Cp);dYfuncvecdt = [dT1dt; dT2dt; dT3dt];

Page 64: 11 Basic Principles and Calculations

Chen CL 63

Thank You for Your Attention

Questions Are Welcome