Problem Solving Techniques in Chemical Engineering

Page 1

Department of Chemical and Biological Engineering

Problem Solving Techniques in Chemical Engineering Brief description This learning material will consolidate and integrate topics you’ve covered in Year 1 to help you transit into Year 2 chemical engineering. It is intended to demonstrate and support the use of basic numerical methods in Excel and MATLAB for solving chemical engineering problems. This skill is highly transferrable and will support your learning as you advance in your chemical engineering studies. Learning objectives This material aims to: 1. embed transferrable skills of Excel and MATLAB to solving chemical engineering problems (all chapters). 2. understand concepts of non-ideal gas (chapter 1). 3. perform calculations using equation of states (chapter 1). 4. apply mass balance to processes without and with recycle (chapter 2). 5. integrate reaction equilibrium into mass balance calculation (chapter 2). 6. perform energy balance for process with variable cp (chapter 3). 7. determine pipe diameter for process requirement (chapter 4). Learning activities 1. An introduction to the theoretical background of each topic. 2. Step-by-step instructions in problem solving. Learning outcome By the end of this exercise, a student will be able to: 1. use Excel and MATLAB in problem solving for a variety of chemical engineering problems (all chapters). 2. differentiate ideal and non-ideal gas (chapter 1). 3. calculate specific volume of non-ideal substances and mixtures using equations of state (chapter 1). 4. perform mass balance for process without and without recycle (chapter 2). 5. perform mass balance for process involving reaction equilibrium (chapter 2). 6. perform calculation for energy balance with variable cp (chapter 3). 7. perform iterative calculation to determine pipe diameter for process requirement (chapter 4).

Prepared by: Dr. Kang Lan Tee


Recommended reading: 1. Finlayson, B. A. (2006). Introduction to Chemical Engineering Computing. Chapter 2 in this book looks at equations of state and Chapter 5 address mass balance. Several questions in this material are derived or adapted from this book. The mathematical packages demonstrated in this book include Excel, MATLAB and ASPEN.

2. MATLAB is a very powerful tool. We have only introduced one of its functions (“fzero”) here. If you are interested to find out more about coding using MATLAB and how it can be used to generate graphs, visit https://matlabacademy.mathworks.com and you will find “MATLAB Onramp”, which is a free basic tutorial to get you started on MATLAB. 3. Refer to your lecture notes from CPE130, CPE140, CPE160 and CPE170 to recall the concepts used in this material.

Prepared by: Dr. Kang Lan Tee


Chapter 1

Page 1 of 35

1.1. Introduction: Non-ideal gas system (equations of state) Previously you’ve studied the ideal gas law (an equation of state, Eqn 1.1) in CPE160, a fundamental concept in thermodynamics. An equation of state is a relationship between the P-V-T of a substance. Solving equations of state (EOS) allows us to find the specific volume of a gaseous mixture of chemicals at a specified temperature and pressure. This is useful because determining the specific volume is the first step in calculating the enthalpy and vapor–liquid properties of mixtures. On a practical level, by knowing the specific volume, you can also determine the size—and thus cost—of the plant, including the diameter of pipes, the horsepower of compressors and pumps, and the diameter of distillation towers and chemical reactors (skills for your Design Project). pV = nRT

Ideal gas:

or

pđ?‘Ł = RT where đ?‘Ł =

!

Eqn 1.1

!

where p is the absolute pressure, V is the volume, n is the number of moles, R is the gas constant, and T is the absolute temperature. The units of R have to be appropriate (consistent) for the units chosen for the other variables. Ideal gas assumes no molecular interactions and has approximate validity for low-pressure gas system. However molecular interactions do exist and this assumption is challenged in many chemical processes at high pressure, for example the Haber-Bosch process for ammonia synthesis usually takes place at 220 atm or more. Numerous equations of state for non-ideal systems exist. They have been developed to address chemical processes at high pressure and are often found in process simulators, e.g. ASPEN (you used this in CPE130). Understanding EOS will provide the thermodynamic basis for not only volume but also fugacity (phase equilibrium) and enthalpy (departure from ideal gas enthalpy), concepts you will encounter in the module CPE230 in Year 2. In this section, we will introduce one of the equations of state for a non-ideal system. The Redlich-Kwong equation: đ?‘?= where

đ?‘Ž = 0.42748

! ! !!! !!

!" !!!

�,

−

!

Eqn 1.2

!(!!!)

đ?‘? = 0.08664(

!!! !!

),

�=

! !!!.!

a and b are positive constants; Tc is the critical temperature (in absolute terms), pc is the critical pressure, Tr is the reduced temperature (the absolute temperature divided by the critical temperature, Tr = T/Tc). Recall the concept of Tc and pc with respect to a PT diagram in CPE160. Tc and pc are the highest temperature and pressure at which a pure species is observed to exist in vapour/liquid equilibrium. The Redlich-Kwong EOS can be rearranged to a cubic equation (i.e. one algebraic equation in one unknown): đ?‘Ł ! đ?‘? − đ?‘Ł ! đ?‘…đ?‘‡ + đ?‘Ł đ?‘Ž − đ?‘?đ?‘? ! − đ?‘…đ?‘‡đ?‘? − đ?‘Žđ?‘? = 0

Eqn 1.3

When the temperature and pressure of a gaseous mixture, and the parameters a and b are given, the specific volume can be obtained by solving the cubic EOS for specific volume, v.

Prepared by: Dr. Kang Lan Tee


Chapter 1

Page 2 of 35

1.2. Step-by-Step problem solving [For best learning outcome, try to solve the problem yourself or by following the step-by-step instructions before referring to the answer.] Exercise 1.1: How to transform an equation? Let’s convince ourselves that Eqn 1.2 can be transformed into Eqn 1.3. đ?‘?=

