Top Banner
Page 1 Recent Advances in Chemical Engineering Problem Solving INTRODUCTION Process computations often require the use of numerical software packages for problem solving. Such a need frequently arises in ChE education and practice, where the main objectives are deriving the mathematical model of the physical phenomena and critically analyzing the results while techni- cal details of the solution can be handled by a numerical software package. For professionals and ChE students who are involved with the development of mathematical models, there are considerable ben- efits in using numerical software packages for model development and implementation as compared to the use of source code programming. Process engineers often have do carry out computations that involve non-conventional processes and chemicals. Such processes cannot be modeled with the stan- dard flowsheeting programs, and the use of numerical software packages in such cases is usually most effective. The objective of this workshop is to provide basic overview of current capabilities of several soft- ware packages (with some hands on experience) so that the participants will be able to select the package that is most suitable for a particular need. Important considerations will be that the package will provide accurate solutions and will enable precise, compact and clear documentation of the mod- els along with the results with minimal effort on the part of the user. This workshop will focus on three widely used mathematical software packages are commonly used to solve Chemical Engineering problems: POLYMATH, * Excel, and MATLAB. Each of these packages has specific advantages that make it the most appropriate for solving a particular problem. In many cases, a combined use of several packages is most desirable. FROM MANUAL PROBLEM SOLVING TO USE OF MATHEMATICAL SOFTWARE The problem solving tools on the desktop that were used by engineers prior to the introduction of the handheld calculators (i.e., before 1970) are shown in Figure 1. Most calculations were carried out using the slide rule. This required carrying out each arithmetic operation separately and writing down the results of such operations. The highest precision of such calculations was to three decimal digits at most. If a calculational error was detected, then all the slide rule and arithmetic calculations had to be repeated from the point where the error occurred. The results of the calculations were typi- * POLYMATH is a product of Polymath Software http://www.polymath-software.com Excel is a trademark of Microsoft Corporation (http://www.microsoft.com). MATLAB is trademark of The Math Works, Inc. (http://www.mathworks.com). Adapted from: Cutlip, M. B. and Shacham, M., Problem Solving in Chemical and Biochemical Engineering with Poly- math, Excel, and MATLAB, 2nd ed., Englewood Cliffs, NJ: Prentice Hall, 2007. Workshop Presenters Michael B. Cutlip, Department of Chemical Engineering, Box U-3222, University of Connecticut, Storrs, CT 06269-3222 ([email protected]) Mordechai Shacham, Department of Chemical Engineering, Ben-Gurion University of the Negev, Beer Sheva, Israel 84105 ([email protected]) Session 7 ASEE Chemical Engineering Division Summer School Washington State University - Pullman, WA July 28 - August 2, 2007
110

Recent Advances in Chemical Engineering Problem …...used to solve Chemical Engineering problems: POLYMATH,* Excel,† and MATLAB. ‡ Each of these packages has specific advantages

