Mathematica Solutions to the Chemical Engineering Problem Set1
Total Page:16
File Type:pdf, Size:1020Kb
MATHEMATICA SOLUTIONS TO THE CHEMICAL ENGINEERING PROBLEM SET1 H. Eric Nuttall Department of Chemical/Nuclear Engineering Farris Engineering Center, Rm 209 University of New Mexico Albuquerque, New Mexico 87131-1341 INTRODUCTION These solutions are for a set of numerical problems in chemical engineering. Professor Michael B. Cutlip of the University of Connecticut developed the problems and Professor Mordechai Shacham of Ben-Gurion University of the Negev for the ASEE Chemical Engineering Summer School held in Snowbird, Utah in August, 1997. The problem statements are provided in another document.1 Professors Cutlip and Shacham provided a document that showed how to solve the problems using POLYMATH. Professor H. Eric Nuttall of the University of New Mexico provided solutions using Mathematica and Professor J. J. Hwalek provided solutions using Mathcad. After the conference, Professor Ross Taylor provided solutions in Maple, and Edward Rosen provided solution in EXCEL. This paper gives the solutions in MATHEMATICA version 3.0. All documents and solutions are available from http://www.che.utexas.edu/cache/ and via FTP from ftp.engr.uconn.edu/pub/ASEE. The written materials are only readable in Adobe Acrobat 3.0 format and higher; however, this software is free via the Internet from www.adobe.com. The MATHEMATICA solutions were derived using version 3.0. This version of MATHEMATICA is the same on all platforms; hence, the notebooks should work the same for all users independent of computer model. MATHEMATICA is a very extensive and comprehensive computational tool; hence, there are several possible approaches and various routines in MATHEMATICA available for solving each of the ten problems. The approach chosen here is that of the author which means other solutions may prove to be better. Also please note that in addition to using the routines provided by MATHEMATICA one can easily write there own programs/functions. This programming capability greatly extends the usefulness of MATHEMATICA. Numerous primers and publications are available to instruct the user on the operation of MATHEMATICA. Also the online help system is very comprehensive and includes numerous examples for each command. I have found MATHEMATICA to be an indispensable computational tool for teaching and solving engineering problems. All of our Ch.E. students at the University of New Mexico know and use MATHEMATICA. This prefer this package overall the others which are also equally available to the students. 1 “The Use of Mathematica Software packages in Chemical Engineering”. Michael B. Cutlip, John J. Hwalek, H. Eric Nuttall, Mordechai Shacham, Workshop from Session 12, Chemical Engineering Summer School, Snowbird, Utah, Aug., 1997. M i Mathematica ASEE Session 12--Problem 1 M 1 1. Molar Volume and Compressibility Factor from Van Der Waals Equation Mathematica Mathematica has its own notebook interface which works somewhat as a wordprocessor but allows mathematical operations directly within the notebook. In addition, it uses the concept of built in or user written functions to perform the mathematical tasks. Note that in these notebooks the gray sections are input and the next line will be output. Mathematica has a good on-line help utility but to learn how to effectively use this application it is best to read one of the many help books such as: Nancy Blachman, Mathematica: A Practical Approach, Prentice Hall. A new edition for Mathematica version 3.0 will be available soon. Ÿ Mathematica--Define equation, paramters and functions * define all the constants used in the equation and H the compressibility factor as a function. Note it is possible to include units with the constants but this was not done in these problems. * L R = 0.08206; Tc = 405.5; Pc = 111.3; Pr P_ := P Pc; a = 27 R^2 Tc^2 Pc 64; b = RTc 8 Pc@ ; D • Z P_,H V_, T_ := •PVL•RT ;T=.; P =•H.; L @ D •H L * van der Waals equation * eqnH = P + a V^2 V - b == RTL H • L H L 4.19695 P + €€€€€€€€€€€€€€€€€€€€€€€ -0.0373712 + V == 0.08206 T V2 J NH L Mathematica ASEE Session 12--Problem 1 M 2 Ÿ Part (a)--Calculate the molar volume and compressibility factor for gaseous ammonia at a pressure of P=56 atm and a temperature of T= 450 K using the van der Waals equation of state. * temperature and pressure * H L T = 450; P = 56; * Solve vad der Waals equation * H L FindRoot eqn, V, 0.57 @ 8 <D V ® 0.574892 * evaluate compressibility factor * 8H < L Z P, 0.574892, T @ D 0.871827 Ÿ Part (b)--Repeat the problem for a series of reduced pressures: Pr= 1,2,4,10, and 20 * Define partial pressures in the array Pr * H L Pr 0 = 0.503; Pr 1 = 1; Pr 2 = 2; Pr 3 = 4; Pr@4D = 10; Pr 5 @= D20; @ D @ D @ D @ D Mathematica ASEE Session 12--Problem 1 M 3 * Create table of P, Pr V and Z * H L TableForm Table P = Pr i Pc, Pr i ,V1@ = V @8. FindRoot@ D eqn, V, 0.56 , Z @P,D V1, T ,• i, 0, 5 ,@ 8 <D TableHeadings@ D< ->8 None,<D"P atm ", "Pr", "V", "Z" , TableAlignments ->8 Center8 H L << D P atm Pr V Z 55.9839 0.503 0.575084 0.871868 111.3 1 0.233509 0.703808 222.6H L 2 0.0772676 0.465777 445.2 4 0.0606543 0.731261 1113. 10 0.0508753 1.53341 2226. 20 0.046175 2.78348 Ÿ Part (c)--Generate a table and plot Pr versus Z plist = Table Pr i , Z P = Pr i@8Pc,@ VD . FindRoot eqn, V, 0.56 ,T , i,@ 0, 5 @ D • @ 8 <D D< 8 <D 0.503, 0.871868 , 1, 0.703808 , 2, 0.465777 , 4, 0.731261 , 10, 1.53341 , 20, 2.78348 TableForm88 plist, TableHeadings< 8 ->< 8None, "Pr",< "Z" , @ 8 8 << TableAlignments8 < 8 -> Center < 8 << D Pr Z 0.503 0.871868 1 0.703808 2 0.465777 4 0.731261 10 1.53341 20 2.78348 Mathematica ASEE Session 12--Problem 1 M 4 ListPlot plist, PlotRange -> 0, 20 , 0, 3 , PlotStyle@ -> PointSize 0.03 88, < 8 << Frame -> True, GridLines@ -> AutomaticD D 3 2.5 2 1.5 1 0.5 2.5 5 7.5 10 12.5 15 17.5 20 … Graphics … Mathematica ASEE Session 12--Problem 2 M 5 2. Steady Steate Material Balances on a Separation Train Mathematica à This set of simultaneous linear algebraic equations can be solved directly using the "Solve" function in Mathematica. There are other linear equation solving routines in Mathematica that could be used for larger sets of simultaneous equations and of course, matrix algebra approach could be used as well. But the method shown is the most common routine and approach in Mathematica for solving equations. Since Mathematica is a symbolic program one can assign the equations equal to variables to simplicity and clarification. à Part (a) Solve the set of linear simultaneous equations for the unknowns: D1, D2, B1, B2. *Xylene* eqnH X=0.07L D1+0.18 B1+0.15 D2+0.24 B2==0.15*70; *Styrene* eqnH S=0.04 DL1+0.24 B1+0.1 D2+0.65 B2==0.25*70; *Touene* eqnH T=0.54 DL1+0.42 B1+0.54 D2+0.1 B2==0.4*70; *Benzene* eqnH B=0.35 DL1+0.16 B1+0.21 D2+0.01 B2==0.2*70; Mathematica ASEE Session 12--Problem 2 M 6 answers= Solve eqnX,eqnS,eqnT,eqnB , D1,B1,D2,B2 *Answer@8 sappearintherule<construc8 t.This <D H ruleconstructmakessymbolicprogramsvery powerful.Theruleconstructwillappearin manyoftheproblemsolutions.* L D1®26.25,B1®17.5,D2®8.75,B2®17.5 ŸThis 88step shown below reduces the answer list from a <<list of lists to a simple list for use in Part (b). Notice that there are one less set of braces around the list! answers=Part answers,1 @ D D1®26.25,B1®17.5,D2®8.75,B2®17.5 à Part8 (b)-Solve for compositions and molar< flow rates in streams B & D Ÿ Part (b)--Equations (again for convenience and clarity the equations are assigned to variables) eqn1=D==D1+B1; eqn2=XDxD==0.07 D1+0.18 B1; eqn3=XDsD==0.04 D1+0.24 B1; eqn4=XDtD==0.54 D1+0.42 B1; eqn5=XDbD==0.35 D1+0.16 B1; eqn6=B==D2+B2; eqn7=XBxB==0.15 D2+0.24 B2; eqn8=XBsB==0.1 D2+0.65 B2; eqn9=XBtB==0.54 D2+0.1 B2; eqn10=XBbB==0.21 D2+0.01 B2; Mathematica ASEE Session 12--Problem 2 M 7 *Againthe"Solve "functionisused. H Itisnecessarytosubstituteintothe equationsthesolutionsfromPart a .* H L L answers2=Solve ReplaceAll eqn@ 1,eqn2,eqn3,eqn4,eqn5,eqn6,eqn7, eqn8,eqn9,@8eqn10 ,answers , D,B,XDx,XDs,XD<t,XDb,XBDx,XBs,XBt,XBb 8 <D XDx®0.114,XDs®0.12,XDt®0.492,XDb®0.274,XBx®0.21, XBs®0.466667,XBt®0.246667,XBb®0.0766667, B®26.25,D®43.75 88 *TheanswersfromPart b are H listedintherule<<construcH Ltasatable* L Part answers2,1 TableForm @ D•• XDx®0.114 XDs®0.12 XDt®0.492 XDb®0.274 XBx®0.21 XBs®0.466667 XBt®0.246667 XBb®0.0766667 B®26.25 D®43.75 Mathematica ASEE Session 12--Problem 3 M 8 3. Vapor Pressure Data Representaton by Polynomials and Equations Mathematica In this problem the same temperature versus pressure data is fit using three different models, i.e., 1) a polynomial with increasing order--linear regression 2) the Clausiu-Clapeyron equation--linear regression of transformed data 3) the Antoine equation--nonlinear regression or curve fitting In each case, the final model and data are graphed on the same plot for comparison.