!" !!!

−

! !(!!!)

Eqn 1.2

Hint: Multiply both sides with v(v+b)(v-b),

đ?‘?đ?‘Ł đ?‘Ł + đ?‘? đ?‘Ł − đ?‘? = đ?‘…đ?‘‡đ?‘Ł đ?‘Ł + đ?‘? − đ?‘Ž đ?‘Ł − đ?‘? đ?‘?đ?‘Ł ! + đ?‘?đ?‘?đ?‘Ł đ?‘Ł − đ?‘? = đ?‘…đ?‘‡đ?‘Ł ! + đ?‘…đ?‘‡đ?‘Łđ?‘? − đ?‘Žđ?‘Ł + đ?‘Žđ?‘? đ?‘?đ?‘Ł ! − đ?‘?đ?‘Ł ! đ?‘? + đ?‘?đ?‘?đ?‘Ł ! − đ?‘?đ?‘? ! đ?‘Ł = đ?‘…đ?‘‡đ?‘Ł ! + đ?‘…đ?‘‡đ?‘Łđ?‘? − đ?‘Žđ?‘Ł + đ?‘Žđ?‘?

Rearrange the equation, đ?‘?đ?‘Ł ! − đ?‘?đ?‘Ł ! đ?‘? + đ?‘?đ?‘?đ?‘Ł ! − đ?‘…đ?‘‡đ?‘Ł ! − đ?‘?đ?‘? ! đ?‘Ł − đ?‘…đ?‘‡đ?‘Łđ?‘? + đ?‘Žđ?‘Ł − đ?‘Žđ?‘? = 0 đ?‘Ł ! đ?‘? − đ?‘Ł ! đ?‘…đ?‘‡ + đ?‘Ł(đ?‘Ž − đ?‘?đ?‘? ! − đ?‘…đ?‘‡đ?‘?) − đ?‘Žđ?‘? = 0

Prepared by: Dr. Kang Lan Tee

Eqn 1.3


Chapter 1

Page 3 of 35

Exercise 1.2: How to use Excel and MATLAB in chemical engineering computing? Software and simulator can often be useful in solving chemical engineering questions and ASPEN, which you learnt in CPE130, is a good example. Using the Redlich-Kwong EOS in this exercise, we will introduce how Excel and MATLAB can also be used. Find the specific volume of n-butane at 393.3 K and 1682 kPa using the (a) ideal gas equation and (b) Redlich–Kwong EOS. Tc = 425.2 K, pc = 37.5 atm and the universal gas 3 -1 -1 constant is 82.06 cm .atm.mol .K . Compare the results obtained from the Redlich-Kwong EOS and the ideal gas equation. Do you think the assumption of ideal gas holds true at these conditions? What happens when the system pressure is 2 atm? [Hint: Repeat calculations for (a) and (b) using p = 2 atm.] Before you start calculation, check unit consistency. Note that the given pressure of 1682 kPa is not consistent to the units of the gas constant 3 -1 -1 82.06 cm .atm.mol .K . When solving an equation, units of values used across the whole equation must be made consistent. Conversion factor can be found in engineering textbooks, 100 kPa = 0.986923 atm Therefore, 1682 kPa = 16.60 atm (a) Solve using the ideal gas equation. p� = RT (Ideal gas equation) �=

RT 82.06x393.3 = = 1944 cm! . mol!! đ?‘? 16.60

(b) Solve the Redlich-Kwong EOS using Excel and MATLAB. đ?‘Ł ! đ?‘? − đ?‘Ł ! đ?‘…đ?‘‡ + đ?‘Ł đ?‘Ž − đ?‘?đ?‘? ! − đ?‘…đ?‘‡đ?‘? − đ?‘Žđ?‘? = 0 Using Excel to solve the Redlich-Kwong EOS. Step 1: Open a new worksheet in Excel and organize the data as shown here.

Prepared by: Dr. Kang Lan Tee

Eqn 1.3


Chapter 1

Page 4 of 35

Step 2: Calculate values of “a” and “b” and “Tr” using the formulae in Eqn 1.2.

Step 3: Setup the calculation for v as shown below.

3

-1

Use 1944 cm .mol [answer obtained from ideal gas calculation in (a)] as your initial value for v. You can see that fv ≠ 0 in this case and does not satisfy the Redlich-Kwong equation (Eqn 1.3). Step 4: To solve for v, go to “Tools” menu and select “Goal Seek”. Set the parameters as shown in the figure below and press “OK”.

Prepared by: Dr. Kang Lan Tee


Chapter 1

Page 5 of 35

Excel will start iteration and return the v value that satisfies the condition for fv = 0.

[Note: In many cases when using goal seek, the fv can be of a very small value, e.g. fv=1.2345E-04, but these are small enough for the purpose.] Step 5: As an alternative to “Goal Seek”, you can also use the “Solver” function in Excel. Set 3 -1 v = 1944 cm .mol again, go to The “Tools” menu and select “Solver”. [Note: If “Solver” does not appear, choose “Add-Ins” and load Solver from the Analysis ToolPak.]

Step 6: Compare the results obtained from the Redlich-Kwong EOS and the ideal gas equation. Do you think the assumption of ideal gas holds true at these conditions? 3

The specific volume of 1506 cm /mol (from Redlich-Kwong EOS) is 22.53% smaller than that 3 calculated using the ideal gas equation (1944 cm /mol). System does not approximate an ideal gas system. Step 7: What happens when the pressure is 2 atm? [Hint: Repeat calculations for (a) and (b) using p = 2 atm.] When you repeat the calculations (Steps 1 to 4 by using p = 2 atm, i.e. change cell B12 to “2” in your Excel sheet), 3

