0% found this document useful (0 votes)
316 views162 pages

Adidharma - Mathcad For Engineers PDF

Uploaded by

Omar Dario Rozas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
316 views162 pages

Adidharma - Mathcad For Engineers PDF

Uploaded by

Omar Dario Rozas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 162
UNIVERSIDAD NACIONAL DE JUJUY BIBLIOTECA invent. ING.6445 Top. 66.0:004.4 Mathcad for Chemical Engineers Second Edition Hertanto Adidharma University of Wyoming Valery Temyanko University of Arizona TOP: 66.0:004.4 ADI 2.e. - N° Inventario: ING.6445 IVACU Contents Preface to the Second Edition Chapter 1. Introduction Chapter 2. Getting Started with Mathcad 2.1. Mathcad Worksheet and User Interface 2.2. Variables and Functions 2.3. Arrays: Vector and Matrix 2.4. Working with Units 2.5. Graphics Features 2.6. Symbolic Math Capabilities Example set 2.1 Problems Chapter 3, Non-Linear Equation 3.1. Polynomial Example set 3.1 3.2. Non-Polynomial Example set 3.2 Problems Chapter 4. System of Equations 4.1. System of Linear Equations Example set 4.1 4.2, System of Non-Linear Equations Example set 4.2 4.3, System of Equations with Constraints Example set 4.3 Contents Problems Chapter 5. Curve Fitting 5.1. Interpolation 5.1.1. Linear Interpolation 5.1.2. Cubic Spline Example set 5.1 5.2. Regression 5.2.1. Linear Regression 5.2.2. Polynomial Regression 5.2.3, Non-Linear Regression Example set 5.2 Problems Chapter 6, Differentiation and Integration 6.1. Differentiation Example set 6.1 6.2. Integration Example set 6.2 Problems Chapter 7. Optimization 7.1. Extreme Value Problem 7.1.1. Unconstrained Function 7.1.2. Constrained Function Example set 7.1 7.2. Linear Programming Example set 7.2 7.3. Non-Linear Programming Example set 7.3 Problems 52 61 61 61 62 65 67 70 71 7a 79 79 82 91 91 91 94 96 97 98 101 102 104 Contents Chapter 8. Differential Equation 8.1. Ordinary Differential Equation 8.1.1. First Order ODE 8.1.2. System of First Order ODEs 8.1.3. Higher Order ODE — Initial Value Problem 8.1.4. Higher Order ODE ~ Boundary Value Problem 8.1.5. Second Order ODE ~ Cylindrical/ Spherical Coordinate 8.1.6. System of Higher Order ODEs Example set 8.1 8.2. Partial Differential Equation 8.2.1. Parabolic PDE 8.2.2. System of Parabolic PDEs 8.2.3. Elliptic PDE Example set 8.2 Problems Chapter 9. Miscellaneous 9.1. Data Handling 9.2. Data Exchange with Excel 93. Introduction to Mathcad Programming 9.3.1. Conditional (ifStatement) 9.3.2. Loops (fox/ while Statement) Example set 9.1 Problems Index. 109 109 109 113 114 116 118 119 121 124 125 127 128 129 131 141 141 141 144 145 147 154 Chapter 1 + Introduction 1 hapter 1 troduction The profession of chemical engineering officially started as ear- ly as 1888, when Professor Lewis Norton of the Massachusetts Institute of Technology introduced “Course X” and united chemical engineers with a formal degree. Soon after that, Tulane University and the Univer sity of Pennsylvania followed the suit by adding four-year program to their curriculum. The first programs were the combination of mechani- cal engineering and chemistry with an emphasis on the industrial needs of that time. Indeed, the challenges at that time required very different logics compared to what modern chemical engineers are facing today. ‘The complexity of the logics grew as the process requirement became more demanding due to economical, environmental, and/or technologi- cal considerations. Nowadays, in performing their tasks, such as operation, equip- ment design, process design, process control, and process analysis, chem- ical engineers utilize more sophisticated mathematical frameworks. As shown in Figure 1.1, the problem solving in chemical engineering in- volves several steps. First, the physical problem with all of the con- straints must be clearly defined. At this stage, it is also very important to properly state the final goal. Second, a mathematical model of the sys- tem of interest has to be formulated using fundamental theories such as force balance, momentum, heat, and mass balance, thermodynamics, and rate laws (momentum, heat, and mass transfer, kinetics). This is a critical step in problem solving. If a model is incorrectly formulated, one will obtain erroneous results although the mathematical solution of the mod- elis perfect. fo Third, after a mathematical model has been correctly formulated, the task is reduced to how to solve it fast and reliably. Before the com- puter era, mathematical models had to be simple enough so that analyti- cal or numerical solutions can be obtained in a reasonable period of time. Since numerical solutions in the past were very time consuming, if achievable at all, chemical engineers sacrificed the accuracy of the solu- tions by oversimplifying the problems. Fortunately, modern computing allows us to perform such tasks much faster and deal with more and more complex mathematical formulations. This means that unnecessary 2 Chapter 1 + Introduction assumptions in developing mathematical models could be removed, op- timization of an integrated system could be performed, and what-if anal- ysis could be easily done, When a numerical method or procedure is de- veloped, it must be carefully and rigorously checked for errors and tested on some problems of known solutions. Due to the advanced improvement on the mathematical software packages, many basic numerical methods, such as routines (functions) for solving non-linear equations and ordinary differential equations, have been at our fingertips, Thus, the errors originated from numerical me- thods used can be minimized. Fourth, after a mathematical solution has been obtained, result verification must be performed to ensure the correctness of the problem solution. This can be done by critically analyzing the results and/or comparing with the available experimental data. Of course, in analyzing the results, logical thinking, good sense, and deep understanding of the fundamental theories underlying the physical problem are needed. If the results violate theories, do not make sense, or do not agree with experi- mental data, a revision of the model or numerical approach should be considered. Figure 1.1, Problem solving in chemical engineering The success of problem solving in chemical engineering is clearly determined by the accuracy of the model, the versatility of the computa~ tion, and the capacity of analysis. The first factor calls for a thorough understanding of the fundamental theories underlying the physical problem, the second calls for a versatile and powerful computational tool, and the third calls for both understanding theories and computa- tional tool. Therefore, learning a computational tool is critical in chemi- cal engineering. We need a computational tool for a certain problem not only to solve the mathematical model obtained, but also to learn the behavior of the system, for which what-if analysis is usually performed. We intui- Chapter 1 + Introduction 3 tively like to experiment, by varying parameters and variables and ana- lyzing their effects, to obtain a better understanding of the system beha- vior. Learning by doing, experiencing, and observing is usually very ef- fective. ‘The desired computational tool should therefore provide us with not only robust numerical tools, but also easy ways to interpret and ana- lyze the results of different scenarios. Mathcad is one of such tools that we will learn in this book. Mathcad Worksheet and User Interface Chapter 2 * Getting Started with Mathcad apter 2 tting Started with Mathcad As in learning other software packages, in learning Mathcad, before we can develop more complicated procedures to solve mathemat- ical problems, we need to understand Mathcad’s basic features, such as definition and syntax. The effort needed for this purpose is minimal and much less than that needed for learning other software packages because Mathead’s basic features, as we will find later, are very intuitive. Howev- er, one should not overlook the details to avoid unnecessary mistakes. Keep in mind that bad input or instruction produces bad output or result (garbage in, garbage out). If we are familiar with other program packages run on Windows, such as Microsoft Word or Excel, we will find the Mathcad user inter- face very familiar. As shown in Figure 2.1, Mathcad has Menu Bar, Stan dard Toolbar, Formatting Toolbar, and Math Toolbar. A tool bar that is different from that in many Windows applications is the Math Toolbar. This Math Toolbar makes mathematical calculations very easy and con- venient to perform. The Math Toolbar allows a user to access all mathe- matical symbols and operations. If we click on any button on this bar we will see an expanded toolbar under the specified category on the screen. The following buttons are available from the Math toolbar: Calculator Toolbar Graph Toolbar Vector and Matrix Toolbar Evaluation Toolbar Calculus Toolbar Boolean Toolbar Programming Toolbar Greek Symbol Toolbar ye PN any es wp yo Symbolic Keyword Toolbar 6 Chapter 2 « Getting Started with Mathcad eau Bat 6 1 Star Toot ‘= Farting Totter Plug Flow Reactor Design “hie werksheet i an example how ocesign a plug lew rector using Matnese Fate constant: ogois #*! Concenraton ef Alnthe reed: Ca ene rt eprint) =k Gy (1-Xa) omonratecreacanthaterennes: ig, <2 on sutton for ug How etre dered rommal balance: Ygsaltne| ya For Me08) yaaa oar? “0 Ma=O8: VotCos) = 643807 Figure 2.1, Mathcad Worksheet and Liser Interface We can find out the name of each toolbar by letting the mouse pointer rest on a button, The function of each toolbar is pretty much self-explanatory. For example, the Calculator Toolbar contains all of the basic arithmetic operators we usually find in a calculator. Some of them can also be directly typed through the computer keyboard, for example “for multiplication, ‘/* for division, “*” for power, etc. We will learn and use most of the toolbars as needed in the subsequent sections and chapters, Mathcad is essentially a worksheet for calculations. If we look at Figure 2.1 once again, one of the nicest features of Mathcad becomes ob- vious ~ we could develop a solution procedure just as we would do it on paper. We type the problem statement and variable definitions, then va- riable assignments, function definitions, and mathematical equations of the solution, and finally, graphical representation of the solution. Note that we can type math equations just as we would write them on paper. This is a natural and intuitive way to develop a problem solution, making it very easy to read and debug if necessary. Text, tables, equations, and graphs can be mixed on the same worksheet. To insert a text region, for example, type a double quotation mark (") (or click Insert, Text Region from the Menu Bar) and type the text we want. Thus, we can use Math- cad not only to obtain the results but also to elegantly present them. .2 Variables and Functions Chapter 2+ Getting Started with Mathcad The power and versatility of Mathcad become evident from the use of variables and functions. Mathcad has several built-in variables, such as x (3.14159), e (2.71828), and g (9.807 m/s*), which can be directly used once we open a worksheet. However, most of the time we will use our own variables, which are called user-defined variables. A variable is defined by assigning a quantity to a variable name, for example: xis3 ys2x+1 z= 112.5 Note that by default any assignment in Mathcad is done by typing a co- Jon (“:”), not an equal sign (when we type a colon, Mathcad will show a colon and an equal sign). This assignment is sometimes called the “define as equal to” operator. In fact, we can override the default operator dis- play in the Worksheet Options in the Tools menu, but this is not rec- ommended for beginners. ‘As we can see, a number, an expression of other previously de- fined variables, or a range of values might be assigned to a variable. In the next section, we will learn that a matrix/vector can also be assigned toa variable and in the last chapter, we will learn that a component can also be assigned to a variable. Thus, the type of a variable is directly de- termined by the type of the value assigned. An equal sign (“=”) is used when we want Mathcad to display the value of a defined variable or evaluate an expression (or a function) and display the result. From the example above, if we want to display the value of variable y, then we type “y” and “= y=7 The following examples show the use of equal sign for evaluating an ex- pression and a defined variable: 3-y-1=20 Wisxt+ 5=8 ‘The variable z in the example is defined as a range variable, which has a range of values. In this assignment, the initial value is typed first, fol- lowed by a comma (“,”) and the second value, then a semi-colon (“;”), 8 Chapter 2 » Getting Started with Mathcad and the last value. If the second value is omitted, the default interval is 1 (interval = the difference between the second and the first values). Names in Mathcad can be a combination of alphanumeric, Greek letters, prime symbol, subscript (literal subscript), and underscore, but it should start with an alphabet or a Greek letter, which can be accessed from the Greek Toolbar. Mathcad distinguishes uppercase and lowercase letters, This name convention holds for any names including names for functions, matrices, and vectors. Variable names may also contain operator symbols, as shown [eal This can be done by pressing [Ctrl][Shift]] to insert a pair of brackets Thus, the term on the left side is in fact the name of the variable, which has been defined to have a value of 1. below Mathcad has a huge array of built-in functions readily available once we open a worksheet. Click on the 43) icon on the Standard Tool- bar to see all of the built-in functions. We can also define our own func tions (user-defined functions), for example: 2.4 f0) = 3X + =~ 5 + sin(x) x (iy x wn-(" 2 i h(x, ) = x+ £09 -1 (34 P(M):=M + ( ; ;) The variables in the bracket on the left side are called arguments. The choice of argument(s) for a function in a certain problem could be the Key to problem solving. The argument(s) can be of any type, ie, scalar, vector, matrix, or function. In the example above, f and g have scalar arguments; h has scalar and function arguments, while p has a matrix argument, Similar to variable assignment, the type of a function is also determined by the type of the assigned value resulted from the expres- sion defining the function. Thus, fand hare scalar functions while g and P are matrix functions. See the next section for information on vec- tor/matrix, Chapter 2 = Getting Started with Mathcad Mathcad always performs the calculations from left to right and from top to bottom, which is intuitive. This means that before a user- defined variable/function can be used for a certain mathematical opera- tion, it should have been defined, i.e. given a value or an expression, somewhere above or on the left side of the operation. There is an excep- tion for this general rule of the calculation flow, as described in the later section. There are two other things that should be remembered when de- fining a variable/function. First, if the user-defined name is the same as one of the built-in names, then the user-defined variable/function will override the built-in variable/function. Second, variable names and func- tion names in a worksheet are not distinguishable. It means that if we define a function y(x) and later we define a variable y, then we will not be able to use y(x) anywhere below the definition of the variable y. When we redefine a variable or a function, Mathcad will warn us by flagging it with a green wavy underscore, It is always a good idea to avoid this green wavy underscore by just changing the name of the vari- able/function, Arrays: Vector and Matrix Mathcad can also handle arrays. Thus, variables can also be de- fined as array variables, such as vectors and matrices. A vector is a matrix with a single row or column. The initialization (assignment) of an array can be done in three different ways: (1) Using the Vector/Matrix icon from the Vector/Matrix Toolbar The assignment is done by typing the name of the array and a colon, and then followed by choosing Matrix from the Matrix Toolbar or pressing [Ctrl-M]. Examples of this initialization are shown below: 140 2 fe) & 1 8 B=] 1 “102 5 If the number of elements of an array is more than 600, the assign- ment must be done using other ways described below. (2) Using a range variable as an array subscript (index variable) This type of initialization is shown in the following examples: 10 Chapter 2 = Getting Started with Mathcad 2 Bs 0.4 G psiti 2 2 o1234 B=|1| C=/12345 L 5 23456 Here, i and j are range variables. The index of B, shown as a sub- script, is typed using the left square bracket (“[*) key followed by the name of the range variable, which is “i” in this case. After typing a colon, the values of elements of B, i.e., Bu, Bi, and Bz, are then en- tered, From one element to the next, we type a comma (",”) and Mathcad automatically creates an empty placeholder. In this exam- ple, we define Bo = 2, Bi = 1, and Br =5 This initialization is handy when the elements of an array have a certain pattern, such as those of matrix C above, and the number of elements is large. The index of C is also typed using the left square bracket key followed by the name of the first range variable, a com- ma, and the name of the second range variable. (3) Using data table If we use data table, click Insert, Data, Table from the Menu Bar, and . then type the name of the array. An example of this initialization is shown below: 0 1 2 0 1 & 0 2 1 3 2 “i 0 2 Note that the default starting index in Mathcad is in fact 0, not 1 Thus, for example, the first element of A is a) To set the starting index of arrays to 1, click Tools, Worksheet Options in the Menu Bar and change the Array Origin to 1, or by redefining the built-in variable ORIGIN on the worksheet: ORIGIN= | where symbol “=” means that the redefinition is globally applied throughout the worksheet (this symbol can be accessed in the Evaluation Chapter 2 « Getting Started with Mathcad 1 Toolbar). This global assignment clearly overrides the rule of calculation process (from left to right and from top to bottom). Please be aware that if we use a range variable to initiate an array and we still use the default starting index, the range variable must start from 0, otherwise the initialization will be incorrect, as shown below: 0 2 7 1 5 which means we created a 4x1 vector (Bo will automatically be set to 0 when it is not defined)! In general, an index of an array can be a variable, a number, or an arithmetic expression. The following examples are legitimate indexed variables (again the subscripts are created using the left square bracket key): By Ses Pr.3-1) This index should not be confused with a literal subscript that is used as a part of the variable name. A literal subscript can be typed using a pe- tiod (“.”) key. The following are examples of variables with literal sub- script: Psat % ‘We cannot have an arithmetic expression for this subscript because liter- al subscript is not a variable/number. Note that r2 here is a variable name, not an element of an array r. Many array operations can be done easily in Mathead, such as array addition and subtraction, dot product, cross product, matrix mul- tiplication, matrix inversion and transposition, and calculation of deter- minant. For example: 3,2 51 As Be 14 02 0.09 ae c=(aBy ! ( Det = |C| = 0.01 12 Chapter 2 * Getting Started with Mathcad -1 usvxwe| 13 9 ‘There is a unique type of array operator, i.e., vectorize operator, which is very handy for calculations involving a lot of data. This vector- ize operator applies any arithmetic operator and/or function element- wise (clement by element). To apply vectorize operator, we use an arrow sign above the operation or function, which can be accessed from the Matrix Toolbox. For example: 4 ———> (0.082 wis] 3 sale ou 2 0.139, 19 yi — 0) ex +3 few) =| 12 2 ‘Although many functions and operators, when applied to vectors, auto- matically perform operations on the elements of those vectors (arrays), the use of vectorize operator is recommended to avoid unnecessary mis- takes, An example below shows a potential problem: 16 (w-w) =| 9 wew=29 4 The second operation (without the vectorize operator) is in fact a dot product of two vectors. 2.4 Working with Units: Built-in and User-defined —_—— Ss In Mathcad, although there are some restrictions, physical units can be incorporated into most of calculations. Built-in and user-defined units can be considered as built-in and user-defined variables. When we want to incorporate a physical unit with a value, we just multiply the value with the name of the unit, such as shown in the example of area calculation below: D=2.Sin A==D 4 Chapter 2 « Getting Started with Mathcad 13 If the unit isa built-in unit, the name of the unit can be typed directly or inserted by clicking Insert, Unit from the Menu Bar. Knowing the exact names of the built-in units we will be using is important to avoid unne- cessary error. One example of common mistake: the name of unit ‘gram’ in Mathcad is incorrectly thought as ‘g’, but the correct one is in fact ‘gm’. If we forget about this, Mathcad will not warn us because ‘g’ is a built-in variable (gravitational acceleration). Therefore, use Insert, Unit from the Menu Bar if we are not sure about the unit names. If the unit is a user-defined unit, the unit should have been previously defined in term of built-in units and the name of the unit is also typed directly when it is used. The following is an example how we define and use a user-defined unit: kbar := 1000bar P kbar Mathcad always stores values and displays all results in SI units (the default unit system is SI system). Changing the default unit system is possible but not recommended. For the example above, if we evaluate A, we get A=3.167x 103m? a Note that an empty unit placeholder appeared on the right side (a small black solid box). We can easily change any unit displayed to the desired unit by typing the unit name in the empty unit placeholder. For exam- ple, if area in ft? is desired, we type “ft” in the unit placeholder: A= 0.0348 If another area unit is then desired, for example mm®, just replace “fe” with “mm”. There is no unit placeholder anymore once the unit place- holder has been filled. Calculations that incorporate °C and °F as the temperature units can also be performed. For example: t= 25°C = 298.15K_ t=77°F t= 30°C cal op = AH :=ep-(tl ay a2 gm A°C ° em Note that there are two types of Celsius and Fahrenheit built-in units, ie., temperature unit (°C or °F) and temperature difference unit (AeC or ASE), which should be distinguished from each other. These temperature units can be inserted by clicking Insert, Unit from the Menu Bar. The temperature unit °C or °F is in fact a postfix operator/function, for which, unlike the temperature difference units and other units, a multiplication 14 Chapter 2 * Getting Started with Mathcad operator (“dot”) must not be used. If we use absolute temperature units, both temperature and temperature difference units are the same, i.e., K orR. Remember that units are treated like variables. Consequently, if we define a variable named m, this will confuse ourselves with the unit “meter”. Thus, if units are incorporated in our calculations, we need to avoid using unit names as the names of our user-defined va- riables/functions, particularly when the unit will be used. If this should happen, i.e., if a unit name needs to be used as a user defined varia~ ble/function, we need to insert a namespace operator to differentiate the unit name from the user-defined variable. For example: m3 = 0.5- Meni The namespace operator [unit] is created by pressing [Ctrl][Shift]N and typing the word “unit”. The m in the definition of r above is the unit “meter”, not the variable m, which has been defined to have a value of 3. Since some Mathcad built-in functions do not support or fully support units, as we will find in the subsequent chapters, the unit incor- poration in the calculations is in fact recommended for advanced users. For beginners, the units of all variables can be made consistent before calculations, which can be easily done in Mathcad, and then the calcula~ tions could be performed without incorporating any units 2.5 Graphics Features: x-y Plot of Data and Functions Mathcad has many graphic features, including 3-D plot, contour plot, and animation. In this section, we discuss only x-y plot because it is the most widely used graphic representation. We will learn other plots in later chapters as needed. Data and functions can be plotted easily in Mathcad after inputting the data or defining the functions. Data pairs should be inputted in the forms of vectors of the same size. For example, if we want to plot two quantities obtained from an experiment, where x is the independent variable and y is the dependent variable, we need to create vectors x and y first. A graph frame is created by clicking the Graph Toolbar from the Math Toolbar and choosing x-y plot (scattered plot). To let Mathcad know what we want to plot, we have to type the variable/function names in the empty central placeholders of the abscissa and ordinate (x- and y-axes). The other empty placeholders are for scale adjustment. Mathcad will automatically plot the data once we hit [enter] Chapter 2 « Getting Started with Mathcad 15 or click any region outside the graph region. If we want to plot a second experimental data z measured at the same set of independent variable x, we need to create the vector z before the graph region (remember that Mathcad processes any calculations from left to right and from top to bottom). To incorporate this second dependent variable in the existing graph, we click on the name of the first dependent variable on that graph and type a comma (“,”) immediately after the last letter of the name of the first dependent variable. Then we type “z” in the second placeholder that just appeared. If the second set of data is measured at a different set of independent variables, say xl, the vector x1 has to be created first along with the vector z and remember that x1 and z must be vectors of the same size. Besides inserting z at the y-axis on the graph, we also insert x1 at the x-axis by typing a comma (“,”) immediately after the last letter of the name of the first independent variable. Below is an example of how to create x-y plot: 0 0 1 1 1 5 t=] 2 His] 4 x=] 2 y:=| 8 3 9 4 14 4 16 T 1s a d00 lor 1 9% x S Aaa yf 6 I 2 1 L 0 1 2 3 4 OF course, the vectors can also be created using other methods as de- scribed in Section 2.3. Sometimes we need to format our graph to obtain a better pres- entation. For example, we can change the symbols from circles to squares or change the symbol plot to line plot. We can also type the plot title, axis labels, and legends. To format a graph, double click the graph and a new window for formatting pops up. The formatting features are straightforward and the readers are encouraged to try by themselves. If 16 Chapter 2 + Getting Started with Mathcad we need to know the values of the independent and dependent variables for a certain point in the graph, we can trace the plot by right clicking on the graph and choose Trace from the pop-up menu. For plotting functions, it is a good practice to define the func- tions as described in section 2.2 before we create a graph frame, although we can directly type the expressions in the empty placeholder of the y- axis. To create the graph, again a graph frame is created by clicking the Graph Toolbar from the Math Toolbar and choosing x-y plot (scattered plot). For Quick Plot, we type the independent variable name on the x- axis, the function name on the y-axis placeholder, and hit [enter] or click any region outside the graph region. Mathcad plots the function at an independent variable range of [-10,10] by default. To plot the function at different independent variable range, the minimum and maximum val- ues in the range must be typed in the empty placeholder of the x-axis. In plotting a function, in fact, Mathcad calculates the function at points of certain interval, which is, by default, a thousandth of the width of the independent variable range. To plot the function at a different interval, the independent variable must be defined as a range variable before the graph region, Other functions can also be plotted on the same graph by defining the functions before the graph region and inserting the function names at the y-axis (a comma after the first function name is also used to create an empty placeholder) Recall that when we redefine a variable or a function, Mathcad will warn us by flagging it with a green wavy underscore. However, Mathcad will not warn us when we use a defined variable or built-in variable/unit as the independent variable in a plot because we in fact do not redefine that variable. The following example illustrates this poten- tial problem: AR) = 9-R? 0.971 T 0.971) T A(R) 0.977 7 AR) a97F 4 = 000 0.9 t 0.965 i ‘i 555 0.556 0.557 0.555 0.556 0.557 R R In this example, R is a built-in temperature unit (Rankine), which is equal to (5/9)-K. Therefore Mathcad only plot one point, as shown in the Chapter 2 « Getting Started with Mathcad 17 right graph, which cannot be seen if the plot format is line plot (left graph). To plot the function A properly, we can use R1 instead of R for the independent variable or redefine R as a range variable. Before we proceed to the next section, it is important to know how to control the units used in x-y plot when units are incorporated in our calculations. It has been mentioned in the previous section that Mathcad stores values and displays all results in SI units. This also applies to the graphical features. Mathcad displays x-y plots with x and y values in SI units. The following example illustrates the use of units in x-y plot: AG) snr r= 2in,2.1in., 8in 0.1 —1—T 0.1 or 4 aw oP 4 Ao as 0.057 4 _™_0.05- a er roa 05 0.1 O15 0.2 0.25 0.05 0.1 0.15 0.2 0.25 r r m In the example above, we want to plot A(z) in the r range of 2 to 8 in. The independent variable r should be defined as a dimensional range variable, i.e., a range variable that has a unit. When we define a dimen- sional range variable, we must provide the second value to inform Math- cad about the step. Although both graphs represent the same plot, the right graph is the recommended plot because one will immediately un- derstand that the units of r and A(r) are m and m®, respectively. The units are entered as if they are divisors, for example, for the x-axis, we type [][/l[m]. To display the plot in different units, replace the units in the denominators with the desired units: 18 Chapter 2 = Getting Started with Mathcad 2.6 Symbolic Math Capabilities Mathcad has some symbolic math capabilities. This means that in some cases, we can use Mathcad to analytically or symbolically solve math calculations. For example, in engineering we frequently need to perform differentiations, integrations, or matrix inversions analytically, which can be done easily in Mathcad (of course, if analytical solution does exist), This symbolic math could be done using a live symbolic equal sign, ie., “>”, or a symbolic keyword and a live symbolic equal sign. For example: Evaluating a definite integral b xt] dx > atan(b) — atan(a) 2 x +l a Evaluating the inverse of a matrix 3x+5 3x45 Bxt5 3x45 1 xt x Bx+5 3x+5 3x45 Simplifying an expression at. x-2 simplify > X 3x42 Collecting coefficients of a polynomial ~aib 2 2 a P.(y — b)-v? = R-Tev" + ar(v —b) coeffs,v > -RT-Pb Poo) Solving an equation symbolically {RUT + 4BPRT-RT (sy =1+B °| solve,p > DBRT pa _RT+YRTGBPSRD 2BR-T Chapter 2 « Getting Started with Mathcad 19 These symbolic keywords and equal sign are available in the Symbolic Keyword Toolbar from the Math Toolbar. A symbolic keyword is needed to perform a certain operation or give an additional con- straint/condition. In the examples above, the symbolic keyword “simpli- fy” is used to simplify an arithmetic expression, “coeffs” is used to collect the coefficients of a polynomial in v, and “solve” is used to obtain the expression for p from the given equation (note that to type an equation, the equal sign is the bold equal sign, which can be obtained from the Evaluation Toolbar or by pressing [Ctrl][= All examples in this chapter clearly demonstrate the synergy of power and elegance with which Mathcad performs its basic operations. There is no intention to cover all features or functions of Mathcad here, but rather to create an impression about what Mathcad can do and how easily math operations and plotting can be done. Various other impor- tant functions will be demonstrated in the following chapters and how to-use them in solving chemical engineering problems is also presented. Example set 2.1 1, Shell-and.-tube heat exchangers are widely used in industries to exchange oat between hot ‘and cold fuids, The effectveness-NTU methad is a caloulaion approach commoniy applied for hheat exchanger design and performance analysis. For 24 shel-and-tube heat exchanger: (@) Calculate the effectiveness (:) for a heat capacity ratio (C,) of 0.8 when the number of transfer units (NTU) is 2 (6) Create a plot of heat exchanger effectiveness &) as a function of tha numberof transfer ‘units (NTU) in the range of 0 = NTU = Stor heat capacity ratios (C,) of 0, 0.25, 0.5, 0.75, and 1.0. For a 2+ shelhand-tube heat exchanger, the effectiveness can be obtained from: (et here is the effectiveness for one shel ofthe heat exchanger given by [ oe Pees) a {@) We need to define C, and NTU before we can calculate, and 8 Note that r here is just a iteral subscript, not an index. NTU=-2 Chapter 2 + Getting Started with Mathcad ‘Since ¢ is dependent on e,,calaulate c first then et Not that 1 hoo also a iteral subse, not an index fees es ie (b} To croate a plot, we need to oreate the function , which is dependent on another function ‘Of course, we can use this function to soWve part (a): e(0.8,2) = 068 os £(0,N H{025,NTUL) 9, (05,NTU!) HQIS.NTUI) 0, 2(099999,NTUL) 0g qui (On the plot, the name of the independent variable is changed to NTUI because NTU has ‘been defined to have a value of an part (a). II we used NTU on the plot, Mathcad wou plot only one paint at NTU = 2 for each C,. Note that for C, =, the numerator and denominator ofthe equation of « become 2670. “Thats why om the plot we use C, = 0.99009 for an approximation. We can also take the limit and assign the result to a diferent function: afi refer VERTU seq(NTU)= tim. {C,.NTU) > Boleseinfed got ! xtu Fis oan EN, In Mathcad, the limit operator, which can be accessed in the Calculus Toolbar, ean only be used with the symbolic equal sign. “The function then can be used to plot or calculate the effectiveness for any NTU. For ‘exampie, for NTU = 2: eqn(2) 0623 compared (0.999982) = 0.618 Chapter 2+ Getting Started with Mathcad 21 2. lr at 80°C (T,) flows over a long, 25-mm diameter cyinder wth embedded electrical heater. Ina series of tast, measurements were made ofthe power per unit length, required to ‘maintain the cyinder surlace temperature at 300°C (T,) or ciferentiroe-stream velociyV of the air. From energy balance, this power per unit lena isin fact the convection heat rate por Unit length. The results are as fliows: Airvebcity, Yims) 1 | 2 | 4 | 8 | 2 Heat ate,g"(Wimy 310 | 438 | «25 880 | 1080 Determine the convection coeticient (h] foreach velocity and display your resuts graphically, ‘The convection heat rate per unit length is given by ‘A(T, Tha) ‘where Ais the circumferential area of the cylinder per unit length Solution: We define all ofthe known variables and paramotors: T= 300c = 25mm 310 438 ei=| 025 | The prime is typed by pressing [CtifF7) 80 | ™ 2 1080, ‘The circumierential area af the cyinder per unit length needs to be calculated frst: Ar nd=0079m ‘The convection coeticient is calculated from the gven equation: 16446) 23297 as.is7|— By using vectorize operator, al values of = lsat hat cillerent velocities can be calculated 5] mk ‘ee atonce. 57.296, h(x.) ho) 2. Explain the difference between the following ORIGIN redefinitions: ORIGIN= ORIGIN= 1 22 Chapter 2 * Getting Started with Mathcad 3. Implicit multiplication, i.e., the omission of “.” (multiplication opera tor), in mathematics is very common, e.g., 2x, 34 etc. In fact, in Mathcad we are also not required to use this operator to type such ex- pressions. However, this feature is not recommended. In other words, use the multiplication operator in any multiplications to avoid unne- cessary mistakes. Explain the difference between the following ex- pressions: hi=y(x+ 2) hi=y(x+ 2) 4. Fibonacci sequence is a sequence of numbers in which each number equals the sum of the two preceding numbers (of course, except the first two numbers, which are both equal to 1): 1,135, 5.8. TS Use Mathcad to enlist the first 30 numbers of this sequence. Hine Create a range variable i from 3 to 30 and an array (indexed variable) £, where fi and f are both set to 1. Then, create a recursive formula for & representing the i-th element in the Fibonacci sequence. Math- cad will automatically calculate the i-th element using the formula for all values of i. Note that this calculation is similar to “do loop” con- taining only one formula in FORTRAN or other computer languages. 5. A constant that is commonly used in chemical engineering is the gas constant R. The value of R can be obtained from Mathcad. Click Help, Reference Tables from the Menu Bar to open Mathcad Resources: Reference Tables window. Click on Fundamental Constants under Basic Science category and R can be found in Physico-Chemical Con- stants group and copied to an active Mathcad worksheet. The value is R= 8.314472 mole K Using Mathcad, calculate R for the following units: a. _atm-cm*/(mole-K) b. bar-m’/(mole-K) c. torr-m/(kmole-K). Hint. create a user-defined unit: kmole. 6. Second virial coefficient (B) is an important gas property. In fact, this property is related to the molecular interaction between two mole- cules. If we know the second virial coefficient of a gas, for a given pressure (/) and temperature (7) we can estimate the molar density (p) of that gas using the virial equation of state: Chapter 2 * Getting Started with Mathcad 23 4B pRT where R is the gas constant. Note that the second term on the right side can be considered as a correction term, because for an ideal gas: P{pRT= 1; an ideal gas is a gas that does not have any molecular inte- ractions. ‘The second virial coefficient can be estimated from statistical thermo- dynamics, for example for a square-well fluid, which is a model for more realistic fluid, it is given by B-l og ana 2 on) 2 aN = the second virial coefficient of a hard- sphere fluid o= the diameter of the molecule = the well depth of the molecular potential A=a dimensionless parameter related to the well width of the molecular potential A= the Boltzmann constant Ni = the Avogadro number a. Plot the second virial coefficient of CO: as a function of tempera- ture, say from 200 to 1200 K. The square-well parameters for CO? are o= 3.917 A, A= 1.83, and ¢/k= 119.0 K. b. Plot on the same graph the second virial coefficient of CHs as a function of temperature. The square-well parameters for CHs are = 3.40 A, A= 1.85, «/k= 88.8 K. c. Calculate the molar density (in mol/cm!) of CO» at 7’= 680 K and P= 40 bar using this virial equation of state. d. To investigate the behavior of a real gas, plot vs. T (400 < T= 700 K) at P= 60 bar and pvs. P(0 < Ps 60 bar) at T= 400 K for CO using this virial equation of state, On those graphs, also plot the molar density of an ideal gas. By analyzing these graphs, at what conditions would a real gas behave like an ideal gas? Do you know why? Write your comments. A first order reaction is carried out in a series of N equal-size mixed flow reactors, The total conversion (X) achieved for this system is given by 24 Chapter 2 * Getting Started with Mathcad =(l+kz)” Xx where &is the reaction constant (= 0,075 hr) and ris the mean resi- dence time in a single mixed reactor. a. Plot the total conversion of this reaction as a function of z (0 < z< 40 hrs) for N= 4. b. Plot on the same graph the total conversion as a function of for N=2, ¢. Calculate the total conversion if the number of equal-size mixed reactors is 6 and the residence time of the fluid in a single reactor is 5 hrs. d. Suppose we allocate a total of 10 hrs for this reaction (}t, = 10 hrs, the summation is over all reactors) and a large conversion is desired, would you suggest having a lot of small mixed reactors or a few large mixed reactors? Explain your reasoning using some calculations. Hint. a larger reactor has a larger fluid residence time 8. In chemical industry, the cost of piping system (pipes and fittings) and pumping are important costs that should be considered. ‘The annual cost of a pipeline with a standard carbon steel pipe and a motor- driven centrifugal pump is given by: C=0.45L +0.245LD" +325VP +61.6P"* +102 where J is the length of the pipeline in ft, Dis the pipe diameter in inch, and Pis the power of the pump in hp, which can be calculated from: , ia P= 4av10* 2 a1.92%10° a In the above equation, Q is the volumetric flow rate of the fluid in ams a. Plot the annual cost as a function of pipe diameter, say from 0.25 to 6 in, for 1000 ft pipeline with a fluid rate of 20 gpm. b. What is the annual cost needed if a pipe with a diameter of 1 in is used? Is there an optimum diameter for this pipeline? Explain why it is expensive when a very small pipe diameter is used. Chapter 2 * Getting Started with Mathcad 25 9, In petroleum industries, it is common that the molecular weight of an oil fraction is unknown and thus must be estimated by using a corre- lation. A correlation that is widely used is developed by Riazi and Daubert, which is also referred to as the API (American Petroleum Institute) method. The correlation can be applied to hydrocarbons with molecular weight ranging from 70-700, which is nearly equiva- lent to boiling point range of 300-850 K, and the API gravity range of 14.4-93. This molecular weight (4 correlation is given as a function of the average boiling point (73) and the specific gravity at 60°F (SG) of the oil fraction of interest as follows: M = 42.965 exp(2.097 x10“T, —7.78712SG + 2.08476 x 107 7, SG)T, 70" SG#988 where his in K and SGis related to the API gravity (AP): _ 14s API +1315 a. Estimate the molecular weight of an oil fraction that has an aver- age boiling point of 344.7C and an API gravity of 50. b. Plot on the same graph Mvs. 7 (400 < Ti< 600 K) with API grav- ity = 20, 40, and 60. Chapter 3 * Nonlinear Equation 27 apter 3 mlinear Equation Nontinear equations, both polynomial and non-polynomial, are commonly encountered in chemical engineering applications. In solving a nonlinear equation, it is well known that we may have more than one root, For a polynomial equation of order n, there are exactly 12 roots that satisfy the equation. IF complex roots do exist, they must appear in pairs, ie., complex numbers and their conjugates. For a non-polynomial equa- tion, it is uncertain whether we have only one toot or more. In many cases, we are only interested in real roots and most of the time only one real root has physical meaning, which is the solution of that particular physical condition. However, obtaining two or more real roots that have physical meaning is not uncommon, such as found in the phase equili- brium calculations. In chemical engineering, complex roots are impor- tant for process control analysis. Mathcad provides us with easy and simple procedures to solve a nonlinear equation. In this chapter, we also introduce a procedure, referred to as pa~ rametric procedure, which is very useful in solving many parametric problems in chemical engineering, In a parametric problem, the un- known to be calculated is dependent on some parameters, the values of which will be varied. This parametric problem often occurs in what-if analysis. lynomial Mathcad has two built-in functions that can be used to find roots of a polynomial, i.e., polyroots and root, In fact, find function with a Given block can also be used to find roots of polynomials or other nonli- near equations, but it will be discussed in the next chapter. The proce- dures of using polyroots and root functions are described in Procedures 3.1 and 3.2, respectively. As can be concluded from Procedure 3.1, if the variable x of a polynomial f(x) has a unit, each coefficient of the polynomial will have different units. Thus, each element of the vector c should have different unit, which is not allowed in Mathcad. Therefore, polyroots function does not support units. 28 Chapter 3 * Nonlinear Equation Procedure 3.1 ; polyroots “The potyraots function isthe best function for finding al roots without provicing any iil guesses. For example, we want to find the roots ofa eubie polynomial fh 22+ 3x- 50D S In other words, we want to solve f(x) = 0 4 Collec al coetficients of the polynomial using the symbolic math for collecting coefficients and assign them to an array variable (vector) ( 3 3 eM) coal § | ; 1 Remember that when we do this, the variable x must have never been defined (no value Nas ‘een assigned to x), olnernise f(x) is not considered as a polynomial, but a number, a: ee pyott fd aloo ve musth tee 0 aac ool os sepa (0)=| 23-2480 (srs 2a) 313 =0284 5 489%, = 2373+ 2.4821 » x i Inthis case, we have one real root and two complex roots, Parametric procedure for _polyroots For example, we want to find the roots ofa cubic polynomial with ane parameter a: flay) ent 3y-30.—D2 +3? Now he parameter a must be ineused 25 ‘an argument in all functions and dependent variables i the procedure that are aos - B dependent on the parameter. fay = Hayy) eoetts,y > | (a) = polyoots (otal) Fora=2: Fora=16 asa (1082-2408!) The ooteforany a 2ana- 24821 yet | 1052 2anxi| can be calculated (srs 2a ones) ae ‘As noted in Procedure 3.2, root function requires an initial guess to find the root. In fact, the success of using this function depends on how close the provided initial guess to the real root is. Ifthe initial guess is not close enough to the desired root, the root function may give another root or fail to converge. If the root function fails to converge, it ‘will be colored in red and an error message will be shown when one dlicks on it, Plotting the function that is being solved is therefore very important to obtain a good initial guess for a real root. Unlike polyroots function, root function does support units. Chapter 3 + Nonlinear Equation 29 Procedure 32: root ‘oot function can oniy find one root ata time. Although root function can also find imaginary root: by using complex number as intial guess, root function is mainly used to find the real rts of a polynormial For example, we want to find the rots ofa cubic polynomial: Hoyen tS ex-3 Incther words, we want to solve f(x) = 0 1. Plot the function to get the idea about the number of real roots and the initial guess. vvalues of x) that make fs) = 0. T ' {~~ [7] Byanaiyaing thie plot, we know that / \/ there are thre real rots (oo 08 06 2. Detine an initial quess: .~1 3. Use the root function to find one of the roots that is close to the initial guess 2 = root a) ,3) = 0.646 4, Repeat stop 2 and 3 for other roots Inilval ques: y= root fls).9) == Initial guess: x. -s 35 = Foot 1).m) = 4.646 “The parametric procedure forroot function or any ether function is similar to that for polyroots function, where the parameters should be included as arguments in all functions and ‘dependent variables that are dependent on the parameters. See Example 2 of Example set ‘31 inthis chapter as an example. Example set 3.1 1, Caleulate the molar volume of carbon cioxide at 400 K and 50 bar using Peng-Robinson equation of state: Rr wo Veabv-b Uunere Fis the gas constant, Tis the ansolute temperature, V is the molar volume, and a and b are the parameters calculated trom: waseire|. s os? PASTE | (osr464e 1 seaie-a2om)|1-() | ouvrzr90R Fe where Teis the eitcal temperature, Pcis the critical pressure, and « isthe accenitic factor. Data for carbon dioxide: Te = 304.2 K, Pe = 73.83 bar, m= 0.224 Solution: ‘As we can see irom the equation above, to calculate the molar volume V, we are dealing with a polynomial. Since polyroot willbe used here, we cannot incorporate units in cur Calculations and thus the unit of the gas constant from the Reference Table should be ‘made consistent fist 30 Chapter 3 + Nonlinear Equation Fromihe Maen Plone Table: = sate SE 4s elma eines Ritoses ream Pest For 004: eer Calculate parameters a and b a. os? a tess asnie ae vane [i-(2)"] Pe Te Te = 0077T96R e Pe Collect the coefficients of the polynomial we want to solve voy cabv-w)—erls aev—0) + avo A= -6.026418195e7) The symbolic Keyword "oat is used to limit the number of significant figures in a coats. 515 e=hY) "| 120880151525 | result. In this case, we limit the number Moat,10°” | -31925.43086 | of significant figures to 10 for defining the 500 coelficents Volume calculation using polyroats ‘V-=polyroots(e) =| 20.108- 40.1271 598.292 Volume:=V, = 598292 emémol 20,108 40. =| 2. A brick wall of 0.2 m thick (L) separates a hot combustion gas ofa furnace trom the ambient ‘ir and its surtouncings. Under steady-state condition, the temperature ofthe inner surface of the brick wal (T,) is 628 15 K and of the ambient air (T,) is 293.15 K. Free convection heat \ransfor tothe aris characterized by @ convection coeflicient (h) of 15 Wim? K. Thermal ‘conductivity ofthe brick wal (k) is 1.2 Wim.K andits suriace emissivity (<) of 07. The temperature ofthe surrounding (T,) can also be assumed 293.15 K. a. What isthe brick outer surface temperature (T,)? Plot the brick outer surface temperature (T,) a8 a function ol the brickinner surface temperature (T) asumming all of the other parameters constant (400 < 800K) From energy balance: Energy transfered tothe outer surface = Energy transtered trom the outer surlace F774 -1,) +¢0(1,4-1,4) ‘where ¢= Boltzmann constant = 5.67 10-8 Wim®.K# ‘Solution, 8 1 @BISK =02m 300K,301K..600K iia guess: + Torwouern.n=seomw A) 3004000060 Chapter 3 + Nonlinear Equation 31 ». We can repeat the calculation in part (a) above several times for illerent and plot the ‘results manually. However, parametric procedure isthe best way to do this, ie., by making 7T, as a function of, Include in the funaion (1, amet) +€0( Ty! -1y') A tolt)=wa((r1).1) Now ator aint vss, of ) a p ) we use the value of T in part (a). tics, hao apne on preter rtd 1 Foret) T the conesponn vale of, z
  • yroots(e) =| 0336 | ? neat, 107 | -113951.6449 Ens oss ) 151935.5265 ‘Then the sizeof the unreacted particle core is 3.36 mm (one roots negative and the other ‘s greater than the inal size of the patio) 32 Chapter 3 + Nonlinear Equation 3.2 Non-Polynomial For finding roots of a non-polynomial equation, roor function will do the job. As in using this function for polynomial problems, the initial guess is very important. If the initial guess is not close enough to the desired root, the root function may give another root or fail to con- verge. Example set 3.2 —— {An electric wire witha bare radius (r,) of men and a surface temperature (7) of 400 Kis covered with an insulation, The temperature othe surrounding air (T,) 18298 K. The convective heat coetcient (hy) is 20 Wiim2K) and the conductivity ofthe insulation K) is 0.4 Wim K «Plot the heat loss por meter of wire as a function of the radius ofthe insulated wire (.) Say from 1mm to 60 mm, and discuss whether the heat loss decreases as we add more insulation ‘Assure that T, is constant and not affected by the insulation thickness b. Caloulate tho thickness of the insulation ifthe heat loss per meters 60 W axt(ty—To) “The heat loss can be calculated trom q = — where = thelength ofthe wite K Solution: tom ks mk 2. Create a function for heat loss: afr) p= brn. 2:m. 60mm At first, by adding insulation, the heat loss increases! After f, reaches a criical value at 20 ‘mm, adging more insulation results in the 106 decrease ol heat loss, Do1s 0.08 ©. f(y) alr) —sOW Tere ate2 root for Ka) =0, 28 canbe analyzed tom the grap above Initial quess: ry: 1mm Insulation thicknoss: y= rot (i) t9) = 10:315mm tery ny =9315am Initial quess: 9: SOmm fro {r) 19) = 46:745mm Ug = 487450 2, Caleulate the bubble point temperature (yaoi) of & mixture containing 0.8 mol traction ‘benzene (xg) and 0.7 mol fraction toluene (x7) at pressure (P) of 1 am. The vapor pressure (Peg) ofthese compouncs asa function of temperature can be represented well by Antoine a4 of va WG, equation Antoine equation: Psa, whore A,B}, and C, ae Antoine parameters for component and i the temperature [°C] Chapter 3 + Nonlinear Equation 33 “The bubble point temperature can be calculated by solving the following equ: Pe ag Peatal ty puie) + 7 P82tr( bubble) Data: Benzene: A= 15.90086, B = 2788.507, C Toluene: A= 16.01066, B= Solution Benzene: Ayo 1590085 By 2788507 Cy =220.790 x03, Toluene: Apr 1601065 Bp 303 Cp 219.377 xp bay P7690 (Vatm =760 mmHg) srseaen: ratin.n.ooey(a-—22) (Create a function for bubble point calculation: Ao s=ag-Psat(-AB.Bg Cp) + PPoat(Ap.BpsCq) —P nd Il guess: «= 100 sal tole = O0119,1)=98456. °C ty le = ae 150 * 3. Aheal exchanger is needed in a chemical process. One possible choice would be a standard type, which costs $4000, This heat exchanger will have a usoful fe of 6.5 years and a scrap value of $300, Another possibie choice of equivalent design capacty costs $7000 but will have a usoful ile of 10 years and a scrap value of $800. ‘Assuming an effective compound intrest rate of 6% ‘exchanger gives the least yearly cost cue to depreciation. », At what effective compound interest rate the two types of heat exchanger give the same yearly depreciation cost? 06) per year, determine which heat ‘Yearly cost due to depreciation can be calculated from: = (C-$) aep=1 where G isthe initial cost ofthe equipment, is the scrap value of the equipment at the end of its ‘selulife, mis the lifetime of the equipment in years, and 1s the compound interest rate per year. Solution: Create the depreciation ncton: —14C,$.n,)= (C5) ‘a. Compound interest ate: i= 0.06 aeyna Heatexchangerl: cy: 4000 §) = 300 ny =6s Yeauly cost due to deprecation: —{Cy.Syanji) = 482.132 Heatenchangerll: c:-7000 Spi=800 ngs 10 Yearly cost ue to depreciation: 1(C,Sy.ngi) 470381 tholeast) .Construct a function: 1) = {64.5 .0,) - D{Cp.Sp.npi) Init ess: i:-0.05 foot(FLD,D = O47 fim ‘The compound interest rate is 4.7% 34 Chapter 3 « Nonlinear Equation Problems 1. Plot the molar volume of CO: as a function of temperature from 400 to 700 K at 50 bar using Peng-Robinson equation of state as described in Example 1 of Example set 3.1. Hint: Treat the temperature as a pa- rameter. N . Repeat the molar volume calculation for CO at 283 K and 50 bar us- ing Peng-Robinson equation of state as described in Example 1 of Ex- ample set 3.1. At this condition, it is known that CO is a liquid. As you will also find, at this condition, the equation of state will give you three real positive roots. When a cubic equation of state gives three positive roots, only the smallest and/or the largest roots have physical meaning. We should never use the other root in volume calculations from a cubic equation of state because this root is unphysical. Use your logical thinking to determine which of the roots is the molar vo- lume of liquid 3. A stirred-tank reactor processes a reaction mixture at isothermal con- dition (50°C), The reaction is A+2B35C KG, C2 and the kinetic rate expression is given by: —r, =——4—# 1+k,C, where k, = the first reaction constant = 0.01 (kgmol/m?) (hr) k, = the second reaction constant = 0.5 (kgmol/m®)*1 C, = concentration of A in the product stream (kgmol/m®) = F,tv C,, = concentration of B in the product stream (kgmol/m®) = F,/v v = volumetric flow rate of the product stream = 2 m'/hour (assume that the volumetric flow rate of the product stream does not change appreciably with the mixture composition, ie., vis constant). F,, = molar flow rate of A in the product stream (kgmol/hour) = Fioll-X,) F,, = molar flow rate of B in the product stream (kgmol/hour) =F, Cn 2F, 10%, A Chapter 3 + Nonlinear Equation 35 F ,, = molar flow rate of A in the feed stream = 9 kgmol/hour Fyq = molar flow rate of B in the feed stream = 18 kgmol/hour X, ~conversion of A= Molesof A reacted moles of A fed The design equation for a stirred-tank reactor is obtained from mass balance: FoX 4 =r, Vv where V’ = volume of reactor (m*) a. Calculate the conversion of A if V= 50 m?. b. Plot the conversion of A as a function of volume of reactor (0.< V= 70 m’). 4, The virial equation of state that relates pressure (9, temperature (1), and density (p) is: P 2 3 — =14 Bp+Cp’ +D, ORT p+ Cp* + Dp’ where & = gas constant, and B, C, and Dare the second, third, and fourth virial coefficients, respectively. For nitrogen at 200 K: B = -0.0361 liter/mol, C = 2.7047x10% (li- ter/mol)?, and D= ~4.4944x10- (liter/mol). a, Determine the density of nitrogen (in mol/liter) at 200 K and 9 atm. b. Plot the density of nitrogen at 200 K as a function of pressure (1 < P <30 atm). Note: At 200 K and pressure up to 33 atm, it is known that the density of nitrogen is always less than its critical density (ge = 11.1839 mol/liter). - Production of propylene glycol by hydrolysis of propylene oxide is carried out in an adiabatic continuous-stirred tank reactor (CSTR) [Fogler, Elements of Chemical Reaction Engineering, Prentice-Hall, Englewood Cliffs, 1992]. The reaction can takes place at low tempera- ture when sulfuric acid is used as catalyst: propylene oxide (O) + water (W) — propylene glycol The standard heat of reaction (AH at Tk = 68°F) for this reaction is 36400 Btu/lbmol propylene oxide. The feed containing 36 mol% 36 Chapter 3 * Nonlinear Equation propylene oxide and 64 mol% methanol enters the reactor at 75°F (Te). a. Determine the temperature of the product stream (17) if the reactor volume ( V) is 350 gallons, b. Determine the conversion (%). The following equations can be obtained from material and energy balances: ct (16.96x10" hrje *7 Y Material balance: = X= a 14(16.96x10" hr“)e “ U, Yo C.(T—T, Energy balance: X= rin ~ Ty) fang + AC, (T-T, } where X= conversion vo= volumetric flow rate entering the reactor = 326.0 f°/br .ctivation energy = 32400 Btu/(Ibmol) .987 Beu/(Ibmol-R) E,, = heat capacity of the mixture entering the reactor per Ibmol of propylene oxide = 400.0 Btu/(Ibmol-R) AG»= the overall change in heat capacity per Ib mol of propyl- ene oxide reacted = —7 Btu/(Ibmol-R) Re= gas constant = 6. Ina tempering process, glass plate, the temperature of which is initial- ly uniform (T:= 300°C), is cooled for 10 minutes (2) using airflow over both sides of the plate, for which its temperature (7, = 30°C) and convection heat transfer coefficient (J = 100 W/(m?K)) are kept con- stant. If the thickness of the plate (2Z) is 30 mm and radiation ex- change is neglected, what is the midplane temperature (7) at the end of the cooling process? Data for glass: thermal conductivity (4) = 1.2 W/(mK) and thermal diffusivity (a) = 5x10 m?/s. At this condition, the midplane temperature can be obtained from heat diffusion equa- tion for unsteady-state one-dimensional conduction: %-T, a = C exp] - Si T,-T,, where ¢) is the first positive root of the following equation: tang, = hL/k £ Chapter 3 * Nonlinear Equation 37 4sing, 26, +sin 2, and Gi can be calculated from C, 7. In a catalyst regeneration, oxygen reacts with carbon contained in an inert spherical solid matrix (catalyst pellet). Carbon is first removed from the outer edge of the solid matrix and eventually from the cen- ter core of the solid. As the carbon continues to be removed from the porous solid, the reactant gas (oxygen) must diffuse farther into the solid matrix as the reaction proceeds to reach the unreacted carbon. This process can be described using the shrinking core model. a. Determine the radius of carbon/oxygen interface (A) after 5000 seconds. b. Plot the radius of carbon/oxygen interface (A) as a function of time (9, For this model, the time necessary for the solid carbon interface to recede inward to a radius R is : : ; t= PcRod -{Z) 2) 6D.C ie Ry Ry where pc= the molar density of the carbon = 0.189 mol/cm? Ro= the initial radius of carbon/oxygen interface (the outer surface of the catalyst) = 0.1 cm. = the volume fraction of carbon in the porous catalyst = 05 De= the effective diffusivity in the porous catalyst = 9.5 10 cm/s Cso= the concentration of oxygen at the outer surface of the porous catalyst = 1.4 10 mol/em* 8. A superheated steam flows through a smooth pipe of 0.635 cm inner diameter (d) for a distance of 10 m (z). The temperature (7) and pres- sure (P)) of the steam at the entrance are 150°C and 500 kPa, respec- tively. Assume that the temperature of the steam is constant. The mass flow rate of steam per unit area (G) is 23.0 kg/(s-m?). a, Calculate the friction factor (f for this flow. Friction factor for tur- bulent flow in a smooth pipe can be obtained from: f =[0.790-In(Re) -1.64]* where Re is the Reynolds number given by: 38 Chapter 3 + Nonlinear Equation 9. Re= “ and jr is the viscosity of steam, which can be assumed constant at 13.8-10-¢ N-s/m?. b. Determine the pressure drop (P:— 2) of this flowing steam. For an isothermal compressible flow, the pressure drop can be obtained after solving the following equation: GRT z 2G?RT, (P fost In) Md M = \~P, where Pris the outlet pressure, Ris the gas constant and Mis the molecular weight of water (= 18 kg/kmol). c. To analyze the effect of mass flow rate of steam per unit area on the pressure drop, plot the pressure drop vs. G [23 < G< 53 kg/(s-m?)]. ‘A sphere made of aluminum alloy with a diameter of 20 mm (D) and a surface temperature of 500°C (7:) is suddenly immersed in a saturated water bath maintained at 100°C (Zim). Since the difference between the surface temperature and the bulk temperature of the liquid is very large, a film-boiling phenomenon occurs. For this type of boiling, the heat transfer from the surface to the bulk of the liquid is governed by convection and radiation. The surface of the sphere has an emissivity of 0.25 (e). a. Determine the initial heat transfer coefficient due to convection (Aeon). A correlation that can be used to calculate this coefficient is given below: Ham D _ 9 ga} 8 ky -64! nk (LT, Tou.) where gis the gravitational acceleration, pris the density of liquid water [= 712.1 kg/m®], pr is the density of water vapor [= 45.98 kg/m], Av is the thermal conductivity of water vapor {= 0.0767 W/(m-K)], cpris the specific heat of water vapor [= 5889 J/(kg-K)], avis the kinematic viscosity of water vapor [= 4.33-107 m*/s], and gis the heat of vaporization of water [= 1.406-10° J/kg). b. Determine the initial total heat transfer coefficient of this film boiling (4). This coefficient can be obtained from the following equation: WS REE t Iggy ht Chapter 3 + Nonlinear Equation 39 where Amc is the initial heat transfer coefficient due to radiation, which can be calculated from Digg = 80(L, + Ty KT? +T2,) sot ed In the equation above, o is the Stefan-Boltzmann constant [= 5.67-10 Wi(m?-K4)], c. To investigate the effect of the surface temperature of the sphere on the initial convective and total heat transfer coefficients of this film-boiling phenomena, plot on the same graph hem vs. Tzand A vs. T: (400°C < T:< 600°C) 10. A tray tower is used to absorb ethyl alcohol from an inert gas stream at constant temperature and pressure using liquid water as the absor- bent. The flow rate of the gas stream entering the tower (V) is 100 kmol/h and it contains 2.2 mol% alcohol (y2 = 0.022). The absorbent entering the tower contains 1 mol% alcohol (xv = 0.01). The number of theoretical trays (A) of the tower is 4. The desired concentration of alcohol in the gas stream leaving the tower is 1.2 mol% (yr = 0.012). a. Determine the required molar flow rate of absorbent entering the tower (J). The required molar flow rate of absorbent can be obtained from the Kremser equation: () where im is the thermodynamic constant (= 0.68) and A is the se- paration factor given by L mV Note that A = 1 is the trivial solution of Equation (1). Do you know why? To analyze the effect of the desired concentration of alcohol in the gas stream leaving the tower on the required molar flow rate of absorbent for x0= 0.01, plot Lvs. yi (0.01 < y<0.014). . Plot Lvs. x0 (0 < x0< 0.013) to analyze the effect of the concentra- tion of alcohol in the absorbent entering the tower on the re- quired molar flow rate of absorbent for y: = 0.012. Is it beneficial to use a pure absorbent? F Chapter 4 + System of Equations ter 4 m of Equations Th chemical engineering, system of equations normally arises i many applications, including unit operations, heat transfer, reactor, ma~ terial and energy balances, reaction equilibrium, and phase equilibrium calculations. Ifa system with n variables is described by 2 independent equations in these variables, then all of these 1 variables can in principle be calculated. If the independent equations are a// linear (system of li- near equations), there is one and only one solution. On the other hand, if any of the equations are nonlinear, there may be mote than one solution for no solution at al. em of Linear Equations In Mathead, a system of linear equations can be solved using two built-in functions, i.e., Jsolve and find. In fact, find function with a Giv- en block (solve block) can solve not only a system of linear equations, but also a system of non-linear equations with or without constraints, as we will see in the next two sections. Procedures 4.1 and 4.2 show how to use solve and find functions, respectively. As seen in Procedure 4.1 and 4.2, find function is easier to use than Lolve function, the approach of which is based on the matrix inver~ sion. However, find function cannot be used directly in the command lines of a Mathcad program (Chapter 9). The Jsolve function does not fully support units because it cannot be used when the unknowns have units of different types. The find func- tion, on the other hand, support units, but it should be used with a cer- tain rule, as described in the additional notes below. Procedure 41: Isolve To use solve, we have to set up the @ equations in te matrix form: oA c where A isthe nxn matrix containing coefficients of the n equations, x is n x 1 matrix (vector) Containing the n variables to be calculated, and C is x1 matrix (vector) containing the constant ofthe n equations. 42 Chapter 4 + System of Equations For example, we want to solve these three linear equations: yl 2y2e aya +2 y-y3=1 2ylsy24 aya42= 1. Create matrices A and C: 123 2) As|o14t ex 1 213) 2} 2. Caloulate the unknowns using solve and assign the resul to any vector variable: 2s yobole(a,oy=| 15 os Inthis case, we assign ito a vector variable y, wo can assign ito other variable names. "Note that infact ‘solve function is equivalent to the following matrix operation: 25 1s os A” His the inverse of matric A Procedure 42: find Find tunction can be used for solving a systom of equations gither analytically or numerically, For example, we want to solve these threo linear equations: yl 292 v-x3 By y24 3934220 For analytical calculation: 1. Consiruct 2 Given biock where all ofthe equations are defined: Given (Givenis a Mathcad statement, we have to type i) yl42y2=-3y3.2 We must use the Boolean equal sign, net the assignment sign (:=) oF the evaluation sign (=). This w-w=) bold equa sign is lyped using (Ct =] or obtained 2yl + y243y0+ 0 from the Boolean Toolbar in the Math Toolbar. Note thatthe equations can be writen the way we want them, we do not need, for example, to.collsct al ofthe unknowns on the let sides, 2. Caloulate the unknowns using find function and assign the results to a vector variable y: 3y3 42 5) Note that to solve a system of equations >| analytically using find tunetion, the function 2.| should be folowed bya lve symbolic equal sign (an arrow), vic can be obtained trom the ‘Symbolic Keyword Toolbar in the Math Toolbar Find unetion can be typed any way we want, such as |} find or FIND, The same for Given statement, indy, 92,98) > 2 yey nhs Wry, = 05 The result of analytcal find function can also be assigned to a column matrix (eee below). Chapter 4 * System of Equations 43 For numerical calculation: 1. Provide intial guesses: yi y2e1 y3=1 _ Inlal guesses must be provided 2. Construct a Givanblock where al ef the equations are defined: For solving systems of linear equations, although rrumerical find function requires intial guesses, this function is very robust, thus tis insensitive tothe choice o initial quesses. 2yl + y2+3y8+ 3, Calculate the unknowns using find function and assign the results to @ colurnn matrix: (yt y (ys 1. The arguments of numerical find function, which are the variables to be found, can be scalar (as in Procedure 4,2) and/or array variables (as in Example 2 of Example set 4.1), but not elements of an array (in- dexed variables), e.g., yi, yz, etc. On the other hand, the analytical find fanction can only take scalar variables as arguments. 1 | a.column matrix or a vectortaray (25) The results can be assigned to either ind(y1y2,y3) = a variable, 69... 05 Notes: 2. If the unknowns have units of different types, the results must be as- signed to a column matrix. 3. In a parametric solve block (parametric problem), when the un- knowns have units of the same type, for numerical find function, the results can be assigned to either a vector function with parameters as the arguments, e.g., y(p.p2) or a column matrix, each element of which is a function of the parameters, ¢.g., yl(py.P2) y2(p1.P>} When the unknowns have units of different types, of course, the re- sults can only be assigned to a column matrix. On the other hand, the analytical find function can only solve parametric problems when the unknowns have units of the same type and the results must be as- signed to a vector function with parameters as the arguments. Example set 4.1 1. A mixture containing 50 wt% toluene (1), 35 w'% benzene (B), and 15 wits xylene (X) is fed to a distillation column. The top product from the column contains 6:8 wits toluene, 91.4 ult benzene, and 2.3 wi xylene, The bottom product is fed lo a second column. The top product rom the second colurnn contains 97.6 ws toluene, 4.25 nt% benzene, and 4.15 wi% xylene, 10 wit ofthe toluene fed tothe process is recovered in the bottom product from the second column, and 83.3 wits ofthe xylene fed to the process is recovered in the same stream. Determine the compositions and flow rates of al srearms ifthe feed flow rale is 100 kg/minute. 44 Chapter 4 + System of Equations Sin ait setsne ae ae feat seam aot rd soe ti) 50% T (wp) 91.4% B (war) 4.25% B (was) 35% B (war) 2.3% X (wi) 4.15% X (Was) 15% X (We) — , aa Sil Sioned ate ea The kg T/min ny kg Timin, 10% of T in F (Ry) een rien nya kg X/min_ ys kg X/min, 83.3% of X in F (Rx) From mass balance, the following system of linear equations can be sel up: Wee Fawr my tg WR FEW My Me Mg = Mag N+ Noe Wor F= Wey 9 + Mee, Sia Fay Nig Mng Tag =r Pa Bg, Fy Wop Fand gy = Fi Wye F RpeOl — Ry=0883 Fi 100 Wp 0.068 450916 Wp =035 wp) =0910wyy 0.0125, “TF ~ BF wx. = 1-9 - By) x3, "13 ~ Bs ora Rrwret axa Rx Given re P= wpny tmp Wx F = wxyny + oxy pr P= gn] + mg y= 3s + Ty mass 48502 N= Find(ny.npa.mpp.nyo.ty.gq) Noal.5 > a ansas 1827, By Ng era N, mage N, ayy aN, mpgAN,, The How rate of stream 1 (kgimin): ny = 23.148 ‘The flow rate of stream 2 (kglmin): ny >—mpy + npg + nix = 76857 Composition of stream 2: ee yg =U wy — Wp = 0.188 The flow rate of stream 3 (kglmin): ny = 47.335 The flow rate of stream 4 (ka/min): ging + Mpg Mg = 2 Composition of stream 4: ra ony rye toi wpy= ™ m4 0.4 q's 1 py mp4 = 0026 Chapter 4+ System of Equations 45 * Solution using /sove function: wn 1 0 0 0 0) win F Jwn oe 1 00 mu “lo 10 0 wn 0 Sel | ws Jo 0-10 wt ° (0 0 0 -1 we 0} | nes * 23.144 a 48.542 on naar x2 . 14.468 4 47535 sor inazy 2. Along column, 1 mby 1 m on a side, is exposed to a hot air such thatthe temperatures of three surfaces (7) of the colurnn are maintained at 600 K vhile the remaining surlaco is ‘exposed to a colder air at 300 K (T,) with a convective heal transler coefficient (h) of 16 ‘Wi(m2k). Estimate the two-dimensional temperature distibution in the column at steady state ifthe conductivity (k) ofthe column materialist Wim K). Tp Tp ot 3 Tt ts To) ts Ti) Ty = Using the energy balance method, we can write the following fnte- CH, +H, Reaction 2: C,H, <> C,H, +2H, ‘Te equi conta of action (375 andthe equim costar of react 2 (Kis 0.195. tw rasdene tect he reacting mature the eat long enough tat, the equ is achieved, detrmino to compooteon a he pode sea ‘Te equ const K;, and Ky canbe exposed in ems ol he extats of he two ramon (an “ er(128) SalG1t 267 (ORE =F} (00 5,73) (100) and the mo action ofeach species in the product stream canbe obiained rom 100-6) ~p {100+ + 245) sean oes & NHS T04 Gy 4 By MO T00+ b+ 28 ‘Solution: onic Given SrlE1 + 289) Saft Dore Gio gH (1008, ~e9}(1004 54 , xo Fin 9) oats [ 7000 21453 99.602 83.085) here are four sets of soktons {-to00 11053 040738 6.1274) Since the extent of reactions are positive numbers, we choose oniy the fourth eet in the last column: a matrix can be accessed from the Matric Toolbar (') {y.__ Te Matix Column operator (M=} fr extracting a column from ‘Composition of the product steam: nti a NUNS Torrey e gy “CM pre ae & __ +2 OTe Tae ReaHe= 9955 xe3414= ORS ACID OOS —nyy = OAT 48 Chapter 4 « System of Equations 2 A ieucdmiture containing 50 mo? npentane (C5) and 50 moPés n-heptane (C7) ata high Dressure enters a flash vaporizer ata lower presure. The pressure anid temperature of he {ash vaporizer can be controlled as needed. The two product steam, ea vapor dreny fare’ liquid stream, coming out rom the vaporizer are in equilibrium. At the coneltion of interest, both liquid and vapor can be assumed ideal thus Raoul’ law can be apphed. The ‘Yao0" pressures of C5 and C7 at temperature PC) can be obtained usina Antone equation to(Psat) = A; Data: Acy= 138183 Bog = 2477.07 Acr= 188587 B= 290132 Cg, 2218.64 3 Determine the maximum operating pressure (P) ithe temperature (7) ofthe vaporizer s set {0.330 K and at least 70% ao the feed should be vaporized (v). Also, calculate the Composition in each product stream (xcs, Xe7.¥¢q, Yor) at the operating pressure, ». Plot the operating pressure as a function of the tracton of vapor vaporized al 330K (o % yor vapor Zs vaporizer zr > liquid Xes Xer Solution: Coeticients of Antoine equation: —Acs:= 1.8183 Aegis 13.8587 330-273 Patesmer ese Bre tern hen The mol action of C5inhe teed: 25-015 Initial guesses: Aes 0.1 P= 80KPa Given ” (veghP= (1409) P5ateg Yes) Res) [= Findlycs.r¢5,P) re) Chapter 4 + System of Equations 49 1a. The maximum pressure when at least 70% ol the feed should be vaporized: P(0.7 = 45.374kPa D.POLPWS.v: v0.01. 3... Determine the bubbe point pressure (P) ofa Saud mitre containing 25 mote cHvotorn (%)) and 75 molt% ethanol at §5°C. Also, calculate the mal fraction of chloroform in the vapor phase ) at that bubble point pressure. From temmodynaics, te folowing equations can be sot up: NOP = y7Poat, dy) where y; ithe mol action of component inthe vapor phase xi the mol acon of ‘component + in the quid phase, Psat, isthe vapor pressure of component, the activity coefcient of component i and 4, is the fugacity coefficient of component i Ix, )r Psat, calculated rom: RT Ind, = B, (P Psat,) + Pll-y,) 3,2 RT ing, = B(P~ Paty) + Pr}, B= 28s By ~ Ba where Ris the gas constant and Tis the temperature in K, The activity coelficients are calculated from a Gamma model: Ing = 0-3)" Ty +24 Aad) Imyz = a7 [4a #24 ~ Ay 1—)] Data: Psat, = 62.97 kPa, Pool, =37.31 KPa 2 = 969 cmthnol, yy = 1623 mlm, Byp = S2em9/mot a2 Aig= 058, Ary ». Plot the bubbie point pressure as function ofthe mol fraction of component 1 in the Haus Phase. On the same graph, also plot the bubble point prossure as a function a the mo! fraction of component 1 in the vapor phase. ‘Solution: Revasterra Su T35C ApH 089 Age 2 Ps vals) CO, +CH, Reaction: CO+3M, > H,O+CH, Chapter 4 + System of Equations 51 At this condition, he equilibrium constants of these two reactions are: Ky = 18283 Ky =0.7002 Determine the equitrium composition of the gas mixture i the ital numbers of moles of CO (n,) and Hy () are 2 and 4, respectively ‘The following two equations can be set up from the definition of equilbxium constant ala + Spklny + 9-264 ~ Sela + Sp)(m + mp 284 - 2a) 2? — (01-28, ~Sn)(nz-28q - 35) (1-284 ~ Sa} Where £, and gare the extents of reaction A and B, respectively. 28-35)" ‘The extent of resction shouldbe a postive number: ba2o gy20 Since the amount ol reacted CO and H, cannot excoed their ital amount, there are two ackitiona inequalities that can be obtained: Dea tips? — 2+ HEys1 ‘The equilsium composition can be caleulated using he folowing equations: Foo? A = nm 28,2 3) +m 284-28 Eq tig ym -2Eq 2p Yous Lotus fist colve the sytem of equations without imposing any constrains ays? me Wnitial quesses: £4005 Ey 05 Given Balen + ep}, (01-284 Ea) Sola + Sp) (o1 + 02-254 - ——rv ee 5 0.7002 (> -25 4 -EpH(n2 2&4 ~ 3p) Fics ‘This soktion sounds reasonable = Finleato) = (hea) because the extens of reaction (Sp 1.966) are positive numbers. Now, let us include the constraints in the Given block and use the same intial quesses: Initial guesses: £42005 gy 05 Given Sala + ép}ns emo gaze The inequality 2 7 signs can be (1-25, Sa) (0 geo accessed from 25q + 8gs2__ the Boolean Selba*6aMor 02-24-2400 yoy 2Bq+ Rey st 3 (01-26 ~Sahima-28q 40) ea (0278) Ent isis the correct sot } rialen80) = (on) This isthe corect solution \ép a Chapter 4 System of Equations Mo 2a~tp Ba“ 2a— Bp Yeo» 4 yy 88 COM Tm 2b, -28y Ha a) 48-22, -28q bn kat FO See vous SB 208 Gem PEA 2 Thus the compositon ofthe ga8 mite: ¥e0= 054 yyp=01S1——yogy= 01158 Yous=0.128— yyaq=0.013 Problems 1. a, Determine the bubble point temperature (2) of a liquid binary mix- ture containing 20 mol% acetone (x:) and 80 mol% methanol at 1 atm (P). Also, calculate the mol fraction of acetone in the vapor phase (yi) at that bubble point temperature. From thermodynam- ics, the following equations can be set up: y,P = x,y, Psan, (l-y,)P = (1x )yPsat, where Psatiis the vapor pressure of component jand yris the activ- ity coefficient of component i ‘The vapor pressure (Psat in kPa) at eC can be calculated from An- toine equation: B, In Psat, = A, -— t+C, where cis the temperature and Ai, B;, and G are the constants for component given below: A B Cc Acetone (1) 14.3916 2795.82 230.00 Methanol (2) 16.5938. 3644.30 239.76 The activity coefficient can be calculated from a Gamma model: 7, =exp(0.64—x,)”) 72 = exp(0.64x?) b. Plot the bubble point temperature as a function of the mol fraction of component 1 in the liquid phase (xi). Note: y-axis: ¢, x-axis: x7, c. Create a new graph to plot the bubble point temperature, which is a function of x, vs. the mol fraction of component 1 in the vapor phase (yi), which is also a function of x. Note: y-axis: 1, x-axis: 7 Chapter 4 + System of Equations 53 Then, include cvs. x as in part b on this graph so that you have two curves. 2, A saturated solution of AgNOs at 100°C is cooled to 20°C in a crystal- lizer and the crystals formed are filtered out. The wet filter cake con- tains 75 weight% solid crystals (we) and 25 weight% saturated solu- tion, The remaining water in the wet cake is then removed in a dryer. a. Determine the mass of AgNOs eventually recovered (R) per 100 kg saturated solution fed to the crystallizer (F). b. Plot the mass of AgNOs eventually recovered (R) per 100 kg satu- rated solution fed to the crystallizer as a function of the percentage of solid crystals in the wet filter cake (we). Why does the mass of AgNOs recovered decrease with increasing percentage of solid crystals in the filter cake? Can the wet filter cake contain 65 weight% solid crystals? Explain. Solubility data: Temperature (°C) | Solubility of AgNOs (g/g solution) 20 0.689 (s20) 100 0.905 (si00) Filtrate: Water Saturated solution: m: ke vapor 109% 20C 20°C >) Crystallizer >} Filter >| Dryer > Saturated so- 1. Solid lution AgNOy Filter cake: AgNO; Fre 2, Saturated T.AgNOs: m, kg recovered Weight fractions: solution, weight 2, Saturated Rke ‘sto AgNOs fractions: solution: my kg (> Sic0) xO son ABNOs (I-59) H:0, We obtain the following equations from material balance: “i-w, > (= Sia )F = (= 539), + = S39 Jims F=m+m,+m, ‘The mass of AgNO3 eventually recovered is then calculated from: R= SpF SoM 54 Chapter 4 + System of Equations 3. A first order irreversible liquid reaction will be carried out in a conti- nuous-stirred tank reactor (CSTR). The reaction is as follows: A products =r, =kC, —-k=k, caf MOR) where ~r1 is the reaction rate [mol/(cm*.hr)], C1 is the concentration of A in the reactor [mol/cm*], which is the same as the concentration of A in the exit stream, cis the reaction constant, kois the frequency factor (= 450 hr*), and Tis the absolute temperature of the fluid in the reactor in Kelvin. The reaction is exothermic and it is suggested to use a cooling medium with a temperature of 273.15 K (7%). A feed stream containing 0.5 mol A/cm® (Cis) will be used and the residence time of the fluid in the reactor (t) will be 0.2 hr. General equations derived from mole and energy balances are as follows we dt ( where r= time (hr) AH ,, = heat of reaction = -151000+2-(7-298.15) J/mol cw = the average heat capacity of the solution = 30 J/(mol-K) x = the dimensionless heat transfer parameter = 80 Determine the steady-state concentration of A and the steady-state temperature of the fluid in the reactor. At steady state, the concentra- tion of A and the temperature of the fluid in the reactor do not change with time. Thus, at steady state, dC/dt= 0 and dT/dt= 0. - } A total of 20,000 scfm of air (Z will be treated in a membrane separa- tor. Assume the composition of air is 79 mol% Nz and 21 mol% O2 (2). A low-density polyethylene membrane of 0.2 uum thick (0) is be- ing considered. Assume a pressure of 1.03410 Pa on the feed (reject) side (ps) and a pressure of 1.034x10° Pa on the permeate side (p). If the desired cut 0 (fraction of feed permeated) is 0.2, determine the area of the membrane needed (Ax) and the oxygen mol fraction in the reject stream (x2) if complete mixing model can be used. The permea- bilities of oxygen (Ps) and nitrogen (Ps) in the membrane are 2.2x 10° and 0.73x10-? cm (STP)/(cm?-s-Pa/cm), respectively. For complete mixing model, the following equations can be derived from material balance and mass transfer: Chapter 4 + System of Equations 55 x, =(1-0)x, +O, a9, = Aad py,) a, (i-y PyAu(Ds lx.) Pill-y,)) ’ t where yp is the oxygen mol fraction in the permeate stream. . A fresh feed (F'= 100 mol/hr) containing 26 mol% Nz (xx2"), 73 mol% Hp, and 1 mol% inert (xu/) is fed to an ammonia production process. Before it enters a reactor to produce ammonia, it is combined with a recycle stream (R mol/hr), which contains the same substances. This recycle stream has 10 mol% inert (xi). In the reactor, the following reaction takes place: N,+3H, > 2NH, The conversion of Nz (X) in the reactor is 25%. The products coming out from the reactor ($ mol/hr) pass through a condenser where all the ammonia produced is condensed and separated from the remain- ing gases. The remaining gases are recycled after being partly purged to prevent the accumulation of the inert in the system. Determine the rate of the stream entering the reactor (mol/hr), the recycle stream, and the ammonia produced (xwas§). ee ee ee awn purge The following equations that need to be solved are obtained from ma- terial balance: Mixing point: Xyopl + Xy2eR =XyryM F+R=M XpF +X gR = XjyM Reactor: Lya55 =(1— X)eyryM ay ~ Xn )M ~3XXy 244M 56 Chapter 4 + System of Equations Total element balance: 2XyoeF =XynasS + 2X vox Xin yl 21 xyap — Xap JF = 3X nusgS + 21 Xyoe Xn) 1k Two additional equations from the definition of mol fraction: Mal 2Xy2m) = ¥ar Xy25 + Xy2g +X ys + 6. A counterflow double pipe heat exchanger is designed to cool a process fluid entering at 100°C (1). The flow rates of the process fluid through the annulus (ir, ) is 0.1 kg/s and the cooling medium (i, ), which is water, through the inner tube (D/= 25 mm) is 0.2 kg/s. The water enters at a temperature of 30°C (¢.) and the length of the double pipe (Z) is 3.762 m. If the overall heat transfer coefficient Usis known to be 770 W/(m?-K), determine the outlet temperatures of the process fluid (cis) and water (sx). Specific heats for the process fluid (cs) = 2131 J/(kg-K) and for water (c) = 4178 J/(kg-K) From heat bal- ance and heat transfer the following equations can be obtained: abt ln ta) ts) = 0 (6, —1,) in ft bho — be 1,C (bao) = Eben — bes) 7. The minimum reflux ratio of a debutanizer shown below needs to be determined. The mole fraction of each component in the feed (zs), the specified molar flow rates of components in the distillate (d), and the relative volatility (as) are as follows: [Component | 7 ZR di{lbmol/hr] aia iC Z 0.0137 2 2.43 C4 2 05113 442 1.93 iC5 3 0.0411 13 1.00 n-C5 4 0.0171 ds 0.765 n-C6 5 0.0262 0 0.362 n-C7 6 0.0446 0 [0.164 | n-C8 7 0.3106 0 0.0720 aco | 8 0.0354 0 0.0362 Chapter 4 + System of Equations 57 : C4 ie Distillate i-CS n-C5 n-C5 Peed C2 ——+ n-C7 n-C8 n-C9 nC4 i-CS n-C5 reg Bottoms n-C7 n-C8 C9 The minimum reflux ratio (Rain = Lnia/D) can be obtained by solving Underwood equations: where Lnin is the molar flow rate of liquid returned to the column at minimum reflux, D is the molar flow rate of distillate withdrawn from the column, and gis the feed quality (~ 0.8666), i.e., mole frac- tion of liquid in the flashed feed. The two quantities @ and @ must satisfy the following constraint: 1, >0, > 03; >0, >a,; Solve the above system of non-linear equations and calculate the min- imum reflux ratio. 8. An exothermic reaction is carried out in an adiabatic continuous- stirred tank reactor with a fluid residence time of 0.27 hours (7). The standard heat of reaction (AH? at Ta = 293.15 K) for this reaction is ~1.216-10° J/mol. 58 Chapter 4 + System of Equations a. From material balance, the conversion (X) of reactant is given by: kt 1 l+kt 2 In the equation above, k is the temperature-dependent reaction constant correlated by the Arrhenius equation: wit k= Ae F where 7'is the temperature of the product stream, A is the fre- quency factor (= 4.711-10° s), 2 is the gas constant, and £ is the activation energy (= 7.536-10* J/mol). Plot the conversion from this material balance as a function of temperature of the product stream (260 < 7'< 400 K). . Plot on the same graph (created in part a) the conversion obtained from energy balance as a function of temperature of the product stream for three different feed temperatures (Jin): 263.15, 273.15, and 293.15 K. From energy balance, the conversion of reactant is given by: s Con —Ty) —AH x (2) where Cnir is the heat capacity of the reactant entering the reactor (= 1675 Jmol-K)) and AH is the enthalpy change of reaction measured at the temperature of the product stream, which is ob- tained from: AH = AH}, +AC, (7 -T,) where AG is the overall change in heat capacity per mol of reac- tant that is reacted (= -29.31 J/(mol-K)) c. For Zin = 273.15 K, determine the actual temperature of the prod- uct stream that gives the highest possible conversion. The actual temperature of the product stream and conversion can be obtained by simultaneously solving Equations (1) and (2). What is the actual conversion for this particular Tin? Plot the actual temperature of the product stream that gives the highest possible conversion as a function of the feed temperature (260 < Tin < 300 K). Plot the highest possible conversion as a function of the feed tem- perature (260 < Tin < 300 K). Do you think it is desirable to have a feed temperature colder than 270 K? & 2 Chapter 4 + System of Equations 59 9. In manufacturing, a special coating on a curved solar absorber surface of area (A:) 15 m? is cured by exposing it to an infrared heater of width (W) 1 m and area (Ai) 10 m?. The absorber and heater are each of length (Z) 10 m and are separated by a distance of (H) 1 m. The de- sired surface temperature of the heater is 1000 K (Zi). The heater has an emissivity of 0.9 («), while the absorber has an emissivity of 0.5 (2). The system is in a large room, the wall temperature of which is 300 K (7). The needed net rate of heat transfer to the absorber sur- face (q2) is 77.1 kW. The heat transfer is assumed to be entirely due to radiation. a. Determine the heater power requirement (g1). The heater power can be calculated from: where / is the surface radiosity of the heater and ois the Stefan- Boltzmann constant (= 5.67x10-* W/(m?-K‘). The surface radiosity of the heater can be calculated by solving the following equations: 6A, 8, (of! -,)= FAV, J.) + FAV, of) Sh ors JJ Raed )*Fy Also) (v,-0n!) where fi is the surface radiosity of the absorber, is the surface temperature of the absorber, and Fj is the view factor between sur- face iand surface j, These view factors are calculated as follows: fr}.x 1+¥? tan Fy =n r aXY 14x? 4¥? i+ 1-2, +Y: Fon ( E = xan! Yan 1+X° where x= yo 4 H H Fy=l-F, = FisA, Fry 60 Chapter 4 + System of Equations b. To analyze the effect of the separation distance between the heater and the absorber on the heater power requirement, plot gi vs. H (05 s H< 3 m), and on the surface temperature of the absorber, plot vs. H(0.5 < H< 3 m). Discuss whether or not your plots are reasonable. Chapter 5 + Curve Fitting 61 Chemical engineers deal with a lot of data that are crucial for modeling, process analysis, and process design. Data are often obtained or given for discrete values along a continuum, from which we often re- quire trend analysis and/or estimates at intermediate points. If we are developing a mathematical model for a certain process or physical phe- nomenon, we may also need to obtain some model parameters fitted to experimental data. The procedure that we need for these purposes is called curve fitting. There are two general approaches for curve fitting, i.e., regres sion and interpolation. The choice of the approach is dependent on the extent of error associated with the data of interest and the purpose of the curve fitting, If the data exhibit a significant degree of error (“noise”), any individual data point may be incorrect. In this case, regression should be the correct approach, from which a trend or pattern of the da- ta can be obtained. Interpolation should not be used for such data. If the data are known to be very accurate, for example data ori- ginating from standard tables, we could use either regression or interpo- lation depending on our purpose. If we would like to obtain parameters of a model that we develop, we should use regression. On the other hand, if we only require estimates at intermediate points, interpolation is often the best approach. iterpolation Interpolation is the estimation of values between precise discrete points. We encounter this kind of estimation in many applications in chemical engineering, for example in the calculations of thermodynamic properties of water from the steam table. 5.1.1 Linear Interpolation Linear interpolation is an interpolation using a linear function connecting two points. We use this linear interpolation when we know that the trend of the data is indeed linear or the interval between the two points is quite narrow. 62 Chapter 5 * Curve Fitting In Mathcad, linear interpolation can be done easily using linterp function. When we use /interp function for a set of data, in fact we create linear functions, each of which connects two data points. Thus, if we have 7 data points, we generate 7-/ linear functions. This function supports units. Procedure 5.1 shows the use of this function. 5.1.2 Cubic Spline If the trend of data is not linear and we want accurate estimates, cubic spline is often the best interpolation approach. In this approach, we create a third-order polynomial (cubic equation) for each interval between two adjacent data points. The cubic equation for interval i be- tween two adjacent data points, i.e., (x-, ye2) and (x y2), is as follows: SC) where f(x) represents the second derivative of the function at x= x and runs from 1 to N, which is the total number of intervals (V2 2) Unlike linear interpolation where the curve drawn over the whole range of independent variable is not smooth (the slope of the in~ terpolating curves at the data points changes abruptly), the fitting curve generated using cubic spline is smooth. The first and second derivatives of the functions are thus continuous at the data points. Cubic spline can be done in Mathcad using Jspline, pspline, or cspline function to obtain the second derivatives at the data points, which are required in generating the fitting curve, as indicated in Equa- tion (5.1). The Aspline, pspline, and espline functions differ in how the second derivatives at the end points, i.e., /(x0) and F(x), are specified, The Jspline function specifies that the second derivatives at the end points are zero, the pspline function specifies that the second derivatives at the end points are equal to those of their immediate neighbors, i.e., Fx) = Fx) and Flax) = FU), while cspline function specifies that the second derivative at 20 is extrapolated linearly from [xi, f(x)] and [2z, F(2)] and that at xvis extrapolated linearly from [xv-1, FLaw-)] and [xw2, F(xw)). In the case when N = 2, cspline function specifies that the second derivative at xvis zero and that at xois extrapolated linearly from Chapter 5 + Curve Fitting 63 (x, £Ux)] and Le, Fl2)]. After obtaining these derivatives, we use interp function to generate the fitting curve. These cubic spline functions and interp also support units. Procedure 5.2 describes the use of these func- tions. ‘These cubic spline functions and /nterp function can also be used to perform two-dimensional interpolation. The functions require that the data of the dependent variable be presented as a square matrix. In other words, the number of points of the first independent variable must be the same as that of the second independent variable. Procedure 5.3 demonstrates the applications of these functions for two-dimensional interpolation. Procedure 8.1: itera For example, we have the following se of data consisting ofan independent valable x and a ‘ependentvatiable y x 15 30 40 55 y 52 78 92 HA 0 and 50. 1. Construct two vectors forthe independent and dependent variables: We want to calculate the values of y at 1s) ‘The elements in the vector of ww w the independent variable must be in 4 92 ascending order ss} nt 2, Plt these data to see if near interpotation isa sultable approach 8. Create a function to represent the interpolating functions (titing curve) for all intervals by sing linterp function: YC) = Linteap(vs vy 9) [Although we can directly use lnterp function o calculate y at any x witout creating a ‘unction itis a good practice to create such a function, 4, Caleuate the y values: For extrapolation i. xis ouside tho data rango, tee ‘one ofthe two funtions of the end intervals wl be StX=2 312) 6.067 sod eopening on which sie of the data range atx=5: (5) 10457 the esrapoiaton is performed 5. We coud ais pot the fiting curve 1 Each intervals represented by a linear io |unction connecting the two end points of y the interval {325 35 45 35 64 Chapter 5 + Curve Fitting Procedure 5.2: Ispline/pspline/espline & interp (One dimensional interpolation) For example, we have the following set of data consisting of an independent variable x and ‘dependent variable y and we want to calculate the values of y at x= 5.0 and 10.0: x 20 30 40 65 70 90 110 y 52 79 98 110 118 127 145 4. Constuct two veotorsforx andy: (20 (52) 30 9 Note: The elements in the vector 2 ofthe independent variable must | 0 95 be in ascending order ves] 55 wis] 110 70 us 90 127 (uo) (4s, 2, Caleulatd the second derivatives needed using lsoina/psplinelespline function: ys :cexpline(vx.vy) The syntax fr Ispline or pspline is the same, 3. Creale a function te-represent the Miting curve using inlerp function: (3) = imerp(v8 v5, ¥9 9) 4. Calculate the yvalues: (5) =1059 (10) = 13.416 65, tis aiways a good idea to plat the fiting curve: , Inthis case, each interval is represented by a cubic equation connecting the two ond points u of the interval xy bo uf a Extrapoation tox valves beyond the data range 1 isnot recommended. If we extrapolate, one of 7 the two functions of the end intervals will be é Used depending on which side of he data range J 11 the extrapolation is performed. Procedure 5.3: Is ine/espline & inter (Two dimensional interpolation For example, wo have the folowing set of z data thal depend on two independent variables x Andy and we want to caiuite the value of z atx = 25 and y = 7.0: xy. 52 79 35 140 20. Tir 2.205 Tare Bie, —r TBI26 73.163. 130 44.092 4012930 13.957 14472_—*14 808 55 43.965, 15.002 15507 15902 +1. Construct two veotors for x and y: 20 (2) Note:The elements inthevectos of v=]? wx) 2 | the independent variables must be 40 9s inascending order (ss) 9) 2. Construct a matix augmenting these two vectors: xy i augment(vs,¥¥) 6. Cansit a matrix contaning he xd: tars 12209 12714 139) 136 116 185 405 ran aor a2 1966150218507 1898 Ma:= 4. Calculate the second derivatives needed using spline function: ys =cspline(May.Mz) The frstargument isthe matrix containing the independent variables and the second is the mari. containing the dependent variables. Chapter 5 + Curve Fitting ‘5, Create a function to represent the iting curve using inferp function 9) sate *] 6. Calculate the zvalue: 425,719) Example set 5.1 1. The mean molar heat capacity of nitrogen between 298 K and T al 1 alm has been tabulated as folow: TK) 8730 4730 573.0 673.0 7730 8730 9730 cp Wimolk] 29.19 2929 29.48 2968 2997 9027 9056 Determine the mean molar heat capacity of ritrogen between 208 K and a. 450K 525K © 740K Solution: x3) 29.9 a 2929 73 29.6 | ors 29.68 969 = inter(T.¢.9) - ™ nos1 sn 3027 (vn 3056, 8. (439 =29267 Jmol) b. y(s25)=29.378 dllmol K) © y(749 =29.874 emo! K) a {as SO TEATS 973 Tx 2. The vapor pressure (P) of water and the specific volume (v) of saturated water vapor are tabulated in a steam table 11°C] oor 30 60 30 120 150 180 Pika) ets 07577 0.9349 1.1477 1.4022 1.7051 2.0640 Vim] 206.196 168.192 197.734 119986 90.784 77.926 65.038 Determine the vapor pressure of water and thespecific volume (v) of saturated water vapor at 40 b. 1080 014°C Using cub spine Souion: (en) o6u13 206.136) 3 | 02877 18132 ‘ oss worm] 5 t=] 9 [rc Pix | 1.1477 |-kPa ves] 113386) R 14022 oaea | 1s 7081 71926 | (as | 2.0640, 65.038 66 Chapter 5 * Curve Fitting \sP = spine(,P) vv = coplne(t») PC) inerp(AP 47.9) yv() = inerp(sv L099 & yPI%C)=0.6sTRPa—B yPCLOSC = 1228kPa——G—_—yPCIAC) = 1 508KPa ; 3 3 yw °C) = 192.592 yv(10°E) = 106.379 yo(14°C) = 82.846 is rn is x= 0°¢,0.01°C. 20°C 207 2. wl 0. o Sos 0 18 20 sw 1520 {ITRSK 273.15. CTS K 235K 5.2 Regression In regression, an overall trend is characterized by specifying a function beforehand. If a theoretical model is not available, visual in spection of the data plot is usually helpful in determining a trial func- tion. If we can transform a non-linear model into a linear model, linear regression is often preferable. For example, consider a set of data, Cx and t, which will be characterized by the following model: I 1 CR Ro ket where Cro and k are constants. This model can be considered as a non- linear model if we plot Cx vs. t. However, we can transform this non- linear model into a linear model by defining a new dependent variable y, which is equal to 1/Cs. Thus, the model becomes: 1 y= kt} CRo which is obviously a linear model. After we obtain the parameters of the model, some criteria are then devised to quantify the adequacy of the fit. The most widely used criterion is the correlation coefficient (2) or the coefficient of determina- tion (r). For a set of data consisting of independent variable x and de- pendent variable y, which is modeled with y= f(x), the correlation coef- ficient and the coefficient of determination are given by Chapter 5 + Curve Fitting 67 6.2) (6.3) respectively, where S, = the sum of the squares around the mean of the dependent variable y (the spread of the dependent variable that exists prior to regression) =D S, = the sum of the squares of the residuals around the fitting curve (the spread that remains after regression) - Db, -se)F y= the mean of the data yi= the individual data of the dependent variable a0 = the individual data of the independent variable If a model fits the data perfectly, S-= 0 and thus the correlation coefficient or the coefficient of determination is equal to unity. Al- though the correlation coefficient provides a measure of the degree of the adequacy of the fit, we have to be careful in interpreting its value. Just because ris close to 1 does not guarantee that the fit or the model is correct. 5.2.1 Linear Regression In Mathcad, linear regression can be done using several built-in functions, i.e., intercept and slope functions, Jine function, and regress function. Since regress function is a general function for polynomial re- gression, its procedure will be described in the next section. Procedures 5.4 and 5.5 show how to use intercept/slope and line functions, respec- tively. Slope and intercept functions support units, but not Zine function because the result from this function is a vector, the element of which cannot have different units. To measure the goodness-of-fit, we calculate the correlation coefficient using corr function, which corresponds to Equation (5.2). The corr function supports units. We show the use of corr function in Proce- dure 5.4. 68 Chapter 5 * Curve Fitting Procedure 5.4: intercept & slope For example, we have the folowingdata; x = 1.0«« 22 BS AS 50 y 18 45 72 84 97 ‘and we want io regress them using alinear model: y = ag +ayx 1. Create two vectors representing independent variable x and dependent variable y: 10) 18) 22 as} vex] 35] w= 67 43 sa) so) 102) 2, Plo the data to visually inspect if a linear model would do the job: ‘8 Caleulate the intercept (a) and the slope (a,) ofthe fiting curve using intoregpt and slope functions: vy) = 2.038 4g = interept(vs.vy) =-0.2 ay = slope 4. Create a function representing the model, ie, the fiting curve: Y(@) ay + ay-x_ Yl8) is @ scalar function and its argument (xis also a scalar 5, Plat this fitting curve on the data plot to visually check the mode! 4 Itis always a goad idea to visually check the goodness-of-fit of the model oo" Note: vis a vector and xis @ scalar. x — ak ecard yy 9(e) 0998 ee ‘Thus, the dependent variable vy is well correlatediited by the mode! (x) Procedure 5.5: line Forthe example of Procedure 5.4, we can also use fine function to obtain the parameters {intercept and slope) ofthe fiting curve. Only number 3 of the abave procedure is changed: 9, Caleulate the siope (a,) and the intercept (ag) ofthe fiting curve using fine function: = linevs.vy) 02 ) [Note that fine function generate a vector containing the coefficients #=( 5 aay) intercept and stope) ofthe ne. a= 02 9 -2038, 5.2.2 Polynomial Regression For polynomial regression, we use regress function to obtain the parameters of the fitting curve and use /nterp function or write our own polynomial to generate the fitting curve. Of course, we can use these functions for linear regression; a linear function is a first order poly- Chapter 5 * Curve Fitting 69 nomial. The adequacy of the fit is then also measured using the correla- tion coefficient x As we can expect, regress function does not support units. Procedure 5.6 describes the use of these functions. Procedure 56: roaress & intern For example, wehave the folowing data: x 4.02.03 4085.0 y 42 47 120 165 247 and we want to regress them using 2nd order polynomial 1. Create two vectors representing independent ay taprt aye (10 2 variable x and dependent variable ze 7 20 47 2. Plot the data to visually inspect if the 4 . ‘model would do the ob, The plot is won] 95) wyse) 120 ‘combined in step 5. 40 los 50, 242) 8. Caloulate the parameters (ay, a,, and a) ofthe fiting curve using regress function: ‘The order of polynomial: vos regress (vey, 8) eam: ' indices of arrays, not labels (literal subscripts). This ‘way, we can simpy the assignments, 4. Create a function representing the model, Le, the fiting curve, using intorp function I= lleomwrd | ROARK x or erate our own polynesiat: yi) = 3° (ay) kth order polynomial poly vod (,, oly ino 5. Calculate the coreation eneticient and pot the fting curv on the data pot to visually cheek the mode! 29 bom) 4 rs conlvy. sox) = 0999 So! 2019 J O a 6 These functions can also be used to perform multivariate regression, as demonstrated in Procedure 5.7. Procedure 5.7: regress & intorp(Multivariate rearession) Suppose that zis a function of x and y, and the following experimental data are obtained! x] es [ata 5 6 [85 [8 [47 a {os [7 fe [10s | 15] 403 z [790 | 645 | 7e.08 [33.08 [4520 | 25.60 | 71.05 3250 ‘We want to regress the data using a second order polynomial with 2 independent variables: x ¥ (cgy!) andeatoulatez atx = 7.5 andy =42 ioj=0 70 Chapter 5 * Curve Fitting 1. Create 8 vectors containing the values of x,y, and 3 7.90) 5 sas 7 1809 ° 33.43 u | 4520 5 os 25.60 |s Is 710s lag, 103 32.50) 2, Create a mati by augmenting vectors containing independent variables (2345 6 25 8 47) (357911 sis i) 3. Use regress function to obtain the parameters ofthe fiting surface: May = augment(vx, yy) May" vss repress(May.v2.2) ws" = (3-3-2 0.202 -0.125 3.958 0.713 ~5.094 0.961) 4, Create a function representing the fiting surface by using inforp function and calculate 2: ‘) tit cn en This surface plot can be created from the Graph Toolbar. To plot the data points, type vectors vx, vy, and vz (in parenthesis) in the emply piace hhoider-To plot the fiting surface, ype @ ‘comma followed by the funetion name, The ranges of x and y, in which the fiting surlace zis created, have been modified (double click the igure, choose Quick Piot tab, and change the start (amnva.e and end values). 5.2.3 Non-Linear Regression Mathcad provides several built-in functions for several non- linear models, such as exponential or logarithmic function. Here, we will discuss only genfit function, which is a general function for any non- linear model. Since the result from genfit function is a vector containing the model parameters that might have different units, this function does not completely support units. Procedure 5.8 shows the use of this func- tion. Similar to find function for solving a system of nonlinear equa- tions, genfit function is also highly sensitive to initial guesses. If genfit function does not converge, one may try to change the numerical me- thod used by right clicking on the genfit function and choosing the de- sired method, to change the initial guesses, or to scale the data so that all model parameters are of similar order of magnitude, Plotting the fitting function with the guess values could also help us in refining the guess values. Chapter 5 + Curve Fitting 71 Procedure 5.8: genfit For example, wo have te following deta: x 41 12 14 15 468 18 20 at y 34 27 18 47 14 13 07 06 and we want to regress them using a non-linear model: ro 14 Be 1. Create two vectors representing (ay independent variable x and dependent 12 variable y j14 18 2. Create a vector containing th initial Is | uW ‘guesses of A and B and a function bal (ay representing the model fancton a u The fist element the J @ ( ) iat guess for A and 2h ai UJ the seconds tor 8. 21) Low, YOA.B) i Note that the parameters must be listed after th TBs 3. Calculate the parameters (A and B) ofthe fiting curve using gent function: oe §) at J pees vesn (32) 4 Calculate the correation coetticient and plot the fiting curve on the data plot to visually check: the moda 5 a ream goa ae) 10991 4 Ts Rs Example set 5.2 1. Flowmeter calibration data are a olows: Roading, x 5 © mm Flowrate Ftiterstou} 902 5008 1050.5 1859.2 20197 Whatisthe tow rate ihe onmoter reading is 682 Solution: 5 130.2 20 5003 Create vectors containing the given date: x=] 40|—pe-| uns *0 1632 (30 2ois7 Plot the datato 20 the relationship between X and F: F pa near uncon of X ma gine) ay slpetXF) 2a0) 000 YO) a9 + ays x (53) = 1313.844——ersmour R Chapter 5 * Curve Fitting Pot the fiting curve to visually chack the goodness-oF ft a0 emo doo | 22 ae o 020 40 ow) 100 xx ® a Experimental density (,) data as a function of pressure (P) for Np at 200 K (T) are as follow: P fat) 32 60 90 120 140 170 190 21.0 plmolfiter| 0.1995 0.3825 0.5895 0.8108 0.9685 1.2257 1.4159 1.6281 Using these data, estimate the second, third, and fourth vial coeticients “The virial equation of state that relates pressure and density is = ie ppscp? sp? — R =gasconstant= 0.08208 Hera pe snot K \shere B,C, and D are the second, third, and fourth viral coefficients, respectively. Solution: ‘The vial equation of state is transformed into: Bs Cp+Dp2 second order polynomial — R=008206 T= 200 (0.1998 (32) 0.3825 60 0.5895 90 osios 120 P ° Ps Zor x 0.9685 le PRT P tay 70] Note that veetorization is used to calculate element 14159) 19.0| — byelement in a quick way. Least) (210) Calculate the coefficients: y regress (p.¥.1) D=a,= 20x 104 Plot the data and the fiting curve to check the goodness. it yO = interp(¥,0.Y 9) [7 _ The corretation coetticient: a = recon ¥.7p) = doo yOu -00 qed > os ts Chapter 5 = Curve Fitting B 2. A slab of wood 50.8 10° m thick (2h) is dried from both sides by alr. Te following data are oblained from the experiment: Time, [hours] 5 1 1% 2 2 30 Wood free moisture, XCIkg H,Ohg ary wood) 0.245 0.230 0.211 0.197 0.187 0.176 “The troe moisture in wood as a function of time can be approximated by Where % is the inital tree moisture of the wood [kg H,01kg dry wood), his hal of the wood thickness [m], and D is the itussiviy of water in the wood [mm2/hour}. Estimate the difussivity of water in the wood. Solution: 25.4107 ‘Two parameters, Le, % and D, are to be ite. 5 028s 0 0.230 (2) ef Is oan 2a) we HtXp.D) =X : 20 ous] Mh%o-?}=%0 25 puis? 1% 0.299 { gent v4,VXG.0) lo 2.879% 10 one iB) += 0998 ‘The diftusivty of water in the wood p= 28794 10° mehr 1. Accurate data on the liquid molar volume (Vi) of nitrogen at melting points are as follows: 80.0 30.731 TK 64.0 68.0 72.0 76.0 Vi [ec/mol] | 32.225 31.912 31.527 31.124 Estimate the liquid molar volume of nitrogen at a melting point of 70 K 2. The mean activity coefficients (y) of aqueous solutions of NaxSO+ have been tabulated as follows: 74 Chapter 5 + Curve Fitting my] o1 | 03 | 05 | 07 [ 09 T 14 10.4483 | 0.3230 [0.2692 | 0.2360 | 0.2128 [0.2036 | 0.1769 m [is | 22 | 26 3 34 1 38 Loto [0.1498 [ 0.1431 | 0.1394 | 0.1380 | 0.1386 “What are the activity coefficients of aqueous solutions of Na:SOs for molality (m) of 0.2 and 1.2? Also determine the molality of the solu- tion that has an activity coefficient of 0.4. Use cubic spline. we The enthalpy of superheated steam at a certain condition needs to be accurately determined, From the steam table, the following enthalpy [H, ki/kg] data are available: P[kPa\T{K] | 300 350 400 450 500__| 150 3073.3, 3174.7 3277.5, 3381.7 3487.6 200 3072.1 3173.8 3276.7 3381.1 3487.0 250 3070.9 3172.8 3275.9 3380.4 3486.5 300 | 3069.7 3171.9 3275.2 3379.8 3486.0 Determine the enthalpy of superheated steam at 420 K and 190 kPa. 4, Experimental data of reaction constant (A) for a first order reaction as a function of temperature (7) are as follows: TIK] 303.0 310.0 314.0 319.0 325.0 kis] 0.0053 | 0.0113 | 0.0190 | 0.0365 | 0.0727 ‘The temperature dependence of the reaction constant could be corre- lated by the Arrhenius equation: : k=de™ where A is the frequency factor, R is the gas constant (-8.314 JimoL.K), and £ is the activation energy. Determine the activation energy for this reaction. What is the reaction constant at 305 K? 5, A reactive substance R reacts according to the following reaction: R= products The following data are obtained from experiment: Time, t [sec] o {2 ]5 | 8 | 10| 20 Concentration of R, Cr [mol/liter] 15] 10| 0.7 | 0.6} 05 | 03 We would like to analyze the experimental data and suggest what the order of reaction is. Then, we also want to determine the reaction constant k. Chapter 5 + Curve Fitting 6 For a zeroth order reaction, the following relation must be satisfied: Cag —Cy = ht where Cro is the initial concentration of R (Ck at ¢= 0) and k is the reaction constant. For a first order reaction, the following relation must be satisfied: In(Cyo)—In(Cy ) = At For a second order reaction, the following relation must be satisfied: 1 1 vine aly Ce Cro Suggest the most probable order of reaction for this reaction (explain the reason) and then determine the reaction constant. What is the unit of k for this order of reaction? Estimate the concentration of the reactant after 30 seconds. 6. Experimental data of relative vapor pressure of glycerol-water mix- tures at 20°C are as follows: Weight faction of glycerol 0.000] 0200] 0250] 0350] 0356 0.479] ooo] Relative vapor pressure 1000] 0942} 0923} oss7] osss as2s| 0.814} [Weight fiaction of glycerol 0.600] 0.648] 0750] 078] 0830 0920] 1.009] Relative vapor pressure 0.737[ 0695] o5s7] 0535] 0.446 0.275| 0.000] Perform a polynomial regression to obtain a model for relative vapor pressure as a function of weight fraction of glycerol. Then, estimate the relative vapor pressure for a mixture containing 10 weight% gly- cerol. Note: You need to investigate the order of polynomial that best fits the data. 7. Experimental vapor pressure (Pu:) data as a function of temperature (0 for chloroform are as follows: [tro of wf w]e] aT sof oT Pa {mmHg} 615 101.0 159.3 | 242.6 | 357.9 | 513.6 | 718.7 | 983.2 tp} 80. 90. 100 Ho 120 130 140 150 Pat [mmHg] | 1317.7 | 1733.9 | 2243.7 | 2859.2 | 3593.0 | 4457.9 | s4o6.4 | 6631.0 a. Using the experimental data above, determine the parameters of An- toine equation for chloroform. Antoine equation relates vapor pres- sure to temperature. 76 Chapter 5 + Curve Fitting B ‘Antoine equation: P,, = exp, A-——> ia = i t+ <] where A, B, and Care the Antoine parameters. b. Using the parameters obtained in part (a) and Antoine equation, estimate the vapor pressure of chloroform at 56°C 8. In the design of an absorption column (packed column), the mole frac- tions of solute at the gas-liquid interface (x,y!) at several points in the column must be determined. xis the mole fraction of solute at the in- terface on the liquid side and ysis the mole fraction of solute at the interface on the gas side. From the concept of mass transfer, it is known that: EE gy yn Ene Tae from which x/and y;-will be calculated. In the above equation, &y’is the gas-film mass transfer coefficient, As'is the liquid-film mass trans- fer coefficient, a is the interfacial area per unit volume of packing, y ka and xare the mole fractions of solute in the bulk gas and liquid phas- es, respectively, at any point in the column, and the terms in the de- nominator are the log-mean averages given by the following expres- (ry HEP) ay = _(i-x)-(=x) wf?) Hf ‘Atacertain condition, y and xare related to each other through an operating curve, which is derived from material balance: Box (_% 2 ox x U we # g| te = _*a Vi-x \I-y, V'il-x, where L’is the molar flow rate of solute-free liquid (= 2800 Ibmol/hr), Vis the molar flow rate of solute-free gas (~ 900 Ibmol/hr), and ys (= 0.4) and x (= 0.16) are the mole fractions of solute in the bulk gas and liquid phases at the bottom of the column, respectively. Since the mass transfer resistance at the interface can usually be neglected, ys and x-are related to each other through an equilibrium curve (equili- brium relationship): Vi= Sog(%) Chapter 5 + Curve Fitting 7 For this system and the given conditions, the following equilibrium data are available: x | 0 | 0.0126 | 0.0167 | 0.0208 | 0.0258 | 0.0309 | 0.0405 y | 0 | 0.0151 [0.0201 | 0.0254 | 0.0321 | 0.0390 | 0.0527 x: | 0.0503 | 0.0737 [ 0.096 | 0.137 | 0.175 | 0.210 y | 0.0671 | 0.105 | 0.145 | 0.235 | 0.342 | 0.463 a. From the given equilibrium data, use a curve fitting method to create the equilibrium function £(x). b. Determine the mole fractions of solute at the gas-liquid interface (x,y) at several points in the column where the mole fractions of solute in the bulk liquid phase are x = 0, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, and 0.16 Data: ya = 30 Ibmol/(hr-ft®) and kx a= 250 Ibmol/(hr-ft) ). The activity coefficients of chloroform and 1,4 dioxane in a binary liquid mixture of chloroform (1)/1,4 dioxane (2) at 50°C can be esti- mated from Margules equations: ty sexphss (dy + 2d 4.2)5 )} Ya = expt (dy +2(4y— An.) )p where 71 is the activity coefficient of chloroform, 2 is the activity coefficient of 1,4 dioxane, x, is the mol fraction of chloroform, 1 is the mol fraction of 1,4 dioxane (xe= 1 — xi), and Av and Az are the Margules parameters for this binary system. These two parameters are usually obtained from vapor-liquid equilibrium data. Determine the mol fraction of chloroform in the mixture such that y1 = From vapor-liquid equilibrium experiment, the following data are ob- tained: xy | 0.0932 | 0.1248 | 0.1757 | 0.2000 | 0.2626 GURT | -0.064 | -0.086 | 0.120 | -0.133 | -0.171 x, _| 03615 | 0.4750 | 0.5555 | 0.6718 GRT | -0.212 | -0.248 | ~0.252 | ~0.245 where G'/RTis the dimensionless excess Gibbs free energy. To obtain Aizand Az, the following relation can be applied: oF Rie ti 4 Pei Chapter 6 * Differentiation and Integration 79 apter 6 ferentiation and Integration Th chemical engineering, differentiation and integration are of- ten performed, If the function is known, we may try to differentiate or integrate symbolically using the derivative or integral operator with the symbolic equal sign. If the function is too complicated, we could use the derivative or integral operator and obtain the derivatives or integrals numerically. These operators can be accessed from the Calculus Toolbar in the Math Toolbar. In some cases, we need to find the derivatives or integrals from a set of data. In this case, we have to find the function(s) that can well represent the data, This can be done by using a method described in Chapter 5. We use regression when the error of the experimental data is big. When the data are smooth, we could use either regression or inter- polation; interpolation is usually the easiest approach when we do not know the type of the function. Differentiation Procedure 6.1 shows the symbolic (analytical) differentiation of known function, Procedure 6.2 shows the numerical differentiation of known function using a derivative operator, and Procedure 6,3 shows the differentiation from a set of data. Procedure 6.1; Symbolic Differentiation For example we noodt calulate ho ist derivate ofthe folowing tunction atx = 0.1 9 = 4344+ nog + 3YKegl224) 1. Use the derivative operator from the Calculus Toolbox and the symbolic equal sign and ‘assign the result toa function, for example fx): 0) fay) >3xl + 34 cos(a)# Set 4 Ie * ‘Note: The prime (') symbol is typed using (CullF 7). 2. To caloulate the derivative of fx) at x = 0.1 140.1) = 9.281 Procedure 6.2: Numerical Differentiation For example we need to calle the second deivalve wih respect tox othe folowing Rectonabe=0 tangy 202 lox?) Ey ext {y= Panes gs) sy —_ Sys 3+ sing fay 80 Chapter 6 + Differentiation and Integration 1. Use the derivative operator from the Calculus Toolbox and dliecly assign to a new function’ Fete) Note: The default derivative operator can be changed to partial carivative operator by right licking the mouse on the derivative operator and clicking View Derivative As Partial Dorivative 2. Calculate the derivative at x=0.1 andy 2 using the above function: (01,02) =-49.781 Procedure 6.3: Differentiation of Data For example we need to determine the frst derivative of y al x= 4.8 using the following data: 1 (25 us si wlsa] iss Fe 0 aa} 07 1. Ploty vs, x to observe the smoothness of the data. From the plot below, we know th data are smooth, Thus, we could use cubic spline interpolation to ft the data vs espline(ay) y1Gx1) = imterp(vs, xy, x1) 2. Plot the fiting curve to check the on 1 interpolation 8, Calculate the derivative at x1 = 4.8 yrexp =Lytixn at yA = 16.051 ji ¢ ea ee Example set 6.1 1. Ina transient mass transfer of CO, through a membrane, the concentration (C in kkgmolim®) profile of CO, ate certain time t aeross the membrane wall can be represented by the folewing equation: oy = 13:10 x! + 7.1108? ~ 14.08" — 0364x+ 0.001 0.001 x 0.001 ‘where xis the distance in m trom the center of the membrane wall. ‘The ditlusivty of CO, through the membcane is 3.26 10° m/s and ean be assumed ‘constant Is the amount of CO, in the membrane accumulating or depleting? ‘Attime , the aocumulation of CO , takes place ifthe input mass transfer thx is larger than the output flux: Neg {at X= -0.009 Noga at x= 0.009 >0 and the depletion of CO; takes place if the input flux is less than the output flux: Nog (at X= -0.009 -Nogs (at x= 0.009-<0 “The mass transfer flux (Ngog in Kamal/(s.m®)) atx m trom the center of the membrane isgivenby p sce ax Neos Chapter 6 « Differentiation and Integration 81 ‘Solaion: Deg2=32610 © mes isis! y tiga’ ~ 140% 0364+ 0.001 ay Lao a Noort Porc ree Neoxt-0.000 = 1.009% 10° © kamalim?.s) rae} \ Neox0.00! 22510 * kgmollin?.s) o ito Nox. - Nogyl0.0n =-2165% 10° KgmoWim.s) depletion 2, Data or eaton of CCD, sty n weer at 206 K ata constant pressure ( ap) of bar tise] 44 95 163 246 S47 a1 S80 “786 A94 1073 V iter) 0.498 1.000 1.501 2000 2498 3.002 3.608 4.004 4.502 5.000 “The fiter area of the piale-and-tramo press (A) is 400 on and the slurry concentration (c,) is 20.0 gllter. Estimate the specific cake resistance ( a) in mkg and the resistance ofthe fiter ‘medium to fitrate flow (R,) in mt, At 298 K, the viscosity of water is 8.937 104 Pas, ‘The equations for constant-pressure titration are as follows: A2cap) MEAP) sronpresomnyerto a Solutic { 44 ) 0.498) sl “sn x= Oiter, 0.0 iter...6 Titer tinear function of V. cs t 38 grow ue ay= 46x WF 9) =6512% 10> a wm wWox so) ay taps rscorkii aco) = a9 Hee 82 Chapter 6 « Differentiation and Integration 4p, : aii 93610 “Pos minusAp = 3-bar a As=400en? , 0 4 liter fv) 209, aoe agyAcminasap " fag R= OE rast 10! 2 # im vo! ay A minusap 8 @ as 1.695% 19! ° 40? Bs ie 6.2 Integration Procedure 6.4 shows the symbolic (analytical) integration of known function, Procedure 6.5 shows the numerical integration of known function using an integral operator, and Procedure 6.6 shows the integration from a set of data. Procedur ‘Symbolic Integration For example we need to calculate the intogral ofthe folowing function trom A) = 3xew29 1. Use the integral operator from the Caloulus Toolbox and the symbalic equal sign and assign the result to a function, for example int(a,b): 2. To calculate the integral of (x) Irom 041 100.5: 1 10.0.5, we can just use the function above: 1nW(0.1,0.5) = 0.733 Procedure 6.5: Numerical integration For example we need to calculate the integral of the following function from x = 0.1 100.6 and y, =02 1004 : 3) Bay 3x sing + 3p ena? Fay) = Sn Sey z (y « 2eanca)ns xy 1. Use the integral operator rom the Caleulis Toobox and dirty assign to now futon [Pena 2. Caloulate tne integral from Inw(a,b, 6.4) 11005 and, |nn(0.1,05,02,04) = -0391 Procedure 6.6: Integration of Data For example wo need to determine the integral oy from 20004: 0 4 using the following data: (1) 25) } 18] 81 2s | 100 S32) 7" ass | 4a 330 (sa (so) Chapter 6 Differentiation and Integration 83 1. Ploty vs. x1o observe the smoothness of the data. From the plot below, we know that the dia are not smaotn. Thus, we could use polynomial regression to fi the data, ket vere y.0) VOD =iteiv.xy.a)—rsconly.gi08) += 0996 2. Plot thofiting curve o chee the “ oodness ot visually 4 4 3. Calculate the integral: aleulate the integ be. > vig, 21M aa Ini(a,b) = | y10x dst In@2,4) = 38.272 nal Example set 6.2 1. The vetoety protie of an incompressible laminar low through a circular pipe of radius His ‘given ay: wt | (JI 1 the distance rom the center of the pipe nas! UK Determine he velocity atthe certer (pq, of this fow ifthe diameter ofthe pipe i 2in an the average velocity (v.11 cmvsec. Then plot the velocity profile inthe pipe (asa function of, ‘The velosiy atthe Cente is related tothe average velocity by the following equation VayerR? Solon: R=2in — Vyyg= ae F=0in,00hin, 210 Velocity (emisee) Distance from the center (in) 2. The heat capacty (of a gas is tabulated as a uncon ol temperature (t t°0) 2 50 80 110 140 170 200 290 Cp WimoeC) 2895 2913 250 2048 2965 29.82 29.99 20.16 Caleulate the enthalpy change (3H) for § mol (n) ofthis gas going trom 60 (,) to 180°C () The enthahy change Is caleulated trom: ati 84 Chapter 6 * Differentiation and Integration Rebien, 20 (28.95 | 10 2948 | 140, 20.65 | 170 29.82 (220, 30.16) 0: > yt) Hite. G.3) aitscm | ih oy 100 200 300 y t ‘AH = 1772 J Problems 1. A theoretical equation of state for hard-chain fluids, which is derived from thermodynamic perturbation theory, is given in term of the re- sidual Helmholtz energy a = mF yin moa (=n) (=n) where m is the number of segments in a chain and 77 is the reduced density given by ay 3 = MZN po In the equation above, Na is the Avogadro number, p is the molar density, and is the hard-sphere segment diameter. The compressibility factor Z(= Pw/R7) of any fluids can be calculated from the residual Helmholtz energy using the following equation: Z=l+n én a. Plot the compressibility factor as a function of the reduced density, say from 0 to 0.4, for a hard-chain fluid consisting 5 segments per chain. b. What is the compressibility factor of this fluid at p = 0.003 mol/cm®? Each segment has a diameter of 35 A 2. A mixture of 200 mol containing 60 mol% n-pentane and 40 mol% n- heptane is distilled in a tank under differential conditions at 1 bar un- til 120 mol has been distilled. What is the composition of the liquid Chapter 6 Differentiation and Integration 85 w left in the tank? The equilibrium data are as follows: x_| 1.000 | 0.867 [0.594 | 0.398 | 0.254] 0.145 [0.059 | 0.000 1.000 | 0.984 | 0.925 [| 0.836] 0.701 [0.521 | 0.271 [0.000 where xand yare mol fractions of n-pentane in the liquid and vapor phases, respectively, The following equation is derived from a material balance for simple differential distillation: where Zois the number of moles of liquid originally charged, Zr is the number of moles of liquid left in the tank, 0 is the initial mole frac- tion of n-pentane, and x7 is the final mole fraction of n-pentane. . Calculate the vapor pressure of carbon dioxide at 283 K using Peng- Robinson equation of state described in Example 1 of Example set 3.1. Graphically, vapor pressure is a pressure at which area I, shown in the Pressure-Volume (PV) plot below, is exactly equal to area II. Poe is the pressure calculated from Peng-Robinson equation of state Ppp( Volume} 400 Mathematically, vapor pressure is a pressure (P) at which the follow- ing equation is satisfied: PU, -V,)= [PrpaV # 86 Chapter 6 + Differentiation and Integration where Vis the molar volume and the subscripts Gand Z denote the gas and liquid phases, respectively. Hint. Since calculating molar volumes of gas and liquid requires pres- sure, you need to create functions to describe the molar volumes of gas and liquid phases (as functions of pressure). 4, In an experiment, the following data were obtained for a gas phase reaction: ¢(min) 0.0 25 5.0 10.0 | 15.0 _| 20.0 P(mmHg) | 7.8 10.5 12.7 15.8 17.9 19.4 This reaction can be modeled by using the following equation: # -1Gn,- Py dt where ris time, Pis the total pressure, Po is the initial pressure, & is the reaction constant and qis the order of reaction. From the data ob- tained, determine the reaction constant and the order of reaction. What is the unit of 4? 5, A packed countercurrent cooling tower operating at 1 atm (P) will be designed to cool the existing process water. The flow rate and tem- peratures of the entering and leaving water have been dictated by the process requirement. If the dry air flow rate (6) is designed to be 1.356 k/(s.m’), calculate the height of the tower (2). At the condition of interest, the following data are known: 1. The volumetric mass-transfer coefficient in the gas phase (kc) is 1.207107 kgmol/(s.m3.Pa) 2. The enthalpy of the entering air (/fi) is 71.710" J/kg 3. The enthalpy of the leaving air (#72), which is obtained from the heat balance, is 129.9x10° J/kg 4, The enthalpy of air at the gas interface (Ff) as a function of the en- thalpy of air (#) is tabulated as follows: H( Weg) | 71.7 | 835 | 94.9 | 1065 [ 118.4 | 129.9 H4(10° J/kg] | 94.4 | 108.4 | 124.4 | 141.8 | 162.1 | 1847 The height of the tower can be calculated from: G1 ——_— ja MoyPke Hi -H where M,,,is the molecular weight of air [= 29.0 kg/kgmol]. Chapter 6 + Differentiation and Integration 87 6. Ina material fabrication process, an oxidized-nickel cylinder 3 cm in diameter and 10 cm in length is cooled in a vacuum chamber, the wall temperature of which is kept constant at 300 K (7s). The initial tem- perature of this cylinder is 1000 K (7) and the target final tempera- ture is 600 K (7). Estimate the time needed for the cooling process. The properties of nickel at the average temperature of the process are density (p) = 8900 kg/m®, specific heat () = 530 J/(kg:K), and emissiv- ity (2) = 0.49. For this condition, the time needed can be calculated from: _ pve, ie aT sod 3T'-T? where cis the Boltzmann constant [= 5.67x10* W/mK*)], Vis the volume of the cylinder, and A is the surface area of the cylinder. 7. Ina certain application involving parallel airflow over a flat plate of length 2 m (Z), the spatial variation of temperatures measured in the boundary layer is accurately correlated by the following expression: T= 204470 - so) rc] where xis the distance parallel to the plate measured from the leading edge [in m] and y'is the distance normal to the plate measured from the plate surface [in m]. a, Estimate the free stream air temperature (T:), ie., at large y, and the surface temperature (7:). b. What is the local heat flux at x= 1 m (assume thermal conductivi- ty k= 0.03 W/(m-K))? c. What is the average heat flux from this surface? The local heat flux is given by: The average heat flux is given by: Gm = HT, -T.) where A is the average convection heat transfer coefficient obtained from 88 Chapter 6 + Differentiation and Integration 1, h diya and h, L 0 T,-T. Hint: For this fast varying function, ic., T changes greatly with y, numerical derivative operator is not accurate. Thus, use symbolic dif- ferentiation, In the development of an artificial kidney that could be worn by the patient, a reaction that converts urea to ammonia and carbon dioxide by using enzyme urease needs to be studied. One set of experimental data using a certain amount of urease is as follows: G kmol/m? 0.2 0.02 | 0.01 | 0.005 | 0.002 Tiree, MOM/(m*-s) 1.08 0.55 0.38, 0.2 0.09 In the table above, Cis the concentration of urea and ~rirs is the rate of urea conversion. : The time needed to reduce the concentration of urea from Coto Cris given by: G aC t= (~ 6 Parca From reaction kinetics, it is known that the following model, re- ferred to as Michaelis-Menten equation, relates the rate of urea con- version to the concentration of urea: VAC Foes = ine CG where Vm and Xm are constants for a certain amount of urease. Estimate the time needed to reduce the concentration of urea from 0.5, to 0.2 kmol/m’ using the same amount of urease as that in the above experiment. What are the units of Vm and Kin? A gaseous stream consisting of 40 mol% ammonia (7 = 0.4) in an in- ext gas is scrubbed with water in a packed column. ‘The inert gas mo- lar flow rate (V) is 900 Ibmol/h. The diameter of the column is 4 ft. Under the operating conditions, the estimated value of the gas film mass transfer coefficient (4)’2) is assumed constant at 30 Ibmol/(h-ft). ‘The desired ammonia concentration in the outlet gas stream is 3.2 mol% (y2= 0.032). Chapter 6 « Differentiation and Integration 89 a, Determine the height of packed bed needed (z), which can be cal- culated from: ze" A ° “a b= ° _ll-y) with (= y),y = In| where Sis the cross sectional area of the column and yris the mol fraction of ammonia at the water-gas interface, which in turn de- pends on the mol fraction of ammonia in the bulk gas phase (y) as shown in the data listed below: ¥_| 0.032 | 0.080 | 0.125 | 0.166 | 0.206 | 0.243 v.| 0.004 | 0.029 | 0.056 | 0.084 0.115 | 0.148 y_| 0.278 | 0.311 | 0.342 | 0.372 | 0.400 y; | 0.183 | 0.221 | 0.261 | 0.304 | 0.349 b, Plot the height of packed bed as a function of the desired ammonia concentration in the outlet gas stream (0,032 < y2< 0.20) 10. In the design of a tray tower for absorption, for a certain solute-free liquid molar flow rate (Z), the operating curve of the absorption op- eration, which relates the solute mole fractions in the bulk gas and liquid phases, is given by: Li x, #3 =e x U-y, VI, y Lx, +— + So Vil-x \i-y, Mt-x, where y is the mole fraction of solute in the bulk gas phase, xis the mole fraction of solute in the bulk liquid phase, Z’is the molar flow rate of solute-free liquid, V’is the molar flow rate of solute-free gas (= 85 kmol/hr), and y; (= 0.01) and x: (= 0.002) are the mole fractions of solute in the bulk gas and liquid phases, respectively, at the top of the column. This operating curve is used in conjunction with the equilibrium curve. 90 Chapter 6 + Differentiation and Integration Equilibrium data for the system of interest are given below: x oO | 0033 | 0.072 | 0117 | 0.171 y 0 0.0396 | 0.0829 | 0.1127 | 0.136 a. From the given equilibrium data above, use a curve fitting me- thod to fit the data. Plot the data and the fitting curve (0 < x< 0.18). b. In the same graph, plot three operating curves for L’= 170, 150, and 130 kmol/hr. . In the design of an absorption tray tower, it is crucial to deter- mine the minimum solute-free liquid flow rate that can be used. Any operations using liquid flow rate close to this minimum liq- ° uid flow rate require many trays. When minimum liquid flow rate is used, the operating curve becomes tangent to the equili- brium curve (the fitting curve obtained in part a). In other words, the operating and equilibrium curves have a common tangent line at a point. Determine this minimum solute-free liquid flow rate. Hint: To solve this problem, use the criteria of tangency of two curves To check whether the calculated minimum solute-free liquid flow rate ig correct or not, plot the equilibrium curve along with the operating curve when the minimum liquid flow rate obtained from part ¢ is used. & Chapter 7 * Optimization 91 apter 7 timization The important task of chemical engineer is to design new, bet- ter, more efficient, more environmental-benign, and more economical process systems as well as to improve the operation of existing process systems. This important task calls for a deeper understanding of chemical engineering principles, which underlie all physical and chemical phe- nomena occurring in processes and operations, and optimization me- thods to determine the best possible solution. ‘There are several types of optimization problems we might en- counter in engineering, for example the extreme value problem, linear programming, and non-linear programming, which will be discussed in this chapter. . Extreme Value Problem An extreme value problem is an optimization, either minimiza- tion or maximization, of an objective function without any constraints or with constraints that can be solved using stationary point approach. Although Mathcad has very versatile functions for solving opti- mization problems, as shown later, we still discuss conventional ap- proaches using stationary point, These conventional approaches give us better understanding of the issues arose in optimization problems. 7.1.1. Unconstrained Function For optimization of a function without any constraints, the solu- tions are conventionally obtained by finding the stationary points, i., equalizing the first derivatives of the function with respect to the inde- pendent variables to zero and solving these equations, the procedure of which has been described in Chapters 3 and 4. In order to determine the types of stationary points, i.e., maxi- mum, minimum, or saddle point, we need to construct a matrix called Hessian matrix at the stationary point. For optimizing a function of 2 independent variables, the Hessian matrix is an xn matrix: H=[2,| the element of which is defined as follows 92 Chapter 7 + Optimization os Boao evaluated at the stationary point where x/and are the independent variables. Then, the type of the sta- tionary point is minimum if all of its eigenvalues are real and positive numbers (the Hessian matrix is positive definite) maximum if all of its eigenvalues are real and negative numbers (the Hessian matrix is negative definite) saddlepoint otherwise (the Hessian matrix is indefinite) The eigenvalues of a matrix can be calculated easily using ejgenvals func- tion, Procedure 7.1 shows this stationary point approach. As we can notice from Procedure 7.1, the solution of an extreme value problem using stationary point approach is quite tedious, In fact, Mathcad offers easy ways to solve optimization problems. We can use minimize function to find a minimum stationary point and maximize function to find a maximum stationary point. However, we cannot di- rectly find saddle stationary point. Procedure 7.2 shows how to use these two functions. Minizuize/ maximize function supports unit. If the inde- pendent variables have different types of unit, the solution must be as- signed to a column matrix, If minimize or maximize function gives an error message: "Could not find a maximum/minimum', there are two possibilities: the initial guesses are not good, thus need to be changed, or the function does not have a maximum ora minimum. Procedure 7.1: Stati int method for an unconstrained function ‘Suppose we want to determine the values of the following function atthe stationary points > tiaynle sya) ales 1.Whenever possible, plot the function to get he dea o the solutions Chapter 7 + Optimization 93 Surface anc contour plots can be accessed trom the Graph Toolbar. The function ‘name we want to pot is typed in the empty place holder. The contour plot helps us to determine initial guesses, 2. Deline functions for calculating al ofthe second derivatives needed inthe Hessian matrix: 2 2 é - aa a Ao feay gyon=2Leay — hyoo =r flan Fyne fy sity wy 3. Construct the Hessian matrix fg) spe (ye) ys? 4. Create a function for calculating the eigenvalues ofthe Hessian mati 45) = igeoals Hop.) Hoy) ‘5. Create a function to find stationary points using Given block and find function: Given the functions very complex, find function may not work. In this case uy to replace the find function with minerr function, which wil ry to find the closest solu. Minerr function has the same arguments as find function Layeo Laay=0 « & sty) = Find(xy) Note thatthe arguments x and y on the lft side are in fact the intial guesses, which are stil left open. We want to use different intial guesses to obtain diferent roots. 6. Determine the stationary poinis, type of each stationary point, and the values of the function: 3 (zee penay-(2 an (Se rin sus paa0.9 esse v90.0-( Son) wa-(2%) a -(9 ‘nn iil 1.848, a \ 28.691 (31.707) sas 85508 ( 45.488) any-(“8°) ayn) =tmnsi7 ax ( a(n) bo) / 4nd ais , ( a1-(2%) — aoun)2 ve aes 3.5 7 je some ound resin) a-(oes) wn) »-(22) fans, in pasts oe) =Lsana) Aor Procedure 7.2: minimize/maximize for an unconstrained function ‘Suppose we want to determine the values of the following function at the stationary points: riayyalery—i +lery?—a) 4. Whenever possible, plot the function to get the ideas ofthe solutions. 2. Create functions for catculating minimum and maximum stationary point using minimize and ‘maximize functions: x/and yi are the needed inal guesses, which are conveniently used as parameters. sonin(xi yi = Minimiz Fx sant yi) == Maximizéfxi yi) 94 Chapter 7 + Optimization 3, Caleulate the stationary points and the values ofthe function, for example: (me *) 2) ) Coa we would not change the intial guesses, we may not need to create the function in step 2, as shown below: (3 4 ) foxy) 204% 10 \2) tata gueses: aica git (*):-atninatexisn=(3) 7.1.2. Constrained Function For optimization of a function subject to equality constraints, the solutions are conventionally obtained using the method of Lagrange Multipliers. Consider the minimization of a function of 2 variables, re- ferred to as the objective function, subject to m equality constraints: Minimize FOF) Bi Aye X,) =O B5(% 2p ud, ) = 0 Subject to Sm (XX o05X,) = 0 The method of Lagrange Multipliers converts this problem to the follow- ing unconstrained optimization problem: Minimize L(x.2) = f(x) - Sag, which now has +m independent variables, i. sss; Am. 1's are called the multipliers. Xt, X2, ..., Xa, and Ar, Ax, The rest of the procedure is to find the stationary point(s), de~ termine the type of the stationary point(s), and determine the values of the function at the stationary point(s). To test whether the stationary point corresponds to a minimum, a maximum, or a saddle point, we again use the Hessian matrix described in the optimization of uncon- strained function. The Hessian matrix does not include the derivatives of the function with respect to the multipliers. Procedure 7.3 shows how to optimize constrained function using the method of Lagrange Multipliers. In fact, the example in Procedure 7.3 can be transformed into an unconstrained optimization problem by solving for y (in term of x) from the constraint and then substituting to the objective function. Thus, the objective function will have only one Chapter 7 * Optimization 95 independent variable, ie., x. However, this cannot always be done, al- though it is always a good idea to try to reduce the number of the inde- pendent variables by substitution. A simpler method is again to use minimize and maximize functions. Procedure 7.4 demonstrates the use of minimize /maximize function for this purpose. Procedure 7.3: Lagrange Multipliors ‘Suppose we want to sve the folowing optimization problem Subjectio avy 220 4. Create the function tobe optimized and a funtion representing the constraint Minimize fxy)=(0-2F + Rayo ey aeuy)-2aty 2 2, Whenever passible, plat the objective function and constraint to get the idea of the solution: ‘The numbered curves aro the ~\ function gi) fg 3, Gonstruct the unconstrained function, ie., the Lagrangian function L: Uy) =fhay) Rea) 4. Detine tunctions for calculating al ofthe second derivatives needed in the Hessian mati ae 2 nak) tyytoyy £2 yd) Lyybmyar Glyn « s cady er oe Lyfayedd byonydd 5. Constuct the Hessian matix Hay.) = = LyylesA) tyybeysA) Lard) 6. Create a function for calulting the eigenvalues ofthe Hessian matrix: (4s) = eget (5.63) 7. Find a stationary point using Given block and find function: Initial guesses: x. Given fuayaed Luayays0 Cumyd & yy @ £8, Determine the type ofthe stationary point and the value of the function: 2) minum yoyo) 08 Cheese (2 me 1(Pgp)) = 132% 10° 96 Chapter 7 * Optimization Procedure 7.4: minimize/maximize for a constrained function ‘Suppose we want to solve the folowing optimization problem. Minimize fixy) = x- 2 +? Subject to axe y—2=0 1. Create the function to be optimized: Oxy) = (x 2Y +y 2. Whenever possible, plot the function to get the ideas of the solutions. 3. Construct a Given block for the constraint and provide initial quesses: Initial guesses: x24 y= Given 2xty-220 4. Calculate the minimum stationary point using minimize function: (x) 12) ) tay 08 )=itcny)-( 2) \y Example set 7.1 1. Substance D is produced by decomposition reaction of Ain a mixed reactor. The reaction is accompanied by two othor undesired side reactions: E Chis the concentration of Ain te the exit stream, gf, aN fp atec fe=0.2C, —_a¥@ the reaction rates of the |, production of B, C, and D, ip=05Cq? respective D (desired product) "b= Sa” spectively From the kinebe considerations, the concentration of D inthe exit stream s given by p= —— (no-€a) Cyg= 3 moliter Bite Determine the optimum concentration of Ain the ext stream that maximizes the desired product D. Also, whal is the maximum concentration of 0 at this condtion? osc? Solution: —Cay=3 — CyfCa) Initial guess: 7 (Cx0-Ca) 1 02€, + 05642 ae A+ O5Cy C4 =Maximindp.C4) y= 1473 moter (optimum C4) cofealos So ~ ColCa) =0696 moltter (maximum product) — —— y it corviriorial iE nse (ying evince ob : I Inital guess: Cqi=1 Given c / A @ in *egfcy)=0 ween) Fina{Cy) Cg =1473——Cp[Cq) = 0696 Test he sttionary point Co(Ca) =-0.88 maximum ay’ 2, Synthesis gas can be produced by catalytic eforing of methane (CH ,) with steam at high temperature and atmospheric pressure: (Oy (1 2H,O (2) => CO, (4) 4 (6) ‘Tho water gas-shit reaction also occurs along with the above reaction: 60, +H, -—-> 60 (8) +0 Chapter 7 + Optimization 97 Ifthe catalytic reforming is carried out at 1000 K and 1 bar, determine the equilibrium ‘compostons (mol factions) ofthe mixture. The reactants are supped tothe reactor in the ratio of 2 mol steam to 1 mol methane. Tho equlbrum compositions canbe caleulatod by minimizing the total Gibbs ree eneray of the tem (6) Miimize —G(,.ny.ay gm) Subjoct to matoral balances: n+, + my=1 , titaiteced nei fin 420+ 20,=% component inthe mixture nyt t2n “The mol fraction of component i and the total Gibbs free energy of the systemis can be: cealeulated trom: 3| a G=L(oa6) + RE ah ‘here the summation is aver all components in the system, Ris the gas constant, Tis the absolute temperature, and 4G, isthe standard Gibbs energy change of formation for ‘component i, The standard Gibbs eneray change of formation at 1000 K for each of the ‘component is as folows: \sm204mot! AG. 4G, 192420-mot | 2002401mo! | AG,=-195790}mor | AG, = 0Fmol ! Solution: CH4(1) 202) CO) COZ) -H2(5) ORIGIN 19720) ima.s Nee Re8314972 T= 1000 aG =| -200240) , (2) 398790) Gm =D (a6) ° ir ers, ci 3 1 s= Minimind 9) oat 8370 10°?) ores =| 0.702 016 oa 0287 082 3.133, oat Linear Programming Many operations management decisions attempt to make the most effective use of limited resources and obtain minimum operating cost or maximum production and profit. Resources typically include money, time, machinery, labor, and raw materials. Linear programming is a widely used technique designed to help engineers plan and make decisions necessary to allocate resources. 98 Chapter 7 * Optimization Linear Programming is an optimization of a linear objective function with linear inequality and/or equality constraints. Again, we can use maximize! minimize function to solve this type of problem. Pro- cedure 7.5 describes how to use these functions, which is similar to that has been discussed in the previous section. Prosedure 7.5: mininlea/maximive for Linear Programming Suppose we want to solve the folowing optimization problem Mavimizo —f(xy)=34+2y Subjectto xs2yed 9 Oecd xy 41. Dotine the function: f(x,y) = 34+ Dy Sxt2yeld ys 2.Gieintial guesses: x0 y= 0 3, Set up the constaints in @_ Given block Given “xe2ys4 sxs3 x-ys3 Q '=Manimizét.ay)=| y Example set 7.2 1. Five crude oils of diferent grades are processed in a refinery to produce four different products: gasoline, heating ol jt fuel, and lube ol. The following table shows the iractions f products that can be obtained from a crude ol! [Crude oF soline | Healing oi | Jet fuel | | product per bbl of crude™ | true —|—~as oe ot Crude2 | 05 a2 02 Crude3_ | 03 0.3 0.3 Gudea [oa a8 O2 rudes [0 ot a2 The fractions do not add up fo 7 due to losses in processing thor cata [Crude Oi_| Cost, $YbbI_| Operating cost, $/obI Availability, bblweek Tce 7200 LC [Crude 2 2000 “Cruse 3 17.00 Crude 1 750 Cruces 6.50 Product | Pre B61 | Maximum demand, botiwesk axis —| 500 ee +} Heaing oi | 95.00, 95,000 Jot el 51.00 75,000 Lube of 40.00 30,000 For maximum prot, determine the amount af each crude oil to be processed per week. What isthe profit par week? Chapter 7 + Optimization ‘This isan optimization (inear programming) problem: Maximize Plxysrsayety%,) where Pis the profiiweek and isthe crude Subjoctto —Avallabitty: x, 80000 x, < 100000 xy = 100000 xq < 100000 x, = 60000 Maximum product demand (what can be sold) 06, 1 05, + 0.3%, + Oba, + Oba, 5 170000 02K +02 1034 + 034, + Ota, = 85000 O.b, + 02% + 03x, + 024, + 02, < 75000 0.2, £30000 Postivevariables 20 420 420 420 x20 Soluion: oRioIN= ‘Setup the objective function: (note thatthe equation can be typed in several nes using [CtrifEater) Fa) =(065, 055 +035, 45,4 Oa} 105. +(02% 402, + 0345 +03, + 0.145) 95 #(O-bx + 02x + 033, +025, + 024 )614 02-140 (tS a + HO + Say + 66m) —(125, +208 + 1205 +754, + 6) 0000 100000 Initial guesses: x:-| 100000 Jove 0000 J Given 80000 5 100000 x, < 100000, O55, 4 05x, + 0.33, + Oba, + 1.4, = 170000 O2n + 0.2% 4 0335 + 0244 + 0.hxy = 85000 Oty, + 02% + 03x, + 02x, + 0.2%, 75000 02, = 20000 x20 '= Maximize x) 3? = (80000 90000 70000 $0000 40000) Crude: x, -s0000 buiweek Crude 4: , — sq900 bblWweek Crude 2: x,=s0000 Dbiiweek Crude &: x — Gono bblWeek 5 s Crude 3: x, 70000 bbIWeek Prof: p(x) —s91000 Seek 2. A company manutactures three chemical products: product 1, product 2, and product 8. The: needed resources of each products shown in the folowing table: [Product |~Enginesring | —Divect labor | Raw maieial | sence tr ioe ) 10 | 3 at a ef “There are 100 hr of engineering, 600 hr of labor, and 200 Io of material available per day. ‘The unt profits on these products are $10, $6, and $4, respectively, ®. Determine the units of each product to be produced for maximum prot per day. What Is the maximum proit? , What isthe unit profi of product 3 that must be increased to before it becomes ‘economical to produce? ©: Ifitis possible o increase the direct labor hours by 10% by scheduling overtime that ‘equites an additonal labor cost of $60/day, analyze whether this labor increase is ‘economical or not 100 Chapter 7 + Optimization ‘This i Linear Programming problem: Maximize Aa .ay-5) (profit per day) Subjectio x, + 2a +5100 (engineering service) 10x, +g + Sx, = 600 (rect labor) Sa 42x +x 5300 aw materia) 20 x20 Solution: ORIGIN: 4. Objective function: (3) = 10, + 6x, + 4 Initial uesses: at 2y ta S100 x20 10a, + 4 + Sx, $600 yee Ba, tay tx $300 x= Maximiad 9) so) Product: xe] 2s] Producta: 4 = Profit: pRi= fix) 0) Products: x, -0 Pri = 650 Siday As we can see from part (a), praduct 3 is not economical to produce when the unit proftis, ‘$4, To analyze this problom, tis bate to write the objective function as a function of the Unit profs 100 so that we can plot x, as a function othe unit profit of product 3 Note that in the argument, the SEP) Pa HP parameters must be typed after the Given independent variable x. my 2a 4m 5 100, 420 nats 1 “The inllal cuossos are tho x 1x, + 4% + $4, $600 520 values obtained in pat (a) Sax, +2 + 4, $300 20 fp ,.p2,p3) == Maximize 2) pl=10 p26 pSi=4,4001.12 ‘Thus, the unt profit of [product 3 should be $5.63 bbotore it becomes ‘economical to produce, €. To analyze this, we need to rewrite the objective function and change the constraints (unfortunately, we are not allowed to have parameters in the constraints): 0) WOH eg H Hy xe] O ° Given Ms 4,4 2ay +9 S00 1x, 45+ 545 <60011 (10% neroase) Sax, +2 +4 $300 x20 420 4,20 xi Manimizf,3) Chapter 7 * Optimization 101 (575) Product t: x, <0 So] 2125) product2: x= 21.25 Profit: pRo= 1x) SOF Products: x, =0 PRo=7025 Siday PR2-PRI=525 Ris not economical to schedule overtime, because the increase of profit is less than the addtional labor cost needed ($60) on-Linear Programming If any of the equalities and inequalities in the constraints and/or the objective function is non-linear, the optimization problem is referred to as the Non-Linear Programming. Maximize minimize function can also be used to solve this type of problem. Procedure 7.6 demonstrates the use of these functions, which is similar to that discussed in the pre- vious sections. Procedure 7.6: minimize/maximize for Nov-Linear Programming Suppose we want lo sole the folowing optimization problem: Maximize iy = 10%, + 44(x) + 2 Subject to 20 420 (x)? +05(x)2 ay + dy + Sx, <5 x 1. Set up the optimization problem: ORIGIN 1 Fo) = 10, + 44 Given x, Foy 45, 545 2. Create a function to obtain the optimum point by using maximize function: p(X)» Maximizef.x) The argument xis a vector for the intial guesses 3. Caleulate the optimum points p(x) for soveral sets of inal guesses and caloulate the ‘becive function to determine the global maximum (20 34.804) [Note that for non-linear pay = 1 132] (p69) =361.238 programming, the maximize {or minimize) function might ‘ve us the local optima. Lo (2 x=| 1 pod \o 0 (maximum) Fy of] = o) fp) = 528.475 32.425 102 Chapter 7 * Optimization Example set 7.3 4. Achemical company sails 3 products: A,B, and C. Is revenue function canbe represented a: Re 104, +4(x)° + 55x, $104month where xj. %2, and xy afe the monthly praduction rates of A,B, and ©: From the breskeven analysis, the minimum production rates of A, B, and C must be 6, 2, and + tonvmonth, respectively. The production rates of B and C must also folow the folowing restriction: 2 2fa) + 3(x)2 15 ‘Additional restrictions must be considered due to the raw material availabilty ty For maximum revenue, deterrine the production rate per month for each chemical What is the revenue at his optimum points? Bx, $40 x + 3 +535 Solution: ORIGIN= 1 Ris) = 10x, 9 4x) 4 58% Given y23) 422 yet (production rate) Ayn + 8x S40 (materia availabilty) apt day ty s35 (materia avaiabilty) MaxiizdR9) 2 (5 Kay Thus, the optimum production rates are 22.20 ton Ammonth, 2:48 ton Bimonth, and 1.00 ton Gimanth with a revenue of $251.62 1O!Mmonth. 2, Thygeson and Grossmann [AICHE J. 16, 749 (1970}] studied the optimal design ofa through ‘ireulation system tor drying catalyst pellets, To maximize the production rato, the folowing ‘optimization problem was obtained: Minimize = 0064s Jen -0184(5)"*] -] Subjectto —1.210!* — (3000+ x))(x 03 4 onfo.8s(,) x20 20 ‘where x, is the fluid velocity and x isthe bed depth, Determine the design fluid velocity ‘and the bed depth that give maximum production rate, Solution: ORIGIN 1 409 a006tx [exf-0.84()°*4] 1] Given 420 20 rzidl? — (3000+ 1} {a}? =0 41-enfo1s4(a) x] 20 (3) == Minimiza C9) Chapter 7 * Optimization 103 77136322) fipts)) =-$9437 oom ) eo) 100) (<0) » 4 , ()ve-( 0 195587) soo) a0 ‘9 ) 2307 von) 709) 31765877) 03a) (p09) = 153.714 vor) =(°) -(°) p00) =0 (0) oJ 1) sg -[9) gga ana (2) ren =(%) ipa) =-53568 so) nos tal (2) we) Unfortunately, in this case minimize function gves us many solutions depending on the initial, (quesses, so that we are not certain whether —153.714 is the minimum This might be due to scaling problem, one variables several ordar of magnitude highor than the other. Ifwe have any idea about the order of magnitude of the variables, we had better rescale the variables so that they take on values between 0.1 and 10. For this problem, itis known that the fluid velocity is in the order of ton of thousands while the bed depth isin the order of one tonth to 10. By substituting x yy) = 10 Xyngy)s HO objective function and constraints become: w9=64(a)[exf-o1se its) ]-1 Given 120- (3+ 105} (5/220 yz0 4,2 sreedom(uts)ajso geo xl s= Minimiza x) Since now we know the order of magnitude ofthe variables, Le., Between 0.1 t0 10, we can try some initial gueses inthis range: e()) (EF) fine) we()we-(227) ayn w(?) w-(°) ty -0 G 0g * si ex(t!) nsf) again “Thus, the solution is less sensitive tothe intial quesses. ‘The optimum fluid velocity is 3.177% 10" and the optimum bed depth is 0.342 104 Chapter 7 * Optimization Problems 1, Substance A reacts according to an elementary autocatalytic reaction: A+ROR+R —1, =kCi,X ,(1-X,) where ~ra is the rate of reaction, k is the reaction constant [= 1 li- ter/(mol.min)], Cwo is the concentration of A in the feed mol/liter], and XA is the conversion of A. \ ‘The process is carried out in a recycle reactor, which has the follow- ing design equation: Xa T=Cy (R41) ji, ola 1 where ris the space time (residence time), Ris the recycle ratio, and Aivis the final conversion of A [= 0.9]. Determine the optimum re- cycle ratio that gives minimum reactor volume (minimum space time). What is the residence time of the reacting mixture in the reac- tor at this optimum recycle ratio? 2. Consider a gas pipeline transmission system where compressor stations are placed Z miles apart [Sherwood, A Course in Process Design, MIT Press, Cambridge, 1963]. The total annual cost of this transmission system and its operation is C(D,P,,L,r) = 7.84D° P, + 450,000 +36,900D 6 6 4 8STX10" | 7210 (2-1) i iE where D is the pipe inside diameter (in), P is the compressor dis- charge pressure (psia), Z is the length between compressor stations (miles), ris the compression ratio (P//P), and P:is the compressor in- let pressure (psia). If the flow rate is 100x106 scffday, determine the design variables, i.e., D, P, L, and x, for minimum annual cost. The flow rate (Q is related to the design variables: D® Q=3.39 (scffhr) fl where fis the friction factor (= 0.008D~"), 3. Product R will be produced at 80 mol/hr (Fa) in a mixed flow reactor, in which the following first order reaction takes place: Chapter 7 + Optimization 105 AOR r= AC, where ra is the reaction rate of R formation, kis the reaction constant (= 0.5 hr), and Cy is the concentration of A in the reactor. The con- centration of reactant A in the feed (Cu) is 0.2 mol/liter. The cost of reactant (P) at this concentration is $0.80/mol A while the cost of reactor including installation, instrumentation, depreciation, etc. (P), is $0.02/(hr-liter). Determine the reactor size, feed rate, and conver- sion that should be used for optimum operations, i.c., minimum cost. Also, determine the unit cost of R for these conditions. Assume that the unreacted A is discarded. On an hourly basis, the total cost is F=VP, + FP, where Vis the volume of the reactor and Fwvis the molar flow rate of A. For a first-order reaction, the volume of reactor, which is derived from mole balance, is given by By ‘0X, A KC o(l-X,) where X% is the conversion of A, from which we can also relate the product rate to the feed rate: F, = F'yyX Note that if the conversion is low, the reactor volume needed will be small, but the amount of reactant A needed for a certain product rate becomes large. On the other hand, if the conversion is high, the amount of reactant A will be small, but the rector volume needed will be large. 4, A company produces alcohol in two grades through a single process stream. The unit profit on product A is $1.5/gallon and on product B is $0.9/gallon. Since the purity of product A is higher than that of product B, product A needs 1.5 times the processing times of product B. Product B alone can be produced at 1500 gal/day. Contract sales re- quire that at least 300 gal/day of product B be produced. For optimum profit, determine the amount of products A and B that should be pro- duced per day. What is the profit? 5, In a three-stage compressor, the process of which is adiabatic reversi- ble, one needs to optimize the discharge pressures from the first and the second stages so that the total work needed is minimized, For a given diatomic gas and final pressure (Ps = 78 bar), the optimal pres- sures are obtained as the solution of the following problem: i 106 Chapter 7 * Optimization Minimi R.P)=PF By : inimize fA PY=RI4| | Subjectto P21 (the gas enters the three-stage compressor at 1 bar) (the gas pressures are monotoni- cally increasing from inlet to out- let) where Pi and P: are the discharge pressures from the first and the second stages, respectively. Determine the optimal discharge pres- sures from the first and the second stages. The total heat transfer area of three cross-flow heat exchangers in se- ries, as shown in the figure below, is to be minimized. Cold fluid is heated in each heat exchanger by hot fluid. Each heat exchanger can be modeled by a steady-state lumped model: WC,(T, -T..)=UAlG, -T) where W/Cp= heat capacity of the cold fluid [= 10° Btu/(hrF)] T= temperature of cold fluid leaving heat exchanger / = temperature of cold fluid entering heat exchanger / overall heat transfer coefficient in heat exchanger / eat transfer area of heat exchanger = temperature of hot fluid entering heat exchanger 7 Hot Hot Hot fluid fluid ‘fluid | 3 d 40°F | 00°F Cold fluid | Exchanger 1 >| Exchanger 2 >| Exchanger 3 > 50°F om J J a, What are the design variables that can be adjusted to minimize the total heat transfer area of this three-stage heat exchanger? b. Write the objective function, i.c., the total heat transfer area as a function of the design variables. c. Write the constraints considering that the temperatures of the cold fluid are monotonically increasing from inlet to outlet and the temperature of the hot fluid entering a heat exchanger must be higher than that of the cold fluid leaving the heat exchanger. Chapter 7 + Optimization 107 d. Determine the optimum design variables and the minimum total heat transfer area of the system. Data: Us = 120 Btu/(hr-ft?.°F) U>= 80 Bu/(hrft2"F) Ui = 40 Btu/(hr-£-°F) 7. Ina pharmaceutical industry, three highly demanded products (A, B, and C) are produced in a single process stream consisting three con- secutive steps. It is possible to run the equipment in each step 24 hours a day. Contract sales require that at least 2 kg/day of product A be produced. [ Product A Product B Product C Profit, S/kg. 40 60 80 ‘Time needed to process one kg of product in every step, hours Step 1 3 2 4 Step 2 1 1 7 Step 3 1 3 3 a. How many kilograms per day should each product be produced to give maximum profit? What is the maximum profit? b. Is there unused time available on any of the steps with the op- timal solution? If yes, which step does not run 24 hours a day? c. Unfortunately, there is an energy crisis leading to widespread blackouts. A few power generators with limited capacity are available in the production site, but one of them cannot run for more than 12 hours/day. As a consequence, one of the produc- tion steps must not run more than 12 hours a day. As a produc- tion manager, decide which step should operate no more than 12 hours. Do some calculations to support your reasoning. Chapter 8 * Differential Equation 109 hapter 8 ifferential Equation Ditterential equations are of fundamental importance in engi- neering. For chemical engineering, differential equations appear for ex- ample in transport phenomena, chemical reaction engineering, unit op- erations, and process control. Although Mathcad has a limited capability in solving differential equations, it can solve many problems in chemical engineering. We will discuss ordinary differential equations first fol- lowed by partial differential equation. Keep in mind that all of the func- tions used for solving differential equations require dimensionless va- riables. 1 Ordinary Differential Equation (ODE) ‘An ordinary differential equation is a differential equation that has only one independent variable. An ODE is called an n-th order ODE if the highest derivative in the equation is of order 7 and is called linear if itis linear in the dependent variable and all of its derivatives. A differential equation can also be classified according to the known conditions. A differential equation with initial conditions is called an initial value problem (IVP). In IVP, the conditions (the value of the dependent variable and/or all of its derivatives) are known at a single value of independent variable, which is the starting point. If the condi- tions are given at two different values of independent variable, the prob- Jem is called boundary value problem (BVP). The number of conditions in IVP or BVP must be the same as the order of ODE. 8.1.1. First Order ODE To solve a first order ODE, in Mathcad we can use several func- tins, such as odesolve, rkfixed, and Rkadapt functions, which will be discussed in detail. The ODE must be linear in its highest derivative. For odesolve function, by default, it uses Adams/BDF method, which means Adams (Adams-Bashford) or BDF (Backward Differentia- tion Formula) method depending on whether the system is non-stiff or stiff, The other available methods can be accessed by right clicking on 110 Chapter 8 « Differential Equation odesolve and choose a particular method from the pop-up menu. Proce- dure 8.1 shows how to use odesolve function to solve a first order ODE. Procedure 8.1: edesolvefor a sinoe fist order ODE ‘Suppose we wantto soe a single ODE from x=2 to x= 10 Ly omays-% with an intial condition: & 4. Define the stating and the end (lerminal points ofthe independent variable x: Starting point: g:-2 Endpoint: y= 10 ‘The end point can be greater or less than the staring point 2. Set up the ODE along withthe intial condition in a. Given block Given \Note: a. The dependent variable (y) must be typed ‘asa function b.ln.a Given block, wo must use the Boolean equal sign (bold equal sian. 3 ©. The derivative must be typed on the left side ofthe equation Ly 69 - 003900 a yo {y= Odesoive(s,b) odesolve function can be typed any way we want, such as Odesolve or ODEsolve I wo want to sot the number of points, the syntax is Odesolve(x.b.npoints). Remember that the smaller the number of poins, the less accurate the interpolated value willbe, “Tho solution y is a function that can be plotted as a function of the independent variable x Itcan also be used to calculate the dependent variable a a certain value of the independent variable: For example at x YS) =-759 IWthe ODE contains a parameter, we have a parametric problem and the following procedure should be followed: Given 56) py =x yi =3 S20) Pr ‘y(p) = Odesolve(x,b) The parameterp is now included as an argument. ‘To plot the solution for a certain parameter, itis necessary to define the independent vatiable as a range variable to reduce the lime needed for ploting 422,205.10 For =0.02atx=5: — y(n02,5) = 759 Note thatthe parameter must be lyped before the independent variable. 0.02.8) 7} WO4.%) 2s Chapter 8 + Differential Equation im Since odesoive function uses a numerical method, the solution obtained is an approximation. The values of the dependent variable (i.e., the solution) are saved at equally spaced discrete points of the indepen- dent variable. By default, the number of points is 1000. If the value of the dependent variable is needed at an independent variable other than the discrete points, the solution will be interpolated using [spline func- tion (see Section 5.1.2). For rkfixed function, as suggested by its name, it uses a Fixed step Runge-Kutta method to solve the ODE. In some applications, for example, when the rate of change of the dependent variable is large in a certain region, we may need to use an adaptive method, which uses dif- ferent step size in different region. In such cases, we could use Rkadapt function, By using rkfixed/Rkadapt function, we can also solve an ODE with decreasing independent variable, i.e., the starting point is larger than the end point. Procedure 8.2 demonstrates the use of rk/ixed func- tion while Procedure 8.3 demonstrates the use of Rkadapt function. Procedure 8, Pix0d fora fist order ODE =10) ‘Suppose we want to solve a singlo ODE from x =2 to Ly 03 wth an intial condition: y¢2) = 3 « 1 Set up the diferential equation Dixy)-00ry x Here, D represents the derivative function 2. Sel up the inital condition: vind 3. Solve the ODE using rkfixed function: x02 ‘ne starting point n= 100 the numberof interval between x0 and x 163 Note that x here is the end point. Of course we ‘ean infact set te end point and remove the ‘argument, bt this approach is recommended. a = tis a matrix containing the values of the if Fl 3] independent variable x in the first column wa) =e 20g] 2.841] — (u'°) and the values of dependent 4 2:16] 2676 | variate yin the second column (1). 3 224 ~~ “The dependent variable can be plotted oN as a function ofthe independent ort - variable wi? \ 112 Chapter 8 + Differential Equation 4. f we want to calculate the dependent variable ata certain value ofthe Independent ‘variable, sel up a function for this purpose. sdiiebig),~ wepiacio mec censncrn sass Foreranpleat x=: ” (5 =-759 \ lithe ODE contains a parameter, we have a parametric problem and the following procedure shauld be folowed: 4. Set up the differential equation: Dip.xy)s= py —x Now, pis inciuded in the derivative tunction, Any additional parameters must be typed before the independent arc dependent variables. 2 Sot up the intial condition; yi = 3 2, Solve the ODE using rixed function: the starting point n= 100 ‘the number of interval between x0 and x ups) = rhixedyi,x0.2,0,D(p)) [Note that x here isthe end point ana 1p has boon included in the argument mos of D and u. (0.02.19) = Py 7 ql eC 4. To calculate the dependent variable ata certain value of the independent variable siocns-lupat®), Westin ant of te second ctr, Forerampo tors O02 (0.02,5) = 7.59 Procedure 8.3: Rkadapt for a fst order ODE Suppose we want to sole a single ODE from x= 2t0x= 10: dy2—1——winanintat contin: y= * 3.98 This ODE has an analytical solution: _y,t4) =2.+ a 398-2 1. Setup the ital condo: 2. Sot up the iterental equate: Dey) 398- ‘8. Sole the ODE using Rkadapt function: s0=2 the starting point a=30 the numberof interval betwe0n x0 and x u(x) = Rkadapt(yi,x0,x0,D) x is the end point ‘Note: Make sure capita Ris used in Rkedapt function. Ts tis matix containing he values ofthe a independent variable x inthe ist column wl [a] 2267| 0937 (©) and ine values of dependent 2] 2533] a7e 0, ‘atabley inthe second eatumn (x ss lo yn the seco 0) Hi we want to solve it using rkfixe function, then 0,30,0) Note that here the numberof intervals used is 30, w= fixe, 2, Chapter 8 « Differential Equation 113, Yal}) isthe analytical solution. ‘Thus, the results obtained using ‘kfixed function (dashed line) with only 30 intervals is incorrect. In order to get the correct results, ne number of intervals must be increased, (On the other hand, Rkadopt function does a great job with a fewer number of intervals aio) 4. we want to caleulate the dependent variable ata certain value of the independent variable, set up a function for this purpose: 0-0"), (5) = 0.505 8.1.2. System of First Order ODEs We can also use the odesolve, rkfixed, and Rkadapt functions to solve a system of first order ODEs. The advantage of using rkfixed /Rkadapt function to solve a system of first order ODEs is that we can solve parametric problems by including the parameters in the arguments of the derivative function; odesolve function cannot solve a system of first order ODEs with parameters. Procedures 8.4 and 8.5 show the use of odesolveand rkfixed functions, respectively, for this purpose. Procedure 8.4: odesolve for a system of ‘Suppose we want to solve two simultanous ODES from x = 2 to x = 10: S91 —oayt = x ‘ Lyre xy2e yi gy y with inital conditions: y1(2 1. Define the stating and the end (terminal) points ofthe independent variable x: Starting point: 4-2 End point’ 19 2. Set up the ODE along with the initial condition in a. Given block Given y169 ~oo2yi(a) =x Hay=3 ae es ‘ £09 + xy269 = y109 may=0 -e 3G) y 8. Solve the ODE using adesolve function: ‘Nate: The first argument in the odesolve function here is a vector containing the name of the functions that we want to soWve ». The odesolve function in this case retums a vector of functions ol x, which is the ‘solution to tho system of ODEs,
  • You might also like