Mar 10, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Page 1

    Recent Advances in Chemical Engineering Problem Solving

    INTRODUCTIONProcess computations often require the use of numerical software packages for problem solving.

    Such a need frequently arises in ChE education and practice, where the main objectives are derivingthe mathematical model of the physical phenomena and critically analyzing the results while techni-cal details of the solution can be handled by a numerical software package. For professionals and ChEstudents who are involved with the development of mathematical models, there are considerable ben-efits in using numerical software packages for model development and implementation as comparedto the use of source code programming. Process engineers often have do carry out computations thatinvolve non-conventional processes and chemicals. Such processes cannot be modeled with the stan-dard flowsheeting programs, and the use of numerical software packages in such cases is usually mosteffective.

    The objective of this workshop is to provide basic overview of current capabilities of several soft-ware packages (with some hands on experience) so that the participants will be able to select thepackage that is most suitable for a particular need. Important considerations will be that the packagewill provide accurate solutions and will enable precise, compact and clear documentation of the mod-els along with the results with minimal effort on the part of the user.

    This workshop will focus on three widely used mathematical software packages are commonlyused to solve Chemical Engineering problems: POLYMATH,* Excel,† and MATLAB.‡ Each of thesepackages has specific advantages that make it the most appropriate for solving a particular problem.In many cases, a combined use of several packages is most desirable.

    FROM MANUAL PROBLEM SOLVING TO USE OF MATHEMATICAL SOFTWARE•The problem solving tools on the desktop that were used by engineers prior to the introduction of

    the handheld calculators (i.e., before 1970) are shown in Figure 1. Most calculations were carried outusing the slide rule. This required carrying out each arithmetic operation separately and writingdown the results of such operations. The highest precision of such calculations was to three decimaldigits at most. If a calculational error was detected, then all the slide rule and arithmetic calculationshad to be repeated from the point where the error occurred. The results of the calculations were typi-

    * POLYMATH is a product of Polymath Software (http://www.polymath-software.com).† Excel is a trademark of Microsoft Corporation (http://www.microsoft.com).‡ MATLAB is trademark of The Math Works, Inc. (http://www.mathworks.com).• Adapted from: Cutlip, M. B. and Shacham, M., Problem Solving in Chemical and Biochemical Engineering with Poly-math, Excel, and MATLAB, 2nd ed., Englewood Cliffs, NJ: Prentice Hall, 2007.

    Workshop Presenters

    Michael B. Cutlip, Department of Chemical Engineering, Box U-3222, University of Connecticut, Storrs, CT 06269-3222 ([email protected])

    Mordechai Shacham, Department of Chemical Engineering, Ben-Gurion University of the Negev, Beer Sheva, Israel 84105 ([email protected])

    Session 7ASEE Chemical Engineering Division Summer School Washington State University - Pullman, WAJuly 28 - August 2, 2007

    Michael CutlipNoteAll the files mentioned in the problems are available as attachments to this PDF file. The programs should automatically appear in the appropriate software package. The attachments tab is to the left

  • WORKSHOP - MATHEMATICAL SOFTWARE PACKAGES Page 2

    cally typed, and hand-drawn graphs were often prepared. Temperature- and/or composition-depen-dent thermodynamic and physical properties that were needed for problem solving were representedby graphs and nomographs. The values were read from a straight line passed by a ruler between twopoints. The highest precision of the values obtained using this technique was only two decimal digits.All in all, “manual” problem solving was a tedious, time-consuming, and error-prone process.

    During the slide rule era, several techniques were developed that enabled solving realistic prob-lems using the tools that were available at that time. Analytical (closed form) solutions to the prob-lems were preferred over numerical solutions. However, in most cases, it was difficult or evenimpossible to find analytical solutions. In such cases, considerable effort was invested to manipulatethe model equations of the problem to bring them into a solvable form. Often model simplificationswere employed by neglecting terms of the equations which were considered less important. “Short-cut” solution techniques for some types of problems were also developed where a complex problem wasreplaced by a simple one that could be solved. Graphical solution techniques, such as the McCabe-Thiele and Ponchon-Savarit methods for distillation column design, were widely used.

    After digital computers became available in the early 1960’s, it became apparent that computerscould be used for solving complex engineering problems. One of the first textbooks that addressed thesubject of numerical solution of problems in chemical engineering was that by Lapidus.3 The textbookby Carnahan, Luther and Wilkes4 on numerical methods and the textbook by Henley and Rosen5 onmaterial and energy balances contain many example problems for numerical solution and associatedmainframe computer programs (written in the FORTRAN programming language). Solution of anengineering problem using digital computers in this era included the following stages: (1) derive themodel equations for the problem at hand, (2) find the appropriate numerical method (algorithm) tosolve the model, (3) write and debug a computer language program (typically FORTRAN) to solve theproblem using the selected algorithm, (4) validate the results and prepare documentation.

    Problem solving using numerical methods with the early digital computers was a very tediousand time-consuming process. It required expertise in numerical methods and programming in orderto carry out the 2nd and 3rd stages of the problem-solving process. Thus the computer use was justi-fied for solving only large-scale problems from the 1960’s through the mid 1980’s.

    Mathematical software packages started to appear in the 1980’s after the introduction of theApple and IBM personal computers. POLYMATH version 1.0, the software package which is exten-sively used in this book, was first published in 1984 for the IBM personal computer.

    Introduction of mathematical software packages on mainframe and now personal computers hasconsiderably changed the approach to problem solving. Figure 2 shows a flow diagram of the problem-

    Figure 1 The Engineer’s Problem Solving Tools Prior to 1970

  • WORKSHOP - MATHEMATICAL SOFTWARE PACKAGES Page 3

    solving process using such a package. The user is responsible for the preparation of the mathematicalmodel (a complete set of equations) of the problem. In many cases the user will also need to providedata or correlations of physical properties of the compounds involved. The complete model and dataset must be fed into the mathematical software package. It is also the user’s responsibility to catego-rize the problem type. The problem category will determine the type of numerical algorithm to beused for the solution. This issue will be discussed in detail in the next section.

    The mathematical software package will then solve the problem using the selected numericaltechnique. The results obtained together with the model definition can serve as partial or completedocumentation of the problem and its solution.

    CATEGORIZING PROBLEMS ACCORDING TO THE SOLUTION TECHNIQUE USED*Mathematical software packages contain various tools for problem solving. In order to match the

    tool to the problem in hand, you should be able to categorize the problem according to the numericalmethod that should be used for its solution. The discussion in this section details the various catego-ries for which representative examples are included in the book. Note that the study of the followingcategories (a) through (e) is highly recommended prior to using Chapters 7 through 14 of this bookthat are associated with particular subject areas. Categories (f) through (n) are advanced topics thatshould be reviewed prior to advanced problem solving.

    (a) Consecutive Calculations

    These calculations do not require the use of a special numerical technique. The model equations canbe written one after another. On the left-hand side a variable name appears (the output variable), andthe right-hand side contains a constant or an expression that may include constants and previouslydefined variables. Such equations are usually called “explicit” equations. A typical example for such aproblem is the calculation of the volume using the van der Waals’ equation of state.

    * Adapted from: Cutlip, M. B. and Shacham, M., Problem Solving in Chemical and Biochemical Engineering with Poly-math, Excel, and MATLAB, 2nd ed., Englewood Cliffs, NJ: Prentice Hall, 2007.

    Figure 2 Problem Solving with Mathematical Software Packages

    R 0.08206=

    Tc 304.2=

    Pc 72.9=

  • WORKSHOP - MATHEMATICAL SOFTWARE PACKAGES Page 4

    (1)

    The various aspects associated with the solution of this type of problem are described in detail inProblems (4.1) and (5.1) (Molar Volume and Compressibility from Redlich-Kwong Equation). In thosecompletely solved problems, the advantages of the different software packages (POLYMATH, Excel,and MATLAB) in the various stages of the solution process are also demonstrated.

    (b) System of Linear Algebraic EquationsA system of linear algebraic equations can be represented by the equation:

    Ax = b (2)

    where A is an n × n matrix of coefficients, x is an n × 1 vector of unknowns and b an n × 1 vector ofconstants. Note that the number of equations is equal to the number of the unknowns.

    (c) One Nonlinear (Implicit) Algebraic Equation

    A single nonlinear equation can be written in the form

    (3)

    where f is a function and x is the unknown. Additional explicit equations, such as those shown in Sec-tion (a), may also be included. The use of the various software packages for solving single nonlinearequations is demonstrated in solved Problems (4.2) and (5.2) (Calculation of the Flow Rate in a Pipe-line).

    (d) Multiple Linear and Polynomial Regressions

    Given a set of data of measured (or observed) values of a dependent variable: yi versus n independentvariables x1i, x2i, … xni, multiple linear regression attempts to find the “best” values of the parame-ters a0, a1, …an for the equation

    (4)

    where is the calculated value of the dependent variable at point i. The “best” parameters have val-ues that minimize the squares of the errors

    (5)

    where N is the number of available data points.In polynomial regression, there is only one independent variable x, and Equation (4) becomes

    (6)

    T 350=

    V 0.6=

    a 24 64⁄( ) R2Tc2( ) Pc⁄( )=

    b RTc( ) 8Pc( )⁄=

    P RT( ) V b–( )⁄ a V2⁄–=

    f x( ) 0=

    ŷi a0 a1x1 i, a2x2 i, … anxn i,+ + + +=

    ŷi

    S yi yiˆ–( )2

    i 1=

    N

    ∑=

    ŷi a0 a1xi a2xi2 … anxi

    n+ + + +=

  • WORKSHOP - MATHEMATICAL SOFTWARE PACKAGES Page 5

    Multiple linear and polynomial regressions using POLYMATH, Excel and MATLAB for multiplelinear and polynomial regressions is demonstrated in Problems (4.4) and (5.4) (Correlation of thePhysical Properties of Ethane).

    (e) Systems of First-Order Ordinary Differential Equations (ODEs) – Initial Value Problems

    A system of n simultaneous first-order ordinary differential equations can be written in the following(canonical) form

    (7)

    where x is the independent variable and y1, y2, … yn are dependent variables. To obtain a uniquesolution of n simultaneous first-order ODEs, it is necessary to specify n values of the dependent vari-ables (or their derivatives) at specific values of the independent variable. If those values are specifiedat a common point, say x0,

    (8)

    then the problem is categorized as an initial value problem.The use of POLYMATH, Excel, and MATLAB for systems of first-order ODEs is demonstrated in

    Problems (4.3) and (5.3) (Adiabatic Operation of a Tubular Reactor for Cracking of Acetone).

    (f) System of Nonlinear Algebraic Equations (NLEs)

    A system of nonlinear algebraic equations is defined by

    f(x) = 0 (9)

    where f is an n vector of functions, and x is an n vector of unknowns. Note that the number of equa-tions is equal to the number of the unknowns. Treatment of systems of nonlinear equations (obtainedwhen solving a constrained minimization problem), is demonstrated along with the use of varioussoftware packages in Problems (4.5) and (5.5) (Complex Chemical Equilibrium by Gibbs Energy Mini-mization).

    (g) Higher Order ODEs

    Consider the n-th order ordinary differential equation

    (10)

    This equation can be transformed by a series of substitution to a system of n first-order equations. (

    ( )

    ( )

    ( )xyyyfdx

    dy

    xyyyfdx

    dy

    xyyyfdx

    dy

    nnn

    n

    n

    ,,,

    ,,,

    ,,,

    21

    2122

    2111

    K

    M

    K

    K

    =

    =

    =

    0,0

    0,202

    0,101

    )(

    )(

    )(

    nn yxy

    yxy

    yxy

    =

    ==

    M

    ⎟⎟⎠

    ⎞⎜⎜⎝

    ⎛= −

    xdx

    zd

    dx

    zd

    dx

    dzzG

    dx

    zdn

    n

    n

    n

    ,,,, 1

    1

    2

    2

    K

  • WORKSHOP - MATHEMATICAL SOFTWARE PACKAGES Page 6

    (h) Systems of First-Order ODEs – Boundary Value Problems

    ODEs with boundary conditions specified at two (or more) points of the independent variable are clas-sified as boundary value problems. ).

    (i) Stiff Systems of First-Order ODEs

    Systems of ODEs where the dependent variables change on various time (independent variable)scales which differ by many orders of magnitude are called “Stiff” systems.

    (j) Differential-Algebraic System of Equations (DAEs)

    The system defined by the equations:

    (11)

    with the initial conditions y(x0) = y0 is called a system of differential-algebraic equations.

    (k) Partial Differential Equations (PDEs)

    Partial differential equations where there are several independent variables have a typical generalform:

    (12)

    A problem involving PDEs requires specification of initial values and boundary conditions. The use ofthe “Method of Lines” for solving PDEs approximates a solution by solving a system of ODEs.

    (l) Nonlinear Regression

    In nonlinear regression, a nonlinear function g

    (13)

    is used to model the data by finding the values of the parameters a0, a1 … an that minimize thesquares of the errors shown in Equation (5). The use of POLYMATH, Excel, and MATLAB for nonlin-ear regression is demonstrated in respective Problems (4.4) and (5.4) (Correlation of the PhysicalProperties of Ethane).

    (m) Parameter Estimation in Dynamic Systems

    This problem is similar to the nonlinear regression problem except that there is no closed formexpression for , but the squares of the errors function to be minimized must be calculated by solvingthe system of first order ODEs

    (14)

    ( )0),(

    ,,

    =

    =

    zyg

    zyfy

    xdx

    d

    ⎟⎟⎠

    ⎞⎜⎜⎝

    ∂∂+

    ∂∂=

    ∂∂

    2

    2

    2

    2

    y

    T

    x

    T

    t

    T α

    ),,,,(ˆ ,,2,110 iniini xxxaaagy KK=

    ŷi

    ( )txxxaaadt

    dnn ,,,,,

    ˆ2110 KKf

    y =

  • WORKSHOP - MATHEMATICAL SOFTWARE PACKAGES Page 7

    (n) Nonlinear Programming (Optimization) with Equity Constraints

    The nonlinear programming problem with equity constrains is defined by:

    (1-1)

    where f is a function, x is an n-vector of variables and h is an m-vector (m

  • WORKSHOP - MATHEMATICAL SOFTWARE PACKAGES Page 8

    problem where the integration of the model is carried out in the inside loop and a nonlinear equa-tion solver algorithm adjusts the boundary values in an outer loop. Another is the solution of dif-ferential-algebraic systems of equations where the same algorithms are used but in an oppositehierarchy.

    Multiple Model Multiple Algorithm (MMMA) Problem A typical example of such a problemis the optimization of the semi-batch bioreactor, described earlier, with respect with some of itsoperational parameters. An additional MMMA type problem is the modeling of an exothermicbatch reactor where the two stages of operation (heating and cooling) require different models anddifferent integration algorithms (stiff and non-stiff).

    Solving such complex problems and carrying out parametric studies can be rather cumbersomeand time consuming even if mathematical software packages are used, as manual transfer of datafrom one model to another and consecutive manual reruns often may be required. However, the com-bined use of several software packages of various levels of complexity, flexibility and user friendlinesscan reduce considerably the time and effort required for carrying out parametric studies and solvingcomplex models. Following this premise, the models representing the various stages of the problemsare coded and tested using a software package (for example, POLYMATH) that requires very littletechnical coding effort. After testing the models they can be exported to Excel in order to carry outparametric studies and summarize the results in tabular and graphic forms. In case of MMMA prob-lems, after the modules of the problem are coded and tested separately, they are combined into oneprogram using a mathematical software package that supports programming such as MATLAB. Auto-matic translation of the model into a MATLAB function is done by the latest POLYMATH.

    EXAMPLE WORKSHOP PROBLEMSThe attached problems are from an upcoming book titled Problem Solving in Chemcial and Bio-

    chemcial Engineering.* These problems will be used in the workshop. The problem solutions involvePOLYMATH - P, Excel - E, and MATLAB - M, as indicated in the list below.

    PROBLEM RELATED FILESThe related problem files supplied are supplied as attachments to this PDF file. Just click

    on the Attachments tab on the left to open and use a file.

    * Cutlip, M. B. and Shacham, M., Problem Solving in Chemical and Biochemical Engineering with Polymath, Excel, and MATLAB, 2nd ed., Englewood Cliffs, NJ: Prentice Hall, 2007.

    Table 1–1 Example Problems using POLYMATH, Excel, and MATLAB

    EXAMPLE PROBLEMSPOLYMATH & Excel

    Prob. #.MATLABProb. #

    MOLAR VOLUME AND COMPRESSIBILITY FROM REDLICH-KWONG EQUATION 4.1 5.1CALCULATION OF THE FLOW RATE IN A PIPELINE 4.2 5.2ADIABATIC OPERATION OF A TUBULAR REACTOR FOR CRACKING OF ACETONE 4.3 5.3CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE 4.4 5.4COMPLEX CHEMICAL EQUILIBRIUM BY GIBBS ENERGY MINIMIZATION 4.5 5.5

  • C H A P T E R

    © Pearson Education, Inc. All rights reserved. This work is

    4

    Problem Solving with Excel 5

    4.1 MOLAR VOLUME AND COMPRESSIBILITY FROM REDLICH-KWONG EQUATION

    4.1.1 Concepts Demonstrated

    Analytical solution of the cubic Redlich-Kwong equation for compressibility fac-tor and calculation of the molar volume at various reduced temperature andpressure values.

    4.1.2 Numerical Methods Utilized

    Solution of a set of explicit equations.

    4.1.3 Excel Options and Functions Demonstrated

    Explicit solution involving definition of constants and arithmetic formulas, arith-metic functions, creating series, absolute and relative addressing, if statementsand logical functions, two-input data tables and XY (scatter) plots.

    4.1.4 Problem Definition

    The R-K equation is usually written (Shacham et al.)1

    (4-1)

    where

    (4-2)

    (4-3)

    P RTV b–-------------

    a

    V V b+( ) T--------------------------------–=

    a 0.42747R

    2Tc

    5 2⁄

    Pc----------------------

    ⎝ ⎠⎜ ⎟⎛ ⎞

    =

    b 0.08664RTcPc

    -----------⎝ ⎠⎛ ⎞=

    101

    protected by copyright.

  • 102 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    andP = pressure in atmV = molar volume in liters/g-molT = temperature in KR = gas constant (R = 0.08206 (atm·liter/g-mol·K))Tc = critical temperature in KPc = critical pressure in atm

    The compressibility factor is given by

    (4-4)

    Equation (4-1) can be written, after considerable algebra, in terms of the com-pressibility factor as a cubic equation (see Seader and Henley)2

    (4-5)where

    (4-6)

    (4-7)

    (4-8)

    (4-9)

    in which Pr is the reduced pressure (P/Pc) and Tr is the reduced temperature(T/Tc).

    Equation (4-5) can be solved analytically for three roots. Some of these rootsare complex. Considering only the real roots, the sequence of calculationsinvolves the steps

    (4-10)

    where

    (4-11)

    (4-12)

    If there is one real solution for z given by

    (4-13)

    z PVRT--------=

    fz ) z3 z2– qz– r– 0= =

    r A2B=

    q B2

    B A2

    –+=

    A2 0.42747PR

    TR5 2⁄------------⎝ ⎠

    ⎜ ⎟⎛ ⎞

    =

    B 0.08664PRTR-------⎝ ⎠

    ⎛ ⎞=

    C f3--- ⎝ ⎠

    ⎛ ⎞3

    g2--- ⎝ ⎠

    ⎛ ⎞2

    +=

    f 3q– 1–3

    --------------------=

    g 27r– 9q– 2–27

    -----------------------------------=

    C 0>

    z D E 1 3⁄+ +=

    Inc. All rights reserved. This work is protected by copyright.

  • 4.1 MOLAR VOLUME AND COMPRESSIBILITY FROM REDLICH-KWONG EQUATION 103

    © Pearson

    where

    (4-14)

    (4-15)

    If C < 0, there are three real solutions

    k = 1, 2, 3 (4-16)

    where

    (4-17)

    In the supercritical region when , two of these solutions are negative, sothe maximal zk is selected as the true compressibility factor.

    Table 4–1 Reduced Pressures and Temperatures for Calculation

    Pr Pr Pr Pr Pr Tr0.1 2 4 6 8 10.2 2.2 4.2 6.2 8.2 1.20.4 2.4 4.4 6.4 8.4 1.50.6 2.6 4.6 6.6 8.6 2.00.8 2.8 4.8 6.8 8.8 3.01 3 5 7 9

    1.2 3.2 5.2 7.2 9.21.4 3.4 5.4 7.4 9.41.6 3.6 5.6 7.6 9.61.8 3.8 5.8 7.8 9.8

    10

    D g– 2⁄ C+( )1 3⁄

    =

    E g– 2⁄ C–( )1 3⁄

    =

    zk 2f–

    3----- φ

    3---⎝ ⎠

    ⎛ ⎞ 2π k 1–( )3

    ------------------------+cos 13---+=

    φ a g2

    4⁄

    f3–( ) 27⁄----------------------cos=

    Tr 10≥

    (a) Use POLYMATH to calculate the volume of steam (critical temperatureis Tc = 647.4 K and critical pressure is Pc = 218.3 atm) at Tr = 1.0 andPr = 1.2. Compare your result with the value obtained from a physicalproperty data base (V = 0.052456 L/g-mol). Also complete the calcula-tion for Tr = 3.0 and Pr = 10 (V = 0.0837 L/g-mol). Carry out both calcu-lations only if the parameter C > 0.

    (b) Calculate the compressibility factor and the molar volume of steamusing Excel for the reduced temperatures and reduced pressures listedin Table 4–1. Prepare a table and a plot of the compressibility factorversus Pr and Tr as well as a table and a plot of the molar volume ver-sus pressure and Tr.. The pressure and the volume should be in a loga-rithmic scale in the second plot.

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 104 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    4.1.5 Solution

    (a) The set of explicit equations that is entered into the POLYMATH NonlinearEquations Solver program for solution is shown in Table 4–2.

    Note that the row numbers have been added only to help with the explana-tion; they are not part of the POLYMATH input. Some explanation is included inthe POLYMATH input in form of optional comments (text that starts with the“#” sign and ends with the end of the line). In this particular problem the calcula-tions can be carried out sequentially; thus all the equations are entered asexplicit equations of the form: x = an expression, where x is a variable name. Avariable name must start with an English letter and may contain English let-ters, numbers, and the underscore sign “_”. Note that no special characters, sub-scripts or superscripts, Greek letters, parentheses, and arithmetic operators(such as +, /, etc.) are allowed. In expressions, the multiplications sign “*” must be explicitly typed every-where it is needed. For division, the / (backslash) operator is used; for exponenti-ation, the “^” operator is used; and for calculating square root, the “sqrt” functionis used. POLYMATH supports only the use of the round parentheses “( )”. It isimportant to use enough pairs of parentheses, especially when division isinvolved, to obtain the correct sequence of calculations.

    The equations can be entered into POLYMATH in any order as POLY-MATH reorders the equations so that variables are calculated, appearing on theleft-hand side of the equal sign, before they appear in an expression on the right-

    Table 4–2 Equation Set in the POLYMATH Nonlinear Equation Solver (File P2-01A.POL)

    Line Equation, # Comment1 R = 0.08206 # Gas constant (L-atm/g-mol-K)2 Tc = 647.4 # Critical temperature (K)3 Pc = 218.3 # Critical pressure (atm)4 a = 0.42747 * R ^ 2 * Tc ^ (5 / 2) / Pc # Eq.(4-2), RK equation constant5 b = 0.08664 * R * Tc / Pc # Eq.(4-3),RK equation constant6 Pr = 1.2 # Reduced pressure (dimensionless)7 Tr = 1 # Reduced temperature (dimensionless)8 r = Asqr * B # Eq.(4-6)9 q = B ^ 2 + B - Asqr # Eq.(4-7)10 Asqr = 0.42747 * Pr / (Tr ^ 2.5) # Eq.(4-8)11 B = 0.08664 * Pr / Tr # Eq.(4-9)12 C = (f/3) ^ 3 + (g / 2) ^ 2 # Eq.(4-10)13 f = (-3 * q - 1) / 3 # Eq.(4-11)14 g = (-27 * r - 9 * q - 2) / 27 # Eq.(4-12)15 z = If (C > 0) Then (D + E + 1 / 3) Else (0) # Eq.(4-13), Compressibility factor 16 D = If (C > 0) Then ((-g / 2 + sqrt(C)) ^ (1 / 3)) Else (0) # Eq.(4-14)17 E1 = If (C > 0) Then (-g / 2 - sqrt(C)) Else (0) # Eq.(4-15)18 E = If (C > 0) Then ((sign(E1) * (abs(E1)) ^ (1 / 3))) Else (0) # Eq.(4-15)19 P = Pr * Pc # Pressure (atm)20 T = Tr * Tc # Temperature (K)21 V = z * R * T / P # Molar volume (L/g-mol)

    Inc. All rights reserved. This work is protected by copyright.

  • 4.1 MOLAR VOLUME AND COMPRESSIBILITY FROM REDLICH-KWONG EQUATION 105

    © Pearson

    hand side of the equal sign. In the set of equations given in Table 4–2, for exam-ple, POLYMATH will first calculate f in line 13 and then g in line 14 before calcu-lating C in line 12.

    The calculation of the compressibility factor for the case where C > 0 is car-ried out by the equations in lines 15-18 in Table 4–2. Calculations with variablesE1 and E in lines 17 and 18 deal with possible negative cube roots. Note that thePOLYMATH if statement ensures that the variables are calculated if C > 0, oth-erwise zero value is substituted for them. The syntax of the if statement is:

    x = if (condition) then (expression 1) else (expression 2)

    The condition may include the following operators: and, or (Boolean opera-tors), >, =,

  • 106 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    but these formulas can be seen only when pointing on a particular cell or whenselecting the “View Formulas” option from the Excel “Tools/Options/View” drop-down menu.

    Columns “E” and “F” present the POLYMATH equations and comments(not completely shown) for documentation purposes. It is important to rememberthat only the Excel formulas, stored in column “C,” are used for calculations.

    Some of the Excel formulas generated are shown in Figure 4–2. Severalpoints are worth noting regarding these formulas: 1) Only the right-hand side ofthe equations is included in the Excel formula. The value obtained is assigned tothe particular cell where the formula resides (it is not assigned to a particularvariable). 2) When the formula contains an expression, it must start with theequal (=) sign. If it contains only a numerical constant (like the value 0.08206),the omission of the equal sign is permitted. 3) The Excel formulas are very simi-lar to the POLYMATH equations except that the variable names are replaced bythe addresses of the cells where the particular variables are being calculated. 4)The Excel “If” statement is different from the POLYMATH “If” statement. Thecalculation of the compressibility factor given by z in cell C17 is carried out, forexample, by the formula

    =IF((C14 > 0),((C18 + C20) + (1 / 3)),0)

    The molar volume and compressibility factor obtained by the Excel formu-las for Tr = 1.0 and Pr = 1.2 are the same as obtained by POLYMATH (see Table4–2); thus the correctness of the formulas has been verified. Now the calculationscan be carried out for all the Tr and Pr values shown in Table 4–1. This is accom-plished by the “two-variable data table” tool of Excel.

    First the framework of the Excel Table is prepared as shown in Figure 4–3by entering the desired Pr values listed into separate rows in column G (only

    Figure 4–2 Some of the Excel Formulas of the Exported Problem (File P4-01B1.XLS)

    Figure 4–3 Preparation of a “Two-Variable Data Table” for Calculating Compressibility Factor Values (File P4-01B1.XLS)

    Inc. All rights reserved. This work is protected by copyright.

  • 4.1 MOLAR VOLUME AND COMPRESSIBILITY FROM REDLICH-KWONG EQUATION 107

    © Pearson

    part of the values are shown) and the Tr values are entered into separate col-umns in the 3rd row. The address of the calculated value of the compressibilityfactor (C17, see Figure 4–1) could be entered in the upper corner on the left sideof the table (cell H3). Since the compressibility factor should calculated only ifthe variable C > 0, the cell content should be modified to display only meaningfulvalues. This is achieved with an “If” statement in cell G3.

    =IF(C17>0,C17,"Irrelevant")

    Note that the headings entered in the row 2 are not essential parts of the table,but they are used for “Legend” in the graph to be prepared.

    After entering the Pr and Tr values and the address of the target result, theentire area of the table is selected and the Excel Table option from the Datamenu is chosen, as shown in Figure 4–4. The address of the parameter Tr (C9,see Figure 4–1) is specified as the Row Input Cell, since the Tr values are enteredin a row, and the address of the parameter Pr (C8) is specified as the ColumnInput Cell.

    After clicking on the OK button, the Excel Table is filled with the compress-ibility factors corresponding to the desired reduced temperatures and reducedpressures. Partial results of the calculations are shown in Figure 4–5.

    Figure 4–4 Selection of Row and Column Input Cells for the Excel Data Table (File P4-01B1.XLS)

    Figure 4–5 Partial Results for Compressibility Factor Calculation for various Pr and Tr (File P4-01B1.XLS)

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 108 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    The generated table in the Excel worksheet can be used for preparing theplot (of type: XY, scatter) of the compressibility factor z (on the Y axis) versus Pr(on the X axis) and Tr (parameter). Figure 4–6 shows the resulting Excel plot.

    The molar volume at various Pr and Tr values can be calculated by generat-ing a two-input data table similar to the one shown in Figure 4–5. In this case,the address of the calculated value of the molar volume (C23, see Figure 4–1) isentered in the upper corner on the left side of the table. After the table is gener-ated a new column containing the pressure values is added to the left of the col-umn which contains the Pr values, as shown in Figure 4–7. This table can beused for preparing the plot (of type: XY, scatter) of the molar volume (on the Yaxis) versus P (on the X axis) and Tr (parameter). After the plot is prepared, the“Format axis” options for both the X and Y axes have to be used to change thescales to logarithmic. The resultant plot is shown in Figure 4–8.

    Figure 4–6 Compressibility Factor of Steam versus Pr and Tr (File P4-01B1.XLS)

    Figure 4–7 Two-Input Table for Molar Volume (File P4-01B2.XLS)

    Inc. All rights reserved. This work is protected by copyright.

  • 4.1 MOLAR VOLUME AND COMPRESSIBILITY FROM REDLICH-KWONG EQUATION 109

    © Pearson

    The problem solution files are found in directory Chapter 4 and desig-nated P4-01A.POL, P4-01B1.XLS, and P4-01B2.XLS.

    Figure 4–8 Molar Volume of Steam versus P and Tr (File P4-01B2.XLS)

    www

    Education, Inc. All rights reserved. This work is protected by copyright.

    Michael CutlipNoteAll the files are available as attachments to this PDF file. The programs should automatically appear in the appropriate software package.

  • 110 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    4.2 CALCULATION OF THE FLOW RATE IN A PIPELINE

    4.2.1 Concepts Demonstrated

    Application of the general mechanical energy balance for incompressible fluids,and calculation of flow rate in a pipeline for various pipe diameters and lengths.

    4.2.2 Numerical Methods Utilized

    Solution of a single nonlinear algebraic equation and alternative solution usingthe successive substitution method.

    4.2.3 Excel Options and Functions Demonstrated

    Absolute and relative addressing, use of the “goal seek” tool, programming of thesuccessive substitution technique.

    4.2.4 Problem Definition

    Figure 4–9 shows a pipeline that delivers water at a constant temperatureT = 60°F from point 1 where the pressure is p1 = 150 psig and the elevation isz1 = 0 ft to point 2 where the pressure is atmospheric and the elevation isz2 = 300 ft.

    The density and viscosity of the water can be calculated from the followingequations.

    (4-18)

    (4-19)

    where T is in °F, ρ is in lbm/ft3, and μ is in lbm/ft·s.

    Figure 4–9 Pipeline at Steady State

    P = p2

    z = z1

    2

    1

    z = z2

    P = p1

    ρ 62.122 0.0122T 1.54 4–×10 T2– 2.65 7–×10 T3 2.24 10–×10 T4–+ +=

    μln 11.0318– 1057.51T 214.624+------------------------------+=

    Inc. All rights reserved. This work is protected by copyright.

  • 4.2 CALCULATION OF THE FLOW RATE IN A PIPELINE 111

    © Pearson

    4.2.5 Equations and Numerical Data

    The general mechanical energy balance on an incompressible liquid applied tothis case yields

    (4-20)

    where v is the flow velocity in ft/s, g is the acceleration of gravity given by g =32.174 ft/s2, Δz = z2 - z1 is the difference in elevation (ft), gc is a conversion factor(in English units gc = 32.174 ft·lbm/lbf·s

    2), ΔP = P2 – P1 is the difference in pres-sure lbm/ft

    2), fF is the Fanning friction factor, L is the length of the pipe (ft) and Dis the inside diameter of the pipe (ft). The use of the successive substitutionmethod requires Equation (4-20) to be solved for v as

    (4-21)

    The equation for calculation of the Fanning friction factor depends on the Rey-nold's number, Re = vρD/μ, where μ is the viscosity in lbm/ft·s. For laminar flow(Re < 2100), the Fanning friction factor can be calculated from the equation

    (4-22)

    For turbulent flow (Re > 2100) the Shacham3 equation can be used

    (4-23)

    where e/D is the surface roughness of the pipe (ε = 0.00015 ft for commercialsteel pipes).

    The flow velocity in the pipeline can be converted to flow rate by multiply-ing it by the cross section are of the pipe, the density of water (7.481 gal/ft3), and

    (a) Calculate the flow rate q (in gal/min) for a pipeline with effective lengthof L = 1000 ft and made of nominal 8-inch diameter schedule 40 com-mercial steel pipe. (Solution: v = 11.61 ft/s, gpm = 1811 gal/min)

    (b) Calculate the flow velocities in ft/s and flow rates in gal/min for pipe-lines at 60°F with effective lengths of L = 500, 1000, … 10,000 ft andmade of nominal 4-, 5-, 6- and 8-inch schedule 40 commercial steel pipe.Use the successive substitution method for solving the equations for thevarious cases and present the results in tabular form. Prepare plots offlow velocity v versus D and L, and flow rate q versus D and L.

    (c) Repeat part (a) at temperatures T = 40, 60, and 100°F and display theresults in a table showing temperature, density, viscosity, and flow rate.

    12---v2– gΔz

    gcΔPρ-------------

    2fFLv

    2

    D---------------+ + + 0=

    v gΔzgcΔPρ

    -------------+⎝ ⎠⎛ ⎞ 0.5 2

    fFL

    D---------–

    ⎝ ⎠⎛ ⎞⁄=

    fF16Re-------=

    fF 1 16ε D⁄3.7

    -----------5.02Re----------

    ε D⁄3.7

    -----------14.5Re----------+⎝ ⎠

    ⎛ ⎞log–log⎩ ⎭⎨ ⎬⎧ ⎫

    2

    ⁄=

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 112 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    factor (60 s/min). Thus q has units of (gal/min). The inside diameters (D) of nom-inal 4-, 5-, 6-, and 8-inch schedule 40 commercial steel pipes are provided inAppendix Table D-5.

    4.2.6 Solution

    (a) The problem is set up first for solving for one length and one diametervalue with POLYMATH. The POLYMATH Nonlinear Algebraic Equation Solveris used for this purpose. It should be emphasized that Equation (4-21) (or Equa-tion (4-20)) cannot be solved explicitly for the velocity in the turbulent region asin that region the friction factor is a complex function of the Reynolds number(and the velocity, see Equation (4-23)). Thus Equation (4-21) should be input asan “implicit” (nonlinear) equation. The implicit equations are entered in theform: f(x) = an expression, where x is the variable name, and f(x) is an expressionthat should have the value of zero at the solution. Bounds for the unknown xshould be provided. Minimal and maximal values between which the function iscontinuous and one or more roots are probably located should be provided. Forthe velocity calculation, the following equation and bounds are used:

    f(v) = v - sqrt((32.174 * deltaz + deltaP * 144 * 32.174 / rho) / (0.5 - 2 * fF * L / D)) # Flow velocity (ft/s)

    v(min) = 1v(max) = 20

    Note that the program looks for a solution where f(v) = 0; thus, there is no needto write this out explicitly. The complete set of equations is shown in Table 4–3.

    The solution obtained by POLYMATH is the same as specified in the problemstatement (v = 11.61 ft/s, q = 1811 gal/min).

    Table 4–3 Equation Input to the POLYMATH Nonlinear Equation Solver Program (File P4-02A.POL)

    Line Equation 1 f(v) = v - sqrt((32.174 * deltaz + deltaP * 144 * 32.174 / rho) / (0.5 - 2 * fF * L / D)) # Flow

    velocity (ft/s)2 fF = If (Re < 2100) Then (16 / Re) Else (1 / (16 * (log(eoD / 3.7 - 5.02 * log(eoD / 3.7 + 14.5

    / Re) / Re)) ^ 2)) # Fanning friction factor (dimensionless)3 eoD = epsilon / D # Pipe roughness to diameter ratio (dimensionless)4 Re = D * v * rho / vis # Reynolds number (dimesionless)5 deltaz = 300 # Elevation difference (ft)6 deltaP = -150 # Pressure difference (psi)7 T = 60 # Temperature (deg F)8 L = 1000 # Effective length of pipe (ft)9 D = 7.981 / 12 # Inside diameter of pipe (ft)10 pi = 3.1416 # The constant pi11 epsilon = 0.00015 # Surface rougness of the pipe (ft)12 rho = 62.122 + T * (0.0122 + T * (-1.54e-4 + T * (2.65e-7 - T * 2.24e-10))) # Fluid density

    (lb/cu. ft.)13 vis = exp(-11.0318 + 1057.51 / (T + 214.624)) # Fluid viscosity (lbm/ft-s)14 q = v * pi * D ^ 2 / 4 * 7.481 * 60 # Flow rate (gal/min)15 v(min) = 116 v(max) = 20

    Inc. All rights reserved. This work is protected by copyright.

  • 4.2 CALCULATION OF THE FLOW RATE IN A PIPELINE 113

    © Pearson

    (b) The POLYMATH equation set can be exported to Excel by opening anExcel Workbook, reactivating the POLYMATH equation editor window and thepressing the Excel icon or the F4 function key. The Excel worksheet generated issummarized in Table 4–4.

    Column A indicates the type of the equations in the problem. In this casethere are explicit equations in rows 3 to 16. In cell C16 an initial estimate for theimplicit variable (unknown) is specified. Cell C17 specifies the implicit equationwhose value should approach zero at the solution.

    The implicit equation for velocity v can be solved with Excel by first select-ing the “Goal Seek” utility from the “Tools” dropdown menu. In the “Goal Seek”communication window, the target cell (C17 in this case), its desired value (zero)and the variable to be changed (in cell C16) have to be specified as shown in Fig-ure 4–10. After pressing OK, the value v = 11.61 is obtained with function valuef(v) = –1.02684E-05, thus the solution is the same as obtained by POLYMATH.

    Table 4–4 POLYMATH Equation Set Exported to Excel

    A B C D E1 POLYMATH NLE Migration Document2 Variable Value Polymath Equation3 Explicit Eqs fF 0.00387711 fF=If (Re < 2100) Then (16 / Re) Else (1 / (16 * (log(eoD / 3.7

    - 5.02 * log(eoD / 3.7 + 14.5 / Re) / Re)) ^ 2))4 eoD 0.000225536 eoD=epsilon / D5 Re 572291.1788 Re=D * v * rho / vis6 deltaz 300 deltaz=3007 deltaP -150 deltaP=-1508 T 60 T=609 L 1000 L=100010 D 0.665083333 D=7.981 / 1211 pi 3.1416 pi=3.141612 epsilon 0.00015 epsilon=0.0001513 rho 62.35393696 rho=62.122 + T * (0.0122 + T * (-1.54e-4 + T * (2.65e-7 - T *

    2.24e-10)))14 vis 0.000760873 vis=exp(-11.0318 + 1057.51 / (T + 214.624))15 q 1637.35643 q=v * pi * D ^ 2 / 4*7.481 * 6016 Implicit Vars v 10.5 v(0)=10.517 Implicit Eqs f(v) -1.067599475 f(v)=v - sqrt((32.174 * deltaz + deltaP * 144 * 32.174 / rho) /

    (0.5 - 2 * fF * L / D))

    Figure 4–10 Selection of Variable and Target Cells and Desired Value for “Goal Seek”

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 114 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    The solutions of the set of equations for a large number of pipe lengths anddiameter values is most efficiently accomplished with the Excel “Two input DataTable” capability. “Goal Seek” cannot be effectively applied to create such a datatable. The use of an iterative method such as the “successive substitution”method is recommended.

    The iteration function of the successive substitution method for calculationof the flow velocity is given by

    (4-24)

    where i is the iteration number, F is the function in the right side of Equation(4-21) and v0 is the initial estimate for the flow velocity. An error estimate at iter-ation i is provided by

    (4-25)

    The solution is acceptable when the error is small enough, typically .The successive substitution calculations can be organized for row by row

    iterations in another location on the spreadsheet. This requires that some of therows (and formulas) of Table 4–4 be changed. The expressions which are func-tions of the unknown velocity v (fF, Re, and q) should be grouped separately fromthe constants and placed in rows 13 to 15. This can be accomplished by cuttingand pasting the entire row in the Excel code as needed. The rows that containexpressions that are independent of velocity v should be placed in rows 3 through12. The variable addresses for cells containing these variables should be replacedby absolute addresses in the formulas in cells C13-C16 (See Table 4–5 where the“$” in $C$9, for example, indicates absolute cell address.). The expression for f(v)in cell C17 must be replace by an expression to calculate vi+1 (Equation (4-21)).An additional formula for calculating εi must be added in cell C18.

    The modified cell formulas are shown in Table 4–5. Introducing v0 = 10.5 incell C16 yields v1 = 11.57 in cell C17. Thus the error for the first successive sub-stitution is ε0 = 1.068 as calculated in cell C18 and shown in Table 4–6.

    Table 4–5 Cell Contents after Modifications

    A B C1 POLYMATH NLE Migration Document2 Variable3 eoD =(C10 / C8)4 deltaz =3005 deltaP =-1506 T =607 L =10008 D =0.665089 pi =3.141610 epsilon =0.0001511 rho =(62.122 + (C6 * (0.0122 + (C6 * (-0.000154 + (C6 * (0.000000265 - (C6 *

    0.000000000224))))))))

    vi 1+ F vi( ) i = 0, 1,...=

    εi vi vi 1+–=

    εi 15–×10

  • 4.2 CALCULATION OF THE FLOW RATE IN A PIPELINE 115

    © Pearson

    It is convenient to calculate the iterations for the successive substitutionmethod in another part of the spreadsheet by placing all the variables related toa single iteration in one row (instead of one column). This can be accomplishedby copying the range B13:C18 to range starting in cell H2 using the “Paste Spe-cial” and then the “Transpose” options, found under the Excel “Edit” dropdownmenu. The result gives the relevant heading in row 2 and the calculations for thefirst iteration in row 3 as shown in the top part of Figure 4–11.

    The cell range H2:M2 is a transposed copy of the cell range C13:C18 ofTable 4–6. The iteration number heading has been manually added in cell G2 as“It.No.” and the value of “0” is placed in G3. The first iteration is identified as “1”in column G4. The cell range H3:M3 is then copied and pasted into the same col-umn location in the 4th row. The relative cell address of vi+1 from the thirdrow is manually substituted into the vi column in the 4th row; thus the formulaappearing in cell K4 is “=L3” and the calculation is shown in the bottom part ofFigure 4–11.

    A B C12 vis =EXP((-11.0318 + (1057.51 / (C6 + 214.624))))13 q =(((((C16 * $C$9) * ($C$8 ^ 2)) / 4) * 7.481) * 60)14 fF =IF((C15 < 2100),(16 / C15),(1 / (16 * (LOG10((($C$3 / 3.7) - ((5.02 *

    LOG10((($C$3 / 3.7) + (14.5 / C15)))) / C15))) ^ 2))))15 Re =((($C$8 * C16) * $C$11) / $C$12)16 v(i) 10.517 Iteration v(i+1) =SQRT((((32.174 * $C$4) + ((($C$5 * 144) * 32.174) / $C$11)) / (0.5 - (((2 *

    C14) * $C$7) / $C$8))))18 err =ABS(C17-C16)

    Table 4–6 Cell Calculations after Modifications

    A B C1 POLYMATH NLE Migration Document2 Variable3 eoD 0.0002255374 deltaz 3005 deltaP -1506 T 607 L 10008 D 0.665089 pi 3.141610 epsilon 0.0001511 rho 62.3539369612 vis 0.00076087313 q 1637.34002114 fF 0.00387711415 Re 572288.310516 v(i) 10.517 Iteration v(i+1) 11.5675628918 err 1.067562894

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 116 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    The result of this first iteration shown in Figure 4–11 indicates that theconvergence rate of the successive substitution method is very fast as the initialerror of ε0 = 1.068 is reduced to ε1 = 0.044. Additional iterations can be carriedout by copying the cell range H4:M4 and pasting this range into as many rows asthe number of iterations desired. For the particular pipe diameter and lengthvalues used, the estimated error is below 10-7 after four iterations. However, tobe on the “safe side,” the number of iterations can be increased to ten. Theresults of 10 iterations are given in Figure 4–12.

    The calculations for all the pipe diameter and length values specified in theproblem statement can be automatically carried out within Excel by using the“Two Input Data Table.” First, the framework of the Excel Table is prepared inanother area of the spreadsheet by entering the column headings horizontallystarting in G17 and entering the pipe diameters in feet in the cells immediatelybelow. Then the length values (from 500 to 10,000 in increments of 500) into sep-arate rows starting in cell G19. (See Figure 4–13 where only part of the valuesare shown.) Cell G18 must contain the flow velocity needed for the “Two InputData Table.” The absolute addresses of the calculated value of the convergedflow velocity ($L$13) and the associate error estimate ($M$13) must be used.Since the velocity value is acceptable as a solution only if the estimated error is< 10-5, the following “If ” statement is introduced in cell G18:

    =IF($M$13

  • 4.2 CALCULATION OF THE FLOW RATE IN A PIPELINE 117

    © Pearson

    table but are used for “Legend” in the graph to be prepared. The “Data Table” iscreated by first highlighting the region of the table but not including theheading cells, G18:K38. Then click on “Table” under the Data pull-down menu.In the communication box, the cell C8 (diameter in ft) is specified as “Row inputcell” and cell C7 (pipe length in ft) is specified as column input cell. The resultingsolutions with the specified error tolerance for the indicated range of pipe diame-ter and length values are partially shown in Figure 4–14.

    The “XY Scatter” plot of the flow velocity versus pipe length and diametershown in Figure 4–15 can be created using the “Chart” options from the “Insert”dropdown menu. The plot of flow rate q versus D and L can be created in a simi-lar manner to the flow velocity plot. This is most easily accomplished by copyingthe previously created two-dimensional table to another location such as shownin the left side of Figure 4–16. The Excel “Data Table” formula cell (M18 in this

    Figure 4–13 Setting Up a Two Input Data Table in Excel

    Figure 4–14 Creating the Two Input Data Table for Flow Velocity v in Excel (File P4-02B.XLS)

    Figure 4–15 Flow Velocity Plot versus Pipe Length and Diameter (File P4-02B.XLS)

    02

    4

    6

    810

    12

    14

    1618

    0 5000 10000

    Pipe Length (ft)

    Vel

    ocity

    (ft

    /s)

    D=4"

    D=5"

    D=6"

    D=8"

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 118 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    case) must be modified by entering the absolute address of the flow rate q as$J$13.

    =IF($M$13

  • 4.3 ADIABATIC OPERATION OF A TUBULAR REACTOR FOR CRACKING OF ACETONE 119

    © Pearson

    4.3 ADIABATIC OPERATION OF A TUBULAR REACTOR FOR CRACKING OF ACETONE

    4.3.1 Concepts Demonstrated

    Calculation of the conversion and temperature profiles in an adiabatic tubularreactor.

    4.3.2 Numerical Methods Utilized

    Solution of simultaneous ordinary differential equations.

    4.3.3 Excel Options and Functions Demonstrated

    Use of POLYAMATH and the POLYMATH ODE Solver Add-In for Excel to solvedifferential equations.

    4.3.4 Problem Definition

    The irreversible, vapor-phase cracking of acetone (A) to ketene (B) and methane(C) that is given by the reaction

    is carried out adiabatically in a tubular reactor. The reaction is first order withrespect to acetone and the specific reaction rate can be expressed by

    (4-26)

    where k is in s-1 and T is in K. The acetone feed flow rate to the reactor is 8000kg/hr, the inlet temperature is T = 1150 K and the reactor operates at the con-stant pressure of P = 162 kPa (1.6 atm). The volume of the reactor is 4 m3.

    4.3.5 Equations and Numerical Data

    The material balance equations for the plug-flow reactor are given by

    (4-27)

    (4-28)

    (4-29)

    where FA, FB, and FC are flow rates of acetone, ketene, and methane in g-mol/s,

    CH3COCH3 CH2CO CH4+→

    kln 34.34 34222T

    ---------------–=

    dFAdV

    ----------- rA=

    dFBdV

    ----------- rA–=

    dFCdt

    ----------- r– A=

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 120 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    respectively and rA is the reaction rate of A in g-mol/m3·s. The reaction is first

    order with respect to acetone, thus

    (4-30)

    where CA is the concentration of acetone in g-mol/m3. For a gas phase reactor,

    using the appropriate units of the gas constant, the concentration of the acetonein g-mil/m3 is obtained by

    (4-31)

    The mole fractions of the various components are given by

    (4-32)

    The conversion of acetone can be calculated from

    (4-33)

    An enthalpy (energy) balance on a differential volume of the reactor yields

    (4-34)

    where ΔH is the heat of the reaction at temperature T (in J/g-mol) and CpA , CpB,and CpC are the molar heat capacities of acetone, ketene and methane (in J/g-mol·K). Fogler4 provides the following equations for calculating the heat of reac-tion and the molar heat capacities.

    (4-35)

    (4-36)

    (4-37)

    (4-38)

    rA kCA–=

    CA1000yAP

    8.31T-----------------------=

    yAFA

    FA FB FC+ +-----------------------------------= yB

    FBFA FB FC+ +-----------------------------------= yC

    FCFA FB FC+ +-----------------------------------=

    xAFA0 FA–

    FA0------------------------=

    dTdV--------

    rA ΔH–( )–FACpA FBCpB FCCpC+ +----------------------------------------------------------------------=

    ΔH 80770 6.8 T 298–( )+= 0.00575 T2 2982–( ) 1.27 6–×10 T3 2983–( )––

    CpA 26.6 0.183T 45.866–×10 T2–+=

    CpB 20.04 0.0945T 30.956–×10 T2–+=

    CpC 13.39 0.077T 18.716–×10 T2–+=

    Inc. All rights reserved. This work is protected by copyright.

  • 4.3 ADIABATIC OPERATION OF A TUBULAR REACTOR FOR CRACKING OF ACETONE 121

    © Pearson

    4.3.6 Solution(Partial)

    The POLYMATH ordinary differential equations solver is used for solvingthis problem. Equations (4-26) to (4-38) and other needed equations can beentered into POLYMATH without any significant changes. Note that these equa-tions can be entered in any order as they will be ordered during the problemsolution. The feed flow rate to the reactor FA0 has to be specified in units ofg-mol/s. The molecular weight of acetone (58 g/g-mol) is used for this conversion.The complete POLYMATH problem is summarized in Table 4–8.

    Table 4–8 Equation Input to the POLYMATH Ordinary Differential Equation Solver (File P4-03A.POL)

    Line Equation, # Comment1 d(FA)/d(V) = rA # Differential mass balance on acetone2 d(FB)/d(V) = -rA # Differential mass balance on ketene3 d(FC)/d(V) = -rA # Differential mass balance on methane4 d(T)/d(V) = (-deltaH) * (-rA) / (FA * CpA + FB * CpB + FC * CpC) # Differential enthalpy balance5 XA = (FA0 - FA) / FA0 # Conversion of acetone6 rA = -k * CA # Reaction rate in mol/m3-s7 P = 162 # Pressure kPa8 FA0 = 38.3 # Feed rate of acetone in mol/s9 CA = yA * P * 1000 / (8.31 * T) # Concentration of acetone in mol/m310 yA = FA / (FA + FB + FC) # Mole fraction of acetone11 yB = FB / (FA + FB + FC) # Mole fraction of ketene12 yC = FC / (FA + FB + FC) # Mole fraction of methane13 k = 8.2E14 * exp(-34222 / T) # Reaction rate constant in s-114 deltaH = 80770 + 6.8 * (T - 298) - .00575 * (T ^ 2 - 298 ^ 2) - 1.27e-6 * (T ^ 3 - 298 ^ 3)15 CpA = 26.6 + .183 * T - 45.86e-6 * T ^ 216 CpB = 20.04 + 0.0945 * T - 30.95e-6 * T ^ 217 CpC = 13.39 + 0.077 * T - 18.71e-6 * T ^ 218 FB(0) = 0 # Feed rate of ketene in mol/s19 FA(0) = 38.3 # Feed rate of acetone in mol/s20 FC(0) = 0 # Feed rate of methane in mol/s21 T(0) = 1035 # Inlet reactor temperature in K22 V(0) = 0 # Reactor volume in m323 V(f) = 4

    (a) Calculate the flow-rates (in g-mol/s) and the mole fractions of acetone,ketene and methane along the reactor. Use POLYMATH to calculateand plot the conversion and reactor temperature (in K) versus volume.

    (b) The conversion in the reactor in part (a) is very low in adiabatic opera-tion because the reactor content cools down very quickly. It is suggestedthat feeding nitrogen along with the acetone might be beneficial inmaintaining a higher temperature. Modify the POLYMATH equationset to enable adding nitrogen to the feed, transfer the equations toExcel and compare the final conversions and temperatures for thecases where 28.3, 18.3, 8.3, 3.3 and 0.0 g-mol/s nitrogen is fed into thereactor (the total molar feed rate is 38.3 g-mol/s in all the cases).

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 122 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    The POLYMATH solution that is summarized in Table 4–9 indicates thatthe inlet temperature of 1035 K is reduced to 907.54 K within the reactor as thereaction is endothermic. Consequently the specific reaction rate, k, and the reac-tion rate with respect to acetone, –rA, are reduced by more that two orders ofmagnitude. This results in a low conversion of the acetone, only 15.7%.

    (b) The addition of the inert gas nitrogen to the reactor feed requires theaddition of an equation for heat capacity of nitrogen and modification to theenergy balance.

    (4-39)

    (4-40)

    It is also necessary to add an equation that allows the molar flow rate of nitro-gen, FN, to be calculated when the feed rate of acetone, FA0, is specified.

    (4-41)

    Additionally, the equations for the mole fractions need to be modified toinclude the molar flow rate of nitrogen. Also, the initial condition on the differen-tial equation for FA0 must be specified with the current initial condition. Themodified POLYMATH program for FA0 = 10 kg-mol/s shown in Figure 4–18 canbe automatically exported to Excel by either pressing the F4 key or clicking themouse on the Excel icon from the Differential Equation Solver window.

    Table 4–9 POLYMATH Results for Problem 4.3 (a)

    Variable Initial value Minimal value Maximal value Final value1 CA 18.83535 12.68959 18.83535 12.68959 2 CpA 166.8786 154.9084 166.8786 154.9084 3 CpB 84.69309 80.3113 84.69309 80.3113 4 CpC 73.04238 67.86058 73.04238 67.86058 5 deltaH 7.876E+04 7.876E+04 7.977E+04 7.977E+04 6 FA 38.3 28.44647 38.3 28.44647 7 FA0 38.3 38.3 38.3 38.3 8 FB 0 0 9.853527 9.853527 9 FC 0 0 9.853527 9.853527 10 k 3.580818 0.0344545 3.580818 0.0344545 11 P 162. 162. 162. 162. 12 rA -67.44594 -67.44594 -0.4372133 -0.4372133 13 T 1035. 907.5422 1035. 907.5422 14 V 0 0 4. 4. 15 xA 0 0 0.2572723 0.2572723 16 yA 1. 0.5907454 1. 0.5907454 17 yB 0 0 0.2046273 0.2046273 18 yC 0 0 0.2046273 0.2046273

    CpN 6.25 0.00878T 2.18–×10 T2–+=

    dTdV--------

    rA ΔH–( )–FACpA FBCpB FCCpC FNCpN+ + +------------------------------------------------------------------------------------------------=

    FN 38.3 FA0–=

    Inc. All rights reserved. This work is protected by copyright.

  • 4.3 ADIABATIC OPERATION OF A TUBULAR REACTOR FOR CRACKING OF ACETONE 123

    © Pearson

    The revised Excel worksheet as automatically generated from the POLY-MATH program is shown in Figure 4–19.

    Figure 4–18 The Revised POLYMATH Program Ready for Export to Excel (File P4-03A.POL)

    Figure 4–19 Generated Excel Problem as Exported from POLYMATH (File P4-03B.XLS)

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 124 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    The Excel version of this problem separates the set of equations and datainto four categories (see column A in Figure 4–19). Rows 3 to 17 contain explicitalgebraic equations and constants. The initial values for the variables that aredefined by differential equations are included in rows 18 to 21. The differentialequations are defined in rows 22 to 25, and the initial value for the independentvariable is specified in row 26.

    The names of the variables are shown in column B, and the Excel formulasof the equations are included in column C. Column E presents the equations asthey were entered into POLYMATH. The POLYMATH comments are also copiedinto column F. It should be emphasized that only the formulas in column C areused for calculations.

    The POLYMATH ODE_Solver Add-In is used for solving the equations. Itcan be found in the “Tools” dropdown menu. Before using the ODE_Solver, itshould be verified that the list of Add-Ins shows the “Ode_Solver” as as activeand the “Solver Add-In” is not marked (non-active). This eliminates possibleinterference beween the two Add-Ins in some versions of Excel.

    Selection of the POLYMATH ODE from the “Tools” menu brings up thecommunication box shown in Figure 4–20. Pressing the “Reload” button willautomatically enter the problem into the ODE_Solver communication box. Oth-erwise, the ranges of the cells of the initial values and the differential equationsmust be entered as well as the address of the cell that contains the initial valueof the independent variable and the final value (numerical) of the independentvariable. Checking of the “Show Report” will place the solution output in a newworksheet. The “Intermediate Cells to Store” will output the vector of specifiedcells during the numerical integration.

    When “Solve” is clicked, the POLYMATH ODE_Solver will start changingthe independent variable value until it reaches its final value. During this pro-cess the values of the problem variables will be calculated and updated. At the

    Figure 4–20 POLYMATH ODE_Solver Add-In Communication Box

    Inc. All rights reserved. This work is protected by copyright.

  • 4.3 ADIABATIC OPERATION OF A TUBULAR REACTOR FOR CRACKING OF ACETONE 125

    © Pearson

    end of the integration, the final values of the problem variables will be displayed.Some of those values for this problem are shown in Figure 4–21.

    The “Show Report” option in the ODE solver communication box (see Fig-ure 4–20) automatically creates a new worksheet that includes the table of ini-tial, minimal, maximal, and final values of the integration variables.Additionally, a table of the values of the problem variables versus the indepen-dent variable is generated for the integration range. The number of data pointsdisplayed in the table of the detailed results is the number shown in the “DataPoints” field of the communication box. If there is a need to include additionalvariables in the report, their cell range must be specified in the “IntermediateCells to Store” field. In this case the value of xA is of interest, so cell C3 wasadded to the list of variables to be stored.

    The resulting “Report,” automatically created on a new worksheet and par-tially shown in Figure 4–22, provides the initial, maximal, minimal, and finalvalues of V (cell C26 from the problem worksheet), FA , FB, FC, T (cells C18, C19,C20, and C21), and xA (cell C3). Note that the names of the variables are not nor-mally displayed as they are not essential components of the problem definition inExcel, but they have been added to the spreadsheet for clarity.

    A comparison of the results when pure acetone is fed to the reactor (Table4–9) with the case when 10 g-mol/s acetone and 28.3 mol/s of nitrogen are fedinto the reactor (Figure 4–22) shows that the addition of the nitrogen increasesthe conversion from xA = 0.257 to xA = 0.314. However, this increase comes at the

    Figure 4–21 Final Values of Some of the Variables (Feed Flow Rate of Nitrogen is 28.3 g-mol/s)

    Figure 4–22 Partial View of DEQ Report Worksheet for FA0 = 10

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 126 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    expense of almost fourfold reduction of the flow rates of the reactant and theproducts.

    The tabular results of the Excel “Report” are shown in Figure 4–23 wherevariables have been entered to replace cell addresses in line 28 for clarity. ThisExcel table can be used to prepare temperature and conversion profile plots forthe reactor (see Figures 4–24 and 4–25). It can be seen that even with the addi-tion of the nitrogen, the main part of the reaction is carried out in the first quar-ter (1 m3 volume) of the reactor where the conversion reaches xA = 0.23. In theadditional 75% of the volume the conversion only increases to xA = 0.314.

    Figure 4–23 Partial View of DEQ Report Worksheet Showing Intermediate Data Points for FA0 = 10 (File P4-03B.XLS)

    Figure 4–24 Temperature Profile in the Reactor for FN = 28.3 g-mol/s (File P4-03B.XLS)

    Inc. All rights reserved. This work is protected by copyright.

  • 4.3 ADIABATIC OPERATION OF A TUBULAR REACTOR FOR CRACKING OF ACETONE 127

    © Pearson

    The problem solution files are found in directory Chapter 4 and desig-nated P4-03A.POL, P4-03B.POL, and P4-03B.XLS.

    Figure 4–25 Conversion Profile in the Reactor for FN = 28.3 g-mol/s (File P4-03B.XLS)

    www

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 128 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    4.4 CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE

    4.4.1 Concepts Demonstrated

    Correlations for heat capacity, vapor pressure, and liquid viscosity for an idealgas.

    4.4.2 Numerical Methods Utilized

    Polynomial, multiple linear, and nonlinear regression of data with linearizationand transformation functions.

    4.4.3 Excel Options and Functions Demonstrated

    Use of the Excel LINEST function for multiple linear and polynomial regression.Use of the Excel Add-In “Solver” for nonlinear regression.

    4.4.4 Problem Definition

    Determine appropriate correlations for heat capacity, vapor pressure, andliquid viscosity of ethane. The data files are given and also the data areavailable in Appendix F. Compare those correlations with the expressionssuggested by the Design Institute for Physical Properties, DIPPR.5 (a) Compare third-degree and fifth-degree polynomials for the correlation

    of the heat capacity data (Table A of Appendix F) using both POLY-MATH and Excel by examining the respective variances, confidenceintervals, and residual plots.

    (b) Use Excel to compare the fifth-degree polynomial for the correlation ofthe heat capacity data (Table B of Appendix F) with the two DIPPRrecommended correlations for the appropriate temperature intervals.

    (c) Utilize multiple linear regression in Excel to fit the Wagner equationto the vapor pressure of ethane data found in Table C of Appendix F.Comment on the applicability of the Wagner equation for correlatingthese data. Compare the correlation obtained by the Wagner equationwith that of the Riedel equation recommended by DIPPR.

    (d) Use nonlinear regression to fit the Antoine equation to the liquid vis-cosity data of ethane data found in Table D of Appendix F. Initial esti-mates of the nonlinear regression parameters should be obtained bylinear regression. Verify nonlinear regression results in both POLY-MATH and Excel. Compare the correlation obtained by the Antoineequation with that of the Riedel equation recommended by DIPPR.

    Inc. All rights reserved. This work is protected by copyright.

  • 4.4 CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE 129

    © Pearson

    4.4.5 Solution

    This problem can be approached by first setting up the problem in POLYMATHand achieving a solution. Then the problem is exported to Excel from the POLY-MATH program, and the same calculations in Excel are verified between the twosoftware packages. Further use of Excel is emphasized in the detailed problemsolution and the generation of the tabular and graphical results.

    (a) The temperature dependency of the heat capacities of gases is com-monly represented by simple polynomials of the form

    (4-42)

    where Cp is the heat capacity in J/kg-mol·K, T is the temperature in K, and a0,a1,... are the coefficients (parameters) of the correlation determined by regres-sion of experimental data. The degree of the polynomial which best representsthe experimental data can be determined based on the variance, the correlationcoefficient (R2), the confidence intervals of the parameters, and the residual plot.The heat capacity data for ethane gas are given in Appendix F, Tables A and B.There are 19 data points in Table A but they encompass a wider temperaturerange (1450 K) than the 41 data points in Table B that have a much smallerrange of temperature range (400 K).

    The data of Table A can be fitted to a third-degree polynomial of the formgiven by Equation (4-42) by first using the POLYMATH Regression Program.The results of the polynomial obtained with POLYMATH are summarized in Fig-ure 4–26, and the POLYMATH graphical result is given in Figure 4–27. The highvalue of the correlation coefficient (R2 = 0.9971) as well as the plot of the calcu-

    Cp a0 a1T a2T2 a3T

    3 …+ + + +=

    Figure 4–26 Third-Degree Polynomial Coefficient and Statistics for the Heat Capacity Data of Table A (File P4-04A.POL)

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 130 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    lated and experimental values seems to indicate that the representation of thedata by the third-degree polynomial is quite satisfactory. However, the residualplot of Figure 4–28 shows a clear cyclic pattern, and the error in representationof some of the points is >5%, which is well above the common experimental errorin heat capacity data. In the case of a2, the confidence interval is slightly larger

    in absolute value than the parameter itself. Thus the third-degree polynomialrepresentation is unsatisfactory, and better representation should be sought.

    Figure 4–27 Third-Degree Polynomial Representation for Heat Capacity of Ethane (File P4-04A.POL)

    Hea

    t C

    apac

    ity

    (J/k

    g-m

    ol·K

    Figure 4–28 Residual Plot for Heat Capacity Represented by Third-Degree Polynomial for Data Set A (File P4-04A.POL)

    Inc. All rights reserved. This work is protected by copyright.

  • 4.4 CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE 131

    © Pearson

    The calculations for the third-degree polynomial can easily be carried outwithin Excel. This is accomplished from POLYMATH by clicking on the Excelicon from POLYMATH Data Table after the problem is selected for the variableand the desired polynomial degree. Note that an Excel spreadsheet must be openon your computer in order for the “Export to Excel” to take place. The columnsgenerated in the Excel worksheet, after exporting the problem from POLY-MATH, are partially shown in Figure 4–29. The temperature and heat capacitydata are found in columns A and D respectively, and the formulas for calculatingvarious powers of T are placed in columns B and C. The Excel result is summa-rized in , which corresponds very closely to the POLYMATH solution.

    In a similar manner, the problem for the fifth-degree polynomial can be setup in POLYMATH and exported to Excel. The resulting worksheet is partiallypresented in Figure 4–31 where the data columns are shown. The temperatureand heat capacity data are found in columns A and F respectively, and the for-mulas for calculating various powers of T are placed in columns B through E.

    Consider now the underlying calculations in the Excel worksheet that areshown in Figure 4–32. The first three rows of this table (cell range L4:Q6) areobtained from Excel's LINEST function. Thus the formula in that range of cellsis given by

    where (F4:F22) is the range where the dependent variable, Cp, is stored, the sec-ond range (A4:E22) is the range where the independent variables (temperature

    Figure 4–29 Columns Generated in the Excel Worksheet when a Third-Degree Polynomial Regression is Exported form POLYMATH to Excel (File P4-04A1.XLS)

    Figure 4–30 Third-Degree Polynomial Coefficients and Statistics for the Heat Capacity Data of Table A (File P4-04A1.XLS)

    =LINEST(F4:F22,A4:E22,TRUE,TRUE){ }

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 132 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    and its various powers) are stored. The first logical variable indicates if there is afree parameter (TRUE) in the expression, and the second logical variable indi-cates whether correlation statistics should be shown (TRUE) in addition to theparameter values.

    The regression model parameters are shown in the 4th row of Figure 4–32.The respective parameter standard deviations σj, as provided by the LINESTfunction, are shown in row 5. The respective 95% confidence intervals are calcu-lated in row 7 by multiplying the σj by the statistical t distribution value consis-tent with the number of degrees of freedom (the appropriate t value is insertedby the POLYMATH export utility). The confidence interval of the parameter a0 iscalculated, for example, using the formula

    =2.017*Q5

    The linear correlation coefficient (R2 = 0.999947) in cell L6 and the stan-dard error on the dependent variable in cell M6 are also calculated by theLINEST function. The Variance is calculated in cell L8 (=(M6)^2), and the Sum ofSquares of the Residuals in cell L9 (=SUM(I4:I44)) is calculated from the gener-ated Excel table.

    When changes are introduced in the data, the Excel results table(Figure 4–32) will be updated correctly unless there is a change in the number ofdata points. If the number of data points is reduced or increased, the data rangefor the LINST function must be changed, and a different t value (reflecting thechange in the degrees of freedom) must be introduced.

    Figure 4–31 Fifth-Degree Polynomial Excel Worksheet for the Heat Capacity Data of Table A (File P4-04A2.XLS)

    Figure 4–32 Fifth-Degree Polynomial Coefficients and Statistics for the Heat Capacity Data of Table A (File P4-04A2.XLS)

    Inc. All rights reserved. This work is protected by copyright.

  • 4.4 CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE 133

    © Pearson

    The parameter values for the polynomial shown in Figure 4–32 are used tocalculate the “Cp calc” values of Figure 4–31. For example, the formula to calcu-late “Cp calc” for T = 50 K is

    =$L$4*A4^5+$M$4*A4^4+$N$4*A4^3+$O$4*A4^2+$P$4*A4^1+$Q$4

    Note that these formulas are automatically generated by the POLYMATHsoftware when the export to Excel is requested. The respective residuals,(Cpcalc-Cp), are calculated and placed in column H.

    The residual plot, that can be created within Excel, is presented in Figure4–33. The correlation coefficient is R2 = 0.9999, and the variance has been signif-icantly reduced. All of the confidence intervals are smaller in absolute valuethan the associated parameter values. The residual plot of Figure 4–33 indicatesa random residual distribution with maximum error ~1%, which is very similarto the magnitude of the experimental error for this type of data. Thus it can beconcluded that the fifth-degree polynomial adequately represents the heat capac-ity data of Appendix F, Table A.

    (b) DIPPR5 recommends an equation for heat capacity of ethane for thetemperature range from 200 K through 1500 K

    (4-43)

    with parameters A = 4.0326E+04, B = 1.3422E+05, C = 1.6555E+03, D =7.3223E+04, and E = 7.5287E+02. For the more limited temperature range from50 K through 200 K, DIPPR recommends using a second-degree polynomial

    (4-44)

    with the parameter values a0=3.1742E+04, a1= 2.6567E+01, and a2 = 1.2927E-01.A comparison of the heat capacity data correlations first requires the deter-

    Figure 4–33 Residual Plot Created in Excel for Heat Capacity Represented by Fifth-Degree Polynomial for the Data Set A

    Cp A BC T⁄

    C T⁄( )sinh------------------------------ D

    E T⁄E T⁄( )cosh

    ------------------------------+ +=

    Cp a0 a1T a2T2

    + +=

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 134 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    mination of the fifth-order polynomial for the ethane data of Table B in AppendixF. POLYMATH will then be used to obtain the polynomial and subsequentlyexport the problem to Excel for verification of the polynomial representation. TheExcel solution will then be modified to carry out the heat capacity calculationsusing the two DIPPR equations with each applied over the recommended tem-perature range. A comparison of the polynomial with the DIPPR correlations willthen be made in Excel.

    The problem can be entered into POLYMATH and the fifth-order polyno-mial can be used to correlate the data of Table B in the same manner asdescribed in part (a) of this problem. The fifth-degree polynomial problem speci-fied in POLYMATH can then be exported to Excel. The resulting Excel solutionis shown in Figure 4–34. It is helpful and good practice to also carry out thePOLYMATH polynomial regression in order to verify the Excel solution by com-paring the calculated polynomial coefficients.

    The heat capacity values recommended by DIPPR (Equations (4-43) and(4-44)) and the corresponding residual calculations can easily be compared byinserting two new columns in the worksheet immediately to the right of the “Cpresidual^2” column I in the Excel worksheet (see Figure 4–36). The five coeffi-cients of Equation (4-43) are entered in the range of cells G48:K48 and the threecoefficients of Equation (4-44) are stored in the range of cells G49:I49 as shownin Figure 4–35.

    The calculated heat capacity values from the DIPPR equations can beentered in Column J with title “CpD calc” and the residuals are entered in col-umn K with title “CpD residual.” The formula for calculating CpD for the first 11data points ( ) is given by the Excel equivalent to Equation (4-44).

    =$G$49+$H$49*A4+$I$49*A4^2

    Note that this formula refers to T = 100 K in Figure 4–36.

    Figure 4–34 Fifth-Degree Polynomial Coefficients and Statistics from Excel for the Heat Capacity Data of Table B of Appendix F

    Figure 4–35 Coefficients of the DIPPR Equations (File P4-04.XLS (Cp_Table B))

    T 200K≤

    Inc. All rights reserved. This work is protected by copyright.

  • 4.4 CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE 135

    © Pearson

    The remaining data points use the Excel equivalent to Equation (4-43) as itis applied to temperatures greater than 200 K. This is shown below for cell H19in Figure 4–36.

    =$G$48+$H$48*(($I$48/A19)/SINH($I$48/A19))^2+$J$48*(($K$48/A19)/COSH($K$48/A19))^2

    The residuals for the DIPPR equations are calculated in Column K byentering the formula for the difference between the DIPPR result in Column Jand the measured Cp in Column F.

    The residuals of the heat capacity values calculated by fifth order polyno-mial in Column H and the DIPPR equations in Column K can be plotted in Excelas shown in Figure 4–37. The maximal error in polynomial representation is< 0.1% and the maximal error in the DIPPR correlation is about 0.5%. Note that

    Figure 4–36 Addition of DIPPR Equation Calculations to Excel Spreadsheet (File P4-04.XLS (Cp_Table B))

    Figure 4–37 Residual Comparison of Heat Capacity Representation by a Fifth-Degree Polynomial and the DIPPR Equations for Data Set B (File P4-04.XLS)

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 136 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    the larger error for DIPPR is expected as the DIPPR correlation of Equation(4-43) is for a much larger range of temperature. The residuals of both correla-tions show cyclic trends, and these trends can probably be attributed to priorsmoothening of the experimental data.

    (c) The Wagner equation is considered by many as the most appropriatemodel to represent the vapor pressure data over the full range between the triplepoint and critical point. The most widely used form of the Wagner equation is

    (4-45)

    where is the reduced temperature, is the reduced pres-sure, and . For ethane, TC = 305.32 K, PC = 4.8720E+06 Pa and thetriple point temperature is 90.352 K. Thus the data in Table C of Appendix Fcover almost the full range between the triple point and the critical point, andthe Wagner equation is appropriate for correlation of these data.

    The use of Excel for solving this problem is preceded by the use of POLY-MATH to enter the data into the POLYMATH Data Table. The ability to easilytransform data is utilized in POLYMATH to define additional columns in theData Table as transformation functions defined by

    TR = T / 305.32lnPR = ln(P/4872000)t = (1-TR)/TRt15 = (1-TR)^1.5/TRt3 = (1-TR)^3/TRt6 = (1-TR)^6/TR

    The resulting POLYMATH Data Table is partially shown in Figure 4–38.These data transformations allow Multiple Linear Regression to fit the

    data to the Wagner equation with lnPr as the dependent variable and the inde-pendent variables t, t15, t3, and t6. Note that in this Multiple Linear Regressionthere should be no free parameter; thus, the POLYMATH Data Table option“through origin” should be marked. This problem is exported to Excel after it issetup in the POLYMATH Regression Data Table.

    PRlnaτ bτ1.5 cτ3 dτ6+ + +

    TR-------------------------------------------------------=

    TR T TC⁄= PR P PC⁄=τ 1 TR–=

    Figure 4–38 POLYMATH Data Table with Original and Transformed Data Columns (File P4-04C.POL)

    Inc. All rights reserved. This work is protected by copyright.

  • 4.4 CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE 137

    © Pearson

    The Excel results after export from POLYMATH for fitting the Wagnerequation to the vapor pressure data are partially presented in Figure 4–39, andthe residuals are plotted in Figure 4–40. The correlation coefficient is R2 =0.99999, and all the confidence intervals are smaller in absolute value than theassociated parameter values. The residual plot shows random residual distribu-tion, and the maximum error is

  • 138 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    tion variables and results given in the POLYMATH to Excel worksheet shown inFigure 4–39. Some of the information entered in this prepared worksheet isshown in Figure 4–41 (only four rows of data, out of the 107 data points in thiscase, are shown). The measured temperature and vapor pressure data areinserted in columns A and B.

    The data of “lnPr” and “lnPr calc” (columns C and D in Figure 4–41) arecopied from the POLYMATH migration worksheet that is partially shown in Fig-ure 4–39. Note that in order to paste the “lnPr calc” values, the “Paste SpecialValues” should be used otherwise error messages will be obtained (and the datacolumns and the coefficients of the Wagner equation will not be copied into thenew worksheet).

    In the 2nd row, the numerical values of the Riedel equation parameters areentered with their names shown in the 1st row. In column E, the “lnPr CalcDIPPR” is calculated using the DIPPR recommended equation by manuallyentering the formula for cell D4.

    =($C$2+$D$2/A4+$E$2*LN(A4)+$F$2*(A4)^$G$2)-LN(4872000)

    Then this formula is copied to all the cells below for the entire data set.The residual plot of the “lnPr Res DIPPR” in this case is very similar to the

    residual plot obtained for the Wagner equation (Figure 4–40). The comparisonbetween the two equations is more meaningful if it is carried out with the help ofthe residual plots based on the pressure (instead of ln(PR)). The preparation ofsuch a plot is left as an exercise for the reader.

    (d) A recommended correlation for viscosity of liquids by Perry6 is similarto the Antoine equation for vapor pressure and given by

    (4-47)

    where μ is the viscosity and the parameters are A, B, and C. If T is expressed indegrees K, then parameter C can be approximated by C = 17.71 – 0.19Tb , whereTb is the normal boiling point in K. For ethane, the normal boiling point is 184.55K, and thus the approximate value of C is -17.35.

    Equation (4-47) is nonlinear and can be fitted to the experimental viscositydata of Table D in Appendix F using general nonlinear regression. However, goodinitial estimates are necessary for the nonlinear regression. These can beobtained by linearizing Equation (4-47) using the approximate value of C for

    Figure 4–41 Worksheet for Comparison of Vapor Pressure Correlation by Wagner and DIPPR Equations (File P4-04.XLS (Vp_Compare))

    μln A BT C+--------------+=

    Inc. All rights reserved. This work is protected by copyright.

  • 4.4 CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE 139

    © Pearson

    ethane to obtain

    (4-48)

    Thus, the linear form can be used in the POLYMATH Data Table contain-ing the viscosity and temperature data by creating additional columns to calcu-late the transformed variables Y = lnμ and X1 = 1/(T–17.35). A portion of thePOLYMATH Data Table which utilizes these transformed variables and is set upfor the linear regression of Equation (4-48) is shown in Figure 4–42. The resultsof the POLYMATH Linear Regression are shown in Figure 4–43. These resultsprovide the initial estimates of A = –11.1, B = 364.6 and C = –17.35 for the non-linear regression of Equation (4-47).

    μln A BT 17.35–-----------------------+ a0 a1

    1T 17.35–-----------------------⎝ ⎠

    ⎛ ⎞+ a0 a1X1+ or Y a0 a1X1+= = = =

    Figure 4–42 Setup of POLYMATH Linear Regression for Equation (4-48) (File P4-04D1.POL)

    Figure 4–43 Linear Regression Results from POLYMATH for Equation (4-48) (File P4-04D1.POL)

    Education, Inc. All rights reserved. This work is protected by copyright.

  • 140 CHAPTER 4 PROBLEM SOLVING WITH EXCEL

    © Pearson Education,

    The nonlinear regression can be set up in POLYMATH and then exported toExcel. The setup of the POLYMATH Nonlinear Regression is shown in Figure 4–44which gives the results that are summarized in Figure 4–45 where some 73 itera-tions were required.

    The export of the POLYMATH setup for Nonlinear Regression to Excel bypressing the Excel icon gives the initial worksheet that is partially shown in Fig-ure 4–46. Note that this problem in Excel must be solved by using the Excel Add-

    Figure 4–44 Nonlinear Regression Setup in POLYMATH for Equation (4-48) (File P4-04D1.POL)

    Figure 4–45 Nonlinear Regression Result in POLYMATH for Equation (4-48) (File P4-04D1.POL)

    Inc. All rights reserved. This work is protected by copyright.

  • 4.4 CORRELATION OF THE PHYSICAL PROPERTIES OF ETHANE 141

    © Pearson

    In called “Solver.” This Add-In should be available from the drop-down menu inExcel under “Tools” and then “Add-Ins...”

    The objective function for the nonlinear regression problem within Excel isthe sum of squares of the Y residuals that is found in the cell at the base of the “Yresidual ^2” column.

    When Solver is called from the “Tools” menu in Excel to perform the nonlin-ear regression, an interface appears in which the “Solver Parameters” must beentered. Solver requires that the Target Cell be set as the sum of squares of theY residuals which should be minimized. Also the Coefficients cells for A, B, and Cmust be identified in the “By Changing Cells” entry box. This is shown in Figure4–47. In the “Equal To:” field of the Solver it is important to move the marking toMin (from the default Max marking). After a mouse click on the “Solve” button,

    Figure 4–46 Nonlinear Regression Exported to Excel-Initi