v = 16137 cm /mol (ideal gas equation) 3 v = 15765 cm /mol (Redlich-Kwong equation) The specific volume calculated using Redlich-Kwong equation is 2.30% lower than when using ideal gas equation. The system is a good approximate of an ideal gas at 2 atm.

Prepared by: Dr. Kang Lan Tee


Chapter 1

Page 6 of 35

Using MATLAB to solve the Redlich-Kwong EOS. You can also solve this problem using MATLAB. First, you have to define the problem by writing a script called an m-file. Step 1: Open MATLAB, go to the “HOME” menu, choose “New Script”. The “Editor” window will open as shown here.

Step 2: Prepare the following m-file that will calculate f(v), given the temperature, pressure, and thermodynamic properties. The code in the Editor window is shown below.

% Solving the Redlich-Kwong EOS, Eqn 1.3 function y=specvol(v) % in K atm cm3/mol % parameters for n-butane Tc=425.2; pc=37.5; T=393.3;

Prepared by: Dr. Kang Lan Tee


Chapter 1

Page 7 of 35

p=16.60; R=82.06; Tr=T/Tc aRK=0.42748*(R*Tc)^2/pc*(1/Tr^0.5) bRK=0.08664*(R*Tc/pc) y=p*v^3-R*T*v^2+(aRK-p*bRK^2-R*T*bRK)*v-(aRK*bRK) end [Note: “%” indicates the line is a comment (shown in green), a semi-colen“;” at the end of the line stops the calculated value from printing out on screen.] Step 3: Save this file as ‘specvol.m’ and test the function you have written by giving the command feval (’specvol’,2000) in the Command Window and press “enter”. MATLAB will calculate y for v = 2000.

You will see the values returned as: Tr = 0.9250 aRK = 1.4430e+07 bRK = 80.6143 y = 2.5981e+10 ans = 2.5981e+10 Check these values using the spreadsheet you developed in Excel by specifying v = 2000 3 -1 cm .mol . They have to be the same if MATLAB is working and the coding is correct. Step 4: In MATLAB, the function “fzero” is used to find the root of a nonlinear function. In this example, when you use “fzero” to solve “specvol”. During processing, MATLAB will solve “specvol” by evaluating for a variety of v using the initial value of v=2000 that is given in the command. It is inconvenient to have the constants printed out on screen for all iterations. To avoid this, change the function “specvol” in the Editor window by adding a semicolon (;) at the end of each line. This suppresses the output. Finally in the command window, use v = fzero(‘specvol’,2000)

Prepared by: Dr. Kang Lan Tee


Chapter 1

You can see that the value returned is the same as what you get in Excel.

Prepared by: Dr. Kang Lan Tee

Page 8 of 35


Chapter 1

Page 9 of 35

Exercise 1.3: What happens when your system is a mixture instead of a pure substance? Solving the Redlich-Kwong EOS is useful when you encounter a pure substance under nonideal conditions, as in Exercise 1.2. More often than not, real chemical processes will consist of a mixture of gases. For example in the Haber-Bosch process, N2 + 3 H2 è 2 NH3, three components exist as a mixture. In Eqn 1.2, the constants a and b are derived using the Tc and pc for pure substances, which are known and tabulated quantities. For mixtures, Tc and pc are not readily available, thus a and b are derived using the mixing rule as given below. đ?‘?=

where

đ?‘Ž! = 0.42748

! ! ! !!"

!!"

!" !!!

−

!

Eqn 1.2

!(!!!)

�! ,

đ?‘?! = 0.08664(

!"#$%

!!"

),

�! =

! !.! !!"

!"#$%

đ?‘Ś! đ?‘Ž!!.! )!

