edited by JOHN W. MOORE
Accurate Equations of State in Computational Chemistry Projects Davld Allbee and Edward Jones United States Military Academy, West Point, NY 10996 For engineering and science students, the use of computers must hecome routine both in the classroom and out of the classroom. Here at the United States Military Academy, all freshmen are required to purchase a microcomputer and become familiar with its oneration durine their first semester a t the academy. The computer hardware and its accomnanvine software ~ u r c h a s e dhv cadets are listed in Table 1. * ~ L r i the n ~ freshmen year,-all students are required to take a n introductory course in computer programming in Pascal. Approximately half of the students take programming during the fall semester and the remainder during the spring semester. This limits how computers are used during the first semester in general chemistry, in that any assignment reouirine nromammine is not fair to those cadets without programming experience. However, during the second semester of general chemistry, all students will have had
-.
-
-
Editor's Note: Changes in the Computer Series The Computer Series in this issuemarksthe lMltharticlel and also the 10th anniversary of the series, which began in March 1978. The Computer Series has been edited by John Moore of Eastern Michigan University since its inception. Editing Journal of Chemical Education: Software is now occupying a great deal of his time, and after a decade as editor af the Computer Series he has decided to step down. Suhsequentto this issue the Computer Series will be edited hy James P. Birk of Arizona State University. Birk's broad knowledge of computers and chemical education will he of immense benefit in the continuation and further develooment of the Comouter Series. and we look forward to the many contributions he will make. At a time of tranaititrn such as thir it is useful to review the current situation with respect tocomputer-relatedrontributions to the Journal. There are now two columns devoted to computers: the Computer Series and the Computer Bulletin Board. In addition, reviews of commercial software that is of interest to chemical education appear in the Reuiews section. Journal of Chemical Education: Software is a new venture that publishes software on disk together with written materials that support effective use of that software in chemistrv classrooms and lahoratories. Whrn you suhmit materials for puhlicatim in a n y of these. pleare indicate in yourcover letter which typeufconlribution ynuarexuhmrtting.The followingguidelinesareintended tQ help delineate the four categories. ~~~~~~
~
~~~
~
~
~
~
~
Computer Series (suhmit manuscriptsto the editorialoffice in Austin): publishes articles (usuallyfull-length)that address general issues such as new approaches to the use of computer-based
'
Carehrl readers will have noted that this issue comains Computer Series, 101. but Computer Series, 58 does not exist1 €!an, R. H. J. Chem. ~duc.1988, 65(4), A98. Mwre. J. W., Ed. J. Chem. Educ.:Software 1988, lA(1). 68-72: 18(1), 65-70.
226
Journal of Chemical Education
programming or will he taking programming in conjunction with chemistry. The great majority of chemistry elective students are upperclassmen who have had programming and are familiar with the use of their ~ersonallvowned microcomputer. Ideal Gas Syndrome [PV = nRT] A mathematical relationship describing the P-V-T behavior of matter is known as an equation of state. Most chemistry students are introduced to the concept of equations of state by studying and applying the ideal gas law. After the student becomes familiar with working problems involving ideal gases, the van der Waals eauation is normallv introduced as a> example of an equation of state that is used with real gases. Using the van der Waals eauation of state. the students then woik a few simple problems that normally materials, descriptions of general classes of software or hardware, philosophy and pedagogy, or designs of new courses based on computers or technology. Computer Bulletin Board (submit manuscripts to the editorial office in Austin): puhlishes descriptions (usually brief) of: user-constructed hardware or new applications of commercially available hardware; new applications of commercial software (including spreadsheets, scientific word processors, electronic notebooks, statistical packages, numerical methods programs, graphics packages, ete.). (See Editor Batt's guidelines2for more details.) Software Reuiews (suhmit software far review to the editorial office in Austin): puhlishes reviews of commercially available instmctional software; reviewers are selected by the Software Reviews Editor, to whom volunteers may send their qualifieations. JCE: Software (submit programs and doeumentation to John Moore, Editor, University of Wisconsin, Madison): puhlishes' instructionalsoftware on disk together with written documentation that enhances the value of the software; refer to separate "Notice to Software author^".^ We expect that these four categories will be capable of aceommodating all submissions; the short notes currently published in "Bits and Pieces" will usually fit either the Computer Bulletin Boord or JCE: Software. However, the Computer Series will continue to print short articles that fit the criteria described above. An author should try to indicate which one category best suits a submission, but of course the editors may suggest that a different feature would he more appropriate. Authors of manuscipts that describe the use of computer programs or other computer files may wish to make those programs or files available to others via Project SERAPHIM or other distribution systems; the method of dissemination should be indicated in the manuscript. Since an abstract appears in the Journal describing each program published in JCE: Software, generally such programs will not he described in other Jourml features. Programsthat do not meet the stringent review criteria for JCE: Software might still be suitable for distribution by Project SERAPHIM, and authors will be encouraged to make such submissions. JJL
Table 1. Hardware and Sonware Purchased by Cadets Hardware
Sottware
Math-Zenith 248(80288processor) Extended graphlcs card Monochrome monttor Two floppy disk drives Logitech ~ O U S B 512Kram
MS-DOS 3.1 GW BASIC
Microson Window Microson Word Micro~~ft Paint MicrosoftWrite TlWh" Pee";ll
do not require that volumes or densities he calculated. In eeneral chemistrv courses. students seldom studv or use kodern equations of state. i n more advanced courses such as phvsicd chemistrv, normallv taken during the iunior or senior year, there L o f t e n a tendency on the p& of many instructors to concentrate on the same material that was presented a t the general chemistry level when studying equations of state. The primary reason that the ideal gas equation of state is the one that students learn to depend on whenever doing calculations reauiring P-V-T data is that the ideal eas law requires the stident rouse only the simplest of algeh;a when ~erforminecalculations. Furthermore. when studvine varibus aspecg of chemistry such as kinetics or thermodhamics. manv instructors will arrme that little is gained compared t o i h e time required forstudents to use more modern and more inherentlv complicated equations of state. Both of these arguments have had validity in the past when considering the time that is available to cover so many topics. However, with the advent of inexpensive computers and their increased student accessibility, this argument is no longer valid. van der Waals Equatlon The ideal gas law assumes that the volume of molecules is infinitesimal when compared to the total volume and that there is no force of attraction between molecules. The van der Waals equation was derived in 1873 ( 1 ) by modifying the ideal gas equation to include two new constants. These transform the ideal gas law from a linear equation with intercept a t the origin
to a cubic equation in terms of molar volume. The a constant corrects for intermolecular forces of attraction, and the b corrects for the fact that the molecules occupy space. These constants can be determined by nonlinear least squares reeression of P-V-T data: however. thev are d e ~ e n d e non t the temperature range. values of a and dcan also he calculated from critical properties by applying the van der Waals equation to the critical point and using the fact that a t the critical point, the first and second derivatives of pressure with respect to volume are equal to zero.
d2P 2RT 60 Curvature: -= -- -= d p (V- b)3 V
By solving eq 2 and eq 3 simultaneously at the critical point, the constants, a and b, can be determined from the critical properties. b = VJ3
(4)
a = 3V,2PC
(5)
In order to use eqs 4 and 5, accurately determined critical properties for the compounds of interest must he available.
The accuracy of the van der Waals equation is a vast improvement over the ideal gas equation; however, a t high pressures the van der Waals equation produces poor results. Theequation hasachieved limited suc& with gas mixtures when a and b parameter3 are considered to he functions of composition. Unfortunately, mixture rules such as these do not work well with highly polar molecules or a t high pressures. Development of more accurate mixing rules for the van der Wads equation have been abandoned and present research is being done only on more modern equations of state. Furthermore, the van der Waals equation of state gives poor estimates when applied to the liquid phase (2). For these reasons, this equation is not often used in design work for chemical processes and often provides the chemist inaccurate P-V-T data. The van der Waals equation does serve as a starting point to develop more accurate equations of state. Unfortunatelv. in manv courses of instruction. the students fail to grasp this point;leave the class confide& in the abilitvof thevan der Waals eauation to~roduceaccurate P-V-T data, and are not even in'troduced to the more modern and often more accurate equations of state. Other Cublc Equatlons Fortunately, a number of cuhic equations of state have been developed that have greatly improved upon the accuracy exhibited by the van der Waals equation. Several of the more modern cuhic equations of state are (1) RedlichKwong (1949) equation (3)
where a and b are functions of the critical properties, (2) Soave-Redlich-Kwong (1972) equation (4)
where a and b are functions of critical properties and a is a function of temperature and the acentric factor, and (3) Peng-Robinson (1976) equation (5) RT p = ----
au
V(V+ b) + b(V- b)
(V- b) where a, b, and a are parameters that are similar to those used in the Soave-Redlich-Kwong equation. Of eqs 6-8, the Soave-Redlich-Kwong equation is reported to be the most general and simple analytical equation of state. I t is particularly useful in estimating vapor-liquid equilibrium properties (6).For these reasons, this equation is recommended for presentation to chemistry students as an example of an equation of state that is being currently used in chemistry and chemical engineering. Example Project To Implement Computer Usage in the Study of Chemistry This article presents one method that allows students to become familiar with the use of modern equations of state and also enhances their understanding of how computers can be used in the study and application of chemistry. The ~roiect. in Appendix 1, has been successfully . as presented . Lseh in the advanced gene;al chemistry and physical chemistry courses. It can he modified to meet the academic hackgroundsof students. For example, the instructor can develop the program and allow student access for performing any calculations that are deemed too time consuming. The primary objective of the project is to force the student to use all available tools in the amlication and studv of chemistrv. In completing the project; ihe student must face up t o thefact that the ideal eas law is onlv a roueh and has - approximation .. limited use at low pressures and normally no use a t high pressures when accurate calculations are deemed necessary. The chemical concept involves the formulation and use of an equation that relates pressure, volume, and temperature Volume 66 Number 3 March 1989
227
for mixtures of real gases. This equation must account for the iutermolecular forces of attraction and repulsion and for the fact the molecules occupy space. The pa;ameters of the equation can he evaluated from critical properties as described earlier for the van der Waals equation or regressed from experimental P-V-T data. For student projects, the experimental data [Cog,CaH,o, Ng, and Ne] found in "P-VT Isotherms of Real Gases" by J. L. Pauley and E. H. Davis (J. Chem. Educ. 1986,63,466) could he used in place of the benzene-propane data in the example project described in A. ~.u e n d i x1of this article. From a mathematical standpoint, the required skill is to be able to obtain a root from a cuhic eauation. The solution for roots of nonlinear equations becomes a trivial matter when there is ready access to computers. Software that solves for roots of nonlinear equationsis commercially available for hoth microcomputers and mainframes. If purchase of commercial software is not desired. the reauiredsoftware can be easily developed by either f k u l t y o; students. Althoueh analvtic eauations are available to solve cubic eauationssuch & the equations of state discussed in this a r t k e , this method is not recommended. A more " eeneral ~ r o c e d u r e is to use one of a variety of numerical root-finding techniques that work with all nonlinear equations, not iust cubic eq"ations. One iuch terhnique is the Newton meth;,d, which is often taught during the first semester of a standard calculus course. Appendii 2 provides the Newton algorithm to solve for the volume in the van der W a d s equation of state. This same algorithm can be similarly implemented when using the Soave-Redlich-Kwong equation of state. If the students have a weak mathematical backeround. other numerical methods such as the bisection or secant method could be substituted. These methods reauire simple - aleebra. Any of the numerical methods can hebriefly outlined in class with a simple example in approximatelv 10 minutes. Once covered, numerical methods-&n be used-whenever the need arises for finding roots of nonlinear equations. This helps the student not only in chemistry, but also in his scientific studies in other courses. If the students have no experience in roer ram mine. ". the instructor can develop software for the students and outline the algorithm and how it works. For microcom~uters.the instructor can demonstrate how to turn the compute; on, how to load the uroeram, and how to execute it. For mainframe computers, simplydemonstrate the log-in procedures and how to load and execute the propram. The Dromam can be one that solves roots of nonlinear equations or can be tailored for a particular equation of state.
.
Appendix 1. Example Computer Project (Equations ol State) Problem Statement You are a chemist for an engineering firm that sells chemical process designs. In a newly designed plant that produces propane, the design process requires that a vapor mixture of henzene and propane enter a holding tank at 477.59 K and 2.829 MPa. The mole = 0.3949. The process fractions are Y L o s = 0.6051 and Y,,,. requires that 100 kg of vapor he held in the tank when operating at steady state conditions. What volume must the tank be? Requirements a. Calculate the required tank volume using the ideal gas law. h. Write a computer program to calculate tank volumes for binary
vapor mixtures. The program should calculate compression factors, volumes, or densities from an equation of state. The campression factor can he used to calculate the volume. Consider the following equations of state: (1)van der Waals (2) Soave-Redlich-Kwang. See Table 2 for information on equations of state. See Appendix 2 for the algorithm to calculate roots of nonlinear equations. c. Calculate the percent error of each volume calculated in parts a Table 2. Equations of State Van der Waals ( R a$ P
p=--- nRT (v-nb) Cubic form:
Required data (n: Benzene a = 18.00i2a1m/ml2 b = 0.11541/ml
Fropne a = 8.664 I2atm/moi2 b = 0.08445 l/mol
Mixing rules ( I @ :
-
Other Computer Appllcatlons in Chemlslry I n physical chemistry, successful use of the computer in the classroom has been achieved in the following areas:
Saave47edlic~Kwongequation of state (6): Cubic form: ZS-Z2+4A-B-84-AB=0
where^=* #r2
B=-
bP
RT
(1) Study of simultaneous chemical reactions in chemical kinetics.
(2) Simulation of separation processes such as distillation that require complex calculations involving- fueacitv - .and activitv coefficients.(3) Molecular orbital calculations in auantum chemistrv. (4) Performing data analysis and plotting. (5) Determination of absolute entropies. (6)Bomb calorimetry calculations. (7) Chemical equilibrium calculations. (81 Physical property estimation. (91 Numerical adutron of d~fferentialequations. (lu) Numerical integratmn. Use of computers in the study and application of chemistry allows coverage of topics that have been previouslv avoided berause of time constraints. The students will hicome familiar with the calrulational and data retrieval power of hoth micro and mainframe computers as they routinely use computers both in and out of class. When relieved of the time constraints of calculations.. suhiect material such as " modem equations of state need no longer be omitted from chemistry courses.
228
Journal of Chemical Education
W I Pikers awnlric factor
W(benrene)= 0.212 W(pr0pane) = 0.152 Mixing rules: m
m
C1
I=,
A=
Y,Y,4,
m = number of
where A@= (1 - kr) @,and compounds
y = mole traction m
B = C ya, -1
Note: For this project set kg = 0
and b. The experimental compression fador equals 0.7339. (7) d. Using the results from the most accurate equation of state, calculate the tank volume.
Appendlx 2. Newton Algorithm To Solve for Molar Volume How To Find Roots of a Nonlinear Equation 1. Using the Newton method (a), the molar volume of nitrogen st 500 K and 100 atrn ia calculated. a. Write a convergence function for the van der Waals equation of state and input a, b, pressure, and temperature. f = Vj - (b
+ RT/P)V + (aIP)V - (ablP)
b. Take the first derivative of the Convergence function with respect to volume.
P = 3 V - 2(b + RT/P)V+
(alp)
c. Newton algorithm: d. The ideal gas law is used to provide the initial Void. e. Check to see if the calculated V, is different from Void by a ,. set margin. If not, let Vdd equal V f. Continue calculating V, until the convergence criterion is met. g. Print the answer,.,V 2. You must check for multiple roots whenever working with cubic equations such as the van der Waals equation of state. The largest r w t will be the vapor phase volume, and the smallest root will be the liquid volume. The intermediate root and any imaginary roots have no physical significance and are discarded.
Example InputIOutput Enter a=1.390 Enter b=0.03913 Enter pressure(atrn)=lOO Enter temperature(kelvin)=500 Molar Volume(cubic dm per mole)=0.41936578 Pascal Version (The van der Wads Equation of State) Program Ideal Gas; Const R : Real=0.0820575; Var - -,-
-.-.., . .-, . -..-, -
-
Procedure van-der-Waaln(Var V,Vl,a,h,P,R,T:Real); Begin 11:=V*V*V-(b+R*T/P)*V*V+(a/P)*V-(aah)/P
12:=3*V*V-2*(b+R*T/P)liV+(a/P); End; Begin (*This is the main program*) clrscr: writeCEnter the value of a:'); read(a); writeCEnter the value of b:'); readln(b); writeCEnter the pressure (atrn):'); readMP); writeCEnter the temperature (kelvin:'):
van_der~~aals(~.~l.a,b,~,~,~); while (abs(V1-V)>O.00001) do begin V:=Vl;
van-der-Waals(V,Vl,a,b,P,R,T);
Newton Algorithm Estimate molar volume of nitrogen a t 500 K and 100 atm.
end; writelnCThe molar volume(cubic dm per mole) is:',V); End.
BASIC Version 10 remProgramto calculate volume usingvander WaalsEquation of State: 20 R=0.0820575 30 def fnf(V)=V*VaV-(b+R*T/P)*VVV+(a/P)*V-(a*h)A' 40 def fnfl(V)=3*V*V-2*(h+R*T/P)*V+(a/P) .. . . 50 input "Enter a=";a 60 input "Enter b=";b 70 input "Enter pressure(atm)="P 80 input "Enter temperature(kelvin)=";T 90 rem Ideal Gas Law provides first iteration value 100 V=R*T/P 110 Vl=V-fnf(V)/fnfl(V) 120 if abs(V1-V)