đ?‘Ž=(

!!!"

đ?‘?=

!!!

đ?‘Ś! đ?‘?! !!!

a and b are positive constants; Tci is the critical temperature of each component (in absolute terms), pci is the critical pressure of each component, Tri is the reduced temperature for each component (the absolute temperature divided by the critical temperature, Tri = T/Tci) and yi is the fraction of each component. Let’s apply this new information to the following problem. Consider the following mixture going into a water-gas shift reactor to make hydrogen for the hydrogen economy. CO, 630; H2O, 1130; CO2, 189; H2, 63 kmol/h. The gas is at 1 atm and 500 K. Use Excel (or MATLAB) to compute the specific volume using, (a) ideal gas law (b) Redlich–Kwong equation of state 3

-1

-1

3

-1

R = 82.06 cm .atm.mol .K = 83.14 cm .bar.mol .K 1 bar = 0.986923 atm Parameters Tci pci

CO 132.9 34.99

H 2O 647.1 220.55

-1

CO2 304.2 73.83

H2 33.19 13.13

Units K bar

How do the two answers in (a) and (b) compare? Does the gas mixture approximate an ideal gas? Redo the calculations for a pressure of 200 atm and comment on the results. To solve this problem using Excel Step 1: Open a new worksheet in Excel and organize the data given. Perform unit conversion if necessary.

Prepared by: Dr. Kang Lan Tee


Chapter 1

Step 2: Solve part (a) using the ideal gas law.

Step 3: Calculate the constants a and b for the Redlich-Kwong EOS.

Prepared by: Dr. Kang Lan Tee

Page 10 of 35


Chapter 1

Page 11 of 35

Step 4: Set v = 41030. Find the specific volume (v) by solving the Redlich-Kwong EOS (fv) with “Goal Seek”.

Step 5: To find the specific volume for 200 atm, change “p” from 1 atm (cell B10) to 200 atm in your Excel sheet. The constants a and b are not affected by pressure. The specific volume will be automatically calculated using the ideal gas law. Perform “Goal seek” to solve the Redlich-Kwong equation again for this new condition.

Prepared by: Dr. Kang Lan Tee


Chapter 1

Page 12 of 35

Step 6: At 1 atm, the specific volumes calculated using both the equations have <1% difference. The gas mixture thus approximates an ideal gas. Step 7: At 200 atm, the specific volume calculated using the Redlich-Kwong equation is 70.13% of that calculated using ideal gas law. The system is no an ideal gas. To solve part (b) of this problem using MATLAB. You will need to understand the concept of: 1. Vector: x=[1 2 3] è x is a vector with 3 elements (i.e. 1, 2 and 3) 2. Element by element calculation x=[1 2 3], y=[2 4 6] MATLAB will not perform x*y because of incorrect dimensions for matrix multiplication. To perform element by element calculation, the right syntax is x.*y. Note the period before the multiplication (.*). Thus x.*y=[2 8 18] Try solving Exercise 1.3 using MATLAB now by using the following steps. Step 1: Open a new script file and organize the data given. Perform unit conversion if necessary. Step 2: Setup the code to calculate constants a and b and f(v) for the Redlich-Kwong EOS. Step 3: Save the m-file as “RK_EOS_mixture.m”. [Note: The file name and the function name must be the same.] Step 4: Find the specific volume (v) by solving the Redlich-Kwong EOS (fv) with v=fzero(‘RK_EOS_mixture’,40000) You should achieve the following:

Step 3

Step 1

Step 2

Step 4

Prepared by: Dr. Kang Lan Tee


Chapter 1

Page 13 of 35

The code is also given here. %Solving the Redlich-Kwong EOS for a mixture function y=RK_EOS_mixture(v) % in K atm cm3/mol % parameters for n-butane T=500; p=1; R=82.06; Tci=[132.9 647.1 304.2 33.19]; pci_bar=[34.99 220.55 73.83 13.13]; pci=pci_bar.*0.986923; Flowi=[630 1130 189 63]; Tri=T./Tci; yi=Flowi./sum(Flowi); alphai=1./Tri.^0.5; ai=0.42748*(R.*Tci).^2./pci.*(1./Tri.^0.5); bi=0.08664.*(R.*Tci./pci); yiai=yi.*ai.^0.5; yibi=yi.*bi; a=sum(yiai)^2; b=sum(yibi); y=p*v^3-R*T*v^2+(a-p*b^2-R*T*b)*v-(a*b) end Step 5: To find the specific volume at p = 200 atm, change the value of p in your MATLAB code (line 6). Solve using the command v=fzero(‘RK_EOS_mixture’,200).

[Note: In this Exercise 1.3, we converted the pressure from “bar” to “atm” and performed all 3 -1 -1 3 -1 -1 calculations using R = 82.06 cm .atm.mol .K . If we used R = 83.14 cm .bar.mol .K , no unit conversion would be necessary.]

Prepared by: Dr. Kang Lan Tee


Chapter 1

Page 14 of 35

Let’s review what you have achieved here: 1. You’ve learnt the concept of non-ideal gas (see Introduction). 2. You’ve practiced how to transform an equation (see Exercise 1.1). 3. You’ve used the Redlich-Kwong equation of state to calculate the specific volume of a pure substance (see Exercise 1.2). 4. You’ve used the Redlich-Kwong equation of state to calculate the specific volume of a gas mixture (see Exercise 1.3). 5. You’ve performed unit conversion to achieve unit consistency when solving an equation (see Exercise 1.2 and 1.3). 6. You’ve used “Goal Seek” and “Solver” in Excel to solve the Redlich-Kwong equation (see Exercise 1.2 & 1.3). 7. You’ve use MATLAB to solve the Redlich-Kwong equation (see Exercise 1.2 & 1.3).

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 15 of 35

2.1. Introduction: Material balance Material balance is a concept based on conservation of mass and used by chemical engineers to design plants. This was also a key syllabus in the Year 1 module CPE130. With the mass flow of streams in a process, engineers can design different equipment (e.g. distillation columns, pumps and storage tanks), perform energy balance (syllabus in CPE140) with the help of thermodynamics, determine the corresponding energy cost and calculate the economic viability of the process. Several process units were discusses in CPE130, including the mixer, splitter, separator and reactor. Material balance over single process unit for a 1 or 2 component system is usually straightforward and can often be done manually using a calculator. For example:

1 kg/h N2 Mixer 3 kg/h H2

1 kg/ h N2 + 3 kg/ h H2

1 mol/h N2 + 3 mol/ h H2

1 kg/h N2 + 3 kg/ h H2

1 kg/h N2 Separator 3 kg/h H2

Reactor N2 + 3H2 è 2NH3 50% conversion

1 mol/h NH3 + 0.5 mol/h N2 + 1.5 mol/h H2

When solving material balance for process with multiple units and recycle streams, iterative calculation is often necessary and Excel is useful for simplifying this process (see Exercise 2.1 below). This iterative process is also adopted in many process simulators, e.g. ASPEN (you used this in CPE130). Using Excel for material balance will greatly support your projects in Design Weeks in Year 1 (CPE140) and Year 2 (CPE270).

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 16 of 35

2.2. Step-by-Step problem solving [For best learning outcome, try to solve the problem yourself or by following the step-by-step instructions before referring to the answer.] Exercise 2.1: Using MATLAB to solve material balance of a steady state process? Consider the following array of distillation columns used to separate xylene, styrene, toluene and benzene under steady state and with no recycle. F, B, D, D1, B1, D2 and B2 are molar flow rates in mol/min. (a) Calculate the molar flow rates for streams D1, B1, D2 and B2. (b) Determine the molar flow rates and compositions of streams B and D.

Step 1: Write down the equation set for material balance on individual components for the overall process. Xylene: Styrene: Toluene: Benzene:

0.07D1 + 0.18B1 + 0.15D2 + 0.24B2 = 0.15 Ă— 70 0.04D1 + 0.24B1 + 0.10D2 + 0.65B2 = 0.25 Ă— 70 0.54D1 + 0.42B1 + 0.54D2 + 0.10B2 = 0.40 Ă— 70 0.35D1 + 0.16B1 + 0.21D2 + 0.01B2 = 0.20 Ă— 70

This set of equations can be setup as a matrix as shown here: AX = f 0.07 0.04 0.54 0.35

Prepared by: Dr. Kang Lan Tee

0.18 0.24 0.42 0.16

0.15 0.10 0.54 0.21

0.24 0.65 0.10 0.01

đ??ˇ1 0.15 ∗ 70 đ??ľ1 = 0.25 ∗ 70 đ??ˇ2 0.40 ∗ 70 đ??ľ2 0.20 ∗ 70


Chapter 2

Page 17 of 35

Step 2: To solve the equations using MATLAB, input your matrix in the Command Window as shown here. You will need to understand the following MATLAB language to solve this problem. 1. How to create a matrix in MATLAB: Use a space or comma to separate each element in a row. Use semicolons (;) to separate the rows of a matrix. 2. The \ (backslash) operator: To solve the system of linear equations A*x = B, use x=A\B. The matrices A and B must have the same number of rows.

% Solving the material balance, Exercise 2.1 A=[0.07 0.18 0.15 0.24; 0.04 0.24 0.10 0.65; 0.54 0.42 0.54 0.10; 0.35 0.16 0.21 0.01]; F=70; f=[0.15*F; 0.25*F; 0.40*F; 0.20*F]; %AX=f thus X=A\f where A\=inverse matrix of A X=A\f When X is solved, D1 = 26.25 mol/min B1 = 17.50 mol/min D2 = 8.75 mol/min B2 = 17.50 mol/min

Solution for part (a)

You can find the values of all variables and objects in the right panel “Workspace�. [Note: There is often more than one method of solving a problem. Other than MATLAB, this question above can also be solved using Excel with the functions MINVERSE and MMULT. However, MATLAB excels in matrix computation and is very suitable for solving simultaneous linear equations as in this case.]

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 18 of 35

Step 3: To determine flow rates and composition of streams D and B, setup the material balance over column #2 and column #3. Solve with MATLAB. Molar flow rate Xylene: Styrene: Toluene: Benzene:

D = D1 + B1 X_Dx*D = 0.07D1 + 0.18B1 X_Ds*D = 0.04D1 + 0.24B1 X_Dt*D = 0.54D1 + 0.42B1 X_Db*D = 0.35D1 + 0.16B1

Molar flow rate Xylene: Styrene: Toluene: Benzene:

B = D2 + B2 X_Bx*B = 0.15D2 + 0.24B2 X_Bs*B = 0.10D2 + 0.65B2 X_Bt*B = 0.54D2 + 0.10B2 X_Bb*B = 0.21D2 + 0.01B2

%Calculate the flow rate of stream D D1=X(1); B1=X(2); D=D1+B1; %Clculate the fractional composition of stream D X_Dx=(0.07*D1+0.18*B1)/D; X_Ds=(0.04*D1+0.24*B1)/D; X_Dt=(0.54*D1+0.42*B1)/D; X_Db=(0.35*D1+0.16*B1)/D; %Calculate the flow rate of stream B D2=X(3); B2=X(4); B=D2+B2;

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 19 of 35

%Calculate the fractional composition of stream B X_Bx=(0.15*D2+0.24*B2)/B; X_Bs=(0.10*D2+0.65*B2)/B; X_Bt=(0.54*D2+0.10*B2)/B; X_Bb=(0.21*D2+0.01*B2)/B; The flow rates and fractional composition of streams D and B are shown in the “Workspace� panel on the right of your MATLAB window. D = 43.75 mol/min X_Dx = 0.1140 X_Ds = 0.1200

X_Dt = 0.4920

X_Db = 0.2740

B = 26.25 mol/min X_Bx = 0.2100 X_Bs = 0.4667

X_Bt = 0.2467

X_Bb = 0.0767

Solution for part (b)

[Note: The numerical analysis of (b) is straightforward and can be easily performed with a calculator. However, one would have to perform the manual calculations from the very beginning if a single parameter (e.g. the flow rate, F, or molar composition) in the system is changed. The MATLAB code allows you to easily change a parameter (e.g. flow rate F) and all answers in this material balance will be automatically calculated. It is convenient to save the commands as a script file, for example as MatBal_Ex_2.1, so that you can use it anytime by copying it into the Command window.]

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 20 of 35

Exercise 2.2: Using Excel for material balance of a steady state process with recycle. In Exercise 2.1, material balances across individual unit or overall process involve streams that proceed from left to right. No iteration is required to solve the problem. What happens when a system has a recycled stream? Let’s demonstrate how Excel can perform the iterative calculations for this purpose. Recall the description of ammonia synthesis in the handout of CPE130 (Edition 6.1, pg 32). 6

2800 kg/h N2 1 600 kg/h H2

2

Mixer

Reactor 3

4

Separator

5

N2 + 3H2 è 2NH3 25% conversion/pass

Consider the ammonia synthesis process shown above. This is a steady state process where ammonia synthesis in the reactor is 25% conversion per pass. The ammonia product in stream 4 is separated using a condenser at -35°C. Under this condition, 98 % of the ammonia, 5 % of N2 and 5 % of H2 in condenser inlet will be extracted. The remaining reactants are recycled back to the mixer. Perform a material balance for this process to determine the flow rates of each component in all the streams. [The molecular weight of N2 is 28 g/mol and H2 is 2 g/mol] Step 0: Before starting calculations, consider the units used in the scheme. In reacting systems, it is easier to use moles as chemical reactions work in molar stoichiometry. kg N! kg 2800 ÷ 28 = 100 kmol. h!! of N! h kmol 600

kg H! kg ÷2 = 300 kmol. h!! of H! h kmol

Step 1: Open a new worksheet in Excel and setup the material balance using the known inlet flow rates for stream 1.

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 21 of 35

Step 2: Fill in the equations (e.g. C8=B8+G8) for stream 2 based on mass conservation.

Step 3: Fill in the equations for reactor 3 based on mass conservation, 25% conversion/pass and stoichiometry of the reaction. Note the negative signs for reactants and positive signs for products.

Step 4: Fill in the equations for stream 4 based on mass conservation.

Step 5: Fill in the equations for stream 5 based on the given efficiency of the condenser.

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 22 of 35

Step 6: Fill in the equations for recycled stream 6 based on mass conservation. Formula used in stream 6 is indirectly dependent on itself, resulting in what is known as circular reference in Excel. Consequently, iteration starts in Excel.

The flow rates of all components in all streams are now calculated in the table. [Note: Check that iteration function is enabled in you Excel by going to the Excel menu and click Preferences. Under Formulas and Lists, click Calculation and then under Iteration, select the Limit iteration check box. The Limit iteration box must be checked to enable this function in Excel. If you see slightly different values in you Excel sheet, it is likely due to different Limit iteration settings in your Excel. You can increase the Maximum iterations and decrease the Maximum change to allow more cycles of iteration.]

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 23 of 35

Exercise 2.3: What happens when the reaction is at equilibrium conversion? Recall the concept of chemical equilibrium in CPE150. The conversion of a reversible chemical reaction in the reactor is often governed by chemical equilibrium. For the ammonia synthesis process in Exercise 2.2, what are the flow rates of each component in streams 5 and 6 when the reactor functions at equilibrium conversion? The equilibrium constant for the reaction is given here. 1 3 đ?‘ ! + đ??ť! ⇔ đ?‘ đ??ť! 2 2 đ??ž! =

đ?‘ƒ!"! !/! !/! đ?‘ƒ!! đ?‘ƒ!!

=

đ?‘Ś!"! !/! !/! đ?‘Ś!! đ?‘Ś!!

1 đ?‘?

Px is the partial pressure of component x and yx is the mole fraction of component x. Our reactor is functioning at Kp = 0.05 and p = 220. Step 1: Use the material balance Excel sheet setup in Exercise 2.2 and calculate the mole fractions in stream 4 (i.e. �!! , �!! ��� �!"! ).

Step 2: Setup the equation for Kp in cell B22=B16/((B14^0.5*B15^1.5)*B20).

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 24 of 35

Step 3: The problem now has two iterations, one is the circular reference due to the recycle stream and one is the nonlinear equilibrium equation for conversion in the reactor. (Note: “Goal Seek” did not work for this problem) Use “Solver” in Excel to solve the problem. Set the objective of Kp (cell B22) to value of 0.05 by changing the fractional conversion (cell B3). Use the constraints of 0 ≤ fractional conversion (cell B3) ≤1.0 and “GRG Nonlinear” method to solve the problem.

When solved:

The conversion rate is 74 % in the reactor with a recycle stream of 143 kmol/h. Flow rates of all components in each stream is shown in the table.

Prepared by: Dr. Kang Lan Tee


Chapter 2

Page 25 of 35

Let’s review what you have achieved here: 1. You’ve performed material balance over a train of distillation columns for a 4component system using MATLAB (see Exercise 2.1). 2. You’ve performed material balance for an ammonia synthesis process with a recycle stream, using “Solver” in Excel for the iterative calculation (see Exercise 2.2). 3. You’ve integrated reaction equilibrium into material balance for an ammonia synthesis process (see Exercise 2.3).

Prepared by: Dr. Kang Lan Tee


Chapter 3

Page 26 of 35

3.1. Introduction: Energy balance Performing material balance and energy balance are integral steps of chemical engineering design. Building on the mass balance you learned in CPE130 (and the calculations in chapter 2), chapter 3 looks at energy balance (core syllabus in CPE140) with the help of thermodynamics (CPE160) to determine energy requirement in a process, which consequently determine its energy cost and affects its economic viability. For this chapter, it is useful to revisit key concepts in CPE140, for example phase change, adiabatic process, batch process, continuous process and the use of steam table. Several unit operations were discussed in CPE140, see figure below from CPE140 lecture slide.

Review of unit operations covered in CPE140 Reactors

Heaters/coolers Initial

Final

Heat exchange (Q) Mixer: also batch Feed 1 Product

Initial

Product

Feed

RATE of heat exchange (Q)

Feed

Heat exchange (Q) – OR Q = 0

Evaporator: single stage Pure vapour

Dilute solution

Feed 2 RATE of heat or exchange (Q)

Final

RATE of heat exchange (Q)

Concen. solution

Product

RATE of heat exchange (Q) or Q = 0

Distillation: single stage Liquid mixture

RATE of heat exchange (Q)

Vapour mixture Liquid mixture

Energy balance over single process unit for a 1 or 2 component system is usually straightforward and can often be done manually using a calculator. For example when there is no phase change, !!

đ?‘„=đ?‘š

đ?‘?! đ?‘‘đ?‘‡ !!

if cp is constant, đ?‘„ = đ?‘šđ?‘?! ∆đ?‘‡ Using Excel for iterative calculation is useful when the parameters (e.g. cp) are dependent on process conditions (e.g. T), see Exercise 3.1. In more complex processes, simulators like ASPEN (you used this in CPE130) can simplify calculations significantly. Excel, MATLAB and ASPEN will support your Design Weeks in Year 1 (CPE140) and Year 2 (CPE270) and your Year 3 Design Project.

Prepared by: Dr. Kang Lan Tee


Chapter 3

Page 27 of 35

3.2. Step-by-Step problem solving [For best learning outcome, try to solve the problem yourself or by following the step-by-step instructions before referring to the answer.] Exercise 3.1: Using Excel to solve energy balance when cp is a variable. Flue gas from a process is used to produce saturated steam from water in a boiler. Water at 20°C is fed to boiler to produce saturated steam at 5 bar. The flue gas enters the boiler at 400°C. Assume the boiling operates adiabatically. (a) Use the information below to calculate the change in enthalpy for the water (in kJ/kmol). (b) Use the information below to calculate the change in enthalpy (Δh) for the process gas between two arbitrary temperatures (inlet of 400°C to arbitrary temperature T2). (c) If the feed ratio (on a molar basis) of the water to process gas is 0.2, calculate the outlet temperature of the process gas. You are given the following information: • cp of water = 4.18 kJ/kgK • cp of flue gas = 45 + 0.07T (kJ/kmolK) • Latent heat of vaporization of water at 5 bar (151.8°C) = 2109 kJ/kg Step 0: Note the different units used for cp of water and flue gas. The unit of enthalpy will be converted to kJ/kmol in Step 1. Step 1: Calculate the change in enthalpy of water to solve (a). ∆ℎ!"#$% = 4.18 Ă— 151.8 − 20 + 2109 = 2660

∆ℎ!"#$% = 2659

đ?‘˜đ??˝ đ?‘˜đ?‘” đ?‘˜đ??˝ đ?‘Ľ 18 = 47879 đ?‘˜đ?‘” đ?‘˜đ?‘šđ?‘œđ?‘™ đ?‘˜đ?‘šđ?‘œđ?‘™

This can also be calculated in Excel as shown here,

Step 2: To calculate the change in enthalpy for the waste gas in (b). !!

∆ℎ!"# =

đ?‘?! đ?‘‘đ?‘‡ !!

!!

∆ℎ!"# =

45 + 0.07� �� !!

∆ℎ!"# = 45 đ?‘‡2 − đ?‘‡1 +

Prepared by: Dr. Kang Lan Tee

0.07 (đ?‘‡2! − đ?‘‡1! ) 2

đ?‘˜đ??˝ đ?‘˜đ?‘”


Chapter 3

Page 28 of 35

Step 3: Since the process is adiabatic, enthalpy gained by the water is equal to the enthalpy lost by the flue gas. 0.07 đ?‘€!"#$% Ă—47879 = −đ?‘€!"# Ă—(45 đ?‘‡2 − đ?‘‡1 + đ?‘‡2! − đ?‘‡1! ) 2 The feed ratio is Mwater = 0.2 Mgas, 0.2đ?‘€!"# Ă—47879 = −đ?‘€!"# (45 đ?‘‡2 − đ?‘‡1 +

0.07 đ?‘‡2! − đ?‘‡1! ) 2

Rearrange the equation, 0.2Ă—47879 + 45 đ?‘‡2 − đ?‘‡1 +

0.07 đ?‘‡2! − đ?‘‡1! = 0 2

Setup this quadratic equation in Excel (cell B18), đ?‘Ś = 0.2Ă—47879 + 45 đ?‘‡2 − đ?‘‡1 +

0.07 đ?‘‡2! − đ?‘‡1! 2

Go to Tool, choose Goal Seek and set cell B18 to 0 by changing cell C16, press OK to start iteration.

Following iteration, the calculated T2 is 259°C.

Prepared by: Dr. Kang Lan Tee


Chapter 3

Page 29 of 35

Exercise 3.2: Using Excel to solve energy balance when cp is a variable (Part 2). (a) How does outlet temperature of flue gas vary with feed ratio? Fill in the values of T2 in the following table. Can all feed ratio be used? Feed ratio 0.1 0.2 0.3 0.4 0.5

T2 (째C)

(b) What is the maximum feed ratio of the water to flue gas if the minimum outlet temperature of flue gas must be 25째C? (c) At a feed ratio of 0.5, what is the required inlet flue gas temperature (T1) such that the minimum outlet temperature (T2) can be maintained at 25째C?

Step 1: Using the Excel sheet set up in Exercise 3.1, repeat Goal Seek to calculate the value of T2 at different feed ratio for (a).

Feed ratio 0.1 0.2 0.3 0.4 0.5

T2 (째C) 332 259 180 92 -8

Feed ratio at 0.5 is unrealistic for the boiler since the outlet temperature of flue gas will have to be below zero.

Prepared by: Dr. Kang Lan Tee


Chapter 3

Page 30 of 35

Step 2: Using the Excel sheet set up in Exercise 3.1, use Goal Seek to calculate the value of feed ratio when T2 is set at 25°C for (b).

To maintain the flue gas outlet temperature ≥ 25°C, the maximum feed ratio of water to flue gas is 0.47. Step 3: Using the Excel sheet set up in Exercise 3.1, use Goal Seek to calculate the value of feed ratio when feed ratio is set at 0.5 and T2 is set at 25°C for (c).

To fulfill the process conditions, the flue gas inlet temperature (T1) must be at least 420°C. [Note: This exercise demonstrates that Goal Seek can be used to investigate different limiting conditions in a process from the energy balance perspective. However you will need your engineering judgment to understand the most relevant scenario. In this instance, reducing the feed ratio to ≤0.47 is likely a simpler solution compared to adding a unit operation to heat up the flue gas to ≥420°C. Exercise 3.1 & 3.2 is an extension of Tutorial 4 – Question 1 in CPE140 (2019).]

Prepared by: Dr. Kang Lan Tee


Chapter 3

Page 31 of 35

Let’s review what you have achieved here: 1. You’ve performed energy balance for a boiler involving flue gas (with a variable cp) and water using “Goal Seek” in Excel (see Exercise 3.1). 2. You’ve investigated operating constraints in a boiler to satisfy process conditions using “Goal Seek” in Excel (see Exercise 3.2 and 3.3).

Prepared by: Dr. Kang Lan Tee


Chapter 4

Page 32 of 35

4.1. Introduction: Pipe flow and sizing Following mass balance, it is often necessary to design pipes to transfer fluids from one unit operation to the next. CPE170 introduces basic fundamentals of fluids, for instance the Reynolds number, and how the Moody chart can be used to determine friction factor (�) and how that can be used to determine head loss, pipe diameter, flow rate or pipe length. The equations below were provided in CPE170 (please refer to lecture notes and formula sheet for this module). �� = �=

!"#

! !

Eqn 3.1

!

=

!!

Eqn 3.2

!!!

Δđ?‘ƒ = đ?‘“

Darcy-Weisbach equation, For laminar flow, Re<2000, For turbulent flow, Re>4000,

đ?‘“= ! !

! !! !

Eqn 3.3

! !

!"

Eqn 3.4

!"

= −2.0đ?‘™đ?‘œđ?‘”

! ! !.!

+

!.!" !" !

Eqn 3.5

Where đ?‘…đ?‘’ = Reynold’s Number -3 đ?œŒ = density (kg.m ) -1 đ?‘‰ = velocity (m.s ) đ??ˇ = diameter (m) -1 -1 đ?œ‡ = viscosity (kg.m .s ) 3 -1 đ?‘„ = volumetric flow rate (m .s ) 2 đ??´ = cross-sectional area of pipe (m ) Δđ?‘ƒ = pressure drop (Pa) đ?‘“ = friction factor ! = relative pipe roughness !

In plant design, these equations together with the Moody chart can be used to calculate the following: 1. pressure drop of fluid flow in pipe (i.e. ΔP) 2. pipe length (i.e. L) 3. fluid velocity (i.e. V) 4. size pipes (i.e. D) When D and V are known, it is easy to compute ΔP or L using the Moody chart. If D or V is unknown, Re cannot be calculated and � cannot be determined from the Moody chart. Consequently, calculation of V and D requires iteration, as these parameters are present in the abscissa and ordinate of the chart.

Prepared by: Dr. Kang Lan Tee


Chapter 4

Page 33 of 35

4.2. Step-by-Step problem solving [For best learning outcome, try to solve the problem yourself or by following the step-by-step instructions before referring to the answer.] Exercise 4.1: Using Excel for pipe-sizing problem. A heat exchanger must handle 3.0 L/s of water through a 100 m pipe with roughness ratio đ?œ–/d = 0.0002. The density and viscosity of water varies with temperature according to the following equations: Ď (T) = 46.048 + 9.418T − 0.0329T ! + 4.885Ă—10!! T ! − 2.895Ă—10!! T ! 541.69 đ?œ‡ đ?‘‡ = exp (−10.547 + ) đ?‘‡ − 144.53 Where T is temperature in Kelvin. The pressure drop across the pipe cannot exceed 103 kPa at 25°C. Determine the minimum pipe diameter required for this application. Step 0: Note the units used and perform conversion when necessary. T = 25°C = 298 K 3 Q = 3.0 L/s =0.0030 m /s Step 1: Setup the Excel sheet with all known parameters.

Step 2: Setup equations to calculate Ď and Âľ in cells B11 and B12 respectively.

Step 3: Setup equations 3.1, 3.2, 3.3 and 3.5.

Prepared by: Dr. Kang Lan Tee


Chapter 4

Page 34 of 35

The equation y (cell B19) is derived from Eqn 3.5: 1 đ?œ– đ??ˇ 2.51 = −2.0đ?‘™đ?‘œđ?‘” + 3.7 đ?‘…đ?‘’ đ?‘“ đ?‘“ đ?‘Ś=

1 đ?‘“

+ 2.0đ?‘™đ?‘œđ?‘”

đ?œ– đ??ˇ 2.51 + =0 3.7 đ?‘…đ?‘’ đ?‘“

Step 4: Solve for y=0 using Goal Seek; set cell B19 to 0 by changing cell B15.

[Note: Cell B15 for D needs to be set to a starting positive value (0.001 m in example) to initiate calculation because D ≤ 0 generates f ≤ 0 (cell B18), which gives error in y (cell B19) since it is not possible to SQRT(value ≤ 0).]

The calculated minimum pipe diameter is 42.2 mm. Pipe diameter smaller than 42.2 mm will result in a larger pressure drop than 103 kPa. The calculated Re = 100466 (cell B17) satisfies the condition of Eqn 3.5 where Re>4000.

Prepared by: Dr. Kang Lan Tee


Chapter 4

Page 35 of 35

Let’s review what you have achieved here: 1. You’ve performed iterative calculation using Excel to determine minimum pipe diameter given a maximum pressure drop (see Exercise 4.1).

Prepared by: Dr. Kang Lan Tee


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.