COM IONAL PHYSICS Fortran V&on
This page intentionally left blank
COMPUTAT S Version
Professor of Theoretical Physics Calvomziainstitute of Rchmlogy
Dawn C. Meredith Assistant Professor of Physics Univmsity of New Ham-pshire
'
A Member of the I'erseus Books Group
L
This book was tmtsset by Elkabeth K, Wmd ushg the 'Q@ &xt-processingsyskm running on a Bigibl Equipment Gomodion n 2@m cornpuk~Camera-read~f i i d COPY ww produced on an Appb WerWrikr. FoElswing is a list ofbadernsks used in tke book: V M , VMsMion, W S , W axe &&emaks af Bi@MEquipment Copoaion.
UES, HCFJIS*** CA-DISSPM is a &&emmk of Computer boci-s In&rn&iond,Enc. W= is a bdernmk ofAT&T. XBM-PC is a. W e m m k of Xnteraliond Bushess Mitchhes, MackWsh is a Wademmk of Apple Compukr,Inc, %Won& 4010 iisla &demwk of%k&anix Enc. GO-235 isa mdentak af Graphon Copomtion. WDS3200 is a trdemwk of Humizn Dwiped Sys&ms. %X is a trMemwk of the A m e ~ c mMahernaied Society. PST is a Wemask sf Mme Computers,Enc. Kermit Isa Mexnwk af Wdt Bisnq &oduc:tiox1s, S;mis a r e g b k ~ d of SW Mcrasp&ms,Inc.
Koonin, Skven E. version) I SWen E. Koonb, Dawn Nereditk. p. cm. Includes index. 3.
physie+D@ processing, 2. Physic+Computer p r a g m s , puter program lmguage) 4. Nume~calmalysis. I, Meredith, Dawn,
IE. Title, Q620.XE4K66 1 M 530.1"W02855133-d~L9 ISBN 0-201-X 2774-2 ( h ~ d ~ ~ e r )
90-129
ISBN 0-201-38623-2 [pperback)
Copyight 8199l)byWestviecvPress, a member of the Per~eusBooks Group All rim& resemed. No part of this text publiatjon may be reproduced, stored in a reeied system,or kansmitbd, in my fom or by my me=, ekc&anic,mechicat, phoacopyhg, recordhg, or o t h e m h , wigbout the prior Wtten permimion of the publisher. Prinkb in the Unikd S b k s ofbefica. Prxblhfied simulkneouslyin CmiltZa, 1 0 9 8 ' 7 6 5 4
Preface
Computation is an integral part of modern science and the ability to exploit effectively the power offered by computers is therefore essential to a working physicist. The proper application of a computer to modeling physical systems is far more than blind "number crunching," and the successful computational physicist draws on a bdanced mix of analytically soluble examples, physicd intuition, and numerical work to solve problems that x e otherwige intractable. Unfortunately, the ability "to computen is seldom cultivated by the stmdard zrniwrsity-level physics crtrri culum, as it requires an inteaation of three disciplines (physics, numerical analysis, and computer programming) covered in disjoint courses. Few physics students finish their undergraduate education knowing how to compute; those that do usually leara a L i ~ t e dget of techniques in the coufse of independent work, such as a research projed or a senior thesis. The materid in. this book is ~ m e d r e f i ~ n geomputationd sEns in advanced undergraduate ar be@nning graduate students by providixrg experimce in using a computer to model physical systems. Its s q e includes the minimam set of numerical techaiques needed to od"' physics" on a mmputer. Each of these is developed In the text, often hmristicdy, and is then applied t o solve non-trivial problems in classical, qnantum, and statisticd physics, The= latter have been chosen to enrich or a t e n d the standard undergraduate physics curriculum, and so haw considerable intrinsic interest, quite independent of the computationd principles they illustrate, This book should not be thought of as setting out a rigid or definitive curriculum. I have restricted its scope to calculations that satisfy simultaneously the criteria of illustrating a widely applicable numerical technique, of being tractable on a microcomputer, and of having some parhicalm physics interest. Several import ant numeric& techniques have therefore been o ~ t t e dspEae , iaterpdatim asld the F a t Fburier Transform among them. Computational Physics is perhaps best thought of as establishing m environment rer ring opportunities for further eqloration. There are =my possible extensions and embelEshmerrts of the materid prescjnted; using mevs iana&nation dong these liaw is one of the mom rewwding parts of working through the book.
C"omp.utat%'onal Pltysz'cb?is primwily a physics text, For xnknrum benefit, the student should have taken, or be taking, undergraduate courses in dwsical meclzanic~,quantum mechanics, stat;jstical mechmics, and advanced cafculus m the mathematical methods of physics. Tbis is slot a text on aurnerical analysis, as there hahs been no attempt at rigor or completeness in any of the expositions of numerical techniques. However, a prior course in that subject is probabb not essential; the discussions of numerical techniques should be accessible to a student with the physics background outlined above, perhaps with gome reference to any one of the excellent texts on numerical andysis (for example, [AC~O], [Bu81], or [Sh84]). This is dso not a text on computer programming. AIthough I have tried to follow the principles of good programming throughout (see Appendix B), there has been no attempt to teach programming per se. Indeed, techniques for organizing and writing code are somewhat peripheral to the main gods of the book. Some familiarity with programming, at least to the extent of a one-semester introductory course in any of the standard high-level languages (BASIC, FORTRAN, PASCAL, C), is therefore essentid. The choice of language invariably invokes strong feelings among scientists who use computers. Any language is, after d,only a mews of expressing the concqts underlying a program. The contents of this book are therefore rdevant no m&ter what lanpae;e one vvorfis in. However, some laneage had to be elrosen to implement the programs, and I have selected the Microsoft dialect of BASIC standard on the IBM PC/XT/AT computers for this purpose. The BASIC language has many well-known deficiencies, foremost among them being a lack of local subroutine variables and an awkwardness in expressing structured code. Nevertheless, I believe that these are more than balanced by the simplicity of the language and the widespread ftuency in it, BASIC'S almost universal avdability on the microcomputers most likely to be used with this book, the existence of both BASIC interpreters convenient for writing and debugging programs and of compilers for producing rapidly executing finished programs, and the powerful graphics and I/O statements in this language. I expect that readers familiar with some other high-level language can learn enough BASIC "on the Ay'' to be able to use this book. A synopsis of the language is contained in Appendix A to help in this regard, and further information can be found in readily available manuds. The reader may, of course, elect to write the programs suggested in the text in any convenient 1anguag;e. This book arose out of the Advanced Computational Physics Laboratory taught to third- and fourth-year undergraduate Physics majors
at Csiltech during the Winter m d Spring of 1984, The content ilnd presentation have benefitted grea;t.ly fram the many inspired suggestims af M,-C. Chtt, V. PGnisc11, R. WiUiarns, md D. Meredith. Mrs. Mereditb wads also af great wsistance in producing the find fom of the mannscript and programs. I. also wish to thank my wife, Laarie, ibr her extraordinary galienct;, anderstanang, and support during my twa-year involvemeat in this project.
This page intentionally left blank
Preface to the FOR
Edition
At the request of the readers of the BASIC edition of Computational Physics we offer this FORTRAN version. Although we stand by our original choice of BASIC for the reasons cited in the preface t o the BASIC edition it is dear that many of our readers strongly prefer FORTRAN, and so we gladly oblige. The text of the book is essentially unchanged, but ofthe codes haw been trmslated into standard FQRTRAN-7had will run (with some modification) on a variety of machines. Although the programs will run significmtly faster on mainframe computers than on PC%$we have not increased the mope or complegty af the calculations. Resdts, therefore, are still produced in "red time'" and the codes r e m ~ n . suitable for interactive use, Another development since the BASIC edition is the publication of an excellent new text on numerical analysis (Nclmerical Recipes [Pr86]) which providecs detajled discussions md code for state-of-th-at dgorithms. We highly recommend it as a compaaion to this text. The FORTRAN versions of the code were written with the help of T.Berke (who designed the menu), G . Buzzell, and J. Parley. We have also profited from the suggestions of many colleagues who have generously tested the new codes or pointed out errors in the BASIC edition, VVe gratefully acknowledge a grant from the University of New Hampshire DIS Covery Computer Aided Instruction Program which provided the initial impetus for the translation. Lastly, our thanks go to E. Wood for typesetting the text in T&jX.
Stevetn E Koonz'n
Pasadeaa, CA August, 1989
Dawn C. 1Medith Durham, NE
This page intentionally left blank
How to Use This Book
This book is organized into chapters, each containing a text section, an example, and a project. Each text section is a brief discussion of one or several related numerical techniques, often illustrated with simple mathematical examples. Throughout the text are a number of exercises, in which the student's understanding of the material is solidified or extended by an andyticd derivation or through the writing and rnnning of a simple program. These exercises are indicated by the symbol m. Also located throughout the text are tables of numerical errors. Note that the values listed in t h a e tables w r e taken from runs udng BASIC code on an IBM-PC. When the machine precision dominates the error, your values obtained with FORTRAN code may diger. The example and project in each chqter are applications of the numericd techniques to particular physical problems. Each includes a brid expmition of Ihe physics, f~llowedby a discussim of how the numericd techniques are "c be applied, The examples and projects diRer mly in that the student is expected to use (and perhaps modify) the program that is @ven for the forxner in Appendix B, while the book provides &uidanee in writing progrms to treizt the latter through a series of steps, dso indicated by the symbol m. However, programs for the projiects have dso b e n included in Appendk C; these can swve as models far the student's o m p r o g r a or as a means of investigating the physics without having to write a major progrm "from ~cratch",A number of susetated studies &ccompany each example and project; these guide the student in exploiting the programs and understanding the physical principles and numerical techniques invdved. The progFrams for b d h the examples and projects are avdfable either sver the Internet network or on diskedtes. Appendix E: describes how to obtain files over the network; &ernativdy, there is aa order form in the back of the book .far IBM-PC or Macintosh formatted diskettes. The codes are suitable for running on any computer that h a a FORTRAM77 standard compiler. (The IBM BASIC versions of the code are also available over the network.) Detailed instructions for revising and running the codes are @venin Appendix A. A "laboratory" format has proved to be one effective mode of presenting this material in a university setting. Students are quite able to
zii
Rout to U@emis Book
m k throagh the text on their w n , with the instmctor being a v d 1 d e for consultation and to monitor prosess t;Broup;h brief personat interviews on each chapter. Three chaptens in teen weeks (60 hours) af instruction has proved to be a reasonal>le pace, with students typicdy writing two
of the p r o j ~ t sduring this time, and usiag the "cmned" codes t s work through the physics of the remaining project a~ndthe examples. The dgkrt chapters in this book should therefore be more than sufficient for a one-semester course. Alterrr;n;tively,this book em be nsed ta provide supplementary material far the usud m r s e s in cla@icat,quantum, and statisticd mechanics. Many of the examples and proJects are vivid ill=tratims of basic concepts in these subjects and are therefore suitable for clasgroom dennonstratims os independeIll study.
Contents
Preface, u
Preface Lia the FORTRAN Editiaa, iz Haw to use this baak, zi Chapter 1: Basic Mathematical Operations, 1 2 -1 Numerical diEerentiatioa, 2 1.2 Nnnterieal quadratwe, 6 1.3 Finding roots, 11 1.4 Sernidz~ssicdquantiz-atioa of molecular vibrations, Project I: Scattering by a central potential, &O
14
Chapter 2: Ordinary DiEerential Equations, 25 2.1 Simple methods, 26 2.2 Multistep and impEcit method@,89 2.3 Range-Kutta methods, $2 2.4 StabiEdy, $4 2.5 Order and chaos in. two-disniensiand zndion, $7 Project 11: The stmcture of white dwmf s t a s , 46 11.1 The equations of eqailibrium, 46 11.2 The equation of state, 47 11.3 S e d i ~ gthe equations, 50 B.4 Solving the equalians, 51
Chapter 3: Boundary Value and Eigenvalue Prablems, 55
3*1 The Numerov dgorithm, 56 3.2 Direct intepatian of boundav value problems, 57 3.3 Green" function solution of boundary value problems, 61 3.4 Eigenvalues of the wave equ;t;tion, 64 3.5 Stittioaary solutions of the one-dimensional Schroedinger equ* tion, 67
ziu
Contends
Project 111: Atomic structure in the Martree-Fa& approximation, Y23 f 11.1. Basis af the Hartre@Fock approximation, 72 IfI,2 The tw-electron problem, 75 112.3 Many-electron systems, 78 If 1.4 S~Ivingthe equations, 80 Chapter 4: Special Functions and Gausshn Quadrature, 85 4.1 Specid funcZlion~,85 4.2 Gaussian quadrature, 9b 4.3 Born and eiXcond qproSrnadions ta quantum scattering, 96 Project IV: Partial wave solution of quantum scattering, 108 IV.1 Partial wave decomposition of the wave function, 109 IV.2 Finding the phase shifes, 104 IV.3 Sdving the equations, 1135
Chapter 5: Matrix Operations, 109 5.1 M;xtrix inversion, 109 5.2 Eigenvalues of a tri-diagonal matrix, 11 2 5.3 &duction to tri-diagond fom, f L5 5.4 Determining nudear charge densities, Id0 Project V: A schematic shell model, 188 V.1 Definition of the model, 184 KZ The exact dgenstates, 196 V.3 Approximat;e eigenstates, 158 V.4 Solving the model, 149
Chapter 6: Elliptic Partial Differential Equations, 145 6.1 Disercdizatian and the varizttiond principle, 24 7 6.2 An idesstiw method for boundav value problems, 151 6.3 More on, discretizatio~,1155 6.4 Elliptic equations in two dimensions, 157 Project VI: Steady-state hydrodynamics in two dimensions, 158 VI.l The equations and their diseretization, 159 VI.2 Boundary conditions, f 68 VI.3 Solving the equations, 166
Chapter 7: Pwrabofie Partial DiEerenlial Eqaatiarzs, 169 7.1 Naive discretiz;ztion and instabilities, l69 7.2 Impficit schemes m d the inversion of tri-diagond matrices, 174 "7.3 DiRusion and boundary value problems in tw dimensians, 179 7.4 Iterative methods for eigenvdue problems, 181 7.5 he time-dependent Schroedinger equation, 186 Prdect VXI: Self-osganizaeion in chemical. rextions, 189 V11.1 Descriptiolz of the model, I89 V"11.2 Lillear st abi2ity andysis, 191 VE.3 Nun2erirzd solution of the model, r"$d Chapter 8: Monte Carto Methods, 197 8.1 The basic Mmte Carlo strategy, 198 8.2 Generating random. variables with a spedfied &&ribation, 205 8.3 The algorithm of Metropolis et al., 210 8.4 The Isiag model in two dimensions, 215 Project VIIZ: Quantum Mm& Cado for the H2mdecule, 221 VIII.1 St&ement of the problem, 231 VIII.2 Variational Monte Carlo and the trial wave function, 288 VIII.3 Monte Carlo evaluation of the exact energy, $85 VXII.4 Solving the problem, 229
Appendix A: How to use the programs, 231 AI Insfaflation, 231 A.2 Files, $32 A.3 CompiZatian, 233 A.4 Execution, 635 A5 Graphics, L97 A.6 P r w ~ a mStructure, $88 A.7 Menu Structure, 259 A.8 Default Value Revision, 241 Appendix B: Programs for the Examples, 849 B,l Example 1, 243 B.2 Exanlplc 2, 256 B.3 Exa~nple3, $73 B.$ Exampks 4, 295 B.5 Exan113le 5, 316 B.6 Exan3ple G, $89
B.7 Example 7, 370 B.8 Example 8, 991
Appendix C: Programs far the Projects, C.1 Project I, 409 6.2 Project If, 421 C.3 Project XII, 4914 C.4 Project W , 454 6.5 Project V, $W C.6 Project, VX, 494 C.7 Project VII, 580 C.8 Project VIfI, @S
Appendix D: Cornman UGilif;y Code@,567 D.1 Standardization Code, 567 D.2 Hardware and Compiler Specific Code, 570 D.3 General Input/oatpu%Codes, 574 D.4 Graphics Codes, 598 Appendix E: NeLwork Fife =ans&r, 681
Index, 631"
The problem with computers is that they only give answers -attributed do P. Picasso
Chapter I
Basic Mathematics Operations Three numerical operations -- differentiation, quadrature, and the finding of roots -are central to mhst computer modeling of physical systems. Suppose that we have the ability to calculate the value of a function, f ( s ) , at any value of the independent variable z. In digerentiation, we seek one of the derivatives of f at a given value of x. Quadrature, roughly the inverse of differentiation, requires us to calculate the definite integral off between two specified limits (we reserve the term "integration" for the process of solving ordinary differential equations, as discussed in Chapter 21, while in root finding we seek the d u e s of s (there may be several) at which f vanishes, If f is knourn mafyticatly, it is almost always possible, with fortitude, to derive expEcit formulas for the defivatives of f , aad it is aften possible t s do so for its degnite integal as well. However, it is often the ease that an m d y t i d method cannot be used, even though pife cm evaluate f (S)itself. This might be either because some very complicated numerid procedure is rquired to e d u a t e f and we have no suitable analytical formula upon which to apply the rules of digerentiation and quadraturn, or, even worse, because the wily we can. generate f provides ns with its values at only a set; of discrete abseissm, In these situations, we must employ qpro&m&e form&% expressing the derjvatives and integrd in terms of the values of f we can compnte. Moreover, the root8 of 41 but the simplest functions cannot be found anatyticdly, and nuzrrericd methods are therefore essentialt. This chapter dealfs d t h the computer redigation of these three basic operations. The centrd technique is to appradmate f by a simple function (such as first- or second-degree polynomial) upon which these
ensue
2
2. Basic Mathematical Qpervrdians
Figure 3.1 W u e s of f on an equdEy-spud ladtice. Dmhed lines how the hear interpslalion.
operaLioas caa be performed easily, We will derive only the Simpleet and mo& commonly used fomdas; fufbr treatments can be h n d in many textbooks an nmericd andysis.
1.l Numerical diEerentiatiolz Let us suppose that we we interested in the derivative at z = 0, f'(0). (The formulas we will derive can be generalized simply to arbitrary z by translation.) Let us also suppose that we know f on an equally-spaced lattice of z vdnes,
and that our god is to compute an approximate value of fE(0)in terms of the f, (see Figure 1.1). We begin by using a Taylor series to expand f in the neighborhood
whem all derimtives are evduated at z = 0. It is then simple to verify that
where O(h4) means terms of order h4 or higher. To estimate the size of such terns, we c m assume that J and its derivatives are aJ1 of the same order of magnitude, as is the case for many functions of physical rdemnee. from f i as given by (1.2a), we find, after a Upon subtracting sEght rcjarrangea;lc?n%,
'
The term involving f f N vanishes as h becomes small and is the dominant error associat;ecl with the finige dfference q p r o ~ m i t t i mthat Tetijtin~mly the f i r ~ term: t This "%point" formula would be exact if f were a second-deetje poly~omid in the 3-point interval [-h, +h], because the third- and all higherorder derivatives would then vanish. Hence, the essence of Eq. (1.3b) is the assannptian that a quadratic p o l y n o ~ dinticrrpolatiofi of f throu& the thrw points z = &h, O i s v&d. Equation (1.3b) is a very naturd result, reminiscent of the formulas used to define the derivative in elementary calculus. The error term (of order h2)can, in principle, be made as small as is desired by using s m d e r and smder d u e s of h. Note also that the 8ynmetric difirence about z = O is used, as it is more aecurate (by one order in h) than the forward or badward CliRerenm form~las:
These "2-pointw formulas are based on the assumption that f i s well agproSma2ed by a fineas fanctian over the intervds between z = O and z = &h* As a concrete example, consider evaluating ff(z = 1) when f (g) = sin 2. The exact answer is, of course, cos 1 = 0.540302. The following FORTRAN program evaluates Eq. (1.3b) in this case for the value of h input:
4
1. Basic Mathemalical Operations
FRIlT
10
READ
* , %HT=
*,
VALUE OF ft
C. LE,
O
TO STOP)
WI
IF (B .LE, 0) STOP F P R ~ E = ( S X(x+E>-SXN(X-B] W >/(2*~> DIW=EXACT-FPRIME PRTMT 28,W,BIFF
FOMAT(~=',Elb.$,5X,%MOR=~,E1668) GOT15 10
20
ElD
(If you are a beginner in FORTRAN, note the way the value of H is requested from the keyboard, the fact that the code will stop if a nonpositive d u e of R is entered, the natural way in whi& variable names are chosen and the mathematical formula (1.3b) is transcribed using the SIN function in the sixth line, the way in which the number of significant digits is specified when the result is to be output to the screen in line 20, and the jump in program control at the end of the program.) Result8 generated urlth this progrm, as W& as with s i d a r ones evaluating the forward and backward difference formulas Eqs. (1.4a,b), are shown in Table 1.1. (AU. of the tables of errors presented in the text wre generilted f f ~ mBASIC progras; the numbers may vary from those obtdned from FQRTRATJ code, especidy when numerical roundoff dominates.) Note that the result improves as we decrease h, but only up to a point;, after which it becomes worse, This is because arithmetic in the computer i s performed with only a limited precision (5-6 decimai digits for a single precision BASIC variable), so that when the difference in the numentor of f;he appro~mafsionsis formed, it is subject to large "roundoff" erfors if h is smdl and fi and diger very little. For example, if h = 10-7 then f2
= sin (1.000001) = 0.841472 ; f-l = sin (0.999999) = 0.841470 ,
so that fi -lml= 0.000002 to six significant digits. When substituted into (1.3b) we find f t m 1.000000, a very poor result. However, if we do the arithmetic with 10 significant digits, then
which gives a respectable f' rr: 0.540300 in Eq. (1.3b). In this sense, numerical differe~ltiationis an intrinsically unstable process (no well-defined limit as h --+ 01, aud so must be carried out with caution.
Table 3.1
h 0,50000 0,20000 0,10000 0,05000 0.02000 0.01000 0,00500 0.00200 0,00100 0,00050 0,00020 0,00010 0.00005 0.00002 0,00001
Error in cvduating d;sin t / d ~ l ~= =0.5403@ ~
S ~ e ( ; r i e Forward
Bsckwd
%point $point Eq. (1.3b) Eq. (1.4a) 0.228254 0.022233 01003595 0,087461 0.042938 0,000899 0,021258 0.000225 0.008453 0.000037 01000010 0,004224 0,0000X0 0,002108 0,000820 -0,000014 0,000403 -0,000014 0,000403 0,000105 -0,000163 -0.000014 --0.000312 -0.000312 0.001476 0.000284 0,000880 0,000880 01000880 0.003860
2-point Eq. (1.4b) -0,183789 -0.080272 -0,041139 -0.020808 -0.008380 -0,004204 -0,002088 -0.000848 -.0.000431 -0.000193 -0.000312 --0,000312 -0.00090Zf 0.000880 -0,002100
Symmetric &point Eq. (1.5) 0,001092 0.000028 0.000001 0,000000 0.000001 0.000002 0.000006 -0,000017 -O.O00019 0.000115 -0,000188 -0.000411 0.000681 0.000873 0,000880
It is poasible to improve on the Spoint formula (1.3b) by rdating f to lattice points fnrther removed from z = 0. For example, using Eqs. (1.2), it is easy to show that the U5point" f o d a
caneels dl derivatives in the Taylm series through fourth order. Computing the derivative in this way amumee that f is well-appdmated by a fonrth-degree polynomial over the &point !interval [-21r,2h]. Although reqniring more computation, this approximation is considerably more aecurate, as can be e e n from Tabfe 1.1. In fact, an curacy earnparable to Eq. (1.3b) is obtained with a step some 10 times larger. This ean be an important eonsideration when many d u e s of f must be stored in the computer, as the greater accnracy dows a sparser tabnlatibn and so saves storage space. However, because (1.5) requires more mathematical operations than does (1.3b) and there is considerable urncellation among the varions terns (they have both positive and negative coefficients), precision p m b l ~ mshow ~ up at a larger value of he Forrndit8 for higher derivatives can be conatnrcted by taking appro-
6
l. Basic Mathematical Ogrzrations
Table f .2 4- and S-pint BiRerence: formulas for de~vativw
priate combinations of Eqs. (1.2). For example, it is easy to see that
so that an appraximation to the second derivative accurate to order h2 is
DiEerence formulm for the various derivative^ of f th& are accurate to a higher order in h can be derived straightforwardly. Table 1.2 is a summary of the 4 &ad5-pdnt ewressiaas. Using any function for which you can evduate the derivatives analytically, investigate the accuracy of the formulas in Table 1.2 for various vdues af h. Exercise 1.1
1.2 Numerical quadrature In quadrature, we are interested in calculating the definite integral of f between two limits, a < b. We can easily arrange for these values to be points of the lattice separated by an even number of lattice spacings; i.e.,
is an even integer. It is then sufident for us to derive a formula for the integral from -h to +h, since this formula can be composed many times: a+2h
b
f (s)dz =
f (4
+
a+4h
f(.)dz
+ + * *
*
f (462%
*
(1.8)
The basic idea &hind all of the quadrature formulas we wilI discuss (technically of the closed Newton-Cotes type) is to approximate f between -h and +h by a function that can be integrated exactly. For example, the simplest approximation can be had by considering the intervals [-h, 01 and [O, h] separately, and assuming that f is linear in each of these intervals (see Figure 1.1). The enor made by this interpolation is of order h2f ", so that the approximale iate& is
which is the weU-known trapezoidaf rule. A better approximation can be had by realizing that the Taylor series (1.1)can provide an improved interpolation of f. Using the difference formulas (1.3b) and (1.7) for f' and f",respectively, for 1s put
which can be intepated readily ta give
This is Sinnpsonk rule, wEch em be seen to be accurate to two orders higher than the trapezoidd rule (1.9). Note that the error i s actually better than would be expected naively from (1.10) since the x3 term gives no contribution to the integral. Composing this formula according to Eq. (1.8) gives
As an example, the following FORTRAN program calculates 1
e"dz = e - I = 1.718282
using Simpson's rule for the value of N = llh input. [Source code for the lmger program like this that are embedded in the text are cont;ained m tbe Gmplubats'oncrl Phgaics diskette or avdlabIe over Xaterne~, (see Appendix E); the shorter codes can be easily entered into the reader's computer from the keyboard.]
8
I , Basic Mathematical QpraEdons C chaplb.rS"or m C ( X ) =EP(X) E X A ~ = E ~ (1-2, I.
30
*
!Sact;ion t o ia%epat e
PRZRT ,"ETER I EVm ( ,LT, 2 B ' 3 STIZP) Rm*,1 ZP (1 .LT. 2) SmP IF (NOD(1,2) .HE. 0 ) I=@+$
E=%./#l
.
S W = m C( 0 ) FAC=2 DO 10 X = l , W - I f F (FAC .Eq, 2.) T H D
@
!contribation from X=O !factor for Siapson% rule !loop over Xattice paints ?factors altemage
FAG4 ELSE: FAC=2.
m
IF X=S*LI 10
SW=Sm+FAG*mC(X) COrnICrnE S W = S ~ +(1~,)C XXBfT=Srn*H/3.
!X at thfe point
icontribution t o the fntegsa2 ?contribatioa fron X=%
L)I~=~AC*I"-XZIIT
PRIBT 20,I,DIW 20
FO~AT(6X,i#=i,XS,6X,8~WR=\ElEi.Ef) 60TQ 30 !get motker v a u a oQ I
EED
Resdts are shown in Table 1.3 for variaus d m s of N , together Prith the v d w s obtained nsine; the trapezoidd rule. The improvement from the kigber-order f a m d a i s evident. Note that the resdts are skabltj in the sense that a wdI-dehed limit is obt~xredas N becomes very lztrge and ths! mesh spacing h becams @m&; round-aff arms me unimportant because dl vdue8 of f enter irzte, the quadratare formda Pvith the same s i p , in corrtrast to what happens in numerical diRert?ntiation, An important issue in quadraturn is how s a d an h is necessary to compute the integral to a Egiwn accuracy, Although it is passible to derive rigorous error bounds for the formulas we have discussed, the simplest thing to do in practice is to run the computation again with a smaller h and ob~ervethe chmges in the results.
Table 1.3
Errors in evaluating
1
eZdz = 1.718282
W, ~
N 4
8 16 32 64
h 0.2500000 0.1250000 0.0625000 0.0312500 0,0156250
Trapezoidal Eq. (1.9) -0,008940 -0,002237 --0.000559 -0.000146 -0.000035
~
Simpson's Eq. (1.12) --0.000037 0.000002 0.000000 0.000000 0,000000
Bode's Eq. (1.13b) -0.00QO01 0.000000 0.000000 0.000000 0.000000
Higher-order quadrature formulas can be derived by retaining more terms in the Taylor expansion (1.10) used to interpolate f between the mesh points and, of course, using commensurately better finite-difference approximations for the derivatives. The generalizations of Simpson's rule using cubic and quartic polynomials to interpolate (Simpson's $ and Bode's rule, respectiveb) are:
The! results olE applying Bode's rule are &so @venin Table 1.3, where the improvement is evident, afthough a;t the expense of a more involvt3d computation. (Note that for this method to be applicable, N must be a multiple of 4.) Although one might think that formulas based on interpolation using polynomials of a very high degree would be even m r e suitable, this is not the cme; s;u& pdpornids tend to osciUate vidently and lead go an inaccurate interpolation, Moreover, the coefFicients of the vailues of f at the vaious lattice paints em have both positive aad nega i v e signs in higher-order farxnulas, maEng rouad-oE error a potentid problem. It is therefore usually safer to improve accuracy by using a low-order method and making h smder rather than by resorting to a higher-order formula. Quadr ature formulas accurate to a very high order cm be derived if we give up the requirement of equdlycspaeed abscissae; these are discussed irr Chapter 4. Exercise 1.2 Using any function whose definite i n t e p d you can compate anitlytically, investigate the acuracy of the mrious guadrat;ure nreth-
m
10
d . Ba@ie IkPh&ematieol Operations
ads discussed above far aBerent vdaes of h, Same care and G on sense must be! exerciwd in the wpfication of the numericat quadrature formulas discussed above. For example, an integral in which the upper limit is very large is best handled by a change in vaiable. Thus, the Simpsonk s l e eduation of
with g(z) constant at large z, would result in a (finite) sum converging very slowly as b becomes large for fixed h (and taking a very long time to compute!). However, changing variables to t = r -l gives
whi& can then be evdualed by any of tlne formulas ure hwe discnssed. Integrable sinmlar4tiies, vvhich caase the naive Ibrmdas "co give nonsense, can dso be hmdled in a simple way. For example,
has an integrable singularity at = 1 (if g is regular there) and is a finite number. However, since f ( z = 1) = m, the quadrature f o m d a s &scussed above @v@an infinite result, An accurae result can bc? obtained by changing variables to t = (1- z)'i2 to obtain
which is then approdmated vvith no trou'ble. Integrable singularities can also be handled by deriving quadrature formulas especidy adapted to tl~em,Sunpose we me intefested in
where f (2)b e h m s as Cs-'I2 near 5 = O,with C a.constan%.The integral from h to 1 is regular and can be handled easily, while the integral from O to h can be approximated as 2ch'I2 = 2hf (h). IN
Exweise 1.3
M"fite a program to calculate
%singone of the quadraturn formula8 diswssed above and investigate its accuracy for various values of h. (Hint: Split the range of integration into tvm parts and make a agerent dhange of variable h each integral ta handle the siagufafities.)
1.3 Finding roots The find deznentary operation that is commmly mqnired is to find a root of a function f that we can compute for arbitrary z. One surefire method, when the appraxim;bte location of a root (say at I = %@) is known, i s to guess a trial value of z guaranteed to be less than the root, and then to inerease this trM d u e by smdl positive steps, backing up and halving the step size every time f changes sign. The values of x generated by this procedure evidently converge to $0, so that the search can be terminated whenever the step size falls helm the mqnired talefance, Thus, the fanowing FORTRAN proe;rano finds the positive root of the function f (g) = z2 - 5, 50 = = 2.236068, to a. tolerance of 1 0 ~ ~ using z = f as an initid guess and m initid step size of 0.5: C
ch&plc.for FWCCX) =X*X-5, TOLX=1,E-OB
!fmction wkosa root i s sought !toleruce fox %hiesewch !inf.lsia guess l initf a i l i m c f i o n ? i n i t i d step ! i n i t i a i z s come
X=%.
FOD=WBC(X)
.
DX= fr
ITER=@ 10
COaTSME XmR=SITm+I X=X+E)X PRIIT *,XTER,X,SQET(&,)-X
IF ((FQm+FWC(X))
.LT. 0) TZfEg ! f f sign change, back up
X=X-DX xlX=DX/Z
EID SF IF (ABSCDX) STOP EHD
!increfaen* iteration, corn$ !step, X !ou.lspat cummt values
! arrd havet the attap
.GT. TOLX) GOTO 10
Results far the sequence of z d u e s me shown in Table 1,4, evidently convergiatg to the correct answer, dthough orrly after some 33 iterattions. One must be careful when using this method, since if the initid step size I
Table 2.4
Iteration
Error in finding the pwitivr: root o f f (z)= z2 -- 5
Sear&
Hewton Eq. (1.14)
Secant Eq. (1.15)
if3 too large, it is possible ta step over the root desimd when f has several. roots, r Exercise 1-4 &an the code above far vmious t~lermces,irr;itid
guesses, and ini.t;id ~ t e psizeis. Note that sometimes you might find convergence to the negative root. What happens if you start with an initial gGess of -3 with a step ~ i z eolt 6?
A more efficient algorithm, Newton-Raphson, is available if we can evaltuate the derivative of f for ubitrary a. Tfiis method generates a sequence of values, g', eonverljng to zo under the assumption that f is locally linear near $0 (see Figure 1.2). That is, l
f (g') f '(S')
'
is also shown in Table 1.4, The application of this method to finding where the rapid convergence (5 iterations) is evident. This is the algorithm usually used in the computer evaluation of square roots; a linearization of (1.14) about shows that the number of significant digits doubles tvith ea& itmation, as is evident in Table 1.4. The secant method provides a happy compromise between the eg ficiency of Newton-Raphson and the bother of having to evduate the de~vative.If the derivative in Eq. (1.14) is approximated by the differ-
F i v e 1.2
Geometrical bases of tbe Newton-Rrtphm (left) and se-
cant (fight) methods.
ence formula related to (1.4b),
we obtain the following 3-term I' and zi-l (see Figure 1.2):
recursion formula giving S'+' in terms of
Any two approximate values of $0 can be used for +@ and s ' to start the algorithm, which is terminated when the change in z from one iteration to the next is less than the required tolerance. The results of the secmt method for our model problem, starting with values z0 = 0.5 and z' = 1.0, m also s h w a in Table 1.4, Prcrvided that the initid gue8s;aes ase dose to the true root, convergenm to- the exact answer is dmast as rapid as that of the Newton-Rapksan dgorithm,
Exercise 1.5 Write programs to solve for the positive root of sZ- 5 using the Newton-Raphsan a d secant methods. Invwtigate the behavisr of the latter vvith changes in the initial guesse~for the rmt.
D
When the function is badly behaved near its root (e.g., there i s m inflection point near so)or when there are several roots, the "automatic" ME?wt;on-Raphsonafld secant methodts can fail to converge at dl m converge to the wrong mswer if the initid guess for the root is poox. Henee, a safe and conservative procedure is to use the seaeh dgorithm to loe&e $0 a p p ~ o ~ m a t e and l y then to uae one of the wtomatic meehods.
14
1. Basic Mathernatiurl Qperatians
Exercise 1.6 The function f ( s ) = tanh z has a root at + = 0. Write a p r q r m to show that the Newton-Rqhson method does not co~verge for an iaStid gueshi of z X l. Cm you understand what's going wrong by considering a graph of tanh I? From the explicit form of (1.14) for this problem, desive the critical value of the initid guess abave which coavergence will not occur, Try to solve the problem using the secant method. m a t happens for vmious initial guesses if you try to find the z == O mot of tan z usiw either method?
1.4 Semiclassical quantization of molecular vibrations As an =ample combining several basic mathematicall operations, we consider the problem of describing a diatomic molecule such as 02, which wnsists of two nuclei bound together by the electroas that; orbit about them. Sinm the nnclei are much heavier than the electrons we czm assume that the latter move fat enough to readjust inst;arrtmeously to the changing position of the nudei (Born-Oppenheimer approximation). The problem is therefore reduced to one in which the motion of the two nudei is governed by a potential, V, depending only upon r , the distance between them. The physical principh mspmsibb for generating V will be discussed in detair in Project VIII, but on generd grounds one c m say that the potential is attractive at large distances (van der W d s interaction) and repulsive at short distances (Coulomb interaction of the nuclei and Pauli repulsion of the electrons). A commonly used form for V embodying these features is the Lennard-Jones or 6-12 potential,
which has the shape shown in the upper portion of Figure 1.3, the minimum occurring at rmim= 2'j6a with a depth %. We will assume this form in most of the discussion below. A thorough treatment of the physics of diatomic molecules can be found in [He501 while the Born-Oppenheimer approximation is discussed in [Me68]. The great mass of the nudei allows the problem to be simplified even further by dewupling the slow rotation of the nuclei from the more rapid changes in their separation. The former is well described by the quantum mechanical rotation of a rigid dumbbell, while the vibrational states of relative motion, with energies E,, are described by the bound
Fignre 1.3 (Upper portion) The Leaamd-Janes potentrid and the inner and outer turning point8 kLt, a neg&ive energy. The &;take&tine show8 Ch~fp~rabolicapproxhation to the potential, (Lawer parlion) The corresponding trajectory in ghatcie spwe.
state solutions, +%(F), of a one-dimension$ Schroedinger equation,
Here, m i s the r f ~ d ~ mws ~ e d of the two nucfei, Our ~ ain. l this exampb i s to find tht! enerdes E,, given a particular potential. This can be done wwtly by salving the &Rerentid eigenvdue equation (1.17); numerical methods for doing so will be discussed in Clrapter 3. Hawever, the great mass of the audei. implies that their motion i s neafly dasical, so that approdmate values of the vibrationd ener@es cE, can be obtaliwd by conrjidering the clmsieal motion of the nuclei in V and then applying '"quantization ruks" to d e t e r ~ n e the energies, These quantizatio~rdes, origindly postulatd by N. Bobr and Sornrnerfeld and Wilson, were the bwis of the "old" quantum tbwry
I6
1. Basic XkialFhematiml Operations
from which the modern formulation of quantum mechanics arose. However, they can also be obtained by considering the WKB appraximation to the wave equation (1.17). (See [Me681 for details.) Confined dassical motion of the internudear separation in the potential V(7) can occur for energies -Vo < E < 0. The distance between the nuclei osdllates periodically (but not necessarily harmonically) between as shown in Figure 1.3. Durinner and outer turning points, q, and rout, ing these oscillations, energy is exchanged between the kinetic energy of relative motion and the potential energy such that the total energy,
is a constant (p is the relative momentum of the nuclei). We can therefore think of the oscillations at any (jven energy as defining a dosed trajectory in phase space (coordinates r and p) along which Eq. (1.18) is satisfied, ab; s h m in the lower portion of Figzlre 1.3, An explieit eqnaLim for this trajectory can be obtained by solving (1.18) for p:
The classid motion desaibed above occurs at any enerw between. 0. To qnmtize the motion, and hence obtain approximations to the eigenvdues E, appearing in (1.IT), we consider the dimensionless action at a, @ven energy,
-6 a;nd
where k ( r ) = h-lp(r) is the local de Braglie wave number and the integral is over one complete cyde of oscillation. This action is just the area (in units of h) enclosed by the phase space trajectory. The quantization rules state that, at the allowed energies E,, the action is a hdf-integral multiple of 2a. Thus, upon using (1.19) and recalling that the oscillation passes through each value of r twice (once with positive p and once with negative p), we have
where n is a nonnegative integer. At the limits of this integral, the turning points Q, and rout,the integrand vanishes.
To specialize the quantization condition to the Lennard-Jones potential (l.16), we define the dimensionless quantities
so that (1.21) becomes
is the scded potentid. The quantity 7 is a dimensionless measure of the quantum nature of the problem. In the dassical limit (a small or m large), 7 becomes large. By knowing the moment of inertia of the moleeule (from the energies of its rotational motion) and the dissociation energy (energy reqnired to separate the molecule into i t s two constituent atoms), it is possible to determine from observation the parameters a and 'Vo and hence the quantity 7. For the H2 molecule, 7 = 21.7, while for the HD molecule, 7 = 24.8 (only m, but not h,changes when one of the protona is replaced by a deuteron), and for the much heavier O2 molecule made of two lBO nuclei, 7 = 150. These rather I q e vdues indicate that a s e ~ c l u s i c d appro~xnationis a valid dwcription of the vibratianal motion. The F O R T U N program for Exmple 1, whose source code is cantained in Appendix B asld in the file EXMPLI.FOR, findg, for the d u e of y input, the values of the E, for which Eq. (1.22) is satisfied. After all of the ener@eshave been h n d , the corresponding phase pace trajwt* ries we dram. (Befora attempting to gun this code on yovr camputer syaern, you should review the m&t3rid on the progrms in ""Howto use this book" and in Appendix A.) The following exercises are aimed at increasing yovr undemtmding of the physical principles and numerical. methods demonstrawd in this example. Exwcise l.'? One of the most important aspects of using ie computer a tool to do pbysics is knovving when to have confidence that the program is giving the correct answers. In this regard, an egsential teat ia the d e t ~ l e dquantitative comparison of results urith what is known in =a'lytieaffy soluble situations. Modify the code! to use a pasabotic potential
m
;as
18
1. Basic Malhematic-al Operations
(in subroutine POT, taking care to heed the instructions given there), for which the Bohr-Sommerfeld quantization gives the exact eigenvdues of the Schroedinger equation: a series of equdly-spaced energes, with the lowest being one-half of the level spaeing above the minimum of the potentid. Far sever& vdues of 7, compare the numerical resalts .for this case with what you obtain by solving Eq. (1.22) a n e t i c d y . Are the phase spwe trajectosies what you eqect? Exercise L8 Another important test of a- working code i s to compare its results with what is expected on the basis of physical intuition. Restore the code to use the Lemard-Jones potential and run it for 7 = 50. Note that, as in the case of the purely pmabolic potentid discussed in the previous exerdse, the first excited state is roughly three times as high above the bottom of the well as is the ground state and that the spacing8 between the few lowest states are rougllly constant. This is because the Lennard-Jones potentid is roughly parabolic about its minimum (see Figure 1.3). By calculating the second derivative of V at the minimum, find the ""spriag conatat" and show that the fi.equency of small-amplitude motion is expected ta be:
B
Verify that this is wnslstent with the numerical resuks and explore tbis agreement for different values of y. Can you understand why the higher energies are more densely spaced than the lower ones by comparing the Lennard-Jones potential with its parabolic approximation?
=
Exwcisos %.Q bvwiance of results under changes in the numerical algorithms or their parameters can give additional confidence in a calculation. Change the tolerances for the turning point and energy searches 'be done at mn-time or the number of Simpson's rule points (this by choosing menu option 2) and observe the effects on the results. Note that because of the way in which the expected number of bound states is calculated (see the end of subroutine PARAM) this quantity can change if the energy toferance is vwied.
Exareise 1.10 Replace the searches for the inner and outer turning points by the Newton-Raphson method or the secant method. (When ILEVELZ 0, the turning points for ILEVEL - l are excellent starting values.) Replace the Simpson's rule quadratare for s by a higher-order formula [Eqs. (l.13a) or (1.13b)I and observe the improvement.
B
Table 1.5
Experiment& vvibraLional energi~af the E2 molecule
Exercise 1.1% Plot the E , of the Lennard-Jones potential as functions of 7 for 7 running from 20 to 200 and interpret the results. (As with many other short calculations, you may find it more efficient simply to run the code and plot the results by hand as you go along, rather than trying to automate the plotting operation.)
r
Exercise 1.12 Fbr the Hlz mofecufe, observations show &at the depth of the potedial is 6 == 4.747 elf and the location of the pdentid minimum is Tmjn = 0.74166 A. These two quantities, together with Eq. (1.23),
imply a vibrationd frequency of mare t h m four times lager t h m the experiraentdly absemed energy difference between the ground and first vibrationd state, 0.525 eV. The Zennard-Jones shillpe is therefore not a very good description of the potentid sf the Hz molecnk. Another defect is that it predicts 6 h a n d states, while 15 are known to exist. (See Table 1.5, whose entries are derived from the data quoted in [Wa67].) A better andytic form of the potentid, with more parametws, is required to repmduce gimdtaneou6ly the depth and location of the minimum, the frequency of smaU amplitude vibratians about it, and the total number of bound states. One such fom i~ the Morse potentid,
which &so C= be ~olvedanalyticrzlly. The Marse potentid has a minimum a;t the expected locat;ian a d the parameter P can be a u s t e d to ht the curvature of the miaiI-nurn to the observed excitatioa enerw of the first
2Q
l. Basic Mathematical Qperatians
Figure X,% Quantitim involved h the krcatte~i~g of a particle by central patentid.
a,
vibrational state. Find the value of P appropriate for the Hz molecule, modify the pf~gramabove to use the Morm potent;iaI, and cdcdate the spectmm of vibrational statas. Show that st much more reasonable nu=ber of levels is now obtained. Compare the energies with experiment and with those of the Lennard-Jones potential and interpret the latter digererrces.
Project I: Scattering by a central potential h this, project, urt; uriU investigate the dassical scattering of a particle of mms nz by a centrd poteatid, in particula the Lennad-$ones potentid c0nsiderci.d in Section 1.4 above, h a scattePing event, the partide, with. initial kinetic t?nergy E z~ndimpact parameter b, approaches the potential from a large distance, It is deflected during its pasage n e a e h force center and eveatudy emergee with the same enera, but moving at an. angle O with respect to its original direction. Since the potentid depends ' upon an& the distance of the partide fronn the force center, the aagular momentum is conserved and the trajedory Lies in a plane. Thcr pdar coordinates of the partide, (P,@), are a convenient way to describe its motion, as shown in Figure 1.1. (For details, see any textbook on dasdcal mechanics, such M [Go80].) Of basic interest is the deflection function, O(b), giving the final scattering angle, 0,as a function of the impact parameter; this function also depends upon the inddent energy. The differential cross section for scattering at an angle 0, do/dQ, is an experimental observable that is
related to the defiection function by
Thus, if dOldb = (dbldO)-l can be computed, then the cross section is known.. Expressions for the deflection function c m be found analytically for only a very few potentials, so that numerical methods usually must be employed. One way to solve the problem would be t o integfate the equations of motion in time (i.e., Newton's law relating the acceleration t o the force) to find the trajectories corresponding to various impact parameters and then to tabulate the final directions of the motion (scattering angles). Tbis would involve integrating four coupled first-order differential e q u a tions Eos two coordinates and t h i r velocities in the scattering plane, discussed in Section 2.5 bebw. However, since a n p l a r rxramerrtum is conserved, the evdution of B is related dire6tly to the radial motion, and the probhrn can be reduced to a one-dimensiond one, wEch can be s d v d by quadratare. This fatter approach, which i s simpler and more accurate, is the one we will, pursae here. To d e ~ v an e clbppropriaGe expression for 8 , we begin vvjth the conservation of arrgular momentum, which implie8 &hat
is a constant o-f the motion. Here, dB/& is the augtrlas velocity and v is the asymptotic velocity, related to the bombarding energy by E = i m v 2 . The radid motion owurs in an eRective potentid th& is the sum of V and the centrifugal potential, so that energy conservation implies
If we use
F
as the independent variable in (1.21, rather than the time, we
can write
t yields and salving (1.3) for d ~ / o t thrtn
22
2 . Basic Mathematical Ofterations
Recalling that 0 = n when r = oo on the incoming branch of the trajectory and that B is always decreasing, this equation can be integrated immediately to give the scattering ande,
where r,i. is the distance of closest approach (the turning point, determined by the outermost zero of the argument of the square root) and the factor of 2 in front of the integral accounts for the incoming and outgoing branches of the trajectory, which give equal contributions to the scatterixlg angle. One find transformation is useful before beginning a numerical calculation. Suppose th& there exist8 a distmce rr,,, beyond which vve can safely nedect V. In this case, the integrand in (1.6) m i s h e s as T - ~for large r , so that numericd quadrature could be very ineRcient. In fact, since the p o t e ~ t i dhap aa eEect for r > rm,, , we would just be "wasting time" "describing stra;igJRt-line nrotisn, To hanae this situation &cientXy, note that since 63 = O when V = 0, Eq. (1.6) implies that
which, when substituted into (I.6), results in
The integrals here extend only to rm,, since the integands becme equd when T > Our goal will be to study scattering by the Lennard-Jones potential (1.16), which we can s a f e set to zero beyond P,,, = 3a if we are not interested in e n e e e s smaller than about The study is best done in the hlloMring sequence of steps: Step 1 Before beginning any numerical computation, it is important to have some idea of what the results should look Like. Sketch what you think where the the deflection function is at relatively low energies, E 6 will take place in a predominantly peripheral collisions at large b 5 ,,F at tractive potential and the more central collisions will LLbounce"against the repulsive core. What happens at much higher energies, E > Vo,where
1. Scattering by( a cent& potential
the attractive pocket in V can be neglected? Note that for values of b where the deflection function has a maximum or a minimum, Eq. (1.1) shows that the cross section will be infinite, as occurs in the r&nbow formed when light scatters from water drops. Step 2 To have analytically soluble cases against which to test your program, calculate the deflection function for a square potential, where V ( r )= U. for r < Fmax and vanishes for r > r,,,. What happens when U. is negative? What happens when U. is positive and E < Uo? when
E > U@?
Step 3 Write a program that calculates, for a specified energy E, the deflection function by a numerical quadrature to evaluate both integrals in Eq. (1.8) at a number of equally spaced b values between O and F,,. (Note that the singularities in the integrands require some special treatment .) Check that the program is working properly and is accurate by cafculating deflection functions for the square-well potentid discussed in Step 2. Campwe the accuracy with that of asl dterndive procedure in which the first intepal in (1.8) is evdaated andytiea;lly5rather than mmeri cdy. Step 4 Use your propam to cdc.ulilLee the degection function far scattering from the Lennard-Jones potential at selected values of E ranging from 0.1 to 1 0 0 h . Reconcile your answrs in Step I with the result8 you obtGn. Calcu1;at;e the diflerentid cross section as a function of @ at these energies. Step 5 E your progrm is working comectly, ycru &odd observe, for ener@w E K t a siqulmity in the deflection function whese O appeaas to apprawh -m at some critical vdue of b, brit,that depends on E. This singularity, which disappears when E becomes larger than about V@, is characteristic of Uorbiting." In this phenomenon, the integrmd in Eq. (1.6) has a linear, rather than a square root, singularity at the turning poiat, 80 thitt the scattering aggle becomes logiurithrnically iagnite. That is, the eEective pohential,
has a parabolic maximum and, when 6 = bcrit, the peak of this parabola is equal to the incident energy. The trajectory thus spends a very long time at the radius where this parabola peaks and the particle spirals many times around the force center. By tracing bcrit as a function of energy
23
24
1. Basic Mathematical Operations
and by plotting a few of the effective potential8 involved, convince yourself that this is indeyed what's happening. Determine the x n ~ m u a ne n e r far ~ vvbich the Lennard-Jones potenkid exhibits orbiting, either by a d u t i o n of an agprcfpriate set of equatons invalviag Y and its derivatiw~ar by a systematic numerical investiwtion of the deflection function. If you pufsue the latter approach, ysu Iulight have to reemider the treatment of the aingdafities in %he numerical. quadratures.
Chapter 2
Ordinary Differentia Equations Many of the laws of physics are most conveniently formulated in terms of differential equations. It is therefore not surprising that the nurnericd sdution af differentid equations is one of the mast common tasks in modeling physicd systems. The most general form of an ordinary differentid equation is a set of M coupled first-order equations
where is the independent variablt? and y is a set of M dependent variables (f is thus an M-component vector). Differentid equations of higher order can be written in this first-order form by introducing auxiliary functions. For example, the one-dimensional motion of a partide of mws m under a force field F ( z ) is described by the second-order equation
If we define the morne~rtum
then (2.2) becomes the two coupled first-order (Hamilton's) equations 0% P ~~~
dt
.
nz "dt
*
= F(z),
which are in the h r m of (22). It is therefore suficient ta ccznsjdes in detGl anly nnetlrods for first-order equations, Since the matrix structure
of coupled differential equations is ofthe most natural form, our discussion of the case where there is only one independent variable can be generalized readily. Thus, we need be concerned only with solving
for a single dependent variable y(g). In this chapter, we will discuss several methods for solving ordinary differentid equations, with emphasis on the initial vdue problem. That is, find g(%)given the vdue of y at some initial point, say y(z = 0) = yo. T h i ~ kind of problem occurs, for example, when we are given the initial position and momentum of a particle and we wish to find its subsequent motion using Eqs. (2.3). In Chapter 3, we will discuss the equally important boundary vdue and eigenmlue problems.
2.1 Simple methods To repeat the basic probjem, we me interested in the solution of the differential equation (2.4) with the initial condition y(z = 0) = go. More specificitlly, W are u s u d y interested in the d u e of y at a particular value of I, say z = 1. The general strategy is to divide the interval [O, 11 inLo a large number, N,of equdlg spaced subintmds of length h = 1IN and then to develop a recursion formula relating y, to y,-l, ...l, where y, is our approximation to g(+, = nh). Such a recursion relation will then dew a step-by-step integatioa of the digeratid equation earn a:=Qto1=1, One of the simplest algorithms is Euler" smethod, in whi& we consider Eq. (2.4) at the point x, and replace the derivative on the left-hand side by its forward difference approximation (1.4a). Thus,
so that the recursion relation expressing
in terms of y, is
This formula has a local error (that made in taking the single step from g, to that is O(h2)since the emor in (1.4a) is 6 ( h ) . The LLglobal" error made in finding y(l) by taking N such steps in integrating from I = O to r = 1 is then NO(^^) a Q(&). This error decreases only
linearly with decreasing step size so that half as large an h (and thus twice as many steps) is required to halve the inaccuracy in the final answer. The numerical work for each of these steps is essentially a single evaluation af f . As an example, consider the differentid equation and boundary condition
-= -zy dz
; y(0)
whose solutioiz is y = e-g2/2
=1,
(2.7)
.
The following FORTRAN program integrates forward from s = O to I = 3 using Eq. (2.6) with the step size input, printing the result and its error zls it goes along. G chap2a.for mIG(X,Y)=-X*U f dy/& 20 PRIlT *, "ntar step size ( .l@. O to stop)' REm *, H IF' (H .LE. 0,) STOP !nmbsr of steps to reach. X=3 MSTEP=3./W V=l, !y(O)=I DO 50 IX=O,WSTEP-5 !loop over steps X=IX+H !last X value !new Y ~2~3.~4 fram Eq 2.Q Y=Y+H*FUBG(X,Y) DTFF=EXP f -Q. S* (X+H) **2]-Y !compme with axaet v a u a PRIBT *, IX,X+B,P,DIW 10 COIQTINUE i a t a ~again with new v a u a o f H GOTO 20
Em Errors in the results obtained for
with various step sizes are ghown in the first two cdunms of Tabh 2.1. As expected fmm (&G), the errors decrease linearly with smaller h. However, the fractional error (error divided by y) increases with I as more steps me taken in the ilttegratlon asrd y beeernes smajtler.
28
1, Ordinary Diflemntial Equatrions
Table 2.2
k
Error in integrating dy/cbz
E d e r ? method ~ Eq. (2.6) @(l) ~(3)
z:
-zy with gf 0)
Taylor series
Eq. (2.10) ~(1)
~(3)
1.
ImpEcit method Eg, (2.18) ~(1) ~(3)
Exaeise 2.1 A simple aad aftm stringent test of an =cur&@nmericd integration is to use the find vdue of y abtained as the initid condition to integrat;e bacbwxd fram the find vdue of a: to the starting poia_t. The
m
extentt to which the resulling vdw of y differs from the origind initial condlition is then a measure of the i n a c e u r ~ y Apply this test to the e x a p l e above. Although Euler's method seems to work quite wen, it is generally unsatisfactory because of its low-order accuracy. This prevents us from reducing the numerical work by using a larger value of h and so taking a smaller number of steps. This deficiency becomes apparent in the example above as we attempt to integrate to larger values of z,where some thought shows that we obtain the absurd result that y = 0 (exactly) for z > h-'. One simple ~olutionis to change the step size as we go along, making h smaller as s becomes larger, but this soon becomes quite inefficient. Integration methods with a higher-order accuracy are usually preferable to Euler's method. They offer a much more rapid increase of accuracy with decreasing step size and hence greater accuracy for a fixed amount of numericd effort. One dass of simple higher order methods can be derived from a Taylor series expansion for y,+l about :,y
From (2.4), we have Y,
r
= f(zm,va) 3
which, when substituted into (2.8), results in
where f and its derivittives are to be evaluated at (g,, g,). This recursion relation has a local emor O(h3)and hence a global error 6 ( h 2 ) ,one order more accurate than Euler's method (2.6). It is most useful when f is known analytically and is simple enough to differentiate. If we apply Eq. (2.10) to the example (2.7), we obtain the results shown in the middle t m columns of Table 2.1; the improvement over Eder" method is dear. Algorithms with an even greater accuracy can be obtained by retaining more terms in the Taylor expansion (2.8), but the algebra soon becomes prohibitive in a31 but the simplest czases. 2.2 Multist ep and implicit met hods Another way of ~ E e v i n ghigher accuracy is to use recursion relations that relate y,+z not just to yn, but also to poiats funther "h the past;,n say yn-1, h - 2 l .. To derive such fcrrmulas, we can intef3rate one step of the differential equation (2.4) eznctly to obtain
..
The problem, of CaQrse, is that we d d t know j owr the intmval of integration. However, we can use the values of y at I, and z,-l to provide a linear extrapolation of f over the requirc?d inlervd:
where f i E f ( z i , y i ) . Inserting this into (2.11) and doing the s integral then results in the Adms-Bashforth two-&ep method,
Related higher-order methods can be derived by extrapolating with 6igher&gee polynomials, For example, if f is extrapdated by a cubic pdynsmid fitted to f,, f n m l , f n m 2 , and fnmst the Adams-Bashforth four-Step method results: I
Note that because the recursion relations (2.13) and (2.14) involve several previous steps, the value of y~ alone is not sufficient information to get them started, and so the vdues of ly at the first few lattiee points must be obtained from some other procedure, such as the Taylur series (2.8) or the Range-Kutta metbads discussed below. Apply the Adas-Bashforth two- and four-step dgorithms to the example defined by Eq. (2.7) using Euler's method (2.6) to generate the vdues of y needed to start the recursian relation. Investigate the accuracy of g(%) for vaious values of h by comparing with the walfytied resdts a d by appfyj,ng the reversibiEty teat described in Exercise 2.1.
R
Exc3rcise 2.2
The methods we have discussed so far me ""expfidt" in inhat the gn+l is given directly in terns of the drezldy known value of y,. '"2nnplicit" methods, in wKcb m equation must be solved ta determine % + l t oEer yet another means of achieving higher accuracy. Suppose wre conaidclr Eq. (2.4) at a point r,+l/l (n f # ) h mid-way between two lattice points:
= f(%,+l/l9
~ R + 1 / 2 )*
If we then use the symmetric difference approfinnatian for the derivative by the average of (the analog of (1.3b) with h -+$ h ) and replace its values at the two adjacent lattice points [the error in this replacement is O(h2)],we can write
wkich eorrespands to the recursioa, rel;ation
'
2.2 MulEli~teqpand inapilielib metfaads
This is iillwell and p o d , but the appearmce of g,+$ on both sides of this equation (an implicit equation) means that, in general, we must solve a non-trivial equation (for example, by the Newton-Raphson method discussed in Section 1.3) at each integration step; this can be very time eoctszlming. A particulas ~implification.occurs if f is linear in y, say f(gF3) = g(z)y, in which case (2.17) can be solved to give
When applied to the problem (2.7), where g(%) = --g, this method gives the results shown in the last tvvo columns of Tabfe 2.2; the quadratic behavior of the error with h is clear. Exercise 2.3 Apply the Taylor series method (2.10) and the implidt method (2.18) to the example of Eq. (2.7) and obtain the results shown in Table 2.1. Investigate the accuracy of integration to larger vdzles of z,
m
The Adas-Moulton. methods are bath mdtistep and implicit. For example, the Adams-Modton two-step method can be deriwd from (2.11) by using a quadratic polynomid passing through Awl,f,, asld
m,
&+l3
t o interpolate f over the region from I, to r,+l. The implicit recursion relation that resdts is
The corresponding three-step formula, obtained with a cubic polynomial interpolation, is
Implidt methods are rarely used by solving the implicit equation to take a step. Rather, they serve as bases for Upredictor-corrector" algorithms, in which a "prediction" for y,+l based only on an explicit method
31
is then 'korrected" to give a better value by using this prediction in an. implicit method. Such dgorithxns have the advantage of atlawing a e m tinuous monitoring of the accuracy of the integration, for exmpXe by making sure that the corre&ion is small. A commonly used predictorcorrector algorithm with local error O(h5)is obtained by using the explicit Adams-Bashforth four-step met hod (2.14) to make the prediction, and then caleul&ing the correction with the Adams-Maulton three-step method (2.201, using the predicted value of y,+l to evaluate f,+l on the right-hand Elide.
2.3 Runge-Kutta methods As you might gather Erom the preceding section, there is quite a bit 05 freedom. in writing down dgorithnrs for integating differentid equations and, in fact, a large number of them exist, each having it atvn pecdiarlties and advmtages, One very convenie~tand widely used cla9.s of methods are the Range-Kutta dgorithms, whielt come in varyiag orders of accuracy, We derive here a second-order mrsion to @ve the spirit of the appromh and then simply state the equations for the third- and carnmoxliy used fourth-order methods, To derive a second-order Runge-Kutt a algorithm (there are actually a whde fmily of t b m chmacterized by a continuous parmetef), we approximate f in the integral of (2.11) by its Taylor series expansion about the mid-polnt of the intepation intervat. Thus,
where the error arises from the quadratic term in the Taylor series, as the linear term integrates to zero. Although it seems as if we need to know the appearing in f in the right-hand side of this equation for vdue of g,+, it to be of any use, this is not quite true. Since the error term is already O(h3),an approximation to y,+l whose error is O(h2)is good enough. This is just what is provided by the simple Euler's method, Eq. (2.6). Thus, if we define k to be an intermediate approximation to twice the difference between g,+,/, and y, the following two-step procedure gives y,+l in terms af g%:
This is a second-order Runge-Kutta algorithm. It embodies the general idea of substituting approximations for the values of y into the right-hand
side of implicit expressions involving f . It is as accurate as the Taylor series or implicit methods (2.10) or (2.171, respectively, but places no special constraints on f , such as easy differentiability or linearity in y. It also uses the value of y at only one previous point, in contrast to the multipoint methods discussed above. However, (2.22) does require the evafuatGion of f twietj for each step dong the lattice. Range-Kutta schemes of higher-order can be derived in a relatively straightforward way. Any of the quadratare formulas discussed in Chapter 1can be used to approximate the integral (2.11) by a finite sum of f d u e s , For example, Sirnipson's mle yields
Schemes for generating successive approximations to the g's appewiing in the right-hmd side of a commensurate accuracy then complete the algorithms. A third-order algorithm with a local error O(h4)is
It is based on (2.23) and requires three evaluations of f per step. A fourth-order algorltbm, whieb r e q ~ r e sf to be evaluated four times for each integration step and has a local accuracy of O(hS),has been found by experience to give the beat balance betwmn accurwy and computational egort. Id can be written as fouows, with the ki as intemediate va~iabXes:
Exercise 2.4 Try out the second-, third-, and fourth-order RungeKutta methods discussed above on the problem defined by Eq. (2.7). Compare the camput ationd eEort for a given accuracy with that of other methods.
W
r Exercise 2.5 The two coupled first-o&r equatims
define simple harmonic motion with period 1. By generdizing one of the single-variable formulas given above to this two-variable case, integrate thege equations with any particular initid conditions you choose and investigate the aceurwy with whi& the system returns to its initial state at integrd valum of t.
2.4 Stability A major consideration in integating &Rerentid equations is the Burnericd stability of the dgorithm used; i.e., the extent to whick rouad-off or other errors in the namericd computation em be ampfified, in many cases enough ifar this "noise" to dominate the resuks, To illustrate the problenr, let us attempt to improve; the accuracy of Euler's method and approximate the derivative in (2'4) directly by the symmetric difference approximation (1.3b). We thereby obtain the three- term recursion relation g%+%= 3,-2 4- 2hf(gn,gn) 4- 0 ( h 3 )9 (2.27) which superficidb looks about as useful as either of the third-order formulas (2.10) or (2.18). However, consider what happens when this method is applied to the problem
whose solution is y = em". To start the recursion relation (2.271, we need the vdue of y, as well as go = 1. This can be obtained by using (2.10) to
(This is just the Taylor series for emh.) The following FORTRAN program then uses the method (2.27) to find y for vdues of r up to 6 using the vdue of h input:
8.4 Stability
Table 2.2
C: chap=lb.for IQ PRIHT *,"n%er 8UD
*,
Integration of d g l d z = --g with g ( @ )-- X
vdue of step size ( .Is, O to step)"
E
XF (H .LE. O) STOP P;lutIrnS=rzi YZEM=i.-EI+H+*2/2 ISmP=6./B BQ 20 ZX=2,15TEP X=IX*H WLUS=YPUIIWS-IZ+B+TZE mImS=TZEEO
!V(O) I P (B)
tZsop over X vdtles !X at this step !Y frem Eq. 2.27 Iro23, vaXaarzr
Y-ZIERQ=YPLVS
EXACT=EXP(-X) *, X,EXAm,EXAm-YZEW
20
l g t i c valas at this p o h t
PRINT COITXmE;
Note how the three-term recursion is implemented by keeping track three local variables, YPLUS, YZERO, and YMINUS. A portion of the output oS tkjs code run for h -. 6.1 is shown in Table 2.2. For s m d values of I, the numerical solution is only slightly larger than the exact value, the error being consistent with the O(h3) estimate. Then, near z = 3.5, an oscillation begins to develop in the numerical solution, which becomes dternately higher and lower than the exact values lattice point by lattice point. This oscillation grows larger as the equation is integrated further (see values near z = 6 ) , eventually overwhelming the exponentially decreasing behavior expected. The phenomenon observed above is a symptom of an instability in the algorithm (2.27). It can be understood as follows. For the problem of only
35
(2.28), the recursion relation (2.27) reads
We can solve this equation by assuming an exponential solution of the form g, = AT" where A and r are constants. Substituting into (2.29) then results in an equatim for F,
the constant A being unimportant since the recursion relation is lines. The salations of tbis equatlon are
nrhere we have indicated approxinraeions valid for h < I, The positive root is sEgHtly less than m e and eone8po1lds to the expomutidy decreasing solution we are after. However, the negative root is slightly less thaa --X, and so corresponds to a spurious solution
whose m-itude increases with n and which oscillates ffom fat;tfce point to lattice point, The general solution to the linear difference equation (2.27) is a linear combination of these two exponentid solutions, Even though we m'tght carefully arrrtnge the initial vdues ya and yl so that only the d e c r e ~ i n g sdution is present Tor smalt s, numericd round-off during the recursion relation [Eq. (2.29) shows that two pasitive quantities are subtracted to obtain a smaller one] will introduce a amall admixture of the "bad" solution that will ewntualfy @W to domin&e the results, This instability is dearly wsociated with the thme-tern nature of tbe recursion rdation (2.29). A good rule of thumb is that instabilities and round-off problems should be watched for whenever integrating a sdutim that decreases strongly as the iteration proceeds; such a situation should therefore be avoided, if possible. We will see the s m e sort of instability phenomenon ag&nin our discussion of second-order diRerentid equatians in Chanter 3. Exweise 2.6 Investigate the stability of sever& other integralion methods discussed in this chapter by apphing them to the problem (2.28). Can you give analytical arguments to explain the results you obtain?
B
g.5 Order and chaos in two-dimensional motion
2.5 Order and chaos in two-dimensional mation A fundamental, advantage of. udng computers in physics is the ability to treat systems that caxlnot be sdved astdyticdly, In the usual situation, the numerical resdts gmeraited agree qu&tatively with the intnition W h a t developed by studfirtg soluble models and it is the quantitaive values that are of real interest. However9 in a few cases computer results defy our intuition (and thereby reshape it) and numerical work is then essentiat for a p r v e r understanding. Surprisindy, such cases include the dynmics of simple classic& systems, where the generic behavior diEers quala'tcatively from that Qf the models covered in a traditiond Mechanics course. In this example, we will study mme of this surprising behavior by intepat;ing numerically the trajectories of a partide moving in two dimensions. General discussions of these systems can be found in [Hego], [Ri80], and [Ab78]. WC? consider a particle of unit mass moving in a potentid, V, in two dimensions and a4sunte that V is such that the particle remains confined for all times if its energy is low enough, E the momenta can,jug&e to the two coordinates ( s , g ) are (p,, p,), then the Hamiltonian takes the form
Given any particular initid v d u e ~of the coordinates and nromenta, the particle's trajectory is spedfied by their time evolution, which is governed by four coupled first-order differentid equations (Hamilton's equations):
For any V, these equations conserve the energy, E, so that the constraint
restrict S the trajectory to lie in a thre-dirnensiond manifold embedded in the four-dimensional phase space. Apart from this, there are very few other geaerd statements that caa be made about the evolution of the system. One impart ant class of two-dimensional Hamiltonians for which additiond statements about the trajectories can be made are those that ape
37
38
2. Oranary Biflemnitlial Equations
intwrabke. Far these potentids, there is a semnd function 06 the coordinates and momenta, apart from the energy, that is a constant of the motion; the trajectory is thus canstsrtined to a two-dimensionat ma6fold of the phase space. Two familiar kinds of integrable systems are separable an& wntral potentids. h the separable c a ~ ,
where the V,*, are two independent functions, so that the Hamiltonian separates into t w pards, each involving mly one wordinate and its conjugate momentum,
The mations in a: and g therefm deeouplt,from each other and each of the is separately a constant of the motion. (Equivalently, Hamiltonians ESPY H, - E, is the second quantity conserved in addition to E = H, + h.) In the ease of a centrd poteatid,
so that the angular momentum, p8 = %p, - yp,, is the second constant of the motion and the Hmiftonian can be written m
Pthwe p, is the zraolnenturn conjug& to r. The aCt&tiorrd constraint on the trajectory present in integrable systems allows the equations of motion to be "solved" by reducing the problem to one of evaluating certain integrals, much as we did for one-dimensional motion in Chapter 1. All of the familiar analytically soluble problems of classical mechanics are those that are integable, Although the dynamics of integrable systems are simple, it is often not at aI1 easy to make this simplidty apparent. There is no general analytical method for deciding if there is a second constmt of the motion in an arbitrary potential or for finding it if there is one. Numerical calculations are not obviously any better, as these supply only the trajectory for given initial conditions and this trajectory can be quite complicated liar cases, as can be seen by recdling the Lissajous patterns
h.5 Ondc?rand chaos in two-dimensional motion
Figme 2.3 Ikajectode~of a particge in a two-dimens;iana;l separaplanes, Several ~ n (g,py) d ble potentid as they appear in the trajectorim corrmpa~&rrgto the s m e energy but di@erentinitid condiljone me shorn. najectories A and E are the gmiting ones h a ~ n g vanlshina; .Egand E@,rmpwtively.
of the
(2,g)
trajectories that arise when the motion in both coordinates
An analyds in phase space sugests one way to detect integrability from the trajeetary done. Consider, for exmple, the caae of a sepafable potent;id. Be~ausethe motions of each of the two coordinates are indepeadent, plots of a trajectory in the ($,p,) and ($,py)planes might look as shown in Figure 2.1. Here, we have assumed that each potential V = ,hrzs a single &Rjmum vdue of 0 at particular vdues of z a d g, respectively, The particle move8 on a closed contaur in each of these two-dimensional projections of the four-dirnensiond phase space, each contour looking like that for ordinay one-dirnensimd motion shown in Figure 1.3. The aseas of these contours depend upon how much energy is associated with each coordinate (i.e., E, and E,) and, as we consider trajectories with the s m e energy but with diEerent initid condlitions, the area of one coatour will sMnk as the other grouls. In each plwe t h m is a lidtine; contoar that is appraxhed when all of the energy is in that particular coordinate. These cantoars axe the intersections of the twedimensiand phasa-spaee manifolds containing each of the trajectories and the (y,py)or (z, p,) plot is therefare termed a "surfxe of seetiori." The efistence of them crlosed contours signds the integrability of t htr. sys-tem. Althon& we are able to construct F i e r e 2.1 only because WC?understand the integrable motion involved, a similar plot can Be abtained
39
Figwe 2.2 (Left) Toraid& mmgold coatalniag Ghe trajectory of a, pslrticle in a centrd potentid. (Right) Surface of ~ s t j o nthrough this m h f o l d ad 21 r=: 0.
;Eron %hef rgectory done, Suppoae that every t h e W &smm m e of the coordinates, say 2, to pass throuejh zero with pz > Q , W plot the locaf;ion of the partide on the (g, p,) plane. In other words, crossing through the z = 0 plane in a positive sense triaers a Ustroboscopenwith which art! observe the (y,p,) variables. If the periods of the 2 and y motions are incommensurate (i.e., their ratio is an irrational number), then, as the trajectory proceeds, these observations will gradudy trace out the full (g,p,) contour; if the periods are commensurate (i.e., a rational ratio), then a series of discrete points around the contour will result. In this way, we can study the topology of the phase space associated with any given tonian just from the trajectories alone. The general topology of the phase space for an integrable Hamiltonian can be iUustrated by considering motion in a central potential. For fixed vdues of the energy and angular momentum, the radial motion i s bounded between two turning points, pin and rout,which are the solutions of the equation n
These two radii define an annulus in the (E, y) plane to which the trajectory is confined, as shown in the left-hand side of Figure 2.2. Furthemore,
h.6 Qrdttr and chaos in tzoa-dimensiond mot-l"on 4%
Figme 2,8 Pmible batuxez~of the sudwe mtion af a general integrable system. E a ~ H d label elliptic m d hyperbdic fixed points, respectively, wjhife the curve labded S is a sepaszttrix,
for a fixed value of r , energy conservation permits the radial momentum to take on o d y one of twa d u e s ,
These momenta define the two-dimensional manifold in the (I, y,p,) space that contains the trajecdosy; it charly has the tapdogy of a torus, as shown in the left-hand side of Figure 2.2. If we were to construct a (gypy) sudace of section by emsidering the z = 0 plane, are would obtain two dosed contours, as shown in the right-hand side of Figure 2.2. (Note that y = r when I = 0.) If the energy is fixed but the angular momentum is changed by vi~rybgthe initial conditions, the dimensions of this torus change, as does the m a of the contour in the sudace of section, The toroidal topoloa of the phase space of a central potential cian be shown to be common to all i n t e ~ a b bsystems. The manifold on which
the trajectory lies for @venvdaes of the consta~tsof the motion is c d e d an u"imrimt toms," and these a ~ tm a y of them for a gven mergy. The general surface of section of such tori looks like that s h m n in Figure 2.3. There me cefiajrr k e d points asodated with trajectories that repeat themselves exactly after same pefiod, The elliptic fixed points correspond to trajectories thafr are stable under smafl perturbations. Around e x h of them is a family of tori, bounded by a sepasatrix. The hyperboEc fixed pdnts occur at the Intersectioas of sepruratdces and me stabb under perturbations dong one of the wes of the hyperbda, but unstabb d m g the ather * An interesting guestion, is @Whathappens to the lori of an infqmblr: &@em under a perturbatha that destmys the integprtbihty cif the Hamittonian B", For sma31 perturbatiom, 'host" of the tori about an eBiptic fixed point become slightly distorted but retain their topology (the KAM theorem due to Kolmogorov, Arnold, and Maser, [Ar68]). However, adjacent reg;ions of phase spwe become "chmtic", dving sudwes of section that are a seemingty random splatter af points. Within these chaotic regions =CS nested yet other &ptk fixed point;s and other chaatic regions in a fantastic hierarchy. (See Figure 2.4.) Large deviations from integrability must be invegtigated numerically. One convenient case for doing so is the potentid
which was originally introduced by HQnon and IIeiles in the study of stellar orbits thro~gha gilrlaxy [He64]. This potential can be thought of as a perturbed harmonic osciuator potential (a small constant multiplying the cubic terms can be absorbed through a rescaling of the coordinates and energy, so that the magnitude of the energy becomes a measure of the deviation from integrability) and has the three-fold symmetry shown in Figure 2.5. The potential is zero at the origin and becomes unbounded for lasge values of the coordinates. However, for energies less than 116, the trajectories remain confined within the equilateral triangle shown. The FORTRAN program for Example 2, whose source code is contained in Appendix B and in the file EXMPL2.FOR, constructs surfaces of section for the B6non-WcliXles poteatid, The method used is to integrate the equations of motion (2.31) using the fourth-order Runge-Kutta algorithm (2.25). Initial conditions are spedfied by putting s = O and by giving the energy, g, and p,; p, is then fixed by energy conservation. As the integration proceeds, the (s,g) trajectory and the (y,p,) surface
i9.5 Qder and chaos in two-drimensional motion
Figure 2.4 Nested tori for a. slljightly perturbed integrable system, Note the hierarchy of eltliptk orbits inlerspersed with chwtic regions. A magnification af this hierarchy would show the same pattern repeat& on a smdler scale and so on, ad trrfiitum. (Reproduced &am [Ab78],)
of section u e displayed. Pointis on. the latter are calculated by w;tt;ching for a time step duPing which a: changes sign. When this happms, the precise l~clitti~n of the point an the surface of section plot i s determined by switching t o 2 a~ the independent variable, so that the equations of motion (2.31) beeorne
and then integating one step bwkwasd in a: from its vdue after the time step to 0 [He82]. If the value of the energy is not changed when new initial conditions are specified, all previous surface of sectisn pdnts c m be plotted, so that plots like those in Figures 2.3 and 2.4 can be built up after some time. The p r o g m exploits a symmetry of the Henon-X-feiles equations af motion t o obtain two trajectories &om one set of initid conditio~s,This symmetry can be seen from the equations of motion which me invariant
43
Valley
Figure 2.8
muipolentiait eont;ours of the IXknani-XXe3es potentid,
Eq, (2.35).
if + -+ -I and p, -+ -p,. Therefore from one trajectory we can trivially obtain a "reflected" trajectory by flipping the sign of both I and p, at each point along the original trajectory. More specifically, if we are interested in creating the surface of section on the z = 0 plane we $ready have z = -g, and only the sign of p, must be changed. Practically this means that every time we cross the I = 0 plane we take the comesponding y and p, values to be on the surface of section, without consideration for the sign of p,. If p, is greater than zero it is a point from the initial trajectory, while if p, is less than zero then that point belongs to the reBected trajectory.
2.5 Oder and chaoe in two-9mensitrnal motion
The following exercises are aimed at improving your understanding of the physical principles and numerical methods demonstrated in this example, Exercise 2.7 One necessary (but not suffident) cheek of the aecuracy of the integration in Hamiltonian systems is the conservation of energy. Change the time step used and observe how this affects the accuracy. Replace the integration method by one of the other dgorithms discussed in this chapter and observe the change in accurrccy and eficiency, Note that we require an algorithm that is both accurate and eficient because of the very long integration times that must be considered. kxercise 2.8 Change the potential to a central one (function subroutine V) and observe the character of the (z, y) trajectories and surfaces of section for v a ~ o n sinitial conditions. Compwe the resub with Figure 2.2. and verify that the quatative hatares don't change if you use a diEerent centrd patentid. N d e that yaa wi11 have to adjust the energy and scale of the potential M, that the (r,y) trajectory does not go beyond the equilateral triangle of the HQnon-Heilespotential (Figure 2.5) or else the grapEcs subroutine will fail,
U
Exercise 2.9 If the sign of the y3 term in the Henon-Heiles potential (2.35) is reversed, the Hamiltonian becomes integrable. Verify andyticdy that this is so 'by making a canonicd trmsformation to the variables zrf: y and showing that the potentid is sepasabl~in these variables. MafEe the corresponding chmge in sign in the GO& and &save the character of the sadaces of metion that result for various injtid conditions at a given energy. (You should keep the energy below 1/12 to avoid having the trajectory become unbounded.) Verify that there are no qualitative differences if you use a different separable potential, say the harmonic one of Eq. (2.34). m
U
Exereiw 2.10 Use the code to construct surface8 of section for the
Hhnon-Heiles potentid (2.35) at ener@es ranging from 0.025 to 0.15 in steps of 0.025. For each enera, consider various initid conditions and integrate each trajectory long enough in time (some will require going to t m 1100) to map out the surface-of-section adequateb. For each energy, see if you can find the elliptic fixed points, the tori (and tori of tori) around them, and the chaotic regions of phaee space and observe how the relative proportions of each change with increasing energy. With some patience and practice, you should be able to generate a plot that resembles the schematic representation of Figure 2.4 around each elliptic trajectory.
45
46
h. Ordinary Diflemntial Equations
Project 11: The structure of white dwarf stars White dwarf stars are cold Objects eomiposed largely of heavy nudel and thdr associated electrons. These stms me one possible end result of the conventiond nuclear proces8es that build the elements by binding rrrrcfeons into nuclei. They are often composed of the most stable nudeus, '@Fe, with 26 protons and 30 neutrons, but, if the nucleosynthesis terminates prematurely, C nudei might predominate. The structure of a w&te dwad star is detemined by the interplay between pavity, wEch acts to cornpress the star, and the degeneracy pressure of the electrons, vvhicb tends to resist eompressim. fn this project, we will investjgate the structure of a white dwasf by integrating the equations dtefiniq this eqrtiXibfiurn. VCTe W% determine, among other things, the rdation between the stark rnahts a d its radius, quasltiLies that can be deterxnined ffsm observation. Discussions of the p2rysics of wkite d w d s can be found in [Ch57], [Ch84], and [Sh83].
11.1 The equations o f equilibrium We assume that the star is sphericalk symmetric (i.e., the state of matter at any given point in the star depends only upon the distance of that point from the star's center), that it is not rotating, and that the effects of magnetic fields are not important. If the star is in mechanical (hydrostatic) equilibrium, the gravitational force on each bit of matter is balanced by the force due to spatial variation of the pressure, P. The gravitational force acting on a unit volume of matter at a radius r is
F,.,
Cm
= --z,
P?
where G is the gravitational constant, p(r) is the mass density, and m(r) is the mass of the star interior to the radius r :
The force per unit volume of matter due to the changing pressure is -dP/dr. When the star is in equilibrium, the net force (gravitational plus pressure) on each bit of matter vanishes, so that, using (II.1), we
11. The st;ruckre of white dwarf star8
A digereatid relation betwen the anss and the density can be obtained by differentiating (11.2):
The description is completed by specifying the "equation of state," an intrinsic property of the matter giving the pressure, P(p), required to maintain it at a given density. Upon using the identity
Eq. (11.3) can be written as
Equations (11.4) and (11.5) are two coupled first-order differential equat;ims that determine the structure of the star for a given equation of state, The v d u a of the depeadent variables at r = O a e p = p,, the central density, and m = 0. 1ntegr;hlim outward in r then giws the density profie, the radius of the star, R, being detemined By the point at which p vanishes. (On very general grounds, we expect the density to decrease with increasing distance from the center.) The total mass of the star is then M = m(&). Since both R and M depend upon p,, variation of this parameter d a w s stass of rligerent masa; to be studied,
11.2 The equation of state We must now deternine the equatioxl of s h t e appropri&e fctr a white dvvad. As ment:ioned above, we will assume that the matter consists of large nuclei aad th&r electrons, The nuclei, b e i q heavy, cont;ribute nearly atl of the mass but make almost; no contribuLim to the pressure, since they hardly move about at. d.The dectmns, hwever, contribute virtudly abl of the pressure but essenlidy none of the mass, VVe will be intexsted in densities fas ge&er than that of ordinmy mat;ter, where the electrons am no longer bound to individuitl nuclei, but mther move fredy ~ af electrons thmufi the naakrid. A good model is then a free F e r gas at zero tamperiature, treated with relativistic Xcfnematics. h r matter at; a. @ven mass densi.2,~~ the numb= density of electrons
47
where M, is the proton mass (we neglect the small difference between the neutron and proton masses) and Y, is the number of electrons per nucleon. If the nudei are all $@Fe,then
4
while Ye = if the nuclei are I2C; electrical neutraiity of the matter requires one electron for every protoll. The free Femi gas is studied by considering a large volume If containing N electrons that occupy the lowest energy plane-wave states with momentum p < pt. Remembering the two-fold spin degeneracy of each plarie wave, we have
where n = N / V . (We put h = e = 1 unless indicated explidtb.) The totat energy density sf thege electrons i s
whicfi can be integitted to @vet
% ( l2 + z2)(1 f I ~ ) ~ - log /~
The variaMe z chasacberizes the electron density in terms of
the density at which the Fermi momentum is equal to the electron mass, m,*
11. The &tmrchins,aJ"white dwarf stars G mmner, the pressure is related to how In the usual thermodyn the eneru chwges with volume at k e d N :
Using (11.10~)to find
and differentiating (II.lOa,b) results in
where c' = de/ dz. It is now straightforward to calculate dP/dp. Since P is most naturally expressed in terms of ,I we must relate I to p. This i s most easily done using (11.10~)and (11.6):
Thus, p0 is the mass density of matter in which the electron density is no. Differentiating the pressure and using (11.12, II.13a) then yields, after some algebra,
49
11.3 Scaling the equations It is often usefd to xd-btee equations desellibing a physicd system to dimensiodess form, both for physical. insiglice and for xturnesicd convenience (i.e., to avoid dealing with very l a g e or very s m d nwnbers in the computer), To do this for the equations of white dwasf &metare, we introdwe dimensiodess radius, density, and milss vwiables:
with the ra&us and mass scdes, & and Ma, to be deternzined for convenience. Substituting into Eqs. (IIe4,11.5) and using (11.14) yields, after some reanangement ,
If we now choose MO and & so that the coeEeients in pmerrtheses in these two equ&ions are unity, we find
a ~ tdhe dimensiadess diEerential equations me
g that 7 i s given by Eq. (11.14) These equations axe compkted by rec with r = p'/3. The scaling quantities (II.13b) and (II.17) tell us how to relate the structures of stars with digerent Ye and hence reduce the nnnnericd work to be done. Spedfiedy, if we have the solution for Ye = 1 at some value of pc = p,/po, then the solution at any other Ye is obtained by scaling the density as Y;', the radius as Ye,and the mass as Y .:
J% The structurcl? of while dwarf stars
To give some feeling for the scales (11. IT), recall that the solar radius and mms axe
while the density at the center of the sun is m 1150 gm cmw3. We therefore expect white dwarf stars to have masses comparable to a solar mass, but their radii will be considerably smaller and their densities will be much higher.
11.4 Solving the equations We are now in a position to solve the equations and determine the properties of a white d w d . This cm be done in the folladng sequence af steps. Step 1 Verify the steps in the derivations given above. Determine the leading behavior of E and 7 in the extreme non-relativistic (z &: 1) and relativistic ( x > 1) limits and verify that these are what you expect from simple arguments. Andyze Eqs. (II.IBa,b) when ifs and F are finite and p is smdl to shsw thztO j? vanishes at a finite ra&us; the star therefore has a well-defined surface. Determine the function4 form with whieh p vmishes near the surf=@. Step 2 Write a program to integrate Eqs. (11.18) outward from F = O for Ye = f , Calculate the density p r d e s , total masses, and. radii of stars with selected d u e s of the dinaeasimbss centrd density p, ranging from 10-' to 1Q6.By changing the radial step and the integration algorithm, verify that your s~lutionswe accurate, Show that the totd kinetic and rest enera of the electrans in the star is
where E/V is the energy density given by (11.10) and that the total gravitatimal energy of the star can be written as
Use the scaling discussed above to cast these integrals in dimensionless form and calculate these energies for the solutions you've generated. Try to understand all of the trends you observe through simple physicat reasoning.
51
r Step 3 A commady tl~edde~clLiptimof stellar slrructuse involves a
pdytropic equation of state,
where PO,p0 ,and l? are constants, the latter being the adiabatic index. By suitably scaling Eqs. (II.4,5), show that a star with a polytropic equation of state obeys Eqs. (11.18) with
The degenerate electron gas therefore corresponds to F = 413 in the extreme relativistic (high-density) h i t and I? = 513 in the extreme nonrelativistic (low-density) limit. Patropic equations of state provide a simple way to dudy the effects of varying the equation of state (by changing l?) and also give, for two spedd vdnes of r", andytieal solutions wainst whieh numericill so~ checked, For this latter palpose, if is most convenient lutions c a be to recast Eqs. (11.18) as a single second-order differential equation for p by solving (II.18a) for and then differentiating with respect to f and using (II.18b). Show that the differential equation that results (the LaneEmden equation, [Ch57]) is
and that far ]E'
==
2 the mlutian i s
p 'pc-sin r" F
*
while for I? = 615 the solution is
Use these analytical solutions to check the code you wrote in Step 2. Then study the structure of stars with different adiabatic indexes I? and interpret the results,
I ' The struct-UFY? of ullaile &a$ stars N
Step 4 If things are working correctly, you should find that, as the
central density of a white dwarf increases, its mass approaches a limiting value, (the Chandrasekhar mass, MCh)and the star becomes very small. To understand tkis aad to get an estimat;e of Mch, we cm faurn the steps in an argument originally given by Landau in 1932. The total energy of the star is composed of the gravitational energy (W < 0) and the internd energy of the matter (U > 0). Assume that a star of a given total mass has a constant density profile. (This is not a very good assumption for quantitative purposes, but it is valid enough to be useful in understanding the situation.) The radius is therefore related simply to the total mass and the eonstmt density, Calculate U and W h r this density profile, assuming that the density is high enough so that the electrons can be treated in the relativistic limit. Show that both energies scale as 1/R and that W dodrriltes Zf when the totd mass exceeds a cert%incriticd vdue. It then becomes energetically favorable for the star to collapse (shrink its radius to zero). Estimate the Chandrasekbar mass in this way and compare it to the =salt of your numeric& calculation, Also verify the correcgness of this rtrgumexlt by showing th& U and W for your solutions found in Step 2 become equal and opposite as the star .approaches the finriting mass, Seep F; Scde the mass-radius rdation you found in Step 1 to the cases and I2C nuclei. Three white dwarf stars, Sirius B, corresponding to 40 Eri B, and Stein 2051, have masses and radii (in units of the solar values) determined from observation to be (1.053 f0.028,0.0074& 0.0006), (0.48 it 0.02, 0.0124 0.0005), and (0.50 k 0.05 or 0.72 f.0.08, 0.0115 f 0.00 121, respectively [Sh83]. Verify that these values axe consistent wit h the model we hwe developed. What can you say abbot the compositions of thege stws? m
53
This page intentionally left blank
Chapter 3
Bound
Many of the important differentid equations of physics can be cast in the Earm of a linear, second-order equalim:
where S i s an inhomogeneous ("drivingn) term and k2 is a real function. When kZ is positive, the solutions of the homogeneous equation (i.e., S = 0) are oscillatory with local wavenumber k,while when k2 is negative, the solutions grow or decay exponentidly at a local rate (- kZ)* . For example, consider trying t o find the dectrostatic poteratiaf, @, generated by a localized charge distribution, p(r). Poisson's equation is
which, far a spbericdly symmetric p and Qtr, simplifies to
The standard substitution
then results in which is of the form (3.1) with kZ = 0 and S = -4rrrp. In a similar manner, the quantum m e c h ~ e awave l fanetion, for a partide of mass m
56
S. Boundarq, Value and Eigenvalue Problems
and energy E moving in a central potential V ( ? )can be written as where YAMis a sghericd harmonic and the radid wave function R satisfies
This is also of the form (3.11, with S = 0. The equations discussed above appeas unremarkable and readily treated by the methods discussed in Chapter 2, except for two points. First, the boundary conditions imposed by the physics often appear as constrdnts on the deptjndent vdablr, at t m sepmfe points of tke independent variable, so that solution as an initial d u e problem is not obviously possible. Moreover, the Sehroedinger equation (3.5) is an eigenvdue t the energies that had to physicdy acequatim in which we m u ~ jsad ceptable solutions satisfying the appropriate boundary eonditiws. This chapter is concerned with methods for treating such problems. We begin by deriving aa integration atgorithm parlieulaxly well suited to equal;ims of the form (3.1), and then discuss boundary value and eigenvalue problems in turn.
3.1 The Numerov algorithm There is a particuldy simple an& eficient method for integating secondorder differential equations having the form of (3.1). To derive this method, cammonly c d e d the Numerov or Cowling's method, we begin by approximating the second derivative in (3.1) by the three-point difference formula (1.7),
where we have written out explicitly the 6 ( h 2 ) "error" term, which i s derived easily from the Taylor expansion (1.1, 1.2a). From the differentid equation itself, we hitve
3.8 Birst integmtfiorz of boundarg value pr~bbms 57
When this i s substituted into (3.6), we can write, after some rearrangement,
Solving this finear equation for either gn+1 or gn-l then. provides a recursion relation. for integrating &ther forwxd or bukward in s, with a. bcal
error O(hs). Note that this is one order more accurate than the fourthorder Runge-Kutta method (2.25), which might be used to integrate the problem as; two coupbd first-order equations. The Nunrerw seheme is also more efficient, as each step requires the computation of k2 and S at only the lattice points, Exercise 3.1
Apply the Numerov dgorithm to the pmblem
e~ Iategrate from s = 0 to a: = 1 with vwious ~ t e p~ i z and the eaciency a ~ l dxcuracy with some of the methods discussed in Chapter 2. Note that yon will have to use some h;pedd prowdure (e.g., a Taylor series) to generate the value of yl E y(h) needed to start the three- term recursion relation. 3.2 Direct integration of boundary value problems As a concrete illustration of boundmy value problems, consider trying to solve Poisson's equation (3.4) when the charge distribution i s
wEch has a told charge
The e x x t solution to this problem is b +(F) = I - -(v 2)e-', (3.10) 2 from which @ = r-'# follows immediately. This solution has the expected behavior at large r , 4 4 1, which corresponds to 4! -+ v-', the Coulomb potential frm a unit charge.
+
58
9;
Boundary Vhlue and Eigenvalue Problems
Suppose that we try to solve this example as ;an ordinmy initial vdue problem. Since p has no singular behavior at the origin (e.g., there is no point charge), @ is regular there, which implies that 4 = rQ vanishes at r = 0; this is indeed the case for the explicit solution (3.10). We could then integrate (3.4) outward from the origin using the appropriate rearrangement of (3.8) (recall k2 = 0 here):
However, to do so we must know the value of (or, equivalently, d+/dr = O at r = 0) in addition to q ! ~= 0. This is not a very happy situation, s i n e gSil is part of the very function we're tr~ringto find, and go is not knovvn a pva'ori. We will discuss below what to 1Co in the generd c m , but in the pre~entexmpk, &nee we have asl mdytical golutim, m cm find = $(P = h) from (3.10). The following FORTRAN program does the antward integration to r = 20, storing the sxrlution in m &gray and printing the exact r e d t and efror as it gws along. G cbp3a.for
BIEmSTOM PHI(0:200) EXACT(R)=1 (E+2)*EXP(-B)/2 SOUME(R) S-R*EXP (-R) 12 H=.$ I.
-
ISmP=20./eE C01ST=8*+2/12 SMI=O.
SZ=SOURCE(E) PHX(a)=o PHI( l)=EXkGI"(B) ao 10 XB=I,IS~P-I R=(IB+l)*B SX"=SOUECECR)
!=ray for %he solm%fun ? exact solm%iorr !sowce i w e tion
!xa&ia step !nmber o f p i n t a to R=20 ! ~ o m t a tin E-erov method !arouce; a$ R=O Iso-ca at MB[ i b ~ m d w~ ~ ~ d iatt R=O i ~ n !exact value a% Sfrst poiat rloop ior O U ~ W W ~i x t e ~ a t i o n ?radius a% next point. !sowee a% next poh% !Eq. 3.11
PH~(xR+~)~~+PHI(TR)-PEX(TR-I)+C:OIST*~SP+~~~ *SZ+SX] SM=SZ !roll v a n s s SZ=SP
PRXIS *, R,EXA~(R),P~I(IR+~),EXACT-FHI(IR;+II 10
CORTIrnE STOP
$3 D i m t intclgration of baundary value problems
Table 8.1
Errors in salving the Paisan pfablem defined by %a,
(3.4,3.9)
Note haw computation is minimized by kwping track of the vdues of S at the current and adjacent lattice points (SZ, SM, and SP) and by computing the constant h2/12 appeaing in the Numerov formula (3.11) &side of the ixltegration loop, Results genwated by this progrm axe giwn in the first three columns of Table 3.1, which show that the ~umericdso1af;ionis rather accurate for t however. Tbe error per step gets larger at large r small v, All is ~ o well, (the error after the 20 steps from T = 0 to r = 2 is 3 X 10-', while during the 20 steps from r = 18 to r = 20, it grows by 1.2 X IQ-', 4 times as much), and the solution afiB beeorne quite inaccurate if continued to even larger radii. This behavim is quitre surp~gingbecause the error6 in, the Numerov ietegration should be get.t;ing smdler at large r as gi becomes a constant. firther symptoms of a problem em be found by considePing a mare general caM. Mlt3 then h m RO andytical farmda to give us @ near the origin, which we need to get the three-term recursion relation started. One way to proceed is find @(0) by direct numerical quadratare of the Coulomb potentid,
perhaps using Simpson's rule. There will, however, dways be some error wsoeiated with the vdue obtajxled. We c m simulate such an, ermr in, the code above (suppose it is 5%) by inserting the line (just before the DO
59
fSO
S. Boundarg Value and Eigenualua Prablenas
The code then gives the ersors listed in the fourth cafumn of Table 3.1, Evidently disaster has struck, for a 5% &ange in the initial conditions has induced a 50% error in the solution at large r. Xt is simple to understand what hsts happened. Solutions to the homogeneous version of (3.4),
can be added to any particular solution of (3.4) to give yet another solution, There are tvvo linearly indepenhnt Iromogeneous solutions, and q5 W constant ; @
F-'
.
The general solution to (3.4) in the asymptotic region (where p vanishes and the equation i s homogeneous) can be written as a linear combination of these two functions, but the latter, sub-donainant soIution is the physical one, since we know the potentid at large r is given by @ -, l lr. hprecision in the gnecification of rP at the origin or any numericd roundoff e m in ehe inteeation process c m idroduce a, small admixtare of the at, large r. q5 p soXutim:,which eventudy do~xlale-s The cure fbr this diBeul"cy is &raightforward: subtrwt a multiple of the "'bad," anphysical solugion, to the homogeneaus ewatioll from the numerical result to guarantw the physical behavior in the wymptotie region. It is easy to see that the 'bad" results shown in the fourth column linearly with r for large r. The following lines of code (which can be inserted just before the n a p statement) then fit the last 10 points of the numericd solution to the form (and subtract mr from the numerical results to guarantee the angropriab large-r behavior.
9.8 Gmen'g finctisn golution of boundlsry value problem#
The errors in 4 so obtdned are shown in the final column of Table 3.1; the solution is emn more accur&e at large r than the uncorrected one found when the exact value of PHI(1) is used to start the integration. In this simple example, the instabilities we not too severe; satisfmtory rwults for moderate d u e s of r are obtained with outwasd integration when the exact (or reasonably accurate apprauimate) value of PHI(1) is used, Alternatively, it is also feasible to integate inwasd, otarting at lasge r 6 t h qi = Q,independent of r. This results in, a sdution that often satisfies aiecur&ely the boundasy mndition at r = 0 and avoids having to a quadratare to determine the (approximate) stmting value of
PHI(1). Solve the problem defined by Eqs. (3.4,3.9) by Numerov integation inward from large r using the known wymptotie behavior of tiJ fof the starting values. IIow welI do& your solution satisfy the boundary condition 4(r = 0) z= 01
m
Exercise 3.2
3.3 Green's function solution of boundary value proble When thc? twa salations to the homogeneous equation have very digerent behaviors, some extra precautions must be taken. For example, in describing the potential from a charge distribution of a multipole order l > 0, the monopole equation (3.4) is modified to
which has the two homogeneous solutions For large r , the first of these solutions is much larger than the second, so that ensuring the correct asymptotic behavior by subtracting a multiple of this dominant homogeneous solution from a particular solution we have found by outward integration is subject to large round-off errors. Inward integration is also unsatisfactory, in that the unphysical r-' solution is fikely to dominate at @maltr . One possible way to generate an accurate solution is by combining the two methods. Inward integration em be used to obtain the potentid for r greater than some intermediate radius, r,, and outward integration can be used for the potential when T < +m. As long as r , is chosen so that
61
162
3. Bsundarg Value and BigenuaZue Problems
neither homogeneous solutim is d o ~ a m tthe , outer and inner patenlids obtained respectively from these two integrations will match at F, and, together, descrjlbe the a t i r e sdution. Of course, if the inner and outer potmtids don't quite match, a mult;iple of the hamqeneous golution cm be added to the former to comect for m y hficiencies in aur knowledge of Qr(r= 0). Sometimes the two homogenmns solutions have sach &Eere& behwiars that it is impossible to find a d u e af r, that permits sartisfactory integration of the inner and outer potentids. Such cases can be solved by the Green's function of tlre homogeneous eqluatim. To illustrate, let us consider Eq. (3.1) with the boundary condition 4(x = 0) = #(r = m) = 0. Since the problem is linear, W can w ~ i t ethe sdution as
whert; G is a Green's suction sati~fying
It is clear that G satisfies the homogeneous equation far z f si. However, the derivative of G is discontinuousat I = z', as can be seen by integrating (3.14) from s = r f - E to z = zi f E, where E is an infinitesimal:
The problem, of course, is to find G. This can be done by eoxlsjderinig two solutions to the homogeneous problem, arnd (6>, ~.tltiSfSringtbe boundary conditions at rt: -- O and z = so, respective?ly,md nomaiized so that their Wrmslrian,
is unity. (It is easy to use the homogeneous equation to show that W is independent of 2). Then the Green's function is given by
where r , and z> are the smaller and larger of r and z', respectively. It is s and evident: Ghat this expression for G satisfies the h o m ~ e n e m eguatim the discontinuity condition (3.15). From (3.13), we then have the explidt
3.4 Eigenvaluedr of the wave egeralz'on
This expression can be evaluated by a numerical quadrature and is not subject to any of the stability problem we have seen associated with a direct integration of the inhomogeneous equation. and gi> can In the case of arbitrary kZ,the homogeneous solutions be found numericdly by ouward and inward integr&ions;, respectively, of initial value problems and then normalized to satisfy (3.16). However, for simple forms of k2(x), they are known analytically. For example, for the problem defined by Eq. (3.12), it is easy to show that
are one possible sel of hornqeneaus solutions satisfying the approplliatte boundary conditions and Eq. (3.16). Exercise 3.3 Solve the problem definedby Eqs. (3.9, 3.12) for I = O using the Green's function method. Compare your resdts with those obtajned by direct integration and with the andyticd solution.
m
r Exercise 3.4
Sphel.iedly sy
etric solvtioas to the equa;t;ian
l e d to the ordinary diRerenlia1 equation
with the boundary conditions 4(r = 0) = +(P -r W) = 0. Here, a is a constaat. Write a program %osolve this problem using the Green's function when p is given by Eq. (3.9). Compare your numerical results fir varims; v d u e ~Of a with the andytical golution,
What happens if you try to solve this problem by integrating only inward or only outward? What happens if you try a solution by integrating inwmd and outward to an intermediate zn&ching radius? Bow do your results change when you v a y the rnalching radius?
63
84
3. Boundarg Vialwe and Eigenvalue Problem8
3.4 Eigenvalues o f the wave equation Eigenvalue problems involving differential equations often arise in finding the normal-mode solutions of wave equations. As a simple example with wEch to iuustrate a method of solution, we consider the normal modes of a stretched string of uniform mass dendty. After a suitable scaling of the physical quantities, the equation a d boundary conditions defining these modes cm be mitten zw
Here, Q < 5 < I is the aeded coordinate dong the string, 4 is the transverse displxement of the string, and k: is the constant wavenumber, line d y related to the frequency of vibration. This v a t i o n is an eiwnvdw equationi in the sense th%t solutions satisfying the boundary conditions exist only for particular values of k, {k,), which we must find. Furthermme, it is linear m d homogeneous, so th& the normdzation of the dgenfunction comesponding to any ol the k,, is not fixed, bat can be &osen for convenience. The (un-normalized) eigenfunctions and eigenvalues of this problem are weU-known analyticdly ;
+,,
km = nn ; g5n
sin nz3: ,
(3.20)
where n is a positive integer. Them provide a useful Gbe& of the nurnericd methods for solving thiz; problem. One suitable general strategy for numeric& solution of an eigenvdue problem is an itersltive oon. VVe? mesa a trial eigenva9ue and gemrate a solution by integrating the differential equation as a initial d u e problem. If the resulting solution does not satis@ the boundary conditions, we change the trial eigenvalue and integrate again, repeating the process until a trial eigenvalue is found for which the boundary conditions are s&sfied to within a predetermined tderanec;. For the problem at hand, this strategy (known picturesquely as the "shootingn method) can be implemented as follows. For emh trid value of k, we integrate forward from z = O with the initial conditions
The number 6 i s arbitra~yand can be &osen for convenience, since the problem we are solving is a homogeneous one and the normalization of the solutions is not specified. Upon integrating to s = 1, we will find, in general, a non-vanishing value of 4, since the trial eigenvalue will not be
3.4 Bigemvalues of the wave equation
one of the true eigenvdues. We must then readjust k and integrate ~ a i n , repeating the process until we find ~z = 1) = 0 to within a specified tolerance; we will have then found an eigenvalue and the corresponding eigenfunction. The problem of finding a value of k for which &(l)vanishes is a root-finding problem of the type discussed in Chapter 1. Note that the Newton-Raphson method i s inappropriate since we cannot differentiate explicitly the numerically determined value of #(l)with respect to k and the secant method could be dangerous, as there are many eigenvdues and it might be difficult to control the one to which the iterations will ultimately converge. Therefore, it is safest to use a simple search to locate an approximate eigenvdue and then, if desired, switdt to the more efidemtt secant methed. The following FORTRAN program finds the lowest eigenvalue of stretched string problem (3.19) by the shooting method described above, printing the trial eigenvdue as it goes along. The search (beginning at line 10) is terminated when the eigenvalue is determined within a preci. initial trial eigenvalue and the seareh step size are set sion of 1 0 ~ ~The in the second ~ n third d lines. C chp3b.for
RrnL K ! i n i t i a v a n s s t o stwt search
K=1.
BK=Z,
10
IfOU=S. E 4 5 CA= IITGRT(K, PHXP) PHIClW=tPHIP COmIWE K=K+DE CALL ImGRT (K,PHGP) IF (PHIP*PBTOm .LT. 0)
Em
iasmch t o l e r m t s !fi& FEIP a t f i r s t p e s a fox X: !save i n i t i a l PEIP value ing of search loop Iiacreatalz2; II ! c a ~ u l a t ePEIXP f o r t h i s X:
X=K-DX
THEB ! i f PBSP chagea sign, ba&
DK=DK/~
! and Wve3 t h e aeap
up
IF
IF (ABS(BK)
.m, mu) ~ o m$0 Ican$inue mtil fIK i s s m d 1 enough
EXACT=$.*ATAI(I.) PRIIT STGP
*,
p
!exartt v d m e ~ i
eigenvaae, error =\,EE,EXIm-g
65
643
S. Bouradarg Value and Eo'genvalue Pwblems
Ern !sabzoatina t o c d c d a % aphi(s=l)= FEZP for value of R h p a t SmWWIIE IITGRT(K, PIXIPI ItML K DATA I S ~ P 2001 / !8etap li9t;lice pmaeLers B=%.CBSmP PHIR=O. !i n i t i d canditians PHXZ=.0% CI)IST= (K*B) *+2/%2, !can;9tm%in Imszov meLhod, DQ IQ SX-2,NSmF-2 !forwad recmsian eo X=f FHTP=2*( 5 . -5.*CQm'5T] *PBX Z -( Z tCQBST)+PETPI !Eq 3 . 8 PEEP=PBIFI(%+CBIST) !the real o f Eq,3.8 PHIM=PHIZ ! r o l l valnes l
10
PBXZ=PIXIP COmXmB PRflT *, ZI,BEIP RErnEE
EBB
When run, this program generates results that converge to a value close to the exact answer, a, the error being caused by the finite integration. step and the vdue of TOZK. Exercise 3.5 Use the program above to find some of the higher eigend u e s . Note that the numaicd inzcuracies became greater as the eigenvdue increases and the integration of the more rapidly oscillating eigenfunction becomes inaccurate. Change the search algorithm to the more eBcient secaxlt method, How close does p r initial guess have to be in order to converge to a given eigenvdue? Change the code to correspond to the boundary eonditians
and verify that the numerical eigenvalues agree with the analytical values expected, Exercise 3.6 The wave equation in cylindrical geometry often leads to the eigenvalue problem
m
9.5 StaEt'onarg solutions of lfre one-dimensional Schroeditager equation
The andytical eigenfuactims are the re&= cylindricat Bessd funetian c->f order zero, the eigenvdues bdng the zeros of this function: Show that the substitution 9 = r-'f2# changes this equation into one for which the Mumerov dgarithaa is suitable and modify the code &m to solve this problem. Compare the numerical eigenvalues with the exact vdues.
3.5
Stationary solutions o f the one-dimensional Schroe-
dinger equation A. rich e x a p l e of the shooting method far .eigenvdue problems is the task of finding the stationary quantum states of a particle of mass m moving in a one-dimensional potential V(%).Well assume that V ( % has ) roughly the form shown in Figure 3.1: the potential beeome-s irtfinite at, r = and s =,.,g (i.e., there are 'walls" at these positions) and has a weEl somewhere in between. The timeindependent Schroedinger equation md boundary conditions defining the stationary states are [MeGB]
which is of the form (3.1) with
We must find the energies E (eigenvatues) for which there is a nonzero solution to this probXem. At one c>f these eigeavdues, W q e c t the eigenfunction to oscillate in the dassically dowed regions where E > V(+)and to behave exponentidly in the classically forbidden regions where E < v(%). Thus, there will be '4bound" solutions with E < 0, W&& are localized vvithin the well and decay exponenZ;idy toward the walls and gcontinuum" solutions with E > 0, which have roughly constant magnitude throughout the entire region between the walls, The eigenvalue problem defined by Eq. (3.21) can be solved by the shooting method. Supphse that we are seeking a bound state and so take a negative tdal eigenvalue. Upon integrating toward larger z from i m i n , we can generate a solution, +<, which increases exponentially through the clasicauy forbidden redon and then oscillates beyond .the left turaing pojnt in the classically allowed region (see the lower portion of Figure 3.1). If we were to continue integrating past the right turning point,
fir
68
S. Boundary Value and Eligenvalzre Pmblczms
Figwe 9,1 (Upper) Schematic patentid used in the dbcnmion of the one-~mensionatSclzrrzedinger equation, (hwer) Solutions $P<wd +> aP the Schraedinger eqnation at an arbitrary energ E < Q, The lef% turning point, is used m the matching point. When 6 is m eigeavalue, the de~vativeis continuous at the matching paint,
the integation, wodd become numericdly unstable since, even, at an exact eigenvalue where $<(z), = 0, there can be an admixture of the undesira;ble exponenliay gowing ~ ~ I u t i oAs a . a general rule, integration into a classicay forbidden region is fikefy to be inaceurat;e, Thmefort;, aYt each mergy it is wiser to epenerata a second solu.t;ian, $>, by inlegating from g,, toward s m a e r g. To determine whether the enegy is an E?igenvalue, and $> carr be compared a;t a msatehing point, s , cho~en so that neither integration will be inaccurate. (A convenient choice for s, is the left turning pcrint .) Since both and y5> satisfy a, homagenems equation, thdr nomalizations can dwaya be chosen so that the two functions are equal at r,. An eigenvalue is then signaled by equality of the desivatives at ;z, i.e., the sdutions naatGh smoothly; as is invoked in analyticd sQlvtions of such prablenns. Thus,
If we wpro~ma;t;ethe derivatives by thdr simplest finite diEerence approximations (1.4) using the points s , and $,-h, an equivalent condition is since the nomalizations have been chosen to guarantee +< (s, ) = +> (1,). The quantity in Eq. (3.23) is a convenient scale for the difference, which
+
9.5 Stationary solutions of t-he one-dimensional Schrwdi~gerquodian
can be chosen to make f V p i c d y of order unity. l t might be the value of at x, or the maximum value of ,$t or $>. Note that if there are no turning points (e.g., if E > 0 for a potential like that shown in Figure 3.1), then s , can be chosen anywhere, while if there are more than two turning points, three or more homogeneous solutions, each accurate in different regions, must be patched together. The program for Example 3, whose FORTRAN source code is given in Appendix B and in the R h EXMPE3,FOR, solves fof the seationmy states of a one-dimensional potential by the algorithm described above on a lattice of size determined by the parmeter EFTS. The potentid is assumed to be of the form V ( z ) = &v(z), where the dimensionless function v ( s ) has a minimum value of -1 and a maximum value of +l. (This can always be guaranteed by a suitable linear scaling of the energies.) If the coordinat;e is scded by a physied length a , the Shrwdinger equation (3.21) can be written as
where
is a dimensionless memure of the clmsicd nature of the system and 6 = E/% is the dimensionless energy. All eigenvalues therefore satisfy e > - 1. The function4 form of the patentid defined by the grogram can be any one of three analytical types (square well, parabolic well, and Lennard-Jones potential); the square well may also include a square bump, and the parabolic well may be flattened symmetrically about z = 0. For the value of 7 input, a number of states are sought using an initial trial energy and energy increment. For each state, a simple search on the e n e r g i s made to try to zero the function f defined by (3.23) and, when an approximate eigenvalue is located, the secant method is employed becomes less than the value of the matching tolerance (this value may be changed at run time) For each trid eigenvalue, the Schroedinger equation is integrated forward and bxkward, and the two salations are matched at the left-most turning point where the behwior of the wave if there is function changes from oscillatory to exponential (near ,.,I no such turning point). As the search proceeds, the trial eigenvdue i s displayed, as is the current step in the energy, the current value of f , a ~ d the number of nodes in, the trial wave function. As the solution is
69
78
9. Bopmdarg Value and Bigenvalue Problems
likely to be inaccurate when it is integrated into a dassicalfy forbidden region, the program also indicates whether or not this is the case. When an eigenvalue is found, it is indicat;ed on a g a p h of the potentid by a line at the appropriate level between the left-most and right-most turning points and the eigenfanction is dso gaphed. A dificulty arises fram the ibrbitrary phase of the wave function and the dependence of the sign of f cm that phase. If we are arbitrary &oat; the sign of $, then the sign off is also arbitrary. However, since the search procedure uses the sign of f as a sign4 for crossing a root, this situation must be avoided. Therefore, to ensure that f is a continuous function of e n e r o the sign hctor is completdy determined once the seaseh is started, Often in quantum mechanics, the a v e r d sign of the wave function i s of little consequence. However, in this program the sign of + ( S ) determines the sign of f which in turn signats the crossing of a root. Therefore, to ensure that f is a continuous function of energy we must choose the sign of +(z) carefully. At the beginning of the search a sign is chosen arbitrarily (e.g., $<(h)> 0). This sign convention continues as the energy changes until a new node appears in the trid wave function, To keep f continuous, th& gains the node mast the portion of the wave function (+< or retajn the s m e sign betvveen steps in the search, (By drawing a few graphs you can convince yoursdf that this is the case.) This new s i p convention is retained until another node q p e m , when the new sigxl is chosen by the s m e criterion, The following exercises can help to improve your understmdi~gof the physicd principles and nunrericd methods illustrated in this example. Exercise 3*7 Verify that the code gives the expected mswers for the eigenvalues of the square-well and parabolic-well patentids (y = 50 mjght be a mnvenient mlue to use), Observe how the dismtinuity in the derivative at the matching point is smoothed out as the energy converges to each eigenvalue. Also note the increase in the number of nodes with increasing eigenvalue and, for the parabolic well, the behavior of the solution. near the turning gdnts. For states with l q e quantum numbers, the amplitude of the aftcillations becomes larger new the turning points, consistent with the behavior of the WKB wave function, which i s proportional to the inverse square-root of the classical velocity, (E v ) - ' / ~Find . some solutions in these potentids also for values of y that are small (say 10) and large (say 2001, corresponding to the extreme quantum and daf;ical limits, respectively;
3.6 IS;tat:onary solutions of the one-dimensional Sckrodinger wuation
Exmciw 3*8 For the m d y t i c d y salable square and pafaboGc welh, investigat;e the eEects of &angin% the integration method from the Numerw dgoaithm to the '"nsve" one obldned by appra~matingthe seeond derivative by just the three-point formula (1.7); that is, neglecting the 6 ( h 2 )term in (3.6).
r
16xweist3 3.9 Change the progam so that the eigenvdues me found by integrating only forward and demanding that the wave fanceian vanish Qbserw the problems that arise in trying to integrate an exat g,,,. ponerttidy dying sdution into a classicadly forbiddea regon, (It is wise to keep 7 relatively small fiere so that the instabilities don't become tas large.) r
Exercise 3.10 When the potential. is reflection symmetric about z = 0, the eigenfunctions will have a definite parity (symmetric or anti-symmetric about I = 0) and that parity will alternate as the quantum number (energy) increases. Verify that this is the case for the numerical solutions generated by the code. Can you think of a way in which the parity can be exploited to halve the numerical effort involved in finding the eigenvalues of a symmetric potentid? ff so, modify the code to try it oat. Exercise 3.11 If we consider a situation where v(%) = O for r < I,. and I > S,,, (i.e., we remove the walls), then the zero boundary conditions at $he ends of the lattice are inappropriate for weaMy bound ~ t a t e s ( E 6 0) since the wave function decays very slowly as 1 and g,, are therefore More appropriate boundary conditions at r
Change the code to implement these boundary conditions and observe the eEeet on thc? wave functions afld energies of the states n e a zero energy. Note that if we were to normaEze the wave functiaa in the conventional way, the contributions from these exponential tails would have to be included. Can you derive, in the style of the Numerov algorithm, a numerical redzation of these boundary conditions accurate to a high order in DX? Exercige 3.22 Check nzrmericdly that, for a given golentid, two eigenfunctions, $E and +h, corresponding to different eigenvdues E and E', am orthogond,
B
+~(2)$k(2)dg=
0,
7%
72
S. Boundary Value and Eigetavalue Problemor
as iis m q ~ r e dby the general principle8 of quantum mechanics, m
Exercise 3.13 For small, intermediate, and large values of 7,compare
the exact eigenvdues of the Lennard-Jones potential with the semidassicd energies generated by the code for Example 1. Exercise 3.14 Investigate the eigenfunctions and eigenvalues for potential~you might have encountered in learning elementary quantum mechanics: the Cfunetion potential, a finite square-well, double-well potentials, periodic potentials, etc. This may be done by dtering the potentid in subroutine POTNTL. Interpret the wave fundions and eigenvdues you find. (Note that the code will sometimes have trouble finding two eigenvalues that are nearly degenerate.)
m
Project III: Atomic structure in the Hartree-Fock approximation The self consistent field approximation (Hartree-Fock) is known to be an aemrate descfipti~nof many of the properties of multi-eledron atorns and ions. In this appraxirnatim, each electron is described by a separate single-partide wave funetion (as distinct from the many-electron wave function) that solves a Schroedinger-likeequation. The potential appearing in this equatioa is that generded by the average motion of & of the other electrons, and so depends on their sinde-particle wave fiaelions. The resdt is a set of an-fine= eigenvdue equalions, wEch c m be solved by the methods introdumd in this chapter. In this project, we vviU solve the seIf-consistent field equations to deternine the pound-st&e ~itracture of small atomic systems (e.g., the atoms aod ions of the elements in the periodic table from Hydrogen through Mean). The totd energies cdculated em be compmed direct& with experimental values. The brief derivation we give here cm be supplemented with the maLerid found in [Be68], [Me68], and [We80].
111.1 Basis of the Hartree-Fock approximation ltonian for N dectroas moving about a heavy nucleus of ehar~;ge Z located at the ori@a can be writtea as
Here, the {ri) are the locations of the electrons, m and -e are the electron mass and charge, and rij E ri - rj is the separation between
electrons i and j. The three sums in (111.1) embody the electron kinetic energy, the electron-nucleus attraction, and the inter-electron repulsion. As is appropriate to the level of accuracy of the self-consistent field approximation, we have neglected much smaller terms, such as those assodated with the spin-orbit int;eraction, hypefine interactions, recoil motion of the nucleus, and relativity. A proper quantum meehanicd description requires that we specify the spin state of each electron, in addition to its location. This can be done by giving its spin projection on some fixed quantization axis, = f 1/2. For convenience, we will use the notation (E$,oi) to denote all of the coordinates (space and spin) of electron i. The seE-consistent field method8 ase based on the Rayleigh-Ritz vmiationalt principle, which states that the ground &ibCe eigenfanctim of the Hamiltonian, @(gl,$2,. ..,z N ) ,is that wave function that minimizes the eqectation value, of H, subject to the constraints that B! obey the Pauli principle (i.e., that it be anti-symmetric under the interchange of any two of the z's) and that it be norrvlrilized to unity:
(The notation d N z means integration over all of the spatial coordinates ation over all of the spin coordinates of the N electrons.) Furthermore, this minimum value of E is the ground state energy. A calculation of (111.2) for any normalized and anti-symmetric trial function P therefore furnishes an upper bound to the ground state energy. The fifartree-Fock qproSmatioa is based on restl.icting the trial wave function to be a Slater detex~nant:
Here, the $,(I) are a set of N orthonormd single-particle wave functions; they are functims of the coor&nates of only a siagle electron. The determinant is that of the M x N matrk formed as a and zi each take on their N possible values, while the factor ( N ! ) - ' / ~ ensures that $P is normalized according to (111.3). The physical interpretation of this wave orbitd function is that each of the dectrons moves independently in under the average inguence of all the ather electrons. This turns out; to be a good apprainrdion to the t m wave function of an atom because
4
9. Boundary Value and Eigenvalue Pmblern9
the smooth Coulomb interaction between the electrons averages out many of the det&ls of their motion.
Uairrg the properties of determinants, it is easy to see that @ has the required anti-symmetry under interchange of any two electrons (a determinant changes sign whenever any two of its columns are interchanged) and that i s properly normalized according to Eq. (111.3) if the singleparticle wave fmctiorrs are orthonormd:
Since the Hamiltonian (111.1) does not involve the electron spin variables, the spins decouple from the space degrees of fredom, so th& it is ua;efd to writGe each sinde-pmticle wave functioa as a, product of spme and spin functions:
(111.6) where o, = f1/2 i s the spin projection of the orbit4 a. The orthonormality constraint (111.5) then takes the form
that orbitals c m be orthogond by dther their spin or spac~edependence, The computation of the energy (111.2) using the wave function defined by (IB.4-6) is straightforward but tedious. After some algebra, we have 6 3 0
In this expression, the one-body matrix elements of the kinetic energy are
the electron density i s the sum of" the sinde-paftiele densitirss,
the electrostatic potential generated by the electrons is
(Ill.1l a ) so that V ~ P= ,-4aezp(r)
,
( I l l .l lb)
and the exchange matrix elements of the inter-electron repulsion are
The interpretation of the various terms in (111.8) is straightforward. The kinetic energy is the sum of the kinetic energies of the single particle orbitals, while the electron-nucleus attraction and direct inter-electron repulsion are just what would be expected from a total charge of -Ne distributed in space with density p(r). The final term in (111.8) is the exchange energy, which arises from the anti-symmetry of the trial wave function (111.4). It is a sum over all pairs of orbitals with the same spin projection; pairs of orbitals with different spin projections are 'distinguishable" and therefore do not contribute to this term. The s t r a t e a of the self-consistent field approaeh should now be clear. The variational wave function (111.4) depends on a set of "parameters": the values of the single-particle wave functions at each p&nt in s p w , Variation of these parameters M, as to minimize the energy (111.8) while respecting the constraints (111.7) results in a set of Euler-Lagrange equations (the Eartree-Fock equations) that define the "best" determinental wave fanctim afld @ve m optinad bauad on the tot& enerw. Because these equations are somewhat compficated in detail, we conaider first the tw-dectrm problem, and then turn La situations with thrw or more electronis.
111.2 The two-electron problem For two electrons that don't interact with ewh other, the ground ~titteof their motion around a nudeus is the %a2configuration; i.e., both electrons are in the same real, spherically symmetric spatid state, but have opposite spin projeetions, It is therefore naturd to take it trial wave function for the interacting system that redizes this same configarsttion; the corresponding two single-pastick wave functions me
76
9. Boundary ltalue and Eigenvalere Pwbkens
so that the many-body wave function (111.4) is
This trial wave function i s anti-sy etdc under the interchange of the r the interchmp of th electron q i z s bat is symmetric coordinates. It respects the Pas p h d p l e , since it is antis under the interchange of all variables describing the two electrons. The normalization condition (111.5) becomes
while the energy (111.8) becomes
a
(111.16) with (IIL10) reducing to p(.)
1 4nr2
= 2 x -R'
(r)
and (IIl.11b) becoming
Note that the a&ange energy i s attractive and has a magnitude of onehalf of that of the direct inter-electron repulsion [resulting in a net factor of 114 in the find term of (III.16)] and that various factors of two have entered from the mm over the two spin projections. A common variational treatment of the two-electron system ("poor man's Hartree-Fock") takes R to be a hydrogenic 1s orbital parametrized by an effective charge, Z':
where a is the Bohr radius. The energy (EL16) is then minimized as a func%iianof Z" to find m approximation to the wave function and energy. This procedure, which i s detailed in many textbooks (see, for example,
111. Atomic 9tructum in &c: Narlrm-FNX: appro%imaEion
[Me68]), results in
In carrying out this minimization, it is amusing to note that the kinetic energy scales as while all of the potential energies scale as E*, so that, at the optimal Z', the kinetic energy is -112 of the potential. This is a specific case of a more general virid theorem pertaining to the HartreeFock approximation (see Step 1 below). ation jfQrthe tweelectron problem The full Hatree-Fock app is very much in this same variational spirit, but the most general class of normalized singlepartide wave functions is considered. That is, we consider E in Eq. (111.16) to be a functional of R md require that it be stat;ianary with respect to all possible norm-conserving vdations of the single-particle wave function. If the normalization constraint (111.15) is enforced by the method of fiagrane aadtipEers, for an afbiitrav vsiatim of 6R(r) we require
where E is a Lagange rnultipXier $0 be d e t e r ~ n e daft= variation so that the solution is pmperly nomalized. The standard techniques of vmiatio~dcdcdas then lead to
which is satisfied if R solves the Schroedinger-like equation
Choosing E (the "single-partide energy") to be an eigenvalue of the singleparticle Hamiltonim appearing in (111.23) ensures that R is nomalizable. Equations (III.18,23) are the two coupled non-linear differential equations in one dimension that form the Hartree-Fock approximation to the original six-dimensional Schroedinger equation. Note that only one-half of @ appears in (111.23) since each electron interxts only with the other and not "with itself"; inclusion of the exchange tern in the energy (III.16) is necesswy to get this bookk~pine;right.
TT
78
S. ET-oundargr Vixlue and EigenvaZue Probbms
The assmption of spherical symmetry is m enomous simpEfication in. the two-dectron pro'filem, as it dowed us to reduce the aigenvdue problem for the sin$e-partide wave function aad the Poisson equation folc the potentid from three-&measion4 partid diEerrtntial equations to ordinary differentid equations. For the two-electron problem, it is plausible (and true) that a spherical& sy etric solution has the lowest energy* However, for most many-eleetmn systems, spheric& symmetry of the density m d potential axe by no metbns gailranteed, In principle, non-spherical solutions should be considered, and such "&famedB wave functian~are in fact -the optimal ones for describing the structure of certain nuclei. To undwstand what the probhrn is, let us assume that the potentid 4t is spbericdy symmetric, The solutions to the single--partide Schroe&nger equation in such s potential me orga~zedinto "sheas," each characte~zedby an arbitd angular momentum, I, a ~ ad r d i d quantum number, n. Within each shell, all 2(2l f 1) orbitals associated with the vasious vdues of a, a;nd tbe projection of the orbltd m e f a r momentum, m, are degenerate. The orbitds have the form
However, we must decide which of these orbitals to use in constructing the Hartrw-Pock determinant* Unless the number of electrons is such thak all of the 2(2I 1)substates of a given shell are filled, the density as given by (111.10) will not be spherically symmetric. This, in turn, leads to a nonsymmetric potential and a much more &%cult single-particle eigenvdue equation; the general problem is therefore intrinsically three-dimensiond. A slight modification of the rigorous Hartree-Foch method (the filling or central-field approximation) is useful in generating a spherically symmetric approximation to such "open-shell" systems. The basic idea is to spread the vdence electrons uniformly over the last occupied shell. For example, in discussing the neutral Carbon atom, there would be 2 electrons in the i s shell, 2 electrons in the 29 shell, and 2 electrons spread out over the 6 orbitals of the 2p shell. (Note that we don't put 4 electrons in the 2p shell and none in the 29 shell since the single-partide energy of the latter is expected to be more negative.) Thus, we introduce the number of electrons in each shell, Nnl, which can take on integer values between 0 and 2(21+ l),and, using the wave functions (III.24), write the
+
density (111.10) as
In writing this expression, we have used the identity
In the same spirit, the energy functional (111.8) can be generalized to open-shell situations as
with the exchange e n e r a being 1
E,, = --
13-1"
C N,rNalp C
A=if-l*\
nlnt18
Ia.this expression, I is the i n t e p d
(111.27) where r< and r> are the smaller and larger of r and r' and the 3 - j symbol v ~ s f i e swhen l l'+ A Xis odd and otherwise has tfio vdue
+
(-l
+ l[+ A)! (l - l' + A)! (l + lt - A)! (I
X
5 + +
+ l'+ X + l)! P!
- l')!(JJ - l f ) !@ - X)!
where p = ( l l' A). In deriving these expressions, we have used the multipole decomposition of the Coulomb intesitedion and the standard techniques of angular momentum algebra (Br68]. The Hartree-Fa& equations defining the optimal radial wave functioans aovv foUow from the calculus of varialioas, as in the two-electran
80
S. Boundary Value and Eigenudue Problems
case. Lagrange multipliers Ear are introduced to keep each of the radial wave function normalized and, after some algebra, we have
The eigenvalue equation (III.28a) can be seen to be analogous to (111.23) for the two-electron problem, except that the exchange energy has introduced a non-loc&ty (Fock potential) embodied in F and has coupled together the eigenvalue equations for each of the radial wave functions; it is eagy to show that these two eqvations are equivalent when tbere is a single orbital with l = 0. It is useful to note that (III.26b, 28b) imply that the exchmge energy can be also be writ.tt3lt as
and that, by multiplying (III.28a) by R,r and integrating, we can express the single pastilcle eigenvdue as
111.4 Solving the equations For the numeric4 solution of the Eartree-Pock equa;tisats, we must, jimt adopt a system of units. Far comparison with experimental vdues, it, i s convenient ta merrsure all lea@hs in Angstroms m d 41energies in dectraa
volts. If we use the constants
then the Bahr radius and wdberg have their correct vdues,
For a lmge atom with many electrons, the accurate solution of the Hatree-Fock equsttions is a considerable tmk. Rawever, if we consider the ground states of systems with at most 10 electrons (requiring three shells: 18, 29, and 2p), then the numerical work can be managed in a reasoxlable m o u n t of time. A lattice of several hundred points with a radid step size of 0.01 A extending out to B 3 A should be sufficient for most cases. The best appmach to developing a progrm t;o tistve the Bartree-Fsck equations is to consider the two~eleetra~ problem fir~t,for which t h e is only a sinde radial wave function solving a locd eigenvdue equation, and then to consider the more complex case af several, orbit&. The attwk can be made through the following sequence of steps. Step 1 Verify the dgebslz leading to the find equations presaged above for the two-electron system [Eqs. (III.16,18,23)] and for the multielectron system [Eqs. (III.18,26,28)] and make sure that you understand the phygi~dyincipfes behind the defivations. Prove the virial theorem that the kinetic energy is 112 of the potential energy. This can be done by imagining that the single-particle wave functions of a solution to the Hwtree-Pock equations are subject to a nam-preserving scaling trmdormation,
r
-
~a (r)
+
,
X(~P)
where r is a dimensionless scaling parameter. Show that the total kinetic energy in (111.8) scales as r Z ,while 4 of the potential energies scale as r. Since the energy at the Hartree-Fock solution is stationary with respect to any variation of the wave functions, use
to prove the theorem.
82
3. Boundary k l u e and Bigenualucr Problr?ms R
Step 2
Write a program to calculate the energy from (III.16) if
R is known at all of the lattice points. This will require writing a subroutine that calculates @ by solving (111.18) (you might modify the one given earlier in this chapter) and then evaluating suitable quadratures for the various terms in (111.16). Verify that your program is working by calculating the energies associated with the hydrogenic orbitat (111.19) and comparing it with the analytical results [remember to normalize the wave function by the appropriate discretization of (III.15)]. Step 3 Write a subroutine that u ~ the s shooting m t h o d to solve the radial equation (111.23) for the lowest eigenvdue e and corresponding normalized wave function R if the potential Q i s given at the lattice points. The zero boundary condition at the origin is easily implemented, but the boundary condition at large distances can be taken as R(r = L) = 0, where L is the outer end of the lattice. (Greater accuracy, particularly for weam bound states, can be had by imposing instead an exponential boundary condition at the outer radius.) Note that the radial scale (i.e., R and the radial step size) should change with the strength of the central charge. Verify that your subroutine works by setting @ to O and comparing, for Z = 2 and Z =; 4, the cdculated wave function, c?igenvdue, and enerrgy of the 1s orbital with the analytical hydrogenic vdues. Skep 4 Combine the subroutines developed in Steps 2 and 3 into a code that, given a value of Z, solves the two-ejectrm Hartme-Fock equations by iteration, An iterdon scbe-zneis as MIows, the organization into submutines being obvious: i ) "Guess" an initial wave function, say the hydrogenic one (111.19) with the atpprapPiibte v h e of Z*. ii) Solve (111.18) for the potentid generated by the initial wave function and calculate the total energy of the system from Eq. (111.16). iii) Find a new wave function and its eigenvdue by solving (111.23) and normalizing according to (111.15). i v ) Calculate the new potential and new total energy. Then go back to ii) and repeat i i ) and iii) until the total energy has converged to within the required tolerance. 8
At each iteration, you should print out the eigenvdue, the total energy, and the three separate contributions to the energy appearing in (111.16); a plot of the wave function is also useful for monitoring the calculation. Note that the total energy should decrease as the iterations proceed and will converge relatively quickly to a minimum. The individual contributions to the energy will take longer to settle down, consistent with the
111. Atomic structure in the Hartme-fick appro~mation 83 Table IE1X.X: Binding enerees (in eV) of small atomic sysLems
fact that it is only the total energy that is stationary at the variational minimum, not the individud cmpaoeats; a f ; convergence, the virid theorem discussed in Step 1 should be wtisfied. Try bednning the iteration procedure with different single-particle wave functions and note that the converged solution is still the same. Vary the values of the lattice spacing and the bovndmy radius, &, and prove that your results are stable under these chmges* Step 5 Use: your progrm to solve the Eatre-Fack equation8 for centrd c h a s e s Z = 1-9. Compare the total, energies obtained with the experimental values @WEin N = 2 column of Table III.1. (These binding energes, wkich are the negative of the toed energies, me obtined from the measured ionization potentids of atoms and ions given in [WeTl].) Compare your results &so with the w w e .functions and msociated variational energies given by Eqs. (III.19,20). Note that both approximations shatlld give upper bounds to the =act energy. Give a, physical explanation for the quafitative behwior of the discrepancies as a functioa of Z. C m you use second-order pc?ft;urbationtheory to show that the discrepancy between the Bartree-Fock a ~ exact d eaergies should become a mnstztnt for large Z? Show that for Z = 1, the Hartree-Fo& approximation predicts that the H- ion is unbound in that its e n e r g is greater than thnt, sf the H &torn and so it is energetically hvorabb to shed the extra electron. As can be seen from Table 111.1, this is not the ease in. the red world. In finding the Z .= 1 sdution, yaa might discover thhal convergence is quite a delicate business; it Is very emy for the density to change so much from iteration to iteration that $fie lowest eigenvdue of
m
84
9. Boundary Value and Ei~c~inutxlue Pmblemsr
the sinde-particle H I t o ~ mbwames positive. One way to dleviate this problem is to prewnt the density from chmging too m a d from one itePation to the next, for exmpfe by averagng the new density and the old following step ii) above. SIep 6 Modify your tw&-electronprogram to treat systems in which several orbitds are involved. let is ea~iestto first modify the c d c d a t i ~ n of the total enesw for a @ven set of r d i d wave firactions to indude G,, This ia most convedeatly done by cdcnlating and storing the E",l of Eq. (III.28b) and using Eq. (III.29). Because of the Fock term, the eigenvalue equations (III.28a) cannot be treated by the shooting met hod we have discussed. However, one krcheme is to treat the cdeulated from the previous set of wavf? funetions as infiomogeneous $ems in solving for the new set of wave functions, For trid vatues of the t.,l cdcu1a;t;ed from (111.30) using the previous set of wave functions, (III.28a) can be sdved as uncoupled inhomogeneoas bmndasy vduts problems using: the Green's function method of Eq. (3.18); after normalization according to (III.24), the solutions serve as a new set of wave functions. The twoelectron systems can be used to check the accuracy of your modifications; for these systems you should find that the exchange energy i s -1/2 of the direct inter-electron intewtim enerfSy and that the d u t i o a s converge to the same results as those generated by the code in Step 4. Use this Bartree-&ck code to cdcdate the wave fundons and merges for some of the other systems listed in Table 111.1 and compare your results with the experimental values; interpret what you find. A convenient set of initial wave functions are the hydrogenie orbitals, given by (111.19) for the 16
m
for the 29 and 2p states, respectively. The optimal common value of Z* in these expressions should be determined for any system by minimizing the toed energy.
Chapter 4
Functions and Gaussian Quadrature .S
In this chapter, we discuss two loosely related topics: algorithms for computing the special functions of mathematical physics (Bessel functions, orthogonal polynomials, etc.) and eflicient methods of quadrature based on orthogond functions. In most scientific computing, large libraries supply almost all of the subroutines relevant to these tasks and so relieve the individlzd from the tedium of writing code, h f x t , there is usually little need to know very much about hovv these subroutines work in detail. However, a roug6 idea of the methods used is useful; this is what we hope t o impart in this chapter.
4.1 Special functions The speclaI functions of mathematicd physics were largely devdoped long before large-scde numeric& camput ation became feasible, w h n mtll ytical methods were the rule. Neverthefess, they are still relevant today, for two reasons. One is the insight m d y t i c d solutions offer; they mide our int&tion and provide a framework for the qualit(ative interpretation of more compEcated problems, However, of particdar importance! to numerical work is the fact that specid functions often aflow part of a problem to be solved analyticdly and so dramatically reduce the m o t l M of computation required for it full sdution, As aa inustratian, con~idera one-dimension4 harmonic osciUator moving under an externd perturbation: its f r e q u m c ~W, ~ ,i~ being changed with time. Suppose that the frequency h a its unperturbed value, wo, for times before 2 == 0 and for times after t > T,and that we are interested in the motion for times long after the perturbation ceaws. Given the oscilfator" sinitid coordinate m d vf?focity, one strdghtforwmd methad of
solution is to integate Lhe equations of motion,
as an initid-vdue problem using one of the methods discussed in Chapter 2. However, t h i ~would be ineaicjient, M the motion after the perturbation stops (t > T) is well understood and is readily expressed in terms of the "specid- sine md cosine fuacttio~sinvolved, I($ > T)= s(T)cos
- T) + w c ' v ( ~sin ) wo(t - T ) .
Sinw thwe are very efficient methods I;or computing the trigonometric functions, it is wiser to integate numericalb only the non-trivial part of the motion (0 < t < T ) and then to use the velocity and coordinate at 1: = T to compute directly the sinusoidd function @ven above. Aftbough this example might seem trivial, the concept of using special functions to "do part of tht? arork" is a general one. A useful resource in deali~gwith specid functions is the findbook. of Mathematical Functions [Ab64]. This book contains the definitions and properties of most of the functions one often needs. Methods for computing them are also given, as well as tables of their values for selected arguments. These last are particularly useful for checking the accuracy of the subroutines you are using, Recursion is a pwticdarly simple way of computing some sgeGid functions. Many functions are labeled by an order or index and satisfy recursion rel&ions with re~pectto this labd. If the function can be cornputed explicitly for the few lowest orders, then the hkher orders can be found from these formulas, As an example, consider the computation of the Legendre polynomiais, &(I), for is1 _< I and 4 = 0,1,2,. ... These are important in the solution of wave equations in situations with a sphericat symmetry. The recursion relation with respect to degree is
= I, forward recursion in Using the explicit values Fa($)= 1 and PI(%) I yields PI for any higher value of I required. The following FORTRAN program accomplishes this for any value for s and I input.
ELSE IF (L .Eq. O ) PL=O
.
mm lexplick* form for L=0
ELSE IF (L .EQ. 1) TBm PL=X ELSE PH=i
.
!axpXicit i o m for L=% !valass to s t a r t r e ~ w s i o n
PZ=X
!loop f o r forti~mdrecwsion DO 10 XG=I,L-1 PP=( (2+fL+ l) *X+PZ-EL,*PM)/(IL+l] !&q. 4.1 PM=PZ !rolil v d a e s PZ=PF GOWTIW$
PL=PZ EBB T F PRIm *,X,L,PL GOTO 20
EBD This eode works wlth no problem, md $he r e ~ d t swrw with the v&ues &ven in the tables to the arithmetic precision of the computer. We can d ~ mrngute a the derivlatives of the Legendrt, pdynamids with this dgorithm using the relatioxl
Otber sets of arthoganal palynomials, such as Hermite and Laguerre, can be treated similwly.
As a second example, consider the cylindrical Bessel functions, $,(I) and Y,(s), which arise as the regular and irregular solutions to wave equations In cylindr'rcd gwmetries. These funetions satisfy the recursion relation 2% C,-'(Z) Cn+1(5) = ;Cn(%) , (4.3)
+
where C,, is either J, or Y,. To use these recursion relations in the forward direction, m need the vdztes of and @I. These me most ewify o b t ~ e d from the polynomial appravimations given in [Ab64], formulas 9.4.1-3.
88
4, S p c i d Functions and Gau~lsianQuadratam Table 4.1 Forward recursion fbr the irregular Bexssel function Vn(2)
where y = $13 and
Jo(z) = z-'/2fo cos B
&(g)
= z-'i2fo gin B
(4.w
where fo = 0.79788456 - 0.00000077~-'
- 0.00552740~-' - 0.00009512y-~+ 0.0013723~y-~- 0.00072805~-~
(4.4d)
+ 0.00014476~-~+ E ; IE
Similar expressions for J1 and Ylare given in Sections 9.4.5-6 of [Ab64]. Mote that these formalas we not Taylar sedes, but rather polyna~a;fs whom coefficients have been djusted to best represent the Bessd functions aver the Intervds dverr.
Table 4.2 Gannputatian af the regulrr~:Bmeel funetian Jn(2) Pt
Exact vdae
famrr~:drmrsiran backward recursion
+
0 0,223891E 00 1 O.ti76725E $- 00 2 0,3528346 -5.00 3 0.1289436 4.00 4 0.339951E 01 5 0.703963E 02 6 0,120243E 02 "7.J74944E 03 8 0.221795E 04 9 0.2492346 -. 05 i o a.251s39~ 06 11 0,2304286 07 l 2 0.193270E 08 13 0,14949414: 09 14 0.101295E 10
-
-
-+00 + 00
0,OQOOQOE 0.000rt00E: 0.000@OOi5' 0.000000E -0,0000Q2E -0.OO0075E -O.o@@355rs" -0,0205596 -0.1403Ei3E -0.110234B -0.978959B
+ 00
-+00 - 01 - 02 - 02
- 03 - 03 - 02
- 02
0.1506Q2E -. 10 0.38794OE 110 0,233337E g0 0,867350E 11 0.228676E l1 0.473828E: 12 0.808826E 13 0.117678E 13 O.l4Sr93E f 4 0,167650E 15 0.169200E 116 0.155000E 17 0.1300003 18 Q.100000E 19 0.00000OE 19
-
-
--
-
-
-
b d w a r d recursion
tt.oooaooE + oo
+
o.ooooo0E 00 0,0000006 -I. 00 0,000@00E 00
+
o,ooooooE - or a , o o a a o ~-~oz
- oz
0,ooooooE 0,000o00E 0,~oooooE 0,000000E O.OOO0OOE O.oOo000E
- 03
- 04 - 05 - 06
- 07
o.oooao'i"~- 08
0.000830E 0.1072956
- 09
- IQ
Let us now attempt to cdenlate the Y , by fomard recursion using (4.3) together with the polynomial approximations for the values of Yo and Yl. Doing so leads to results that reproduce the values given in the tables of Chapter 9 of [Ab64] to within the arithmetic precision of the computer, For e x a p l e , we find Ghe results fisted Table 4.1 for a -- 2, 1%is natural to try to compute the regular solutions, J,, with the same forward recursion procedure. Using Eq. (4.4a) and its analog for Jx, we find the errors listed in the third column of Table 4.2; the exact values are given in the second column. As can be seen, forward recursion gives good results for n < 5, but there are gross errors for the higher values of n. It i, relatively easy to understand what is going wrong. We can think about the recursion relation (4.3) for the Bessel functions as the finite difference analog of a second-order differential equation in n. In fact, if we subtraet 2C, from both sides of (4.3), we obtain
which, in the l i ~ oft continuous n, we can czpproxinzate by
In deriving this equation, we have used the thrc?e-point fiaite diEesence formula (1.7) for the second derivative with h. = 1and have identified the local wavenumber, k2(n). Equation (4.6) will have two linearly independent solutions, either both oscillatory in character (when k2 is positive, or when n < r ) or one exponentidly growing and the other exponentidy decreasing (when k2 is negative, or n > I). As is clear from Table 4.1, Y, is the sdution that grows exponentidly with inerea~ingsz, scr that no loss of predsion occurs in farwad recursion. However, Table 4.2 shows that the exact vdues of J, decreahse rapidly with incmwing n, and so preci~ion is lost rapidly as forward recursion proceeds Beyand n = g , TEs disease i s the s m e as that; errcountesed in Chapter 3 in integrating exponentidy dying solutions of second-order differentid equations; its care is &so the same: avoid using %berecursion relation in the direction of decrewing vdues of the function. Exercise 4.1 Use Eq. (4.1) to show that recursion of the Legendre polynomials is stable in either direction.
To compute the regular cylindrical Bessel functions accurately, we can exploit the linearity of the recursion relation and use Eq. (4.3) in the direction of decreasing n. Suppose we are interested in J,(2) for n 5 10. Then, choosing Jlq= O and JI3= 1X &B arbitrarily small number, we c m recar backwards to n =; 0. T h e resulting sequence of numbers will then reproduce the J,, to within an arbitrary normalization, since, as long as we have Ghosen the initial vdue of n high enaugh.?the required solution of the difference equation (4.3), which grows exponentially with decreasing n, will dominate for small n. The sequence can then be normalized through the identity
The following FORTRAN code evaluates the regular cylindrical BesseX functionts using badward recursion.
g00
PRXIT +, "%er nax v d x e 09 n (.Jle. 60; .It. O R W *, mILx I F (IMAX ,LT. 0 ) STOP I F (IHAX
PEGIT
*,#
.GT.
t o stop)"
60) mAX=60
&%ex vazue o f x p
READ * , X C
.
3 f la3mX)=Q
!baekwwd r e c w s i a ~ s
When run for NMAX=14 and X=2, it gives the unnormalized values (i.e., after line 10) shown in the fourth column of Table 4.2 and the errors in the find d u e s shown in the fifth calurrrn of %hattable. The results are surprisingly aecur;zte, e m far vdues of sz dmtl to 14. An dkrnatiw way of obtaining the constant with which to n o m a z e the whole series i s to calculate the value of Jo(2) from the polynomial approximation (4.4a). m Exercise 4.2 Run, the code above for various d a e s of MMAX at k e d X, By wrnparing with tabulated vdues, verify thaG the resufts are accurate as long as NMAX is large enough (somewhat greater than the larger of X and the maximum order desired). Change the normalization algorithm to use the approximations (4.4a,c) for Ja.
92
4. S p i d Funclr"or?9and Gau8arian Quadratam Exercise 4.3 The regular and irregular spherical Bessel functions, jr and nj, safisfy the recursion relaeion
whae 81 is either jr or % l . The explicit formalas far the few laarest mders atre sin a ; jl=.--sin z cos 3= 3 I== sin rt: -cos X: ,
IZ:
= --COS z ; *2:
%g
'
%g
8
cos z sin, z
c -
$2
Z
3
COS 2-- z2
sin z
.
At z = 0.5, the exact vdues of the fultetiotrs of order 2 are
Show that 122 can be c&ulatced either by explicit evdu&ion or by forward mcur~ionand canvim yourself that the latter method will work for all 1 and z. Investigate the calculation of jz(0.5) by forward recursion, exglieit evduatim, and by backward reeursioa and show that the first two methods c m be quite inaccurat;e, Can you see why? TZlus, even if expl;lcit expressions for a fnneLjon me available, the stability of backward recursion can make it the method of clrdce.
Our discassion h a iflvstr&ed s m e pitfds in comput;ing the some commonly used spedal functions. Speeifie methods useful for other functions can be found in the appropriate chapters of [Ab64].
4.2 Gaussian quadrature In Chapter 1, we discussed several methods for computing definite integrals that were most convenient when the intepand was known at a series of equally spaced lattice points. While such methods enjoy widespread use, espeddly when the integrand involves a numerically-generated solution to a differential equation, more efficient quadratare schemes exist if we can evaluate the integrand for arbitrary abscissae. One of the most useful of these is Gaussian qu&ature. Cansida the problem of evaluating
The f"omdasdiscussed in Chapter 1 were of the form
where are the equatly spaeed lattice points. Here, we are referring to the "elementaryn quadrature formulas [such as (1.9), (1.11), or (1.13a,b)],and not to compound formulas such as (1.12). For example, for Simpson's rule (1.11), N = 3 and
fiom the derivation of Simpson's rule, it is clear that tfie fbrmula is exact when f a p d y n o ~ a lof degrw 3 or less, whi& is comrneasurate wigh the error estimate given in Eq. (1.11). More generay, if a quadrature formda based on a Taylor series rrses N points, it will inteqate exactly a polynomial of degree N l (degree N if N is odd). That is, the N wei&ts PU, can be &men to satisfy the N binear equatioas
-
(When N is odd, the quadrature formula is also exact for the odd monomid z N . ) A greater predsion for a given amount of numerical work can be achieved if we me willing to give up the requirement of @quay-spaced quadr&are points. That is, we will choose the x, in some aplimaS sense, subject only to the constraint that they lie within the interval [-l, 11. We then have 2N parametefs at our disposd in co~structingthe quadrature formda (the N z,'s and the N w,'s), and so we should be able to choose them so that Eq. (4.9) is satisfied far p ranging from O to 2N - 1. That is, the quadrature formula using only N arefulfy chwen poinks cwr be made exwt for pdynomials of degret! 2N - 1or bss, This is clearjy mare emcienl than using equdly-qaced abscissa, To see how to best choose the 2,' we corrsidef the Legendre palynsmids, which are orthogonal on the interval [- 1,1]:
944
4. Specl'af Furactions
and Gaussl'sn Quadraturn
It is easily shown that Pi is a polynomial of degree i with i roots in the interval [-l, l]. Any polynomial of degree 2N - 1 or less then can be written in the form where Q and R are polynomials of degree N of the required integral (4.8) is then
- 1 or less. The exact value
where the second step Wows from the orthagondity of .PN to all polynomiats of degree N - 1 or less. If wa now take the s, to be the N zeros of &,then application of (4.8) gives (exactly)
It remains to choose the W, so that; R (a poly~omidof degree N - 1 or less) i s integrated exactly. That is, the W, satisfy the set of linear equations (4.9) when the 2, are the zeros of PN. It can be shown that W, is related to the derivative of .PN at the corresponding zero, Specifidly; 2 20% = (1 sk)[P~(z,)12' TMs completes the specification of what is known as the Gauss-Lt;$endre quadratare formda. Note that it c m be appl-ied to any d e f i ~ t ein_r;egraf between finite lirnits by a simple linear cbange of variable. That is, far an integral between limits I = a and I = b, a change of variable to
-
redues the integrd to the form required, Other non-linear changes of variable that make the integrand as smooth as possible wilt alao improve the accuracy, Other types of wthogond pdynomids provide useful Gaussian quadraturn formulas when the inlegrand has a particular form, Ebr example, the Laguerre polynomials, .Li, which are orthogond on the interGd [O,m] with the weight function e-", lead to the Gauss-Laguerre quadraturn
4.3 B ~ r nand eQonal approsimatr'ons to quantum scattering
where the z, ase the roots of LN and the W, are related to the values of LN+I at these points. Similarly, the Kemite polynomials provide GaussHermite quadratare formulas for integrals of the form OQ
ems'f(z) dz
.
These Gaussian quadrature formulas, and many others, are given in Section 25.4 of [Ab64], which also contains tables of the abscissm and weights. In the practical application of Gaussian quadrature formulas, one does not need to write programs to calculate the abscissae and weights. Rather, there are usually library subroutines that can be used to establish arrays containing these numbers. For example, subroutine QUAD in Example 4 (see Appendix B) establishes the Gauss-Legendre absdssae and weights for many different values of N. As a general rule, Gaassian quadrature is the method of choice when the integrand is smooth, or can be made smooth by extracting from it a function that, is the weight for a stmdard set of orthogond polynomid~. We must, of course, also have the a b s t y to evduate the integrmd at the required abscissae. H the integrmd varies rapidly, we can compound the basic Gsussiaa quadra;t;urefolrmula by applying it w r ~ e v e r dgubintervds of the range of integrat;ion, Of course, wkea t be integfand east be evaluated only at equally-spaced abscissm (such as when it is generated by integrating a differential equation), then formulas of the type discussed in Chapter 1 must be uged. As an iBustration of Gaussian qudrature, coxtsider using a 3-point Gauss-Legendre quadrature to evduate the i n t e r &
Making the cSIange of variable to
results in
For N = 3, the Gauss-Legendre abscissae and weights are
95
96
4. Smeial fineEs'ow and Gaussian Quadmture
Straightforward evaluation of the quadrature formula (4.8) then results in I = 4.66683, while a Simpson's rule evaluation of (4.14) with h = 1.5 gives 4,66228. Gaussian quadrat me is therefore more accurate than Simpson's rule by about a fxtor oT 27, yet requires the same number of evalluations of the integrand (three). r
Exercise 4.4
Cansider the integal
Evduate this intega3 using some of the quadratare formulas discussed in Chapter 1and using Gauss-Legendre quadrat are. Note that the behavior of the integrmd near z = f l i s cause fsr some caution. Compme the accuracy and eficiexley of these v&ous methods for diRerent numbers of abscissa^. Note that this integral can be evatuated exactly with a 4bonepoint" Gauss-Chebyshev quadrature formula oE the foMn
with sm
col3
rZ,
31";
N-4-1 (See Section 25.4.40 of [Ab64].)
wn=-
71"
N+1
72
sin2 -T N+1
.
4.3 Born and eikonal approximations to quantum scatter-
ing In this example, we will investig;ate the Born and eikonal approximations suitable for describing quantum-mechanical scattering at high energies, and in particular cdculate the scattering of fast eledrons (energies greater than several 10's of eV) from neutral atoms. The following project deals with the exact partial-wave solution of this problem. Extensive discussions of the quantum thwry of scattering are given in many texts (see, for example, [Me68], [Ne66], or [Wu62]); we will ody review the essentials here. For particles of mass m and energy
scattering from a central potential V ( r )is described by a wave function
4.3 Born and eikonal ~pppodnzatiansto flantun scerlteriw
l@ (r) that satisfies the Schroedinger equation,
with the botrndary conditian at l a r e distances
Here, the beam is incident along the z direction and B is the scattering angle (angle between r and a). The complex scattering amplitude f embodies the observable scattering properties and is the basic function we seek to detmine. Tbe digeratid cross section is given by
a d the tot& crass section is
In general, f is a function of both E" ajnd B. At this point, many elementmy trc~at;meabof scattering introduce a partid-wave demmpositim of !P, express f in terns of the phase shifis, m d then proceed to discuss the radid S&roc?&nger equation in each pasdid wave, from wEch the phwe shift and hence %beexwt cross wetion, e m be cdculat-ed, We will use this method, wki& is most apprapri&e when the energies are low and only a few partial waves me important, in Project IV bdow. However, in this example, we will con~idertwo approximation schemes, the Born and eikond, which are appropriate to high-mergy situations when many partial waves conkibute, Both, the Born and dkanait approximations are based on an exact integral expression for the scattering amplitude derived in many advanced treatments: m e r V ( ~ )(p) g d3r . f ( B ) = -2rfi2 Here, the wavenumber of the scattered particle is kf, so that and kr*i= cos B. It is also convenient to introduce the wavenumber of the ixrcident particle, ki = kg. The Born approdmation (more precisely? the firs%Born a p p r o ~ m a tion) congists of wsuming that the scattering is weak, ao that the fult scattering wave function @ differs vefy littb from the incident plane wave,
97
98
$. Spct'ctl Fsnctzt'ons and Gawsdarn Quarfralure
exp(iki*r).Making this replacement in (4.20) results in the Born scattering amplitude,
Here, we have introduced the momentum transfer, q = kt - ki, so that
and have used the identity
Note that the Born apprasmation to the scattering amplitude depends only upon q and not separately upon E &ad 8. Better approximations to l! in Eq. (4.20) result in correspondingly better approsnaations to f . OM pogsible improvement is the eikand &pproximation, v d d at high energies and small scattering angles. (See [Wa73] or [Ne66].) This approximation is semiclassical in nature; its essence is that each ray af the incident plane wave suBers a phase shift as it passes tbrough the potential on a straight-line trajectory (see Figure 4.1). Sin= this p h a e shift depends upon the imp& pasameter af the raLy, the wavefronts of tbe wave fitnction asle distorted after passing through the paential; it i s tlris distortian that carries the scattering information.
To derive the dkond approimatioa, we will put, without lass of generafity, (42 3 ) @(F)= eiki"@(r),
+
where is a slowly-vaving function describing the distortion of the hcident wave. Tfpoa inserting thhis into the origind Schmedinger equatian (4.161, we obtain an equation for
+:
+ term can
If we now assume that y5 varies slowly enough so that the be ignored (i.e., k is very large), we have
Here, we have introduced the coordirtilLe b in the plane transverse to the incident be=, so that
Rom synrmelry considerations, we expect that y3 will be azimnthdy symmetric and so independent of 6. Equation (4.25) can be integrated immediagefy and, using the boundmy condition that; $I -.a 1 rua x -4 -W since there is no distortion of the wave befare the pasticle reaches the potentid, we have
V (h, zf) dz'
.
(4.26)
Having obtained the eikonal approximation to the scattering wave function, we can now obtain the eikonal scattering amplitude, f.. Inserting Eq. (4.23) into (4.20), we have
Using (4.251, we can relate V $ directly to &$/at. Furthermore, if we restrict our consideration to relatively small scattering angles, so that q, W 0, then the z integral in (4.27) can be done immediately and, using (4.26) for 4,uve obtain
with the '"rofile fuactian"
Since X is azimuthally symmetric, we can perform the azimuthal integration in (4.28) and obtain our final expression for the eikonal scattering amplitude,
In deriving this expression, we have used the identity [compare with Eq. (4.22)] e-iqb cos 4 d
~ ,
Note that in contrast to fB, f, depends upon both E (through k) and p. An impurtmt praperty of the exact scattefiag mp2itude is the optical theorem, which relates the total cross section to the imaginary part of the forward scattering amplitude. After a bit of algebra, one can show that jC, satisfies this rela4ion in the limit that the inddent momentum becomes large compased t s the length scde over wkicb the potentid vwies:
The Born appro~mcat;iancannot lead to a scattering mplitude that respects this relation, as Eq. (4.21) shows that fr, is purely red. It is also easy to show that, in the extreme high-enerw Emit, w h r e K -+ oo a ~ Xd becomes small, the Born and eikond amplitudes become equal (see Exercise 4.5). The eibonal formula (4.30) also can be related to the usual partial wave expression for f (see Exerdse 4.6). One practical applie&ian of the appradmatiuns discussed above is in, the calculation of the scattering of hi&-energy electrons from neutral atoms. In general, this is a complicated multi-channel scattering problem since there can be reactions leading to find states in which the atom is excited. Hov~ever,as the rewtion pmbabillties ase smdl in comparison to elastic scattering, for many purposes the problem can be modeled by the scattering of an electron from a eentrd potential. This potential represents the combined influeam of the attraction of the central nuclear charge (Z) and the screening of this attraction by the Z atomic electrons. For a neutral target atom, the potential vanishes at large distances faster than r-l. A very accurate approximation to this potential can be had
4.8 Born and eQonal appwdmations to quantum scattering
by solving for the sel&consistent Eartree-Fodc potential of the neutral atom, as was done in Project III. However, a much simpler estimate can be obtained using an approximation to the Thornas-Fermi model of the atom given by Lenz and Jensen [Go49]:
with
and S
= 4 . 5 3 9 7 ~ ' / ~ ~.' / ~
Here, the potentid is measured in eV and the radius is measured in A. Note that there is a possible problem with this potential, since it is singular as r-' at the origin, and so leads t o a divergent expression for X at b =. 0. However, if the poten.tial is regularized by taEng if to be a canstmt within some small radius r,iB, (say the radius of the atoms ls shell), then the cdculated cross sectian will be unaEected except at xnornentnm trmsfers fage enough so that gqrmin > 2. Qur god is to c m p u t e the Born and eikond wpro~mationsto the differential and t o t d cross eections for a given cetllrd potentid at a specified incident energy, and in particular for the potential (4.32). To do this, we must compute the integrals (4.211, (4.29), and (4.30) defining the scattering amplitudes, as well as the integral (4.19) for the total cross section. The FORTRAN progrm for Example 4, whose source code is @yen in Appendix B, as; well in the file EXMPL4,FQR, does these edcdadions and papbs the results on a semi-log plot; the t s t d cross se~tiongiven by the opticd theorem, Eq. (4.31), is also ealcufated. The incident paticle is wsunned to have the mzlss of the electron, and, as is appropriate for atomic systems, all lengths are measured in A and d l energies in eV, The potentid can be chosen to be a square well of radius 2 A, a Gmssian well af the farm
or the Lenz-Jensen potential (4.32). All potential8 are assumed to vanish beyond 2 A. hrthermore, the r-' singularity in the Lenz-Jensen potentid i s cutoff inside the radius of the Is she11 of" the target atam,
201
102
4. Speial
hnctions and Gaussian Quadmlure
Because the diRerentiaf crws sections 'become very peaked in $he forward direetion at the high energies where the Born and eikond approfirnations are vdid, the integration over cos 6 in Eq. (4.19) is divided into two regions far a mare accurate integraiola of tbe forward peak. One of these extends from B = 0 to B = Bcut,where ~cut&,r
f
= 2~ = 2kR,.t sin 58,ut
and RC.&is 1k . for the Lenz-Jensen potential and 2 A for either the squareor Gaussian-well potentials, and the other eaends from B,,b to x. AU integrds are done by Gauss-Legendre quadraturn usiny; the s m e number of points, and the Bessel function of order zero required by Eq. (4.30) is evaluated using the approximations (4.4). The fouowing exercises are aimed at improving your understanding of this p m g r m and the physics it describes. m Exercise 4.5 Verify the dgebrs in the derivations above. Show that in the limit of very high energies, where X is small, so that sin X w the Born and eikond results are identicd, Also prom that the eikand amplitude satisfies the optical theorem (4.31) in the limit where the inei&nt momeaturn becomes large in comparison with the length scde of the potentid. Exercise 4.6 Show that if the eonventiond expression for f in terms of a sum over partial waves [Eq. (IV.4) below] is approximated by an integal over I (or, equivdently, over b = Ilk) and the sma-ll-&/lmge-l approdmation &(cos 8 ) F;I JO(l@)
m
Investigate, is used, Eq. (4.30) results, with the identification ~ ( b=) either numerically or mdytically, the vddity of this; relation between the Bessef function of order zero and the Legendfe polynomids.
Exercise 4.7 Test the Born approdmation. crass sections generated by the code by comparing the numerical d u e s 4 t h the analytical Born results for a square or Gmssim well of depth 20 eV and for varying incident energies from 1 eV to 10 keV. Verify for these cases that ~ ( bas) computed by the code has the expected values. bestigate the variat;ion of the nunrezlicd results with & a g e s in the number of quadratare points. (Note that only particular values of N are allowed by the subroutine generating the Gauss-Legendre abscissx and weights.) m
IV. Partial wave sohtion of quantum scattering
Exereise 4.8 Fix the depth of a square well at 20 eV and cdculate for various incident energies to get a feeling for how the differential and total cross sections vary. Compare the square well cross sections with those of a Gaussian well of comparable depth and explain the differences. Show that the Bmn and eikond results i c p p ~ s deach other at high energies for either potential and that the optical relation for the eikonal amplitude becomes better sadisfied at higher energies.
m
Exercise 4.9 Using the Lenz-Jensen potential m d a fixed charge and inddent energy, say Z = 50 and E = 1000 eV, investigate the sensitivity of the calculation to the number of quadrature points used and to the small-r regularization of the potential. Calculate the cross sections for various Z ranging from 20 to 100 and for E ranging from 10 eV to 10 keV; intergmt the trends you observe, Exercise 4 x 0 Use the program constructed in Project I to calculate the classical differential crass wctim for electroas scattering frem the Lenz-Jensen potential for various Z and incident energies. Compare the results with the Born and eikonal cross sections, Cm p u e~titblishm analytic& connection between the classical description and the quantum approximations:' (See [Ne66] for a detajled discussion.)
m
Project IV: Partial wave solution of quantum scattering Ta this project, we will use the method of partid waves to solve the quantum scattering problem for a partide incident on a central patentid, and in particular consider the low-energ scattering of electrons from neutrd atoms. The strategy of the method is to employ a pafliaI wave expansion of the scattering wave funetion to decampme the thr~-dirmensiond Schroedinger equation (4.16) into a set of uncoupled one-dimensional ordinmy diEerentid equations for the radial wave functions; each of these is t b n soltved as a boundary-vdue problem to determine the phme shift, and hence the scattering aplitude.
IV.1 Partial wave decomposition of the wave function The standard partial wave decomposition of the scatLering wave funetion @ ie
When this expmsion is substituted into tbr! Schroedinger equation (4,161, the ra&aX wave functions we found to satisfy the r d i d diEerengiaf
103
Although this is the same equation as that satisfied by a bound state wave function, the boundary conditions are different. In particular, R vanishes at; the origin, but it hils the large-r aaymgto-ticb e h d o r
RI -+ kr[cos Grjr(kr)- sin 61nl(ks)],
(IV.3)
where jl and nl are the regular and irregular spherical Bessel functions of order I. (See Exercise 4.3.) The scattering amplitude f is related to the phase shifts by
f (B) = 5
(2f
+ l)ei61sin 6rq(cos 8) ,
(N.4)
I=O
and the total cross section is easi?y found from Eq. (4.19) and the arthogonality of the Legendre polynomials, (4.10):
Although the sums in (W.4,5)extend over all I, they are in practice limited to only a finite number of partid waves, TUs is because, for large I, the repulsive centrifugal potential in (IV.2) is effective in keeping the particle mtside the rmge of the potential and so the phase shift is very s m d . If the patentid is negiigible beyond a radius r,,, an estimate of the highest partial wave that is important, lmax, cm be had by setting the turning point at this radius. T h s ,
+
~max(lmax
=E,
2mrkax
wbich leads to E,,, brm,,, This estimat;e is usuatly slightly low, since penetration of the centrifugd barrier leads to non-vanishing phase shifts in. part;ial waves somewhat, higher %hagthis.
IV.2 Finding the phase shifts To find the phase shift in a given partial wave, we must solve the radiat equation (TV.2), using, for example, the Numerov method discussed in Chapter 3. Although the boundary conditions specified by (IV.3) and the vanishing of R at the ongin are non-local, we can still integrate the
f V, I""art;ialwave klolution of qvrantvna scattering
equation as an initid value problem. This is because the equation i s linear, M) that the bonndary condition at large r can be satisfied simply by appropriately normalizing the solution. If we put Rl(r = 0) = 0 and take the value at the next lattice point, R I ( ~= h), to be any convenient smdl number (R will generally rise rapidly through the centrifugal barrier and so we must avoid overflows), it would seem that we were ready to use the Numerov method. However, k(r = 0) is infinite. The solution is to use Eq. (1.7) for Ry(h), along with the known valuesRI(0),Rt(h),and k(h) to find R1(2h). Now we can (See Figure IV.1.) Here, integrate outward in r to a radius r(') > P,,,. V v a ~ s h e sand B must be a line= cambination of the free solutions, krji(kr) and kmr(kr):
R[') = ~kt(')[cosbrjl(kr('))- sin 61nr(kr('))].
(m6) Although the constant A depends upon the vdue chogen for R(T = h), it is largely irrelevant for our purposes; however, it must be kept small enough so that overflows are avaided* Knowing anly R!') does not allow us to solve for the two unknowns, A > t(l), and 61. However, if we continue integrating to a larger radius then we dsa have
&I2)
-
.
= ~ k r ( ~ ) [ c6tjr(kr(2)) os sin 61nl(kr(2))]
(IV.7)
Equations (IV.6,7) can then be solved for tir. After a bit of algebra, we
where jj') = jr(kt(')), etc. Note that this equation determines sl only within a multiple of n, $though this does not affect the physical observables [see Eqs. (IV.4,5)]. The correct number of ir's at a given energy can ned by comparing the number of nodes in R and in the free solution, krjr, which oecar for T < pmX. With the conventionid deenitims we have used, the phase shift in each paftial wave vmishes at hi& energes and approaches fia at zero energy, where Ni is the number of bound states in the potentid in the b'th partial wave.
IV.3 Solving the equations Our gad in a nrtmesicd treatmenL of this problem is to investigate the scattering of electrons with mer@iesffom 0.5 tlV to 10 keV from the potential (4.32); a radius r,,, = 2 A is reasonable. For the charge Z
105
106
4. S m i a l Elmctiaw and Gausst'an Quadraturn
Figwe IV.1 (Upper) Schematic chentGfagilrl potentid (dahed line) and eRective tot& pakntid (saEd line) in a pastlid wave I r 0. The i n d e n * energy is Am shawn (horizontal Iiae), as are the range of the potential (rmax) and the twa matching radii, r(') and.)'(F (Lower) Schemagc scattering wave fnnction, RI (solid line), and free wave func*ion, &P& (dwhed line), fox "thesame erituadian.
w d energ E spedfied, the program should cdculate the p h a e sMft and plot the ra&d wave function for each imiportaant pastid wave, and then s m the contributions fram each t to find the total cross section and the diRerent;id crass section a9 a function of 8 from 0' to 180°,say in 5' steps, This program can be constructed and exploited in the following sequence of steps. Step 1 Wdte a subrougiae that camputea the values of the Legendre polynomials for the degrees and angles required and stores them in an array [See Eq. (4.1).] Aiso write a subroutine that computes jl and nr for a given value of r . (See Exercise 4.3). Cheek that these routines are working correctly by comparing their results wit h tabulated values. Seep 2 Wrige a a;ubrontiae f i a t calculates the? phwe shift, in a specified partial wave. Use the Numerov method to integrate to r(') and then
r
JV. Padial wave solution of quantum scattering
Figure IV.2 WeaHy-bound levefs of the LeneJanmn posential. Levek with a negative p;trity (p and f) are shown by dwhed curves.
and then determine the phase shift from Eq. (IV.8). Note that to is too close to rfl), problems with numerical precision may arise if (both the numerator and denominator of (IV.8) vanish), while too great a distance between the matching radii leads to wasted computation. Check that your subroutine is working properly by verifying that the calculated phase shift vanishes when V ( T )is set to 0 and that it is independent of the choice of the matching radii, as Iong as they are grea;2;er t b a v., .&so check that the phase shifts you find far a square-well poteatid agree with tharse that y o can ~ cdcufate andytically, Note th& since quite a bit sf numel.ical work is invdved in the cdculation of the Lenz-Jensen potentid (4.32), it is most efficient if the d u e s of V at the lattice points are stored in an array to be used in the intqration of all impartant partial w&veS. Seep 3 Write a mdn pragram that, for a e b q e m d energ, calls the subroutines you have congtructed in pedaming the sum aver partial waves to calculate the totd md diEerentia2 croh;s sections. Verify that your estimate of I,, is reasona;ble in that 4 non-vmisbing phwe shifts are computed but .that no computationd eEort is wasted an partid waves for whiCh the phase sEA is negZi&ble.
Step 4 Study the cross section as ia function of e n e r o for severd Z, say 20, 50, and 100, Show that, at low energies, resonances occmring in particular partid waves m&e the m&ar distributions quite camplex and the t o l d cross sections very ener&y-dependent,bat that alT[quantities
m
107
become smooth &ad monotonic at Egh energies. Tabulations of experimental data with which to compare your results are given in [Ki71]. Also compare your high energy results with the Born aad eikond approxirnatisns genera;ted by the p r s r a m in Example 4, Step 5 To unhstafld the ]low-energ resoaances, colasider F i e r e N.2, whi& gives the enerdes of w e A y bound levels in the LenzJensen potentid as a function of Z. By studying the cross section at a fixed energy of 5 eV as s function of Z, how th& the regions new Z = 46 and Z = 59 reflect the extensions of the 2p and Id bsuad st&es into the continuum. By examiaing the Z =. 59 cross swtion, anguIas distribution, p h ~ shifts, e and rodid wave funetiona as functions of eneru mrar E = 5 eV, show that; the resonance is indeed in the I = O a r t i a l wave. Note that sin= the Lenz-Jensen poteatid is bwed on the ThornasFermi approfimation, it is not expected to be accurate in the outer region of the atom. The resonance energiw and widths you find %hereforediRer guantitatively from tho8e that are foand in experiment.
m
Step 6 Use the UlarItree-Fock code from Ffoject 111 to generate the direct potential, @, for the neutral He atom and modify your program to calculate the scattering of electrons from this potentid. Note that when the energy of the inddent electron is large, it is easily "distinguishable" from the electrons in the atom, and so any effects of the Pock (exchange) potential will be small. Compare your results with those produced with the Lenz-Jensen potential. A further discussion of the electron-atom scattering problem can be found in [Bo74].
m
Chapter 5
Matrix Operations Linearization is a common assumption or approximation in describing physical processes and 80 finear systems of equations are ubiquitous in computational physics. Indeed, the matrix manipulations associated with finding eigenvalues or with solving simultaneous linear equations are often the bulk of the work involved in solving maay physical problems. Ia this chapter, we will discuss brieffy twa of the more non-trivid matrix operatiormst inversion and diagondization. Our treatment here will be confined largdy to @directB methods appropriate fm "dense" mattries f where most of the elements are on-zero) of dimension less than severd hundred; iterai;tive methods for treating the very large sparse matrices that wise in the discredization of ordinary and partial dcligerentid equations will be discussed in the foaming two chapters. As i s the case with the special functions of the pmvious chapter, a vwiety of library subroutines ernploying several different methods for golving matrix problems are usudly avdlable m any large computer. Our dis;eussions bere me therefore limited to selected basic methods, to give a Aavor of whad has to be done, More detailed treatments can be found in many texts, for example [Ac70] and [Bu81].
5.1 Matrix igxversian Let us consider the problem of inverting a square ( N x N ) matrix A. This might arise, for example, in solving the linear system
for the unknown vector X, where b i s a known vwtor. The most naturd way of doing this is to follow our trJning in elementary algebra m d use Cramer's rule; i.e., to evaluate A-' as being proportional to the transpose of the matrix of cofactors of A. To do this, we would have to cdcnlate
110
5, Matrig Operations
N 2 deterdnants of matrices of dimension ( N - 1) X ( N - 1). If these were done in the most naive way, in which we w u l d evduate
for the determinmt of the N x N mat;rix A, where P is one of the N ! permutations of the N columns, Pi is the i'th element of P, and ( - ) P is the signature of E", then the numericd work would be horre~bo.tls. Far example, of order N ! multiplications are required to evaluate (5.2). For N = 20, this is some 2 x 1 0 % multiplications. ~ On the fastest computer currently available, 10s multiplications per second might be possible, so that some years are required just to invert this one 20 x 20 matrix! Clearly, this is not the way to evaluate determinants (or to invert matrices, as it turn8 out). One of the simplest practical methods for evaluating AmSis the Gauss-Jordan method. Here, the idea is to consider a class of elemen_t;asy row apttrations on the matrix A. These Involve multiplying a paticdar raw of A by a canstant, interchmging twa rows, or adding a multiple af one row to another. Each of these t h r e operations can, be represented by left-multiplying A by a simple matrix, T. For example, when N = 3, the
will multiply the third row by 2, interchmge the first and second rows, ancl subtrwt one-half of the first; row from the tKrd row, respectively. The Gauss-Jordan strategy is to find a sequence of such operations, which, when appEed to A, reduces it to the unit matrix. That is, so that T = A-' is the required inverse. Equivdently, the same sequence of operations applied to the unit matrix yields the inverse of A. A practical method to find the appropriate sequence of row operations is best illustrated by example. Consider the 3 X 3 matrix A and the unit matrix:
We first apply transformations to zero all but the first element in the first column of A. Subtracting 4 times the first row from the second yields
and then subtracting twice the first row from the third yields
We now go to work on the second column, where, by adding 1/3 of the secscoad raw to the first;, we can zero EtU but the second element:
and, multiplying the second row by -1/6 yields
Findly, we can reduce the third column of TA to the r e q ~ r e dform by adding 113 of the third row to the fimt and sec-ond rms, and then mdtiglying the tErd row by -1:
This finds the required inverse. A. moment's thought show8 how t k s dgadthm c m be geaera-lized to an 1V x N rnafix and that, when this is done, it requires, for Iwge N, of order N 3 multiplications and additions. Thus, it is computationally tractable, as long as N is not too fwge. In practice, several subtleties are important. For example, it might happen that, at some point in the pracedure, the diagond element of TA vanishes in the column we are working on. In this case, an interchange of two rows will bfing a noa-va~shingd u e to this '"ivotn element (if no such row interchange can do this, then the matrix A i s singular). In fact, numericd accuracy requires that; rows be interchanged to bring into
f l2
5. Matrix Operations
the pivot pasition that element in the column being worked on that has the largest absolute vdue. Problems associated with numerical roundoff can also arise during the inversion if elements of the matrix differ greatly in magnitude. For this reagon, it is often useful to scale the rows or columns so that afl entries have roughly the same magnitude ("equilibration"). Various special cases (such as when A is symmetric or when we are only interested in solving (5.1) for x and not for A-' itself) can result ia reductioas of the numerical work. Far exmple, in the latter c a e , we can apply T only t o the vector b, rather than t a the whde unit matrix. Rndly, if we are interested in computing only the deterdaant of A, successive row transformations, whicfi have a simple and easily calculable egect on, the determinant, can be used to bring TA to lower or upper d i ~ o n dform (all ekntents vmishing a b m or b d w the diagonal, respectively), and then the deteminant can be evaluated simply as the product of the diagond elements, Exercise 5.1 Use Eq. (5.2) to show that interchanging the rows o f a matrix changes the sign of its determinaxlt, that adding a multiple of ane row to anot her leaves its determinant unchanged, and that multiplying me row by a c o n s t a t mdtipfies the deteminant by that saxne constant.
m
Exercise 5.2 Write (or just flowchart) a subroutine that will use the Gauss-Jordan method t o find the inverse of a given m&rix, 1ncorporat;e pivoting as described above 2 0 Improve the numerical accuracy.
E
5.2 Eigenvalues of a tri-diagonal matrix We turn now t o the problem of finding the eigenvalues and eigenvectors of an PC7 X N matrix A; that is, the task of finding the N scdars X, and their associakd N-component vectors 4, that satisfy Equivdently, the eigenvalnes are zeros of the N" %h degree characteristic polynomid of A:
n(xnN
PA(A) det (A - XI) =
A)
.
(5.77
n=l
For simplicity, we will restrict our discussion to matrices A that w e r e d and symmetric, sa that the eigenvalues Etre always r a l and the c?igenwctors can be chosen to be arthanormal; this is the most common: type of matrix arising in modeling physical systems. We will also consider only cases where atl or many of the eigenvalues are required, and possibly their
&,l? bf"igc3nvotues a tri-diagonal ntcrkria:
associated eigenvectors. If only a few of the largest or smallest eigenvalues of a large matrix are needed, then the iterative methods described in Seetion 7.4, whicb invalve successive applications af A or its inverse, can be more eaeient. The generat strategy for diagonalizing A is to reduce the task to the tractable one of finding the eigenvdues and eigenvectors of a symmetric tri-diagonal matrix; that is, one in which all elements are zero except those on or neighboring the diagonal. This can always be accomplished by applying a suitable sequence of orthogonal transformations to the original matrix, as described in the next section. For now, we assume that A has been brought to a tri-diagonal form and discuss a strategy for finding its eige~vdaes, To find the eigenvdues of a symmetric tri-diagonal matrix, we must find the roots of the characteristic polynomial, (5.7). This polynomial is &wn in terms of the element8 of A by the deterzninmt
(5.8) where all elements not shown explicitly are zero and where the symmetry of A implies that A,, = A,,. To find the zeros of Payany of the root finding strategies discussed in Section 1.3 can be employed, providing that we can find the numerical value of PA for a given value of X. This latter can be done conveniently in a recursive manner. Let P,(A) be the value of the n x n sub-determinant of (5.8) formed from the first n rows and columns. Clearly, P, is a po?ynomid of degree n, PN = .PA (the polynomial we are after), and
p ~ ( h=) At1 - X ; &(X) = (A22 - A)& (A) - A& . (5.91 Moreover, by expanding the determinmt for P, in terms ol' the minors of the n'th colurn, it is easy to derlve the reearsion relakion
3.13
This, together with the starting values (5.9), allows 8n efficient evaluation of pA* m
Exercise 5.3
Prove Eq. (5.10) above.
Several features of the problem above help considerably in finding d used, it is quite the roots of .PA. If m algorithm like Neartank s m h ~ is easy to differentiate (5.10) once or twice with respect to X and so derive recursion relations altovving the simple evaluation of the first or second derivatives of PA(X).More importantly, it is possible to show that the number of times the s i p chastge~in the sequence
is eqad to the number of eigenvdues less than X, This faet is umful in several. way~3: it is a, means of m&ing sure Lbat no roots are skipped in the search for eigenvduea, it provide8 a gimple lay of loedzing a root initially, and it can be used with the simple search prowdue to locate the root accurately, althou@ perhaps not in the most efieient vvay possible. To make a systematic search for all of the eigenvdues (roots of Pa), it is esserrtid to know where to b e n looking. If we me working through finding the entire sequence of eigenvalues, a natural guess for the nexthighest one is some distance above that eigenvdue just found. Some guidance in how far above and in how to estimate the lowest eigenvalue can bo found in. Gerschgorin" bbounds an the eigenvdurss. It is quite simple to show that
and th&
for dl n. For the tri-diagonal forms under consideration here, the sums over j in these expressions involve only two terms. The lower bound, Eq. (5.11a), is a convenient place to begin a search for the lowest eigenvalue, and the difference between the upper and lower bounds gives some measure of the average spacling between eigenvdues,
5.3 ReSduetion to tri-diagonal form
lExwcim 5.4 Write a subroutine that finds aS1 of the dgenvalues of a tri-diagonal maitrk using the procedure &&crib4 above, together vvith any root-finding dgorlthm. p u fincl convenient. Test your subfoaine on an IV x N tri-diagond matrix of the form
t
whose eigenvalnes are known andytically to be
5.3 Reduction to tri-diagonal form
To apply the method for finding eigenvdues discussed in the previous section, we must reduce a general real symmetric matrix A to tri-diagonal form, That, is, we must find an orthogo~alN X N matrix, 0,satisfying where Ot iis the transpose of 0,such that O'AO is tri-diagonal. Elementary considerations af linear algebra imply that the eigenvdues of the transformed matrix are identical to those af the oiiginail matllix. The problem, of m r s e , is to fiad the preGiaje farm *of 0 for my pafticular matrix A. We discuss in this section two methods far egecting such a trm~formatisrr. The Householdt?r method is a common and convenient strategy for reducing a rxraldx to tri-8iagond form, It takes the miltrh Q to be the prodnct of N - 2 of'chogond m&rices, each of which sucetlissively traasforms one roar and column of A into the required form. (Only N - 2 transformations are required as the last two rows and columns are already in tri-diagonal form.) A simple method can be applied to fixrd each of the 0,. To be mose explidt about how the Wouseholdftr dgorithzn. ucrorks, let us consider finding the Brst mhogonal transfomation, Q which we will choose to a;nniPuilate mmt af the first row and column of A; that; is,
125
Here, k(') is a possibly non- ishing element and the matrix is the result of applying the transformation to the last N - 1 roars and columns of the original matrix A. Once O1 is found and applied (by methods discussed below), we can choose 0 2 8 0 that it effects the same kind of transformation on the matrix A(?);that is, it annihilates most of the first row and column of Lkizt matrk a d Lrmsforms its last N - 2 rows m d coltlmns:
Continued orthogonal transformations of decreasing dimension defined in this way will trmsform, the ori&nd maLrix into a tri-diagond one dtes a total of N -. 2 transformations, the diagonal elements of the transformed nrat;rix being
and the OR-d;iagondelements being
It remdns, of courm, to find -the predse form 0.f each of the Q,, We IUzzstra;te the proceduze with Ox,which we take ta be of the h r m
where O is an N - l-dimensional column vector of zeros, at is a similar row vector, and P is an (H- l) x ( N - l) symmetric matrix satisfying
if 0 is to be arthogond. (In these expressions and the following, for simplicity we have dropped all superscripts and subscripts which indicate that it is the first orthogonal transformation of the sequence (5.13) which is being discussed.) A choice for P that satisfies (5.17) is
-
In this expression, I is the N l-dimensional unit matrix, u is an N dimensionat unit vector satisfying
and the last term involves the outer product c&
U
- 1-
with itselt Each element
of (5.18) therefore reads
-
where n and m range from 1 to N 1. (It should cause no confusion that the indices on P and u rmge from 1 to N - l, whife- thase on the full matrices 0 asld A range fram 1to N.) Under a transformation of the form (5.16), A becomes
where we have defined an N - l-dimension& vector ar ss all elements but the 6rst in the first column of A; th& is, ai =: Aicr,z for i ranginl; ffom l to N - l. Upon comparing (5.20) with the desired form (5.14), it is apparent that the action af l? on, this vector must yield where k is the vector
k = [k,0,O,...,01'.
Equation (5.21) is what we must solve to determine U, and hence the required transformation, P. To do so, we must first find the s d a r h, which is easily done by taking the scalar product of (5.21) with its transpose and using the idempotence of P [Eq. (5.17)]:
so that k = f a . Raving found k (we will discuss the choice of the sign in a moment), we can then rearrange (5.21) as
Upon taking the scalar product of this equation with itself, using a k k= rtAzla, and recalling (5.22), we have
so that we can then solve (5.21) for
U:
This completes the steps necessasy to find P, To recapituJaLe, we first solve (5.22) for k, then calculate the square of the scalar product (5.24), form the vector U according to (5.25), and then finally P according to (5.18). In evaluating (5.24), considerations of numerical stability recommend taking that sign which makes the right-hand side largest. Note that we need evduate only the square of the scalar product as the vector u enters P bilinearly. Note also that a full matrix product need not be performed in evaluating A@).Indeed, from (5.18,20) we have
where the symbol A ia tlzis exprese~ionrstands for the square symmetric m&rix famed from the last N l rows m d columns of the origind matrix. Thus, to evaluate A@),once we have the vector u we need only calculate the vector Au and the scalar utAu. Finally, we note that n a m e ~ c dstabigty durhg the successive trasfarmations is improved if the diagonal element having largest absolute m a g ~ t u d eis in the upper ldt-baad corner of' the sub-nz&fix being trmsfo~med. Tlris can dwaye~ be arranged by a suitable interchange of rows and columns (which leaves the eigendues invwimt) &er each of the arthogand traasfamations is applied.
-
By writing either a detailed flowchart or aa w t u d subroutine, convince yourself that you understand the Householder algorithm descdbed above.
r Exmciae 5,5
With an algorithm for transforming A to tri-diagonal form, we have specified completely bow to find the eigenvalues of a real symmetric matrix. Once these are in hand, the eigenvectors are a relatively simple matter. The method of choice, inverse vector iteration, works as foEows. Let 4:) be any guess for the eigenvector associated with X,. This guess cm be refined by evduating
Here, E is a s m d , non-zero scalar that allows the matrix to be inverted. It is easy to see that this operation enhances that component of 4:) along
5.3 Redu~tirrnIf0 Eri-diagonalfarm
the true eigenvector at the expense of the spurious components. Normalization of (p?), followed by repeated refinements according to (5.27) converges quidtly to the required eigenveetor, often in only two iterations. An dternative to the Householder method is the Lanczas dgodthm [Wh77], which is most suitable when we are interested in many of the lowest eigenvalues of very large matrices. The strategy here is to construct iteratively a set of orthonormal basis vectors, ($,), in which A is explicitly tri-diagonal. To begin the construction, we choose an arbitrary = 1. We then form normalized so that first vector in the basis, the second vector in, the basis as where All = +:kgbl (it i s not the element of A in the first row and = 1: column), and Cz is a normalization chosen to ensure that $i$2 = 0. Subsequent vectors in the basis are It is easy to show that then constructed r-ecursively W with Thus, each successive is that unit vector which is coupled to qb, by A and which is orthogonal to both gb, and The matrix A is explicitly tri-diagonal in this basis since Eq. (5.30) shows that when A acts on @ ,, it yields only terms proportional to and $,+l. Continuing the recursion (5.30) until +N is generated completes the basis md the representation of A in it. The Lanczos method is well-suited to large matrices, as only the ability to apply A to a vector is required, and only the vectors $, and A*, need be stored at any given time. We must, of course, also be careful to choose 9%so that it is not an eigenvector of A. However, the Lanczos method is not appropriate for finding all of the eigenvalues of a large matrix, as round-off errors in the orthogonalizations of (5.30) will accumulate W the recur~ivegeneralion of the basis proceeds; i.e., the scalar products of basis vectors with large n with those having small n urilji not mnish identiedy. The red utility af the La-nczw dgorithm is in cwes where many, but not dl, of the eigenvd~esare required, Suppose, for example, that W
119
are interested in the 10 lowest eigendues of a matrix of dimension 1000. What is done is to generate recursively some number of states in the basis greater than the number of eigenvdues being sought (say 25), and then to find the 10 lomst eigenvdues and eigenvectors of that lirnited sub-matrix. If an arbitrary linear combination (say the sum) of these eigenveetors is then used as the initid vector in constructing a new basis of dimension 25, it can be shown that iterations of this process (generating a linrited basis, diagon&zing the correspondint.; td-diagonal mdrix, and using the normazed sum of lowest eigenvectors found as the first vector in the next basis) will converge to the required eigenvalues and eigenvectors. Exaeise 6.6 Write a subroutine that uses the Lanczos method to generate a complete basis in which a symmetric input matrix A is tridiagonat. The proearn should output the diagonal and a@-diagond elevectors themriidves. Show by ments of A in this bmis, m well W the biit~ii~ explicit exmple that if the &mensim of the matrix is too large, round-0% errors cause the basis w e r a t e d to be inwmrate. Try cming this problem by doing the computation in double-precision. withmetic and obwwe the resdts.
m
Exercise 5.7 A simple limit of the Larrczoa3 procedure far generating and truncatiag the bads is d e n we ~e interegted in only the! lowest eigenvdue and retain only and to form a 2 x 2 matrix to be diagondized. Show thae tlre lawer eigenvdue of this matrix is dways less than or eqaad to AI1, so that iterations of the procedure lead to a monotonic d y decreasing estimate far the Iawe8t eigenvdue of AL. This paocedure is d a ~ d related y to the time-evolution alga~ithmdiseusmd in Section 9.4.
5.4 Determining nuclear charge densities The distribution of electric$ charge within the atomic nudeus is one of the mast basic wpects of nuclear structure. The interxtions of decbrons and muons with the nucleus c m be used ta determine this distr3bution with great precision, as these particles interact almost exdusively t hrongh the well understood electromagnetic interxtion (for a general discussion, see (Fo661). In this example, we will explore how the experimentally determined cross sections for the elastic scattering of high-energy (several 100 MeV) electrons from nudei can be andyzed to determine the nuclear charge distribution; the method relies on the solution of a set of linear equations by mt;tLrix inversion. To illustrate the basic idea, we begin by considering the scattering of non-relativistic electrons of momentum k and energy E from a locatized
5.4 Determining nuclear &awe densitias
charge distribution, p(r), that contains Z protons, so that
and that is fixed in spaee. The electrons interact with this chmge distribution through the Coulomb potential it generates, V(r), which satisfies IPai~~on's equation, V'V = 4 n a p , (5.33) where a = 1/137.036 is the fine structure constant. (We henceforth work in w i t s where K -- e = 1, unless explicitly indicated, m d note that he = 197.329 MeV-h.) The Born appro~matianto quantum sc&tering t2iscussed in the pmvious chapter illustrates how electron scattering cross sections carry information about the charge distribution, atthough precision work r e q ~ r e s a better approdmat;ion to the sc%ttering, as discussed bdow. Equations (4.18,4.21) show that the Born cross section for scattering through an mgle 8 is proportional to the square of the Fourrier tran~forsnof the potential at the momentum transfer q, where q = 2k sin +B. The Fourier transform of (5.33) results in
where is the Faurier transfom of the charge density; Thus, the difirentid cross section can be written as (we use o as a shorthand notation for dgjdS1):
Here, the Rutherford cross section for scattering from a point charge of strength Z is
m is the electron mass, and the nudear 'form factor" is F ( q ) = Z-'p(q). For the spin-0 nudei we will be considering, the charge density i s sphericdly symmetric, so that p(r) = p ( r ) , and
F h ) = F(p) =
dr r sin qrp(r) .
121
Equation. (5.36) illustrates how dectron scattering is used to study nude= structure, Deviations of the mewured c r a ~ ssection from the Ruthefiord vdue are a, &reet mewure of the Fourier trmsform of the nuclear chmge density, It d s o shows that scatterings at hi& momentum trmsfers are needed to prsbe the nucleus on a fine spatial scale, As nuclear sizes are typically several fermis ( 1 0 - l ~cm), a spatial resolution better than 1 fm is desirable, implying xnomeaturn transfers of sewraj. fm-' and so beam energies of several hundred MeV. (Recall that 2k is the =&mum momentum. transfer that can be whieved with a beam of momentum h.) At energies of sew& handfed MeV, the electron is highly dativistic (the electron mass is only 0.511 MeV) and so the discussion above must be redone beginning with the Dirac equation rather than the Sehroediner equation. One trivial. change in the find expressions that result is tha'c ultra-relativistic kinematics are used for the electron (i.e., its momentum is proportional to its energy), so that the momentum transfer can be
The only other modification to Eq. (5.36) is that the Rutherford cross section is reptwed by the Mott cross section,
where the additional factor of cos )B in the scattering amplitude arises from the spin-$ nature of the electron. Let us now consider haw meaured crass sections are to be andyzed to determine the charge density. Suppose that we have a set of I experimental values of the cross section for elastic scattering of electrons from a particular nudeus at a variety of momentum transfers (e.g., angular distributions at one or several beam energies). Let these values be @,P and their statistical uncertainties by Ai. Suppose also that we parametrize the nuclear chmge density by a set of N pwameters, C,, so that p ( r ) = p(r; {C,)). O f course, the C's must be chosen so that the normalization constraint (5.32) is satisfied. That is,
A specific choice for this parametrization will be discussed shortly.
5.4 Determining nuclear charge ctensilieil
The usual methods of data andysis [jCSe69]state that the "best" values of the parameters C, impled by the data are those that minimize
subject to the normalization constraint (5.41) above. Here, of is the '%heoreticdwcross section cdeulated from the appropriate Matt cross section and nuclear form factor; it depends parametriedly upon the C%. This minimum value of xZ measures the quality of the fit, a satisfactory value being about the number of degrees of freedom (the number of data points less the number of parameters). There are several computational. strate@afor finding the parameters that minimize xZ or, equivdently, that satisfy the N non-linear equations
This is a, specific: exmgle of the commonly encountered problem of &nirnizing a non-lineas function of several parmetws; it is d e n fraught with &Bedties [Ac70], not the least of which is finding a local minimum, rather than the globd one usudly mug&, Most strat&es are based on an iterative refinement of a ""g%essnfor the sptinrd C,, sad, if this guess isr dose to the required solution, there is usudly no problem. One ~ommonlyused approarh i s to compute the direction of the N-dimensional gradient [lefthand side of (5.43)] either analytically or numerically at the current guess and then to generllte the newt guess by stepping some distance in C-space directly away from this direction. Alternatively, a multi-dimensional generalization af the Newton-Raphson method, Eq. (1.14), can be used. The simple approach we will adopt here is based on a local linearization of of about the current guess, C:. For small variations of the C's about this point,
C, = c:+Gc,,
the theoretical cross sections can be expanded as
so that
x2 is given by
123
where of is the theoretical cross section corresponding to the current guess, C'. The charge normalization constraint (5.41) can be linearized similarly a
where we have assumed that the current guess is normalized properly, so that Z({C:)) = Z. Equations for the &C's which make x2 stationary can be had by requiring
Eere, we have introduced a L a g r w p multiplier, 2X, to ensure the proper charge normalization. Some simple algebra using Eqs. (5.44,45) then results in the Eineatr equations
h r a given guess for the C", Eqs, (9.47) can be sofved to de2;erdne what change in the C's will reduce XZ, subject to the validity of the linearization, The new impraved values can thm be amd as the next guess, the process being continued until X Z converges to a minimum. To solve Eqs. (5.471, it is convenient to define the (N 1)x (N 1) matrix
+
and the N
+ l-component vector
+
(The inctices m a ~ ndin thege expressions range aad identify X from 1to N.) Equations (5.47) can therefore be written as
which is simply s d w d by inversion o;f" the symmcetpic matrix A:
After the process described above caBverges to the optimal values to the C'ss,m can then enquire into the precision with which the parameters are d e t e r ~ n e d ,This can be related to the matrix A defined above as faBaws. Let us consider an ensemble of data mts in whicb each experimental cross section fluctuates independently abaut its mean vdue. That is, (aoyb~;) = ~ t, & ~ ~ (5.52) where (. ..) denotes ensemble average, and 6of is the deviation of offrom its; mean d u e . Such fliuetuations lead to fluctuations of the G'"sabout their optimal value. Since the b, are linearly related to the experimental cross sections by (5.48), these fluctuations are given by (5.51) as
Upon using this equation twice (for 6C, and &C,) and taking the ensemble average, we have, after some algebra,
The uncertainties in the density parameters can be translated into a more physical statement about the correlated uncertainties in the density itself by expanding the parametxized density about the optimal parameters. In particdar, the correlated ancertdnties in the densities at radii r m$ r f can 'be writtemr as
Thus, ( 6 p ( ~ ) b p ( r ) ) 2can / 2 be taken as a measure of the precision with which p ( ~ is ) determined, although it should be remembered that the
uncertainties in the density determined at different spatial points are correlated through (5.55). We now turn to the parametrisation of p(?). On general grounds (for example, the validity of treating the nucleus as a sharp-surface, incompressible liquid drop), we expect the charge density to be fairly uniform within the nuclear interior and to fall to zero within a relatively thin surface region. This picture was largely confirmed by early electron scattering experiments [Ho57], although the measured cross sections extended only to momentum transfers less than about 1.5fm-' , WE&is barely enough resolution to see the nuclear surface. Such data could therefore yield only limited information, and a suitable form for the density with only three parameters was found to be af the form of a Fermi function:
as illustrated in Figure 5.1. Since it turns out that 4.4&/t > 1, the parameter p0 is essentidly the central density [i.e., p(r = Q)] the parameter &J is the radiua where the charge demity d r o p to one-hdf of its centrd vdue, and g, the surfaGe tEckn-s, is a measure of the distance over which this drop occurs, These thrw parametm are, of course, not all independent, as po c m be related to & and d by the normalization constraint (5.32). Systematic studies of electron scattering from a number of lrudei showed that, .for a nucleus with A nucjmns, suitable vdues were = 1 . 0 7 ~ ' /fm. ~ t = 2.4 f a Mare modern studies of eleclron scattering use higller energy b e a s , and so cover momentum transfers to approximately 4 fa-'. A typical crxampfe of the r a g e and quality of the data is shown in F i ~ r e5.2. Such data have led to a number of "modei-independent'' analyses [Fr75], in which a very flexible parametrization of the charge is used. One of these [Si74] takes the charge density to be the sum of many (of order 10) Gaussian Yumpsn, aad adjusts the location of each lump and the amount of charge it carries to best fit the data. An alternative [Fr73], which we pursue here, assumes that the density vanishes outside a radius R, considerably beyond the nuclear surface, and expands the density as a finite Fourier series of R" terns, That is, for r < E, we take N
C, sin
rp(r) = ta=2
5.4 Determining nuclwr &aqe densities
Figure 5.1 The Fermi function parametzization of the nuclear charge denkty, The density fags ta axle-hdf of its centrd vdne at the rdiua Ra;the dktmce aver which the dendty drops from 90% tto 10% of its central vdue is .t. (Aftm lE0571,)
and for T > R, we take p ( r ) = 0. Equations (5.32) and (5.381, together with some stm&&tforward dgr?bra7show that
F(q) =
4rR2 N
sin qB E CB(-)" (qR)Znn- n2r2qR
(5.59)
%=l
These expressions, together with Eqs. (5.38,40), can be used to derive explicit foms for Win7and hence for the x2 minimization procedure described above. It is usefd to note that the n'th term in. the Fanrier expmsion of the dendty &ves a csntributhn to the farm factar that is peaked neaf q, E nn/R. Hence, truncation of the sedes at N implies little control over Fourier components with q larger than q~ = N Z / & . This m ~ m u mwaveaurnber contained in the pmametrization must be wmmen;urate with the n r d m u n r momenturn transfer cavered by the exthen data at lager momenturn perimeatal data, gm&,. If QN <
127
Figure: 5.2 Experimentd cross iaaitions fcx the dasfic scattering of dectrans from " ~ , iIan energy of 449.8 MeV. (Born [6;180f.)
5.4 Determining nccclear charge dera~ilies 129
trmsfers w i l l not be well described, wK1e if qjy 3 qwX, thm the CB's with n > q,,R/n will not be we#-determined by the fit. We now return to the d e q u w y of the Born appradmation far describing the experimental data. For charge distributions of the shape expected (roughly like those in Figure 5.l), the relatively sharp nuclear surface induces zeros in F(q). That is, there are particular momentum transfers (or equivdently, scattering angles) where the Born scattering amplitude vmishes. At these d a e s of q, correctians assoei&edi with tbe distortion of the pladle wave of the incident electron by the nuclear Coulomb potential becorne reldively mare impoftant, so that the experimentd data has these zeros largely filled in, often to the extent that they become merely shoulders in a rapidly falling cross section (see Figure 5.2). A precision determination of the nadear charge density from the meaured m s s sections therefore requires a mare sophisticated description of the ~ ~ a t t e r i nofgthe electmns from the Coulomb potential. The rigorous solution to this problem involves salving the Dirac equa tion for the dectran in the Coulomb potentid generated by the assumed charge distribution [Ye54, Fr73]. This results in a calculation very similar to th& done in Project IV: a partid wave decompositioa, solution of the radial equation in each partial wave to determine the phase-shift, and then summation over partial waves to determine the scattering amplitude at each scattering angle. While such a calculation is certainly possible, it is too long for interactive programs. However, the eibond approximation to Dirac scattering c m be sufieiently accurak and resuXts in a reasonable amount of a n s m e ~ dwork. The eikond approximation for ultra-relativistic electrons scattering from a charge distribution results in final expressions very similar to those derived in Section 4.3 [Ba64]. The cross section is related to a complex sea2;tering ampgtude, f , by
and the scattering amplitude is given by the Fmrier-Bessel transform [compare Eq. (4.30)]
where the profile function is the integral of the potential along the straightline trajectory at impact parameter b:
For the particular parametrization (5.571, p vanishes beyond R, and V ( r ) is simply -Zn/r in this region. It i s therefore convenient to split the impact parameter integral (5.61) into regions 6 < R and b > R, so that the latter i x l l e ~ a cm l be done analyticdy. This results in
f = h u t e r + hnner = fauter
R
ik:
~ ~ ( p b ) [ e " ~( ~l)] bdb ,
(5.62)
where
with X = qR. In this expression, S,, is a Lommel function (essentially the incoxnplete i n t e g d of tfie produe$ of a Bessel function and a power), which has the usefd aymptotic expaslsion for l a g e X S,,(X)
x ' - ~[l - ( p - X2 - v Z 4"
{(p-
- v 2 ) ( ( p --
- vZ} -
(5.64)
X4
Note that since we will typically have R 2 8 fm a i d q 6 1fm-I, X will be 8 or mare, sknd so the number of terms s h w n shodd be q ~ - t sufficient. e The inLerior contributim to the scattering ampEtude, h,,,,, involves the potential far r < R m d so depends upon the. detailed form of the nudear charge density. Given the simple relation between the potential and density through Poisson's equation (5.33), it should not be too surprising that it is possible to express ~ (
~(b= ) -zcu log
a
~ ~ p ( ~ ) # ( ad~ l p,)
(5.65)
where #(g)
= log
The parametrization (5.57) then allows the profile function to be written in the form
with the change of integration vmiable z = P / R . Equations (5.61-64,66) complete the specification of the eikonal cross section in terns of the nuclear charge density. It is also easy to show that the quantities Win are @wn by
Several fine points remain to be discussed before turning to the program. One is that the nucleus is not infinitely heavy, and so recoils when struck by the electron. To correct for thig, the cross sections calculated above, which have all been for an electron impinging on a static charge distributian, must be divided by the factor
where M is the target mass (roughly A x 940 MeV). Note that this correction vmishes as M becomes lage compared to E. Second, beemm of the e ~ ~ l attrxtion, ~ m b electrons at the nucleus have a sfightly fiigher momentum. than the beam vdue, h the eikonal treatment, tMa c m be approAmalely corrected for by replacing q in afl of the formdas by
and by multiplying the eikonal scattering amplitude by (q.~/q)'. Bere, is a suitable average of the Coulomb potential over the nuclear volume, conveniently given by 4 Zahe
v
where R. i s the nuclear radius. SimilaIy, in the Born approximation (5.40), the nudear form factor is to be evduated at q e ~'bad , the Matt eroBs section is still to be evduated at q. The F O R T U N pro@- for Exmple 5, whose listing c m be found in Appendh B and in the file EXMT"LS.FOR,uses the method described above to analyze electron scattering cross sections for the nuclei 'OCa ( Z = 201, S8Ni (Z = 28), and 208Pb(Z = 82) to determine their charge densities. Many &Ee;rent daka sets for each target, taken at a mriety
of beam energies and angles (see, for example, [Fr77]), have been converted for equivalent cross sections at one beam energy [Ca80].The integrds (5,62,Ii6b967b)are e d u a t e d by 20-paint Gauss-Legendre quadratwe a d the matrix inversion repired by (5.51) is pedarmed by rul eficient implementation of Gauss-Jordan elimination [Ru63]. After requesting the target nucleus, the boundary r d i u s R, a d the number of sine functions N, the program iterates the procedure described above, displwing at ewh iteration plots of the fit, fractiond emor in the fit, m d the char@ density of the nucleus, tagether with the dacss of the G's and the density. The progrm also d10ws for initid iteratiorits with fewer sines t h m we ultimately required, the number then being increased on request, This technique improves the convergence of the more rapidly oscillating campone~tsof the density as iL reduees the effective dimension of the X2 search by first converging the smoother density components. Mote that, a;e each iteration, only points at an eEective marn~?~ftum transfer smdler tkim that described accuratdy by the current number af sine8 are used in calculating The following exercises w i l l be useful in understanding the physical ;md numericd principles iraportmt in this cajcalation.
=
To deck that the progrm is working properly?use the tzlikond famulas and Fermi-function chmge density described abave t a generate a set of "pseudo-data" cross sections ranging from p between 0.5 and 4 fm-'. Make sure that these cross sections are given at intervals typical of the experimental data and also assign errors to them typical of the data. Then verify the extent to which the correct (i.e., Fermifunction) charge distribution results when these pseudo-data are used as input to the program. One potential source of error you should investigate is the "completeness error". That is, the ability of a finite Fourier series to reproduce densities of the tom expected. This can be studied by changing the number of eines used in the fit. Exercise 5.8
Exercise 5.9 Run the eode with the actual experirnentrtl data to determine the charge densities for the three nuclei treated. Study the quality of the fit and the errors in the density extracted as functions of the number of expansion terms used. Also vedfy that the fitting' procedure converges to the same find solution if the initial guess for the density is varied within reasonable limits. Note that the converged solutions do not have a uniform interior density, but rather show "wiggles" due to the specific shell-model structure of each nucleus.
V: A schematic shell model
m Exercise 5.10 density,
Extend the program to calculate the moments of the
and their uncertainties for integer k ranging from 2 to 5. This can be doneconveniently by using Eq. (5.57) to express these moments directly in terms af the C,. VePify that the size of these raomeats is consiskd scaling of the nuclear radius. with an Exercise 5.11 A simple model for the doubly-mqic nucleus 40Ca is a Slater determinant constructed by putting four nucleons (neutron and proton, spin up and down) in the 10 lowest orbitals of a sphericallysymmetric harmonic osdllator potential. Show that the charge density predicted by this model i s
U
m being the nucleon mass and w being the harwhere ro = monic oscillator frequency. Determine the value of ro (and hence w ) rewired to reproduce the experimentd vdue a f t he road-mean-square radius ( M z ) 9and then compare the detailed form of p predicted by this model with thag obtatined from the data, Exercise 5.12 Modify the progam so tEt& it crilculates the Born, rather thaa. eikond, cross seetim a;nd show that the fomer is grossly inadeqaate to describe the data by compasing the Born cross sections for cljstribution with the experimental data.
m
Exercise 5.13 Modify the program to calculate the "off-diagonal" uncertainties in the density determined using Eq. (5.55) and show that the correlation in the uncertainties largely decreases as the separation of dke points increases.
m
Project V: A schematic shell model The assumption of particles moving independently in a potential is a coms many-partide mon approdmation in treathg the quantum m e c h ~ c of systems, For exmple, this picture underlies the Wa&ree-Fock method for treating the many electrons in an atom (see Project III), the shell model for treating the many ~aclt?onsin a ~ueleus,a d rnaxly models far treat;ing the quwks in a badron, Bowever, it is only a r ~ u g happro~mat;ion
133
Figwe V,% Zllnstra,Ibn, of the orbitals in the s~hematicshell modd.
in many cases and a detailed description of the exact quantum eigenstates often r e q ~ r e sconsideration of the "residual" interactions betwen the particles makiing up the system;. In atoms and Badrons, the residual interactions we not strong enough to induce quatative chane;es in the spectmnr expected horn simpfy placing the partides in digezent arbilds. In audei, however, the coherence aknd s t r a g t h of tfre reddud interactions can l e d to a 'kollective" behaviar in whieh, many nucleons pitstieipate in the meitations and the charmter of the dgeastates is quite diEerent from that expected n~vely. Reastic cdculatians of the eEeets of residual interactians are quite campalex astd involve the diagaaaifizattion of large matrice8 expregsirng the way in which the interaction moves particles among the orbitals [Mc80]. Hoatever, the phenomenon of cdle~tivitJtcan be illustrated by a schematic shell model introduced by by Lipbin et al. [Li65], which we consider in this project, The modd is non-trivid, yet simple enou& to be soluble with only a mo&st aumericd diaganalization. It has therefore served as a testing ground for approximations to be used in treating many-body systems and is &so the prototype for more sophisticated group-theoretic models of nuclear spectra [Ar8l].
V.1 Definition o f the model The schematic model consists of N distinguishable partides labeied by n = 1 , 2 , .. ,N. Each of these can occupy one of two orbitals, a lower and an upper, having energies +1/2 and -112 and distinguished by s = -1 and s = +1,respectively (see Figure V.1). There are then zN states in the
.
model, each defined by which partides are @up'' and which are "down", and each having an unperturbed energy (in the absence of the residual interaction) equal to one-half of the difference between the number up and the number dawn..
V. A schematic shell modd
or
Figwe V.3 IBuatration of the re~idrrdirtter~tion~in the wrefiematic modd.
The residud interaction in the stllilematic model is one that changes simultaneously the states of any pair of pils'cicks; it therefore cottpks sta?t;esof the unpertuhed system. In particular, i"tis convenient to take a residual interaction of rjtrmgth -V that, promates any two partides or that drops any two that are "up" to "dawn", that are CEdown" ta gL"up'9 as illustrated in Figure V.2. An interactiart that simultanwusly rrtises one pasticle m d lowers m ~ t h ~ fclm : &so be included, but introduces no quatatively new features. To define the model preGi~dy,it i~ ewiest to use the lanf5rzag;e of second quantization and introduce the operators a i , and their adjoints, a,,, which. re~pectivelycre& and ~lnnikifatea padicle in the srBitrtl ns. As the model is constructed so that no mofe than one particle earn occupy each orbital, it is convenient to endotv them operators with the usual fer&on wti-c~rnmutationrelzn;tions, (V.la) (V*1b) (V.le) The operator ai,a,, then counts the number of particles in the orbital ns t (i.e., it has eigenvaiues O and l),while the operators aLla,-l and anela,l respectively raise or lower the n'th partide. In terms of these operators, the I f a ~ l t a n i mfor the model can be mitten as
135
where we nmd not worry about the unphysied ra9 = =L: term h the residual interaction since an attempt to raise or lower the s m e particle twice yields a van_isEng state.
V.2 The exact eigenstates The Hamiltonian described above can be represented as a matrix coupling the gN states among themselves. Apart from symmetry and a vanishing of many of its elements, this matrix is not obviously special, so that its numerical diagonalization to find the exact eigenstates md eigenvalues is a substantial probiem'for all but the smallest values of N. Fortunately, the relatively simple structure of the problem allows it to be expressed in the liar language of the group SU(2) (the quantum angular momentum operators), a transformation that carries us a good deal of the way to an exact diagonalization and also affords some insight into the problem. Let nk; define the operakors
Thus, J, measures (one-half of) the difference between the number of "upn partides and the numb= of "dawn" particles, wKk-? J+ m d Jcoherently raise or lower all of the partides. Using these operators, the Hamiltonian (V.2) can be written as
where we have iatrodueed the opclra;t;ors I 1 J, = -(J+ f J - ) , J, = --i(J+ - J - ) . 2 2 Using the fundamental anti-commutation rules (V.1), it is easy to show that the three operators J,, J* satisfy the commutation rules of a quantum angular mumeaturn: Thus, although these L6quasi-spinn operators have nothing to do with a physical angular momentum, all of the techniques and experience in dealing with quantum spin operators can be applied immediately to this problem.
V. A schemalie shell model
We can be@n by realizing that ~ i n the e total quasi-spin operator commutes with J,,,,,, it commutes with the H l h d a n and thus each eigenstate of II can be labeled by its total quasi-spin, j , where j ( j 1) is the eigenvalue of J ~ The . eigenstates therefore can be classified into nondegenerate multiplets of 2 j + 1 states each, all states in a multiplet having the same j;the Hadltoaian has a non-wnishing matrix element between two states only if they belmg to the same multiplet, Bowever, since B does not cornraute with J,, its eigenstates wiB R& be simultaneously eigenstate~of this frt'tter operator. To see what values of j are allowed, we can dassify the zN states of the model (not the eigenstates of H) according to their eigenvdues of &, The m e state with the largest eigenvdue of Jz has all particles up, corresponding to an eigenvdue m = * N . We therefore expect one multiplet of 2 N 1 = N + 1 states corresponding to j = N. Turning next t o states with n = 4 N - 1, we see that there are N states, corresponding to one of the & particles down and all of the rest up. One linear combination of these N states (the totally symmetric one) belongs to the j = multiplet, implying that there are N - 1 multiplets with j = $ N - 1 . Continuing in a similar way, there are # N ( N - 1) states with m = -$N - 2 (two particles down, the rest up}, of which one linear combination belongs to the j = $ N multiplet and N - 1 linear combinations belong to the j = f N - 1 multiplets. There are thus ~ N ( N - 3) multiplets with j = # N - 2. By continuing in this way, we can classify the 2N states of the model into multiplets with j running from $ N down to 0 or i, if N is even or odd, respectively. Because W involves only the quwi-win aperat;ors, its action within a multiplet depends only upon the value of j involved. For a given N , the spectrum of one multiplet therefore serves for all with the same j and, in fact, also serves for multiplets with this j in systems of larger N. We can therefore restrict our attention to the multiplet with the largest value of j, + N . By these considerations, we have reduced the problem of diagonalizing the full Kamiltonian to one of diagondizing (V.4) in the N 1 eigenstates of J, belonging to the multiplet with j = -$N. We can label these states as im), where m runs from - j to j in integer steps. Using the usual formulas for the action of the angular momentum raising and lovvering operators,
+
-3 +
i
+
137
we can write the elements of E in this basis a%i
Thus, R is tri-diagonal in this basis and in fact =parate8 into taro un~ m =. - j , - j 2, *. ,, j azd m =L coupled problems invo1.ving t h state6 -j l,-j 3,. . ,f j - 1 when N is even ( j is integral) and the states m =;: - - - j , - j + 2 , . . . 1 + j - - 1 and m = -j+1, - - j + 3 ,..., + j when N is odd ( j is half-integral). For smdl values of j , the resulting matFices can be diagondized rtsldyticdy, while for 2mger systems, the namericd methods discussed in this chapter can be employed to find the dgenvdues m d eigenvectors, The quasi-spin method d a w s us to m&@one ather atatemat about the e x x t solution of the model. Let
+
+
+
.
+
be the unitary operator effecting a rotation in quasi-spin space by an angle of n about the axis (2 $ ) ~ 2 ' / ~It. i, emy to see that this rotation t r a ~ f o r m sthe quwi-spin operators as
+
ltonian (V.4) transforms as Hence, if tj is an eigenstate of H with energy E, then R+ is an eigenstate of JI with energy -E. Thus, the eigenvdues of H come in pairs of equal magnitude and opposite sign (or are 0). This also allows us to see that if N is even, at least one of the eigenvalues will be zero.
V.3 Approximate eigenstates We turn now to approximate methods for solving the schematic model and consider fint ordinary Rayleigh-Schroedinger perturbation theory. If we treat the J, term in (V.4) as the unperturbed Hamiltonian aod the Jz term as the perturbation, then the unperturbed eigenstates are Im) with unperturbed energies = m and the perturbation series is m) = 0, the energies are an expansion in powers of V. Since ( m unperturbed in first order and are perturbed in second order as
Ji
EC)
V, A schematic shelf model
Using Eq, (V.9) for the matrix elerrxents irtvolved, expgcit expressions for
$be? ~ecould-orderener@es can be derived; the fourth-srder t e r m can. d s o be done wi"c a bit of patient dgebra. While the weak-coupling (smdl-V) limit can be treated by straightforward perturbation theory, m agproxirnahn for the strong-coupling (large-V) situation is not so obvious. One appealing approach is the semidassicd method, vdid in the Emit of large N [Ka79, ShSD]. The dimssion be@ns by considering the equ&ions of motion far the timedependence of the expectat;ion values of the quai-spin operators: d (V.13) i- (Ji)= ([Ji, E ] )9 dt where Ji is any one of the three components of the quai-spin, Using the Hamiltonian (V.4) and the commutation rules (V.6), it is easy to write out Eq. (V. 13) for each of the three components:
d z(Jz)
-2v(JyJz
+ JZJ,)
(V.14e)
UnfortunaLely, these equations do not form a closed set, the time derivatives of expectation values of single quasi-spin operators depend upon expectation values of bilinear products of these operators. However, if we ignore the fact that the J's are operators, and put, for example, then a closed set of equations results:
(V.15a) (V.156)
(V.15c) It is easy to show that Eqs. (V.15) conserve
+
J 2 ( ~ 2 f) (~ J ~ )( J~ Z)? , so that a convenient parametrization is in terms of the usud polar angles, ( J , ) = J cos 8 , (J,) = J sin 8 cos t$
, ( J Y )= J sin 8 sin 6 ,
(V.16)
139
where
If we further define ithe variables
and O 5 q 5 2n, then, upon introdudng the convenient p1 5 coupling constant xzdVVssz2JT,, Eqs. (V.15) can be written as
@E(p,q ) X sin 2q = @E@, g) 3 = I + 2-33 dt RT @P
(V.18a) (V.186)
*
Here, E is the eqeetation vdue of the H
E(P,q) g ( H ) = (Jz) - ~
-
( ( J z ) (~J V ) ~ )
(V.19a) (V.196)
By these manipulations, we have transformed the quasi-spin problem ialo o m of a time-dependeat classical system with 6Lmomentum'" and "coordinate" q satisfying equations of motion (V.18). As these equations are of the canonical form, p and q me canonicay conjugate and (V.19b) can be identified as the Hamiltonian for this classical system. Our hrivation h a been heuristic, but not rigomus, A more careful calculation defines the classical Eamiltonian as the expect ation. vdue of the quantum Hamiltonian between coherent states [Ya82]. However, the only modification this procedure gives to our results is the redefinition:
Note that the EX ltonim so derived is a v a ~ a t i o a done, therefore the quantum ground state energy will be lower than the minima in the dassical energv: We can now infer properties of the quantnm eigenstates by analyzing this classical system. Using Eq. (V.ISb), we can calculate the trajectories in phase-space; i.e., the value of p for a given q and E = (H). Equivalently, we can consider contour lines of E in the (p,q) plane. In an analysis of
9 F l m e V.3 Contours of the HwiIlaGan (V.29b) for the we& eaup b g cM = 8 and X = 0.25. The contour pm&aig through Cp = 0, g = 0) has zero energy. The upper and lower boundary lines p = f are contours at energy &*N,respectively. Successive cantoars shown diger in energy by 1, (F~arnKs791.)
these contours, it is useful to distinguish between weak (X < 1)and strong ( X > 1) coupling cases. Figure V.3 shows a typical weak-coupling ease, N = 8 and X = 0.25. The trajectory with the lowest allowed energy, which we can identify with the ground state of the quantum system, has p = - $ N , E = - $ N , and q satisfying the differential equation (V. 18b). Note that this trajectory r a g e s over aJ1 v d u e ~of Q. LR the strong coupfing case, X r 1, the tr;t,jectaries look as shown in Figure V.4, which mrresponds to N = 8 and X = 2.5. There me now minima in the energy surface at p = - $ N I X , Q = a/4, 5~14, which, using the equations of motion (V.18), can be seen to correspond to stationary points (i.e., time-independent solutions of the equations of motion). The energy at these minima is E = - N ( x X-')/4, which we can identify as m estimate af the ground 8taGe enexggr. There is therefore a "phase ternsition" at X = 1 where the g o ~ n dstate chmges h x n one whercl
+
Ffgwer V.4 Sim2ar l o Figure V.3 for the stro~gcoupling, cam ll\C = 8,
= 2.5. The points Al,ar B1,2 me minima masma, respectively, and C J - . ~ .Dlm4 ~ are sacliae points. Gontours through the saddle points, which have energy A ~ N are , dram as dashed lines; thme separ&e trajectories that are locdbed and exleadd in tp. Succwive caatours diger in energy by l. (Ram [Ka73],) X
p = - N to one where p > -{ N , the energy being continuous across this trmsition. This quditative clsmge in the nature of the ground state is a direct consequence of tfie coherence and strength of the interactians among the particles. It should dso be noted that, in direct andogy with the usud quaatuln double-weU, problem, the presence of two degenerate minima in Figure V.4 suggests that the ground and first-excited states will be nearly degenerate, the splitting between them caused only by '%tunnefingBbetween the wells. The se~clmsica-landysis can be extended to predict the energies of excited states as 4 1 , essentially by applyinf~the andog of the BahrSommerfeld quantization rule given in Eqs. (1.20,21) [Sh80]. One finds that M controls the quantum nat;ure of the problem, Prith the system becoming more ""classicaln as the number of particles inaeitses. In the weak coupling case, all trajectories extend over the full range of q. How-
V, A schematic shell mode2
ever, for strong coupling, there are two types of trajectories: those that vibrate around the energy minima or maxima (and are hence confined to limited regions of p) and those that extend throughout all q. It is easy to show from (V.1Sb) that the transitions between these two behaviors ocEl = J (e.g., the dashed lines in Figure V.4). In andogy with the usual quantum double-well, we expect states associated wit h the confined trajectories to occur in near?y degenerate pairs, the degeneracy being broken more strongly as the energy increases above the minima or decreases below the m&ma. V.4 Solving the model The simple semidassical picture we have discussed above can be tested by an analysis of the exact eigenstates of the model. This can be carried sequence of steps. out through the fQllowia(~ m Step 1 Verify the algebrzhia the di~cussioaabove. In particular, s h w that Eq. (V.4) is a valid representation of the Hamiltonian. Also evaluate the second-order perturbation to the energies, Eq. (V.12). Step 2 Verify the correctness of Eqs. (V. 14,18,19) and the discussion of the energy emtours in the strong md weak coupgng cwes, h the
m
strong coupling case, liaemize the equations of motion about the xaifiima d that the frequency of harmonic moticm about these as m d m a a ~ show points is [2(xZ This is the spacing expected between the pairs of newly degenerate states in the exact spectrum.
-
Steg 3 Write a prqram that finds the eigenvduer~of the tri-rliagond Hamiltonian matrix (V.9), perhaps by modifying that written for Exercise 5.4. Note that the numerical wvork can be reduced by treating basis states nrith even and odd m separately and by using the symmetry oE %he spectrum about E = 0. In addition, yoiu can save yours& some tedious bookkeeping concerning the size of the bases by taking N even only. U
Seep 4 Use the p r o e m written in Step 3 to cdcdate the spectrum of the model for selecged vafues of N between 8 and 40 and for valnes of X between 0.1 and 5. At we& coupling, compare your results pvith the perturbation estimates (V. 12). For strong couplings, compare your ground state energy with the s a i d a s s i c d ~jstimateand verify the? expected paifwise degeneracy of the Isw-fying states. Also cornpase the excitation enerfies af:these states with your estimate in Step 2. Wow doea the accuracy of the semi-classic& estina;ille cfiizlnge with N ?
143
Step 5 W ~ t a, e proe;ram that takes the eigenvdues found in Step 2 and solves for the ei@;envectorsby inverse vector iteration [Eq. (5.27)]. For selected vztdues of N and X , compute the expectation vdue oT J, for e x k eigenvecltor , In a seanidasdcra-f interpret atim, this expectaLioe vdue can be ictentiged with the dime-average of p aver the associatt3d trajectory in phase space. Verify that (J,) changes through the spectrum in accord with what you expect from Figareer V.3, V.4,
r
Chapter 6
Partia Differentia Equations Pmtid differential equations are involved in the description of virtudly every pksical situation whem qumtities vary in space or in: ;apace and time, These indude phenomena as diverse W diRueioa, electramagsetic waves, hydrodynamics, and quantum mechanics (Schroedinger waves). In aILl but the simpXest cases, these equations cannot be solved analytieafly and sa numericd methods must be employed for quantitative resuXds, In a typicd numericd treatment, the dependent vwiatsks (such as tempmature or ekctricd potentid) are described by their d u e s at discrete points (a lattice) of the independent variables (e.g., space and time) and, by appropriate discmtizstion, the partial diBerentid equation is ~ d u c e d to a large set of difference equations. Although these difference equations then can be solved, in principle, by the direct matrix methods discussed in Chapter 5, the large size of the matrices involved (dimension comparable to the number of lattice points, often more than several thousand) mitkes such m q p r o z h impractical. Fartunately, the Iocdity of the origind equations (i.e., they invofw only low-order derivatives of the dependent vasiables) makes the resulting digerence equa;tims Usparse" in the sense that most of the elemengs of the matrices involved vanish, Far au& matrices, iter&ive methods of inversion and diagonajbization can be v e v eaeient. These methods ase the subject of tkis and the fdlfswing chapter* Most of the physiedly important partid digerentid equatio~sare of second order and can be clwsified into three types: parabolic, eEptie, or bypwbofic, Roughly speaking, parabofic equat;ians involve only a
146
6,Elliptic Partial Dr'flesntioE Eguations
first-order derivative in one variable, but have second order derivatives in the remajning vaiables. Examples are the diEasion equation and the time-dependent Schraedringer equation, which are first order in time, but secand order in spitce. Elliptic equations involve second order derivatives in each of the independent variables? each derivativt? having the s m e s i p when &B terms in the equation me grouped on one side. This class indudesj Poisson's equation for the electrostatic potentid and the timeindependent SeAroedinger ewation, both in. two or mare spatial variables. Finally, there are hyperbolic equations, wEch involve secand derivatives of opposite sic, such as the wave equatian describing the vibrations of a stretched string. In this chapter, we win discuss some numerical methods appropriate for eUiptic equ&ions, resewing the discussion of parabofit: equations for Chqttlr 7. Hyperbolic equations often can be treated by methods similar to those we discass, although unique difiedties do arise [Ri6?]. For concmteness in our ascussion, FV~?will consider particular farms af'dipLic bounday d u e a d eisnvdue problems fof a fidd q5 in two sp* tial dimensions (I, y). The boundary value problem involves the equation
Although this is not the most general elliptic form, it nevertheless covers a wide variety of situations. For exampie, in an electrostatics problem, 4 is the potentid and S is related to the charge density [compare Eq. (3.2)], while in a steady-state heat diffusion problem, q5 is the temperature, and S is the local rate of heat generation or loss. Our discussion can be generalized strGghtforwardly to other elliptic cases, such as those involving three spatial dimensions or a spatially varying diffusion or dielectric constant. Of course, Eq. (6.1) by itself is an ill-posed problem, as some sort of boundary conditions are required. These we will take to be of the Dirichlet type; that is, t$ is specified on some large dosed curve in the (z, g ) plane (conveniently, the unit square) and perhaps on some additional curves within it (see Figure 6.1). The boundary value problem is then to use (6.1) to find 4 everywhere within the unit square. Other dasses of boundary vdue problems, such as Neumann (where the normal derivative of 4 is specified on the surfaces) and mixed (where a linear combination of 4 and its normal derivative is spedfied), can be handled by very similar methods.
6.1 Dzacmtizatisn and the variational princiiple
Figwe @,l (Left) A twedimen~iandboundary vdutr, problem d t h DirichIet boundary conditions, Vdnes af c j aupe speci6d on the edlr;ee of the unit square and on the surfacw Within, (Right) Discre~zalion. of the problem on a uniform carledan lattice.
The eigenvalue problems we will be interested in might involve an equation of the form
toe;e%herwith a set of D i r i a e t boundmy coaditions. Thia. might arise,
fClT exmple, as the time-independent Schroedinger equation, where c(r is the wave function, V proportiond to the potential, and E is refated to the eigenvdue. Sueh an eqtzation nright dsa be used to describe the fields in an acoustic or electromagnetic waveguide, where E i s then related to the square of the cut-oE freque;ec;r, The eigenvdue problem then confor sists of finding the vdues e~ and the associated eigenfunctions which Eq. (6.2) and the boundary conditions are satisfied. As methods for sdving such problems are closely related, to those .for sdving a relateir parabolic equ;zlion, we will defer their discussion to Chapter 7.
6.1 Discrethation and the variational principle Our first step is to cast Eq. (6.1) in a form suitable for numerical treatment. To do m, we degne a laLtice of points covering the region of interest in the (2,y) plane. For convenience, we take the lattice spacing, h, to be uniform and equal in both directions, so that the unit square in covered by N x N lattice points (see Figure 6.1). These points can be labeled by indices ( i ,j ) , each of which runs from O to N, so that the coordinates of the point (i,j ) are (+i = ih, gj = jh). If we then define # i j = 4 ( $ i 7 y j ) , and similarly for Sij, it is straightforward to apply the th~ee-pointdifference approximation (1.7) for the second derivative in each direction and
141
so approximate (6.1) as
or, in a more convenient notation,
Here,
61 is the second-difference operator in the i index,
and 6; is defined similarly. Although Eq. (6.3) is the equation we will be solving, it is useful to derive it in a digerent way3 based on a vwiatianal principle. Such asr approah is handy in Gases where the coosdinates are not carte&&%W &iscussedin Sectian 6.3 below, or when mare accurate diRerexlccj.formdas are required. It also is guaranteed to lead to symmetric (or he difirence equations, an often usefd praperdy. The variational method also cords some insight into haw the galufion dgorithnr urorks. A good review of this approach can be found in [Ad84]. Consider the quantity E, defined to be a functional of the field 4 of
In some situations, L": has a physic-zll interpretation. For e x m p l e , in ekcdmstatics, -V# is the electric field and S is the charge drmsity, so that E is indeed the total energy of the system. However, in other situations, such as the steady-state diffusion equation, E should be viewed simply as ;z useful quantity, It is easy to show that, at a solution to (6.1), E is stationary under all variations 64 that respect the Diridlet boundary conditions imposed. Indeed, the variation is
which, upon integrating the second derivative term by pmts, becomes
6,l Biscretization and the variational principle
where the line integral is over the boundary of the region of interest (C) ancl n is the unit vector normal to the boundmy. Since we consider o d y vasiations; that respect the bouadau conditions, S# vanishes an C, sa th& the line integrd does W well, Demanding that 6E be zero for d such variations then implies that q5 satisfies (6.1). This then furnishes a vaiatioad grindple fi>P our boundary d u e problem. To derive a discrete approsnnatioa to the partid diEerentid equation based on this vafiational principk, are first approximate E: in terms of the d u e s of the 5eld at the lattice points m d then vary with respect to them. The sirnplest approximatim to E is; to employ the two-point ~ difference formula to approximate each first derivative in ( ~ 4at) the points halfway betwwn the lattiee poiats and to use the trapezoid2 ruk for the integrds. This bads to
Putting
-@E =o @+ij
for all i j then leads to the difference equation derived previously, (6.3). Of course, a more accurah diser&iztttion cm be abtdned by using better approfimations for the first derivativw a d for the integds, t a E ~ gcase that the accuracies of bath are commenszlrate. It is also emy to show from (6.7) that not only is E stationary at the solution, but that it is a d ~ r n u n ras ~4311, Exercise 6.1 Show that the vanishing of the derivatives of Eq. (6.7) with respect to the vdues of 9 a,t the lattice points lead to the difFerence Eq. (6.3). Prove, or argue heuristicdy, that E is a minimum when 4 is the cmrect solution.
Exereilre 6.2 Use the diRertsntiation fbsmulas @ven in Table 1.2 to derive discretizations that are more accurate than (6.3). Can you see how the baandary conditions are to be incorporated in these higher-order form&=? What are the correspon&ng discretizaLions of E andogous to (6.7)? (These are not trivial; see [F178].)
R
We must now &scuss where the boundary conditions enter the set;
of Ijnear equations (6.3). Unless the coordinate system is we11 adapted to the geametry of the surface8 on wbicb the boundam conditions are imposed (e.g., the surfaces are straight lines in cartesian coordinates or
149
150
6,Elliptic Partial Diflerential Ewationol
arcs in cylindrical or spherical coordinates), the lattice points will only roughly describe the geometry (see Fig. 6.1). One can always improve the accuracy by using a. non-uniform lattice spacing and placing more points in the regions near the surfaces or by transforming to a coordinate system in which the boundary conditions are expressed more naturally. In any event, the boundary conditions will then provide the values of the 4ij at some subset of lattice points. At a point far away from one of the boundaries, the boundary conditions do not enter (6.3) directly. However, consider (6.3) at a point just next to a boundary, say (i, N - 1). Since 4iN is spedfied as part of the boundary conditions (as it is on the whole border of the unit square), we can rewrite (6.3b) as
that is, +ilv enters not as an unknown, but rather as an inhomogeneous, known term. S i ~ l a r f yif, a Neumann bollndary mndit;ion were imposed at a surface, say a+/ay = g(%) at y = 1 or, equivalently, j = N , then this could be approsmated by the discrete boundary candition which means that at j = N
- 1, Eq. (6.3) would become
These consideratims, and a bit more thought, show that the discrete approximation to the differential equation (6.1) is equivalent to a system af Enem equations for the unknown vdues of tt, at the intex;ar poi~ts,In a matrix notation, this cm be written aa
where M is the matrix appearing in the linear system (6.3) and the inhomagentjous term s is proportional to S at the interim points and is linewly rdated to the specified vdues of g) or it-s derivatives on $he boundafies, In any sort of prrtcticaf situation there are a very lasge number of these equations (some 2500 if N = 50, say), so that solution by direct inversion of M is impraetied, Fortunately, since the discrete approximation to &he Laplacian involves only neighboring points, most of the elements of M vanish (it is sparse) and there are then effident iterative techniques for solving (6.9). We begin their discussion by considering an analogous, but simpler, one-dimensional boundary value problem, and then return to the two-dimensiond case,
6.2 An iterative method f ~ boundarg r value problems
6.2 An iterative method for boundary value problems The one-dimensional bounday vdue problem analogous to the two-dimensional problem we have been discussing can be written as
with +(0) and 4(1) spedfied. The related variational principle involves
which can be discretized on a uniform lattice of spacing h = 1/N as
when varied &h rtlspect t o cbi9 thls yields the difference equation which is, of course, just the naive discretization of Eq. (6.10). M&hods of solving the boundary value problem by integrating forwmd m d backwad in a: were Gsenssed in Chapter 3, but we can d s o and + N , as a set consider (6.13), together with the known values of of linear equations. For a modest number of points (say N 6 loo), the liaear system above c m be solved by the direct methods discussed in Chapter 5 and, in fact, a very eEcient specid dircrct method e ~ s t for s snch ""ti-distgand" systems, as discussed in Chapter 7. Howwr, to illustrate the iterative methods appropriate for the large sparse nnatriees of' elliptic partial diEercr;ntial equatiians in two or more dimensions, we begig by rewriting (6.13) in a "solved" form for 4i:
Although 'this equation i s not manifestly useful, since we don%know the 4's on the right-hand side, it can be interpreted as giving us an "improved" value for 4i based on the values of 4 at the neighboring points. Hence the strategy (Gauss-Seidel iteration) is to guess some initial solution and then to sweep systematically through the lattice (say from left to right), succesasivelly replacing cif, at each point by an improved vdue. Note that the most "ccurrent'pvdne8 of the 4ikl are to be used in the right-hand side of Eq. (6.14). By repeating this sweep many times, m initial guess for q5 can be "relmed" to the correct solution.
3.51
152
6. Elliptic Partial Digerential Eggation8
To investigate the wnvergenee of this p r o d m e , W generdize Eq. (6.14) so that at each step of the relaxation is replaeed by a linear mixture of its old value and the Uimproved"one given by (6.14):
Here, w is a parmeter that can be djluisted to control the rate of r d w ation: "over-relmation" corresponds to w < l, wG1e @under-relwittian" s rate ofre1;txil;tian means w > 1. The optinzaf vdue of'w that n r ~ m i z e the will be discussed below. To see that (6.15) results in an 'improvement" in the solution, we calculate the change in the energy functional (6.12), remembering that all 4's except +i are to be held fixed. After some algebra, one finds
so that, M long W 0 < u < 2, tbe, energy nevw incmases, and should thus converg;t! t;o the r e q ~ r e dminimum vdne as the sweeps proceed. (The existence of other, spurious minima of the energy would imply tb& the Enear system (6.13) is not well posed.)
Exercise 6.3 Use Eqs. (6.12) and (6.15) to prove Eq. (6.16). As au. example of this relmation method, let us consider the m e dimensional boundary-value problem of the form (6.10) with
The e x x t solution is +(g)
= %(l - 2)
and %heenergy is
9 = -0.64286. 14 The following FORTRAN code implements the relaxation algorithm and prints out the energy after each sweep of the 21-point lattice. An initial guess of +i = O is used, which is clearly quite far from the truth. _E7=---
C cbpba,for
60
PARAHETER (ISTEP=20 !la$fies size BfHEEilSIDXIT PHX(O:XBST~),~(~:ISTEP) !fie26 ancl h**r?*s@nrce PRINT * ,"n%sr msga ( .X@. O fo atop) p !relmaeioxz parmet er READ OmGA IP (QEEGA .LE. 6) STOP
*,
6.2 An i;tclrabiue method for kundarg vadus pmbkms
3153
C
10
H=%./ISmP DO 10 IX=O,ISmP X=IX*B S(ZX)=B*H*I2*X+X PHIC X X ) = ~ . CORTZlB(iJ1E
!fill h**2taomcs ?iafffal guess for f i e l d
C
DO 20 ImR=i,500 DO iS %X=1,1STW-l
~rrr~=~~an(r~-~
!rsla.alion loop !sweep tkoagh laittice ~ + ~ a x ~ x ~!Q. + i ~6.34 +s~
~x~~t~
PHI (rz>=
COmfEm
IF (HQD(XTER-1,201
.
E=O DO 30 IX=l,BS%P
.me0) mm
!soaretimes talc
t
~ (e,gi> ,
energy E
E=E+ C ( P H (IX)-PBX ~ (IX-i>>/fx>**2)/2 R=E-~(Z~I*P~I(IX)/I~*+~ CQ#TIBrNE
]E=E+B PRIIT
20
*,#
itssation = ',itsr,Qensra
=
\,E
Ern IF GOmXm GOTO 50 =D
Resufts for the enere;y as a fnnct;iart of iteration number we shmn in Table 6.1 for t h r &Rerent ~ vdues of u, Desgite the rather pom initid guess for #, the iterations converge m d the converged eaergy is independent of the relaation pafameter, but digers ksomewhtat h a n the exact answer due to discretization enors (i.e., h not vanishingly small); the discrepancy can be reduced, af course, by increshsing N. A detiled =amination of the solution indicates good agreement with the analyticd result. Note thitt the rate of convergence clearly depends upon U. A general analysis [Wa66] shows that the best choice far the relwation p a r a e t e r depends upan the lattice size arrd on the &-metry af the problem; it is u s u d y $reater t h m 1. The ap%irndd u e can be determined empiriedly by exadning the convergence of the solution for only a few iterations befare chooaing a d u e to be used for many iterations.
154
6. Elliptic Partbl Difirenttaf Equations
Table 6.1 Ca~vergenceaf the energy functiand dnkng relaxation sf a l-D bounday vdtlue problem
Iteration
= 0.5
o = 1.0
w
= 1.5
Exercise 6.4 Use the code above to vefify that the e n e w approaches the analytical vdue as the lattice is made finer, Investigate the accuracy of the soiutioa. at each of the lattice points and note thatt the enerw can be considerably more accurate than the sdutim itself; this is a naturd consequeaw of the minimization of E at the comeet solution. Use one of the higher-order discretizations you derived in Exercise 6.2 to solve the problem.
The itppdication of the relaxation scheme described above to two(or even three-) dimensional problems is now straightforward. Upon solving (6.3a) for 4i j , we can generate the analogue of (6.15):
If this algorithm is applied successively to each point in the lattice, say sweeping the rows in order from top to bottom and each row from left to right, one can show that the energy functional (6.7) $ways decreases (if w is within the proper range) and that there will be convergence to the required golution,
Several emsideratioas c m seme to enhance this convepnce in practice. First, starting from a good guess at the solution (perhaps one with simitar, but simpler, boundary conditions) will reduce the number of iterations required. Second, an optimal d u e of the relaxation parameter shoufd be used, either estinrahd a;nalyticdy or determined empiricay, W described abave. Third, it may sometimes be more efficient to concentrate the relaxation process, for several iterations, in some sub-area of the lattice whex the trial sdution is k m n to be particularly poor, thus not wasting effort on already-relaxed parts of the solution. Finally, one can always do a calculation on a relatively coarse lattice that relaxes with a s m d amount of numerical work, aad then interpalate the solution found onta a h e r lat2;ice to be used as the s t e i n %guess for further iterations. 6.3 More on discretiza$iam It is often the c a e that the energy functimaf defining a physicaf problem has a form more complicated than the simple "htegrd alof the square oi' the derivativrs'9that we have been considering so far. lFor example, in m dectrostaties problem with spatidy-varying dielectric properties or in a &@usion probfern with zb spatidly-varying diffusion caeBcie?nt, the boundary-value problem (6.1) is modified to
where D ( s , y) i 8 the dielectric constant or difigion eoeificient, and the corresponding energy functional is [compare Eq. (6.4)]
Although it is possible to discretize Eq. (6.18) directly, it should be evident from the previous discussion that a far better procedure is to discretize (6.19) first and then to differentiate with respect to the field variables to obtain the diEermee equations to be d w d . To see how this works out in detail, consider the analog of the onedimensional problem defined by (6.11),
The discretization andagous to (6.12) is
E56
6. Elfliptic Partial Diflema#id Equations
where Di-1/2 is the diffusion mnstant at the half-lattice points. This might be known directly if we have an explicit formula for D(%),or it might be approximated with appropriate accuracy by $ (-Di ~ i l). - Note that, in either case, we have taken care to center the diEerendng properly. Variation of this equation then leads directly to the corresponding difference equations [compare Eq. (6. U)],
+
These can then be solved straightforwardly by the relaxation technique described above. A problem treated in cylindrical or spherical coor&aat;es presents v(3f~much the s m e kind of situta2;ian. For example, whea the diffusion or dielectric properties are independent of space, the energy functional in cylindricd cooranates wiB involve
where r is the cylindricad radius. (We suppress here the integrations over the other coordinates.) This is of the form (6.201, with D ( T )= r m d an additional factor of r appemiag in the source i&graX. Discretization on a lattice ri = hi in analogy to (6.21) then leads to the analog of (6.221,
-- 0, this equation just
or equivdentfy; that t d s us that rpL = = 0. This is to be expected, as, in the electrostatics l a n g a ~ e Gauss" , llaw allows no radial electric field at r = 0. 1"IC i = 1, and 42, but Eq. (6.24) gives an equation involving three unknowns, +a, putting 450 = W a rough approAmation t a the zero-derivatim boundwy condition gives an equation involving only t w unknowns, whi& is what we expect a% a boundary on the basis of our experience with the ca_rtesim problems discussed above. A more elegant discretization of problems with cylindrical symmetry naturaUly incorparatw the zero-derivative baunda~ycondition at F =r. 0 by working on a lattice defined by = ( i - 3)h. In this case, Eq. (6.24) is still v&d, but for i = 1the eoeffieient oftbe term involving $i-2 m&~hes, giving directly an equation with only two unknowns, 41 and #z. At i
@+/@F= 0 at
T
6.4 Elliptic equations in iwo dimensions
Exercise 6.5 Verib that variation of Eq. (6.21) leads to Eq. (6.22). Write down explicitly the discretizations of Eq. (6.23) on the Ti = ih and ri = ( i f )h lattices and verify their variation leads to (6.24) in either ease. Why can the contribution to the ener$y f u n e t i o d from the region between r = O and F = # h be safely neglected on the ri = ( i - $ ) h lattice to the same order as the accurxy of approdmation used for the derivative?
-
6.4 Elliptic equations in two dimensions The application of relaxation methods to elliptic boundary value problems is illustrated by the program for Example 6, which solves Laplace's equation, V2+= 0, on a uniform rectangular lattice of unit spacing with Dirichlet boundary conditions specified on the lattice borders aad on selected paints Psithin the lattice, This situattion might describe the shadystate temperature distribution within a plate whose edges and certain interior regions we Held at specified temperatures, or it might describe an dectrostatics problem. speGiEed by a nuIliber of equipotentid surfwes. During the iterations, the potential is displayed, as is the energy functional (6.7) to monitor convergence. The code's source listing c m be found in, Appendix B and in the file EXMPL6.E"OR. The following exercises, phrased in the language of electrostatits, might hdp you t a understaind better the physicd and numeric& prindpres ilfustrated by this example. m Exerelsc? 6.6 Vctrify that- the sdutions comesponding to particular boundary conditions in the interior af the lattice a g e e with your intoition, You might try M n g a single interim point to a potential &Rereat ;from that of the boundary, R i n g tvvo symmetricalfy located points to different potentids, or fixing a whole line to a given potential. Other passibilities include constructing a "Faraday cage" (a closed region bounded by a surface at fixed potentid), studying a quadrupaie pattern of boundary cmditians, or cdculating the capacitance of various configurations of conductors. Study of what happens when you inerease or decrease the size of the 1at;tice is dso interestiw. m Exercise 6.7 For a given set of boundary conditions, investigate the effects of under-relaxation and over-relaxation on the convergence of the relaxation process. Change the discretization of the Laplacian to a higherorder formula as per Exercise 6.2 and observe any the changes in I h e solution or the eficiency with which it is appmached.
157
Modify the code to solve Poissonk equation; i.e., d o w for a charge density to be specified throughout the lattice. Use this to study the solutions for certain. simple charge distributions. For example, you might try computing the potential betwen two (line) &ages as a function of their sepafation and comparing it vvith yonr malyticd a p e c t ationa. Exmcise 6.8
Exe-reisfs 6.9 Modify the code to use Neurnann boundary conditions on sdected borders and iderior regions of the l a t t i ~ Study , the solution for simple geoanetries and compare it with what ycru expect.
W
r
Exercise 6.10 Modify the code to allow for a spatidy-varying dielec-
tric constant. (Note that you must change both the relaxation formula and the energy functional.) Study the solutions for selected simple geometries of the dielectric constant (e.g., a half-space filled with dielectric) and simple boundary conctitions, An dter~ativeto the Diridlet bounday conditions are periodic boundary conditions, in which the potedials on the left and right and top and bottom borders of the rectangle are constrained to be equd, but otherwise afbitraq. That is,
W
Exereiscl 6.11
for all i and j . This might correspond to the situation in a crystal, where the charge density is periodic in spaee. Modify the code to incorporate these boundary conditions into Poisson's equation and verify that the solutions look as expected far simple &age distributions. Exercise 6.12 Change the relaxation formula and energy functional to treat situations with an wimudhd symmetry by re-interpreting one of the coordinates as the cylindrical radius while ret4ning the other as a cartesim coordin&e. Use the resulting pragrm to mod4 a eapacitof made of two circular disks, and in particular calculate the capacitance and potential field for varying separations between the disks. Compare your results with your expectations for very large or very small separations.
m
Project VI: Steady-state hydrodynamics in two dimensiorrs The description of the flow of fluids i s one of the richest and most chdlenging problems that can be treated on a computer. The non-linearity of the equations and the complexity of phenomena they describe (e.g., turbulence) sometimes make computational fluid dynamics more of an
art than a science, and several book-length treatments are required to cover the Geld adequately (see, for example, [Ro76]). In this project, we will consider one relatively simple situation that can be treated by the relaxation methods for elliptic equations described in this chapter and that will serve to give some idea of the problems involved. This situation is the time-independent flow of a viscous, incompressible fluid past an object. For simplicity, we will take the object to be translationally invariant in one direction transverse to the Bow, so that the fluid has a non-trivial motion only in two-coordinates, (I, g); this might describe a rod or beam placed in a steady flow of water with inddent speed Vo. We will also consider only the case where the cross section of this rod is a rectangle with dimensions 2W transverse to the fiow and T along the flow (see Figure VI.1). This will greatly simplify the coding needed to treat the boundary conditions, while still allowing the physics to be apparent. We begin with an exposition of the basic equations and their discretization, f o u w with a brief disevssion of $he boundmy eon&tions, and then give some guidance in writing the pragarn and in a t r x t i n g some understanding from it.
VI.1 The equations and their discretization In describing the flow of a f i ~ through d spxe, at least two fields are important: p, the arms den~ity,and V, the vdacity, of the Aluid eft3ment at ea& point in space. These are related throu& two fundamental eqnatims
The first of these (the continuity equation) expresses the conservation of mass, and states that the density can change at a point in space only due to a net in- or out-flow of matter. The second equation (NavierStokes) emresses the emserva%ionof momentum, ltnd states thaL the velodty changes in response to convection, (V V)V, spatial variations in the pressure, VP,and viscous forces pV2V,where U is the kinematic viscosity? arisunzed constant in our discussian, In generd, the pressure is given in brms Of the density and temperature through an "equation of state'" and when the temperature vwiee3 m weB, m addition& equation embodying the conserntion of energy is dsa required. We win assume: that the temperature is constant throughout the fiuid. g
l60
6. Elliptic Partial Digerential Epations
Figure VI.1 Geometry of the twdinrensiond Aow past a pfa~Ieto be treated in this project,
We vviU be interegted in studying time-independent fioars, so that time derivative8 can be die2 to zero in them equations. firthermore, we win assume that the fiuid is incompressible, so that the density ia constant (this is a good approximation for water under many conditions). Equations (VI.1) then become
V*"GI=O; 1 (V* V)V = --VP+vv2v. P
(V1.2~)
(V1.2b)
For two-dimensional flow, these equations can be written explicitly in terns of the I and y components of the velocity field, denoted by zl and v , respectively:
Equations (VL3) are three scalar equations for the fields u, v , and P. While these equations could be solved directly, it is more convenient for two-dimensional problems to replace the velocity fields by two equivalent scalar fields: the stream function, $(z, g), and the vorticity, ((S,g). The first of these is introduced as a convenient way of sa-ti~fyiagthe continuity equation (VI.3a). The stream function is defined so that
It is easily verified that this definition satisfies the continuity equations (VI.3a) for any function $ and that such a euists for all flows that satisfy the continuity condition (VI.2a). hrthermore, one can see that (V = V)$ = 0, so that V is tangent to contour lines of constant the "stream lines". The vorticiey is defined a8
+
+,
which i s seen to be (the negative of) the curl of the velocity field. From the definitions (VI.4), it follows that C is related to the stream function 'Ztt by v2+= C = (V1.6) An equation for C can be derived by differentiating (VI.3b) with respect to y and (V1.3~)with respect to I. Upon subtracting one from the other and invoking the continuity equation (VI.3a) and the definitions (VI.4), one finds, after some dgebra,
Findly, an equation for the pressure can be k i v e d by diaereal;i&ing (VI.3b) with respect to z and adding it to the derivative of (V1.3~) with respeet to ye Upon expressiag a;LI velocity fidds in tezm~of the s t r e m function, one finds, dter a bit of rearrm@ng,
162; 6. BllipEic Partial Riflerential Eqwotionkr
Fimrct Vf .2 The lattice to be used in c&culathg the fluid flow P~ISTL the plate illustrate;$ in Figure V1.1,
Equations (VI.6-8) are a set of non-linear elliptic equations equivalent to the origind hydrodynamic equations (VI.3). They are particularly convenient in that if it is just the velocity field W wmt, o d y tne two equations (VI.6,7) need be solved simultaneously, since neither involves the pressure. If we do happen to want the pressure, it can be obtained by solving (VI.8) for P after we have found and C. To solve Eqs. (VI.6,7) numerically, we introduce a two-dimensiond lattice of uniform spacing h having N, and N, points in the r and y directions, respectively, aod use the indices i and j to measure these coordinates. (See Figure VL2.) Note that since the centerline of the rectangle is a line of symmetry, we need only treat the upper half-plane, y > 0. Moreover, it is convenient to place the lattice so that the edges of the plate are on lattice points. The location of the plate relative to the up- and downstream edges of the lattice is arbitrary, although it is wise to place the plate far enough forward to allow the 'Lw&e" to develop behind it, yet not too close to the upstream edge, whose boundary conditions can influence the flow pattern spuriously. It is also convenient to scale the equations by measuring all lengths in units of h and all velocities in units of the incident Buid velocity, Vo. The stream function is then measured in units of &h, while the vorticity is in units of &/h, and the
+
VI. Steodg-stab
ftyddgnamr'cs in two dimensions
pv.
pressure is conveniently scaled by Upon differencing (VI.6) in the usud way, we have (V1.9) (8; @)id (fi!+)ij = Cij 9 where 62 is the symmetric second-difference, as in Eq. (6.3b). Similarly, (VI.7) can be differenced as
+
where the symmetric first-difference operator is
The lattice Reynolds number, R = &h/v, is a diand similarly for mensionless measure of the strength of the viscous forces or, equivalently, oE the speed of the incident stream. It is rdated to the physical Reynolds a m b e r Re by repking the mesh spacing by the width of the reetage: Re = 2WKIv. Finally, the pressure equation (VI.8) can be differenced as
VI.2 Boundary conditions In order for the elliptic problems (VI.6-8) to be well posed, we must s p e w either the d u e s or the narmd derivatiws d the dream. function, the vorticity, md the pressure at boundaries of the lattice shown in F i p r e VI.2, These boundaries c m be classified into three groups, in the n o t a i m af Figure VX.3: i) the centerline boundasies (A and E); ii) the boundaries contiguous with the rest of the fluid (F, G, and
H); iii) the boundaries of the plate itself (B, C, and D). We treat $t and (' on each of these in turn, followed by the pressure boundary conditions. Throughout this discussion, we use unscaled (i.e., physical) quantities. It also helps to recall that in the freely flowing fluid (i.e., no obstruction), the solution is u = V& v = 0, so that II, = Voy and
5 = 0. The boundary conditions an the centerline su&aces A md E are detemined by symmetry, The y camponeat of the velocityf v , must vanish here, so that the 2 dell-ivative of $ mnishes. It follows that; A and E are
3.63
l64
6, Elliptic Partial Eziflerential Eguations
Figwe VI.8 Boundw candjitionsr t o be i m p a d on the stream function and vorticity.
each stream lines. Moreover, since the normal velocity (and hence the s h on~ B, C, and D, the entire snrfaee t angentid derivative of +) also ABCDE is a single stream line, and we may arbitrarily put $ = O on it. Note that the velodties depend only upon the derivatives of so that the physical description is invariant to adding a spatially independent l this stmmEne fix@@ colnstant to the s t r e m funetion; the e f i o i ~ eof $on the constant. Ekom syanmetry, we can also conclude %h&the vortidty vmishes on A, and E. The boundary conditions on the upstream surface F are also fairly straightforward. This surface is contiguous with the smoothly flowing incident Auid, so that specifying
+,
as is the case far upstream, seems reasonable. Similarly, if the lattice is large enough, we may expect the upper boundary G to be in free flow, so
is one appropriate choice. The downstream boundary H i s much more ambiguous and, as long as it is sufficiently far from the plate, there should be
many plwsible choices, Hawever, the boundary coar&tions on. a boundary that approahes the plate can influace the shape of the solutioa foa~d. One conveaient ghoice is to say that nothing changes beyond the lattice boundarv. so that At the walls of the plate (B, C, and D), one of the correct boundary conditions is that the norxxlairl velodty of the Buid is zero. This we have used &ready by ~ t q d r i a gthat this surface be a sr;treamline, Wowever, the other boundary condi.eion appropriate for viscous Am i s that the tmgeatid velocity be zero. hplementing this by setting the normal derivative of $ to zero wauld be aa overspecific&ian of the emptic prObkm for $J, Irtstead, the "na-sEp" boundary condition is imposed on the vodieily; Consider a point z'j m the upper surf"ace of the plate, C. We c m write the s t r e a fanctian at the point on lattiw spacing above this one, i j l, as a Tqlor series in 9:
-+
Since, at the wall,
and
a2+ a%
-=."m-=
ay2
@Y
C
5
because av/@z= 0, (VI.12) can be reduced to
which provides a Dirichlet boundary condition for C. (This is the general form of the boundary condition; recall that we had previously specified eij = O on the plate boundaries.) The same kind of arguments can be applied to the sudaees I3 and D to yield
Note that there is an ambiguity at the 'corners", where surfaces B and C and D and C intersect, as here the vorticity can be computed in
two ways (horizontal or vertical difference of $l) In.practice, there w e severd ways of resolving this: use one form and verify that the other gives similar values (a check on the accuracy of the calculation), use the average of the two methods, or use the horizontal value when relrwring the point just to the right or left of the corner and the wrticd vdue when rel&ng the poine jlrst above the cosaer, The boundary cmditians for the pressurn on ~uflf(izce~ we of the Neumann type, and follow from Eqs. (VI.3). We leave their explicit finiteagerence form in terms of $ and. f as m exercise, Note that from symmetry, aPl8y = O on the centerlines A and E.
VI.3 Solving, the equations Our general strategy will be t a d v e the coupled non-linear @Upticequations (VI.9,10) for the stream function and vorticity using the relaxation methods discussed in this chapter. One possibb iteration scheme $aes as follotirs. We bedn by chwsing trial vdues comc3span&ag to the freeflawing solution: 2E, = y and f =. O , We then perform one relruration sweep The Dirichlet boundary condiof (VI.9) to get an improved d u e of tions for ( on the walls of the plate are then computed from (VI.13) and then one relaxation sweep of (VI.10) i s performed. With the new value of C so obtained, we go back to a sweep of (VI.9) and repeat the cycle many times until convergence, X f required, we can then salve the pressure equation (VI.11) with Neumann boundary conditions det ned from (VI.3). This iteration seherne can be implemented in the fauowing sequence of steps:
+.
Step X, Write a section of code to execute one relmatiorz sweep af (VI.9) for given C and subject to the boundary conditions discussed above. Be sure to d o w for an arbitra3i.y ~ e l m a t i ~parameter* n This code c m be dapted from that for Example 6; in gmtiedaf, the technique of using letters on the scrwn as a crude contour plot can be useful in displibying
m
+.
of code that cdculates the boundary condion the d a t e wdls if $J is known.
Step 2 Write a section
tions for
Step 3 Write a section of code that does one relaxation sweep of (VI.10) for C if ij, is given. Build in the boundwy conditions discussed above and be sure to allow for an arbitrasy relaxation pmameter. If you have a contour plotting routine and a sufficiently high-resolution terminal, it is usefrt2 to display w d C on the screen together.
m
Step 4 Combine the sections of code you wrote in the previous three steps into a program that execute6 a number af itera;tions of the empled $-C problem. Test the convergence of this scheme on several coarse l a t t i e ~far several different Eeynolds ~umbersand chaices af relzwration parameters.
Step 5 Calculate the flow past several plates by w i n g your program to convergence on some large lattices (say 70 X 24) for several increasing values of the lattice Reynolds number. A typical size of the plate might be W = 8h and T = 8h, while lattice Reynolds numbers might run from 0.1 to 8. For the lager Reynolds numbers, you might find instabilities in the relaxation procedure due to the nonlinearity of the equations. These can be suppressed by using relaxation parameters as s m d as 0.1 and by using as trial solutions the fiow patterns obtained at smaller Reynolds numbers. Verify that the flow around the plate is smooth at small Reynolds numbers but that at larger velocities the flow separates from the b a d edge of the plate and a small vortex (eddy) develops behind it. Check also that your solutions are accurate by running two ernes with digerenit lattice Eeynolds numbers but the same physicd fteynolds numb=.
Ttvo physicdly interesting quaatities that can be compu.t;ed from the flow pattwn we the net pressure and vis~ousforces per unit area of the plate, FP and F@,By spnnetry, these act in the z directian and are measured conveaientfy in tarns of the flow of momentum incident on the face of the plate per unit area, 2Wpr/02. The pressure force is given m
Step fi
where the integrals are over the entire front and back surfaces of the plate, T h i s shows dearly that it, is only the rdative d u e s of the pressure over the plate surfaces that matter. These can be obtained from the flow solution using Eqs. (VI.3b,c). Consider, for example, the front face of the plate. Using (V1.3~)~ together with (M.4,6) and the fact that the velocfties vmish at the plate surface, we can write the &rivif,tie of the pressure along the front face as:
Hence, C from the Bow solution can be integrated to find the (relative) pressure along the front face. Similar expressions can be derived for the
3.68
6". Elliptic firdial Bigerential Equations
top and back faces, so that the pressure (apart from an irrelevant additive constant) can be computed on all faces by integating up the front face, across the top, axld dawn the back face. The net viscous fbm per unit area of the plate is due only to the flaw past the top (and bat tom) surfaces and is given by However, since the boundary canditions on the top surfwe of the plate require av/8z = 0, this can be written as
wfsieh i s conveniently ev;iiuat;c;d from the flow solation- fnvestigate the v ~ i a t i o eof the viscous and presjsure forces with Eeynolds number and compare your re8uXt.s with vrvhat you expect. Step 7 Three other geornedries can be investigated wit;& ody nrinar modifications of the code you've constructed. One of these is a Ujumg", in which. the thickness of the plate is increased until its Bownstrem edge meets the downstream border of the lattice (H). Another is a pair of rectangular plates placed symmetrically about a centerline, so that the fluid can flow between them, as well around them (a crude nozzle). Finally, two plates, one behind the other, can also be calculated. Modify your code to treat each, of these cases and explore the flow patterns a%various Reyndds numbers.
Chapter 7
Differentia Equations Typical parabolic pwtid differential equations one encounters in physical situations are the diffusion equation
where D is the (possibly space dependent) digusion constant and S is a souree fun&ian, and the time-dependent Schroedinger equation,
where V is the poterrtid, In cantrat to the boundary d u e problems encountered in the previms clrapter, thesje problems me generdly of the initial d u e type. That is, we are @wnthe field 4 at an initid time and swk t a find it at a later time, the evolutian being subjtsct to ccjrtgn spatial boundary conditions (e.g., the Schroedinger wave function vanishes at very large distaaces or the temperature or he& flux is specified on some surfaces). The methods by which such problems are solved on the computer are b a s i d y straightforward, although a few subtfeties are involved. We will d m see thiLt t h q provide a n&ur& way of solving eEptic eigetnvdue problenrs, particdasly if it is o d y the few lowest or highest eigenvdues that we required.
7.1 Naive discretization and instabiliitie~ We begin oar diseus~ianby treating digusion in one dimension with a uniform diausion constant. VVe take z to vmy between 0 and 5 and a6sume Diriehlet boundary conditions that s-pedfy the valiue of the fi&d
170
7. Pambslic Partial Diflemntial Eqaotions
at the end points of this irrtervd. After appropriate scalirtg, the andague
As usud, we a p p r u ~ m a t ethe spatial derivatives by finite diRerenees an a uniform lattice of N 1 points having s p i n g h = 1/N, while the time derivative is apgmdmated by the simpkst first-order diAFerexzce fomala assuming a time step A$. Using the supesacript .n: to l&d the tirncl step I 4(t,), 1, = nag), we can approximate (7.3) as (that is,
+
At i = 1 and i = N - 1, this equation involves the Dirichlet baundasy conditions specifying fbo and + N . Equation (7.4) is an ezplicit differencing scheme since, given q5 at one time, it is straightforward to solve for 4 at the next time* Indeed, in an obvious matrix notation, we have: where the action of the operator E is defined by
As an exmple of haw this expUcit acheme d g h t be applied, consider the case where S = O with the boundary conditions #(O) = 4(1) = 0. Suppose that we are given the initial cundit;ion sf a Gausaian catered about 2 = 112,
where the latter two "image" Gaussians approximately ensure the boundary conditions at + = 1 and s = 0, respectively, and we seek to find # at later times. The following FORTRAN code applies (7.5) to do this on a fatdice with. R = 25. G chp"l".Por PIRMmER (ISmP=2S) CIIMEHSIOI PEP (0:I S T B )
ay f o r etalut ian ! i o m of the malytical solutfon GAUSS (X ,T)=EXP(-20 *[X-, Q)**2/ (1.. +~o*T) )/SQRT< $+80*T> EXACT(X,T)=GAVSS(X,T)-GAUSS(X-~. pT)-GAPIS5(X+f.f.,T> H= =.I. /#STEP !
7.1 Naive diacmtizotion and indltabilities
60
!get input irom t e m i W PRIaT *, R &%er tiars step and C D c a l tbs (Q t o s t o p ) ' RBAf) *,BT,TIME I F (DT .EQ. O ,) STOP MImR=TXMB/DT DTH=BT/E**2
T=O , Paxfo)=o. PHI(ISEP)=O DO 1 0 ZX=i,ISmP-1 ~~~(ax)=ai~cletrx*a~T~ I
10
30
COrnXrnE !loop aver time steps DD 20 ImR=l,IXTER !old PBX at l a s t ph* POD=O , !aaw PHI a% this p o h % DO 30 XX=l,lS4I"W-I P ~ M = P B x ( I X ) + D ~( P* ~ U + P B XCII+1)-2*PHI (IX> 1 !roll P a w valtrs P O ~ = P H(XIX) ?stars new v a n e PEX(1x1= P ~ V COVXXFIm I F (MOO(TTm,i0) Q) mEl !@=%pm% evarg SO steps P R I m *, "iteration = ,=B, t h s = #,X-*BT T=XmB*DT Da 40 ~ ~ = ~ D ~ $ ~ ~ ~ % DI~=PEL crx)-gnm(ax*a, T) PRIIT *, "hi \ PHI(XX),' emor R , DDTW
.m,
40
GOBTTXm
M D IF 20
60WIWE GOTO fiO EHIt
Typical results from this code are shown in Flgure 7.1. Things seem be working fine far a time step of 0,00015 and the results agree reasonably well with the matyticd solution, af a spreading Gau~sian,
to
111
172
7.Parablie Partial Diflemnts'al Equation8
This time step is, however, quite small compared to the natural time scate of the solution, t sc! 0.01, so that many steps are required before anything interesting happens. If we try to increase the time step, even to only 0.001, things go very wrong: an unphysicd instability develops in the numerical solution, which quickly acquires violent oscillations from one lattice point to another soon after t r= 0.02. It is easy to understmd what is happening here. Let the set of states II?\ be the eigenfunctions of the discrete operator A with eigenvdues ex. Since R is an hemitian operator, the eigenvdues are real and the eigenvectors can be &wen to be orthonormial. We can expmd the solu.tian at m y time in this basis as
The exact time evolution is given by
so that each component d the solution should evolve as
This eorrespmds to the correct bebavior of the diEusion equation, where short-wavelength components (with larger eigenvalues) disappear more rapidly as the solution 'smooths out". However, (7.5) shows that the expLidt scheme will evolve the expmsian eoeScimts a9
As long as At i s chosen to be small enough, the factor in (7.6) approximates e-mt~.L\tand the short-wavelength components damp with time. However, if the time step is too large, one or more of the quantities 1 - exAt has an absolute value larger than unity. The corresponding components of the initial solution, even if present only due to very small numerical round-off errors, are then amplified with each time step, and soon grow to dominate, To quantify this limit on At, we have same guidance in that the eigenvdues of H are known analytically in this simple madel problem. It is easily verified that the functions (+A)i
= sin
Xni 191
7,&Implicit; schemes and the inuer~irtnof trCdiagona2 matrims
Figwe 7.1 Results for the one-dimexldonal diffusion of a Grtussian; a rs 0.04 i~ used in. calculations, a) and b) result from the ex,pficit algorithm (7.5) while c) is the irnpEcit alg;orilhm (7.8).
fixed lattice sgaeing k
173
174
7. Parabolic Partial Difierential Elquatiom
are (un-normalized) eigenfunctions of H with the correct boundary conditions on a lattice of N l points far X = 1, 2, ..,,N - 1 and that the assodilLed eigenvdues are
+-
The largest eigenvalue of H is EM-I M 4hma,which corresponds to an eigenvector that; dternates in sign. from me latiee point to the next. 1- ~ ~ - ~
n
7.2 Implicit schemes and the inversion of tri-diagonal matrices One way around the instability of the explicit algorithm described above i s to retain the general farm of (7.4), but to replace the second space derivative by that of the solution at the new time. That is, (7.4) is modified to 4 4 = --(6 1 2 4n+l )i S? * h2 At This is an implieit scheme, since the unknown, +"+l, appears on both side of the equation. We can, of course, solve for #"+l as
+
1
7.1 Implicit scheme8 and the tneersisn of tri-dicganal matrices
This scheme is equivalent to (7.5) to lowest order in At. However, it is m&better in that larger time steps can be used, as the operator (1 Bat)-' has eigenvdues (1 exAt)-', all of whose moduli are less than I. for any At. All components of the solation therefore deersme with eaCh time step, as they should. Although this decrease is inaccurate (i.e., not exponential) for the most rapidly osdllating components, such cosnpsnents should not be large in the initid concllitions if the spatid discretization is accurate. In any eve&, there is no amplification, which impties stability. For the lowly varying wmpoaents of the ~olutionearresponding to s m d eigenvdues, the evolution closely approdmates the exponentid at each dim@ajtep. Note that; if m had tried to be more accurake than (7.7) and had used the average of Ghe second space defiva;tiws at the two time steps involved,
+
+
so that the time kolution is effected by
this wodd h w been h o s t as good as the implicit @&erne,because the c0mponent;s of the solution are diminished by fwtors whase absolute V ~ U E Eare S lese t b m one, A potential drawback of the implicit scheme (7.8) is that it requires the solution of a set of linear equations (albeit tri-diagonal) at each time step to find 4n+'; this is equivalent to the application of the inverse of the matrix 1 Hat to the vector appearing in brackets. Since the inverse itself is time-independent, it might be found only once at the beginning of the calculation w d then used for all times, but application s t i l l requires of order N 2 operations if done directly. Fortunately, the faflowing algorithm (Gaussian elimination and bzk-substitution, [Va62]) provides a very efficient solution (of order N operations) of a tri-diagonal system of equations such as that posed by Eq. (7.8). Let us consider trying to solve the tri-diagonal linear system of equations At$ =. b for %heunknowns $i:
+
Here, the A:" are the only non-vanishing elements of A and the bi are k n w n vasttities. This is the form of the problem posed by the evaluation
175
of (7.8) for where t$o and conditions, In pafticular ,
$N
are given by the Dirichlet boundary
To salve this system. of equat;ions, we assume that the sdution satisfies a one-term forward recursion relation of the form where the c*i and pi are coefidents to be determined. Substituting this into (7.11), we have which can solved for qSi to yield with
1
Upon comparing Eq. (7.14) with (7.12), we can identify the following backward recur~iaarefation8 far the a" and P%:
=r i ( ~ t pj bi) .
(7.166) The stratem to solve the system shodd naw be clear. We will use the recursion relations (7.15,16) in a backwards sweep of the lattice to d e t e r ~ n the e ai and pi for i running from dV - 2 down to 0. The starting vdlzes to be used are
which will guarantee the correct value oft$ at the last lattice point. Having determined these coefficients, we can then use the recursion relation (7.12) in a forward sweep from i = O to N 1 to determine the solution, with the starting value q5o known from the boundary conditions. We have then determined the solution in only two sweeps of the lattice, involvinlg of arder N withmetic operations. The foUowing code implements the algorithm (7.8) for the model diffusion problem we have been considering. Results are shown in Fig~ it is dear that accurate solutions ean be obtained with ure 7 . 1 ~where a much larger time step than can be used with the explidt scheme; the
-
7,sImplicit
scheme8 and
the inversion of Ini.diagcmal madrias
increase in numerical effort per time step is only about a factor of two. Note that the ai and -(i are independent of b, 8o that, as the inversion must be done at every time step, it is more effcient to compute these coefficients only once and store them at the beginning of the calculation (DO loop 15); only the Pi then need be computed for each inversion (DO loop 30). G chapm.rfor PmAMmEB ( I S m P = 2 5 ) DJMEgSIOB PBI(0:NSTEP)
!lattice paa-mater ?=ray for eola%ion
PrmEsraH aLpaA(o:~s~~~),~rnh(o:~smpl ,CRMNACO:~~~STEP~ tmalflical soXu%iaa
GAUS~(X,T)=~P(-~~,*[X-~~)**~/(~.+~Q*?~))/SQRT(~+~O*T)
50
EXACT(X ,T)=GAUSS (X, T)-GAUSSf X-S. ,T) -GADS$ (X+$ + ,T) EI=I.IISTEP !abt&in h p a t fzem % @ m i n a BBTm E h t e r tiS11~l s$ep d z;otal t b s ( 0 t o e-t;op)* R E 0 *,BT,TI#E
*,
XF (DT .EQ.
0.)
STOP
L)TH=BT/H*+2
T=O. PPICO)=O. PHI( I S ~ P =Q. )
10
DO l 0 XX=$,'IPSmP-I PHI(EX) =EXACT( IX*H, T) CO~I]rJU& ! i h d &FHb md t?ArnB once AP=-Dm !A coeff icien$s AZ= i,+2*am ALPBA(~VSTEP-I)=o. I s t w t i n g valuaa G ~ ~ A < H S T BI=P - i~ /AZ DO 5 = l - !backumd svsgip ALPHA( E X - % ) =GAM[MA(IX) *l@ GAMA(XX-l)=-%, / (AZ+AP*ALPEfA (EX-1) 1 CQITImE: ! t h e loop ao zo I T g R = i , g r m E BETA(EJSTEP-.I)=PHE(ESmP) !find BETA a t thisj; the
.
15
f 77
DO 25 IX=HSTW-~,X,-% Iba~kwardsweep B~~(Ix-~)=GA~~~Ix~*~AP*BETA(IIC)-PBX~XX~ 1
comxm !find new
Pfff
! a i $ i a l value ! f o m a d sweep
40
PHI(Q)=O. DO 30 IX=O,ISTEP-1 ~ar(rx+l)=~~aa(xX)*PHICfx)+Elma~XX~ 601TI8W !aa%pa% e v s q 10th time step IF fMaD(ITBR, IQ) .EQ. 0 ) THEI PBfm *, "ee~a%ion = l , I=&, t b s = 8,XTEB+I)T T=T;mR*DT DO 40 IX=%,BfSmP-I DIP=PHI (1x1-EXACT( f X*E ,I'] PRXIT *, phi = \ PPHI(IX), Qrrox = 5 DIFF CQHTIEFIJE;
Ern fH 20
GOETIMUE GOTO 50 EBB
=
Exrtrdm 7.2 Use tHe, code above to investigate the accurwy and stabady of the ixnpgcit dgorithm for various vdues of At and far vmious lattice spacings. Study the evdutim of various initid conditions and verify that they correspond to your intuition, Incorporate sourGes or ginks &ng the lat.tiee and study the solutions that arise when 4 vanishw everywhere st; t = 0,
Exercise 7.3 Modify the code above to apply the algorithm (7.10) and stn* its stability properties. Explore the eff:ects of taking digereat linear combinations of 4" and #"+l on the right-hand side of Eq. (7.9)
m
(e.g.,
$4" f
a@"+').
m Exercise 7.4
A simple way to impose the Weummn boundary can-
+
is to require that ltbl = Gfto hg. Show that this iropi_lesthat the forward recursion of (7.12) is to be started with
7.9 Diflusion and Boundary value problems in two dimensions
What is the analogms expression impfied by the more a~eur&econsGraLint 4%= #% , 2hg? mat we the initial conditions for the backward recursion of the a and p coeacicients if Neunxann boundary caditions we imposed at the right-hand edge of the lattice? Modify the code above to incorporate the boundary condition that 4 have vanishing derivative at I = 0 (as is appropriate if an insulator is present in a heat conduction problem) and observe its effect on the solutions. Show that the inversion scheme for tri-diagonal matrices discussed above cannot be applied if periodic boundary conditions are required (i.e., @N = #@).
+
Exercise 7.5
Solve the boundary &e
problem posed in Exerdse 3.4
by diseretization and iwer~ionof the resulting tri-diagonal matrix. Cornpare your solution with those obtained by the Green's f~nctionmethod and with %beandyticd resdt.
7.3 Diffusion and boundary value proble sions
in t;wa dimen-
The diseustsion above shows that diEusion. in one amension. is best handled. by an impliGit method and that the required inversion of a tri-&&&and matrix is a mlativtlly ~isnplletask. It is therefore nal;urat to attempt to extend, this approach to two or mare spatid dimensions;. For the twodimensional dilfnsion equation,
the discretization is straightforward and, following our development for the one-dimensional problem, the time evolution should be effected by
where
Unfortunately, while H is very sparse, it is not tri-diagonal, so that the algorithm that worked so well in one dimension does not apply; some thought shows that H cannot be put into a tri-diagonal form by any permutation of its rows or columns. Wmw, the fact that W em be witten as ak sum of verators that sepatttely iavolve digerences only in the %" or g' indices:
l79
X 80
7, Parvxbiolic Partial Llriflerential Epations
means that an expression equivalent to (7.17) through order At is
This c m now be eduaded exaetly, as ea& of the required inversions involves a tri-diagonal matrix. In particulw, if we define the auxiliary function 4n+1/2,we c m write
+ +
Thus, (1 ~lj&t)-'is applied by forward and badtward sweeps of the lattice in the j direction, independently for each value of i. The application of (1 Hiat)-' is then carried out by forward and backward sweeps in the i direction, independently for each value of j . This "alternatingdirection" scheme is easiiy seen to be stable for all values of the time step and is generdized straightfommdfy to three dimen~ions. The ajbility to invert a tri-&&%on&matrix exaetIy itnd the idea of treating mpwatdy each of the second derimtives of the Laplacia~dso provides a dass of iterative alternating-direction methods [Wa66] for salving the elliptic bsundmy value problems discussed in Chapter 6. The m a t ~ xi n v o l d is witten as the sum, of sewrd parts, each cont~ning second &Rerences in a d y one of the lattice indice@,h two dimensions, for example, we seek to solve [see Eq. (6.3b)j
If we add a term w 4 ta both side8 of this eqzxatios, where w is a cansbant discvssed below, the re~ultingexpression can be sdved for # in Wo dieerelrrd ways:
This pair of equations forms the basis for an iterative method of solution: they are solved in turn, 4 on the right-hand sides being taken as the previous iterate; the solution involves only the inversion of tridiagonal matrices. The optimal choice of the @accelerationparamet er". w ,depends on the matrices involved and can even be taken to vary from one iteration to the next to improve convergence. A rather complicated
analysis is required to find the optimal values [Wa@6].However, a good r d e of thumb is to t&e where cu and p are, respectively, lower md upper bounds to the eigenvdues of Ifi and Hi.In generd, these alternating direction methods are much mare efficient than the simple rdaxatioa scheme &iseu~hsedin Chitpter 6, dthough they are sfightly more: complicated to program. Wote that there is a stight campgcation when bounday conditions are also wecified in the interior of the lattice,
7.4 Iterative methods for eigenvalue proble Our analysis of the diffusion equation (7.1) shows that the net result of time wolutian is to enhance thorn components of the solution with snnder eigenvalues of E relative to those with laxger dgenvdacjs. Indwd, for very long times it is only that cornponeat Pviah the lowest eigenvdue that is sipificant, dthou& it has very snn& mplitude, This situat;ion sugests a sckeme for fin&ng the lowest eigenvdua of an el&pticaperator, a8 defined by (6.2): guess a trid eigenvector and subject it to a Gctitious time evolution that will "filtern it to the eigenvector having lowest eigenvalue. Since we are dealing with a linear problem, the relentlessly deereasing or increasing magnitude of the solution can be avoided by renormalizing mtinuoudy a63 time proceeds, To make the discussion concrete, consider the time-independent Schroedinger equation in one dimension with h = 2m = 1. The eigenvdue problem is
with the narmazation condition
(4 can always be chosen to be red if V is). The corresponding energy functiond is On general grounds, we know that E is stationary at an eigenfunction with respect to variations of C$ that respect the normalization condition and that the value of E at this eigenfunction is the associated eigenvdue.
282
7,Pambalic Parlial Diflewntial Equations
To derive a discrete approkmation to this proMem, we discretize E
and the uram&zation constrdnt t&es the farm
Varia'cion with re~pectto g5i gives the eigendue problem
pJith E entering as a Lagrange maltiplittr ensuring the no~malization, (6ompwe d t h the, derivation of the Rartrw-f"o& eq~ationsgiven in Project 111.) We can interpret (7.27) as defining the problem of finding the real eigenvdues and eigenvectors of a (large) symmetric tri- diagond matrix representing the operator B. Although direct methods for sdving this problern were discussed in Chapter 5, they cannd be applied to the very large banded matrices that arise in two- and three-dimensimd prablems* However, in such ernes, one is usadly intemted in the few Mghes;t or lowest eigenvalues of the problem, and for these the diffusion analogy is appropriate. Thus, we consider the problem.
wkem r is a 'Y&en time, For convenience, we suppose that things have been arranged so that the lowest eigenvdue of X is positive definite. (This can be guaranteed by shifting B by a spatially-independent constant chosdn so that the regultant V;; Is positive for all d.) To solve this "fake" digusion problem, any of the atgoritbms d i g cussed above can be employed. The simplest is the explicit scheme andogous to (7.5): (7.28) 4"+' (1 - HAT)^^ , where Ar is a small, positive parameter. Kere, the symbol m i s used to indicate that is to be norm&zed to unity according to (7.26). For an initial guess, we can ehoose q5O to be anything not orthogond to the exact eigenfunction, although guessing something close to the solution will speed the convergence. At eadt step in this refining process, computation of the energy from (7.25) furnishes an estimate of the true eigenvdue.
-
As an example, consider the problem where
this corresponds to a free partide in hard-walled bax of unit length. The anafytied solutions for the normatized eigenfnnctions as@ and the associated eigenvalues are Here, X is a --zero integer. The following FORTRAN progam implements the scheme (7.28) on a lattice of 21 points and calculates the energy (7.25) at every fourth iteration. The initial trial funetion q5 %(l-s) is used, which rou&fy approdmates the shape of the exaet gzound state. C ckap7c.for
%OQ
PBRAEETm (NSTW=20 f la%%i68 parneter D T ~ I S I O IPHI CO:I S ~ P ) !s c x ~ t i o ~ E= r ,/BSTEP !obtah inpa% irom screen PRIIT *, R &tar step size ( ,sq. O to stop)R BEAE) *, DT
XF (DT .EQ, Q. ) STOP DTE=BT/t3**2 !initial guess for PBX
DQ 10 IX=O,BSmP X=IX*H
arrx(xx>tx+(i , - X ) 10
COrnIrnE: CALL I Q a(PBX ,'lQSTEP]
t n o m a i z e guess !ftera%ion loop
DO 20 f TEE=%,200 POrn=O* DO 30 IX=I,ISTP-I !apply [%-E*DT) P%EV=PEZ(IX)+DTB* (POf,D+PEII (I21+1)-2*PIXI (XX) POU=PBf(IX)
)
PEILS (IX)=PHgv 30
COmXMa !caJccaa%e
hergy, Eq. (7.25)
184
7. Parobolic Partial Bifierenlial Bpations
E=E+(PHI(IX)-PE1 (IX-11)**S? 68m11fila
50
PRSIT mT)XF
* , I
itera%ion= \ ITER,
energy =
', E
SWWVTXMEZ HOW (PHI,BilSTEP) RImISIOl PHX(0:HS"X"EP) XIORM=O.
lQ .
DO 10 TX=Q ,ISTEP mOM=X;1POEH+B&XCIX)**2 COmSmE XNORB=SqRT(BTSTEP/XHORN>
DO 20 TX=O ,BSmP Pax(xx)=PEI(xx)+maw 20
COWXmE. RErnW
END
The xsufts generated by the code above for severd diEerent vdues of AT me shown. in Table: 7.1 Note that far vatues of AT ~f~l&er than the stability limit, $ hZ fi. 0.00125, the energy converges to the expected answer and dws so more rapidly for larger AT. Eowever, if AT becomes too large, the large-eigenvdue componeats of trid dgenfuactian me aplified r&her than diminished, and the eaerD obtdned finally wrresponds to the lawest eigenvdue of H , the exact fisite diEerenw value of which is [see the discussion following Eq. (7.6))
Tkis phenamenm then sugesgs h m to find the eige~valueaf:an operator with the largest absolute value: simply apply H to a trial function many times.
7.4 Itemtive methodsfor eigenvalue problems Table "11 Ganvergence a-f the lowest eigenvdue of the maare-wdl problem. The analytic rmult L 9.85960; the e x a t finile-difference vdue is 9,84933.
Although the procedure outlined above works, it is unsatisfactory in that the Braitation on the size af AT caused by the laLtice spacing often result;s in having to iterate many times $a refine a, poor trid function. This can be alleviated to some extent by choosing a good trial function. Even better is to use an implicit scheme [such as (7.8)] that does not amplify the large-eigenvalrue eamponents for my value of AT, Another possibility is to use exp(- HAT) to refine the trial function. While exact c d d a t i o n of this nrzltrix can. be diseult if large dimensionrs me imvdved, it can be wea-=presented by its series expmsion tbrougb a finite nunrber of terms. This series is e a y to evduaLe since it involves only applying _IS many times ta a trial ~ t a t eand generay a larger AT can be used than if only the first order approximation to the exponential, (7.281, is employed. We have shown sa far how the method we have discussed c m be used to fiad the lsvvest or highest eiigenvdue of m operator or matrix. To see hovv to find other eigenvdues and their assacirtLed eigeduaclions, consider the problem oT finding the second-lawest eigeavdue. We fir& find the lowest eigenvdue and eigenfunction by the method described above. A t r j d function for the ~econdeigenfunctim is then guesged and refined in tbe s m e way, tikking care, however, that at each s t q e of the refinemeat the solution rem&n orthogonalI;a the lowest dgextfunctian already faund.
185
This can be done by continuously projecting out that component of the solution not orthogond to the lowest eigenfunction. (This projection is not required when there is some symmetry, such as reflection symmetry, that distinguishes the two lowest solutions and that i s preserved by the refinement algorithm.) Having found, in this way, the second-lowest eigenfunction, the third lowest can be found similarly, taking care that during its refinement, it remains orthogond to both of the eigenfunctions with lower c?igenvdues. This process cannot be applied to find more than the few lowest (or highest) eigenvectors, however, as numerical round-off errors in the orthogonalizations to the many previously-found eigenvectors soon g o w to diodnate, Although the methods described h o v e have been iuustrated by a one-dimensional example, it should be dear that they caa be appIied directly to find the eigenvdues and eigenfunctions of elliptic operators in two or more dimensions, for example via Eq. (7.19). r Exercise 7,8 Extend the code giwn &mto find the eigenfunctiaas
and eigenvdues af the fifst t-wo exeited sta"ces of each parit;y in the onedimensional square-well. Compare your results with the: exwt solutions and with the analytic4 finite-difference vdues. Exercise 7.7 Write a program (or modify that given above) to find the few lowest and few highest eigenvdues and eigenfunctions of the Laplacian. operator in a two-dimension& region consisting af a s q u m with a square hole cut out of its center. Investigate how your results vary as functions of the hiize of the hole,
7.5 The time-dependent Schroedinger equation The nummical treatment of the tinte-depe~dentSchroedinger equation for a particle moving in one dimension provides a good illustration of the power of the techniques discussed above and some striking examples of the operation of quantum mechanics [Go67]. We consider the problem of findjng the evolution of the (complex) wave function 4 under Eq. (7.2), given its value at some initial time. After spatial discretization in the usual way, we have the parabolic problem
where H is the operator defined in (7.27) and we have put h. = 1. To discretize the time evolution, we have the possibility of employing the analogue of any of the three methods discussed above for the digusion equation. The explicit method related to (7.5), in which the evolution
7.5 The time-dependent Sehrdinger eqzscgtio~z 187 is effected by (1 - iHAt), is unstable for any value of At because the eigendues of this ape~ator,
have moduli (1
+ e:&t2)2/2
greater than unity. The implicit scheme analogous to (7.8), in contrast, is stable far all At, as the moduli of the eigenvdues of the evolution operator, (1 E I A ~ ~ ) - 9' / ~
+
are always less than one. This is still unsatisfactory, though, as the numerical evolution then does not have the important uaitarity property of the exact; evolution; the norm of the wave function contimally decreases with time. Fortunately, the a n d w e of (7.10) turns out to be very suitable. It is
This evolution operator is manifestly unitary (recd that B is hemi tian) with eigenvdues of unit modulus, so that the norm of 4 cornpaged according to (7.26) is the same from one time to the next. (Of course, the square of the real wave function in (7.26) is to be replaced by the modulus squared of the complex wave function.) The algorithm (7.30) also has the desirable feature that it approximates the exact exponential evolution operator, exp(- i H At), through second order in At, which i s one more pQWeF than would h~ been supposed For wtud numeric& computation, it is efficient to rewrite (7.30) as
This form eliminates the sweep of the lattice required to apply the numerator of (7.30). To find, at each time step, the intermediate function X defined by (1
+ i5l HAt)x = 2Q
we write this equation expficitly as
,
3.88
7,Parabolic ParEt"nlDifferential Equations
which, upon dividing by -i&t/2hz becomes
This has the form of (7.11), and can therefore be aolved by the twc~sweep method discussed in. connection with that equation, The FORIICRAN program for Exmple 7, whose sour= code is contained in Appendix Ef and in the file EXMPL7,FQR, nses the method described above to solve the time-dependent Schroedinger equation, Severd analytical forms of the potential (square well or banier, Gaussian well or barrier, potential step, or parabolic well) can be defined on a point lattice whose size is set by the pasameter BPTS. An initial Gaussian or Lormtzim wavepacket of specified average position, average momentum, and spatial width can {;hen be set up on the lattice and evolved under the boundasy condition that d, v d s h at the lattice boundaries. The probability density, l+lz,and potentid are displayed at the requested frequency, while the total prohabillties and average positions of those portions of the wavepacket to the left and right of a specified point are displayed at every time step. The time evolution is continued until the user requests termination of the program * The following exercises will be useful in improving your understanding of' this example. Exercise 7.8 Test the accuracy of the integration by integrating forward for some time interval, changing the sign of the time step, and then continuing the integration for an equal time i n t e d to see if you return to the initial wavepwke. Note that the mergy edctllated in subrcrutine E~EBcYis conserved independent of the time step. Verify that this should be so using Eq. 7.30.
m
Exereise 7.9 Verify that wavepackets in the absence of any potential and wavepackets in a parabolic potential well behave as you expect them to. Exercise 7.10 Send wavepackets of varying widths and incident energies at barriers and wells of various sizes and shapes. Interpret all features that you observe during the time evolution. For square-well and step potentials, compare the fractions of the initid probability transmitted and reflected with the analytic$ values of the usual transmission and refiection coefidents. Set up a resonance situation by considering scattering from potential8 wit6 a "pocket" in them and observe the separation of the initial wavepacket into prompt and delayed components. Set up a "double-well" tunneling situation and observe the evolution. m
Exercise 7.11 Replace the evolution algorithm (7.30) by the unstable explicit method or the non-unitary implicit method and observe the eEects.
m
Replace the vanishing Diridlet boundary condition iibt one lattice end by s zero-derivstivr! Neuxnann botxndary ca~ditiomaxld observe what happens when a wavepadet approaches.
a
Exercise 7.12
In two- m d thr~dimensiondcdculatioas, the l a g e number of lattice points forces the use of as lwge a lattice spacing as is possible, so that higher-order approximations to the spatial derivative become necessary [F178]. Replace the 'three-pointn formula for the spatial second derivative by the more accurate afive-point" one listed in Table 1.2. Dwdop an algorithm, to invefi the pentacdiqmaf matrix indved in the time evolution. Itrapfern& this in the code aad observe any &ages in the results or the computationd cadency.
r Exereri~e7.13
Project VII: Sel&organization in chemical reactions Recent work in several branGhes of physic~h= shown that the solutions of nm-linear equations can display a rich mriety of phenomena. Among these i~ "patdesn selectionn,in which stabb, non-trivid patterns in space and/or time emerge spontaneously from structureless initial conditions. In this project, we win invwtigate axlafyticdly and name~cdlya model of chenaied rextions, the "Bmsalator", whose solutions exhibi.t;behavior thal, is very s i d a r to the striking phenomena, observed in actud chernied systems [Wi74]. Our discussion fdlows that of [Ni77] and [Bo76].
VII.1 Description of the model We consider a network of chemical reactions in which reagent species A and B are converted into product spedes D and E through intermediates X md Y :
(Vll.la) ( V l l .lb ) ( V l l .le) ( V l l .l d ) We assume that the concentrations of A and B are fixed and are spatidy uniform and that the species D and E are 'dead" in the sense of being chernicdly inert or being removed from the reaction volume. We adso assume that the processes (VII.la-d) are sufficiently exoergic to make
190
7.Parabodic Partial Bigerential Equations
$he reverse reactions negEgibft3. Under these conditions, we can mite the foflowing equations for the evdution of the conwntratims of X and Y :
Here, kn-d are the rate constants for the reactions (VII.la-d), respectively, and Dxtu are the diffusion constants of the species X,Y. It is convenient to scale the non-linear diffusion equations (VII3) to a dimensionless form. If we measure time in units of k;', space in units of l , a &asacteristic size of the reaction vsfume, X asld Y in uaies of (kd/k,)fr A in units of (k$/kEk,)i, B in units of kd/kb, and DXPYin units of kd12,then Eqs. (VII.2) become
s it is clear that the caastmdh; A and B can be of order horn t ~ seang, unity, although D X t y might be considerably smaller, depending upon the vdue of I. One trivial golutian ta these equations can be fauad by assudng that X and Y are independent of space and time, Setting all derivatiws .to zero yields a set of dgebraic eguatians that can be aofved for the equilibrium point. After a bit of algebra, we find that equiifibrium fs at
To completely specify the model, we must give the spatial boundary condiLions. Of the various passible ehoices, t w we of parlicular pbJrsid interest. Il"bese are the 'no-flux" boundaq conditions, in whi& the nosmajl derivatives d X and V are reqdred to vmish sn the surface of the reaction volume (as might the case if the chemistry takes plwe in a closed vessel) and the "fixed" boundary conditions, where X and Y are required to have their equilibrium vdues on the surface of the reaction volume.
VII.2 Linear stability analysis To get some insight into the behavior of this system before beginning to compute, it is useful to andyze the behavior of smdl perturbations about the equilibrium stiitte. To do so, W pnt
where F represents the spatial variables and &X,6Y are small quantities dependent upon space and time. Inserting this into (VII.3) and linearizing in the g r n a qnantities, we have
We now speci&ze to the no-flux boundary condition in one dimension. We can then expand SX as Q0
bX(r,t ) =
X
G x , ~ ~ ~cos ' mzr
,
(V11.6)
m=@
and similwly for SY, Were, Q r 2 1 is the spatid camdinate and the w, indicate the stability of eea& n o m d mode, fn particdw, Re w, < O indicates a stable made thzbt damps in time, w&le Re c ~ >. , O inrficalles an unstable perturbatioa that grows; a complex o, indicates a mode that afso oscillates as it grours or damps. For the fixed boundary conditions, the expansion analogous to (VII.6) involves sin mrrr rather than cos mrr. Upon introducing %he Faurier expmsion into the lioearjzed equations (VII.5a,b) aad equating the coefficients of each spatial mode, we obtda the fanowing hamageneous eigendue equations:
Xt is easy to see that these hold for both ltypes of boundary conditions and that the eigenvdues then saeisfy the characteristic equ;ktion
with
292
7, PamboZie Partid Diflerentiot Equations
Figure VX1.Z Stabgity of the u ~ f a r mequilib~umst9;te with rapect to osaatory beha~ar,The m = 0 mode is isbent for fixed boundary conditions, (Ram [%i77f.)
(We have here written X. md l$ explicitly in terms of A and B). The roots of this equation are
Z = ,{a,
- pm f [(a, +
-4 ~ ~ ~ 1 ~ ' ' ) *
A detailed ana?ysis of Eqs. (VII.S,10) reveals several interesting aspe&s about the &ability of the aniform eqvllibrium state. It is ewy to see that if m becomes large for fixed values of A, B, and D X y, , then the w$ become very negative; modes wit h large wavenumbers are therefore stable. Let us now imagine that A and Dxev are fixed and B is allowed to vary. Then, since there we complex roots only if the discriminant in (VII.10) is negative, we can conclude that there will be oscillating modes only if
Since we must have A, > Q, this implies that there are oscillations only
t
I
t
1
I
I Stable
StabiXity of the uniform. eqrrilibrium state with respect ta exponentiay grourine, pertuxbati~ns(From [Ni77].)
Figme lr61.2
Furthermore, if there is a complex dgexvdue, its real part will be pasitiive (an unstable mode) only if
The situation is sururmsized in. Figure TJ1f.l. Modes with red, paitive frequeades are preseat only if ampntA ~ B 1 0, which implies that
If W imagine m to be a continuous variable, then it is easy to see that B,, h= a minimum vdue of
O f course, siftce tbe physied vdues of m are restricted ta integers, as B is increased from 0, the non-oscillzjttory mode m, that first becomes
I94
7.ParaBolic Partial Diflerendial E w a l i ~ n s
unstabfe at B --- B, is that wWhjch i~ c l o ~ e to ~ tthe minimum, as s h o w in Figure VXI.2, To summafiee thia discussion?the uniform eq~libriumstate is unstable with respect to perturbations that osdllate in time when B > B. or B1for no-Bux and fixed boundary conditions, respectively. Similarly, it is nastit,bIe with respect to perhrbalions %hadgrow exponeatidy in time when B > B,,
'VI1E.3 Numerical solution o f the model Although the stability analysis presented above gives some hint at the behavior of the system for various ranges of the pxameters, the h X lridness of the model in the non-linear regime can be revealed only by numerical experiments. These can be carried out through the fallowing steps. Step 1 V e ~ f ythe dgebra in the stability andysis discacased above, Assame a fixed. value of A = 3: in a ane-dimension& situatiamr,and cdcdate the h, and B, for a set of values of the diffusion constants of order 1 0 ~ ~ . How do your results change if the reaction t&es place in the unit square in two space dimensions?
m
m i t e a progam that solves the non-linear digusion equations (VII.3a,b) in one dimension on the interval [0,1] for the case of no-fittx boundary conditions; a rewonable number of spatid points might be between 25 m d 100. The diRasion t e r m shodcl be treated. irnpEcitly to preved unphysicd numericat inst&ili-ties, mrhile the reaction terms can be tre&ed exp2icitly. ZIave your progrm plot out X and V at each time step.
r tet~p2
Step 3 Use your one-dinze~siondproerram to investigate the behavior of the solutions for different values of B, DX*y.A reasonable place to start might be Dx = 1 x I O - ~D, y = 4 X l@-$; the linear stability analysis should then give some guidance as to what values of B are interesting. Investigate initial conditions corresponding to smooth sinusoidal and point-wise random perturbations of the uniform equilibrium configuration (the latter can be generated with the help of function RANR~S, found at the end of Appendix D.3, or your compiler's intrinsic random number generator). Verify that you can find cases in which the system refmes back to the u n i h m state, in whieh it a m p t o t i c d l y a~>proa&es a time-independent solution with a non-trivial spatial variation (dissipative structure), and in which it approaches a space- and time-dependent oscillating solution. Throughout, make sure that your time step is small enough to allow an accurate integration of the equations.
m
Vile Se~-c3rganixationin chemical reactions
Extend your one-dimensionat. mde la szolve the Brusselator with no-flux boundary conditions in two spxe dimensions using, for example, an alternating-direction algorithm like Eq. (7.19). Plot your results for X at each time. (The technique of displaying an array of characters, as in Example 6, can be useful.) Investigate parameter ranges and initial candiltions as in Step 3. Step 4
195
This page intentionally left blank
Chapter 8
Monte C Methods Systems with a large number of degrees of freedom are often of interest in physics. Among these are the many atoms in a chunk of condensed matter, the many electrons in an atom, or the infinitely many values of a quantum field at all points in a region of space-time. The description of such systems often involves (or can be reduced to) the evaluation of integrals of very high dimension. For example, the classical partition interacting through function for a gas of A atoms at a temperature l/@ a pair-wise potential v is proportional to the 3A-dimensional integral
The straightforward evafzration of an i n t a g d like this by one of the quadr&ure formulas discussed in Chapters 1 or 4 is conrpletely out sf the question except for the very smdest values of A. To see why, suppose that the quadraturn allows ea& coordin&e to take on 10 digerent vdues (not a very fine discretization), so that the integrand must be evaluated at points. For a modest value of A = 20 and a very fast computer capable of some 107 evaluations per second, this would take some 2 . 0 ~ ~ seconds, more than 1oa4 times the age of the universe! Of course, tricks like exploiting the permutation symmetry of the inteffrand can re-duce this estimate considerably, but it still should be dear that direct quadra1;ure is hopeless, The Monte Carlo methods discussed in "this chapter we ways of efficierttty evaiuading integrds of Egh dimension. The name &MonteCarlo" arises f"rom the random or U&mce" chwacter of the method and the f a o u s casino in Monaco. The essentid idea, is not ta evaluate the integrand at every one of a large number of quadrature points, but rather
198
8,Monte Carlo Method8
at only a representative random sampling of abscissm. This is and~goua to predicting the resalts of an election on the basis of a poll of a smdl number of voters. Although it is by no means obvious that aoything sensible can come out of random numbers in a computer, the Monte 6x10 strateg turns out to be very appropriate fof a brad dass of: problems in statisticd a d quantum mechanics, Mare d e t ~ l e dpreseat;ttions of the method than that given here can be found in [Ha641 and [Ka85].
8.1 The basic Monte Carlo strategy Even though the reai pawer of Monte Caflo methods is in evduating multi-dimensional intepds, it is easiest to illustrate the basic ideas in a one-dimensional siluation. Suppose that; we have to evduate the iatepal
for s m e padicular function f . Chrtpters 1 and 4 discussed several &E &rent qudratare formulw that employied vdues of f at very particular values of 2. (e.g., equally spaced). However, an alternative way of evaluating I is to think about it as the average o f f over the interval [Q, l]. In this bight, a plau~liblequadrature formula is
Heref the werage of f is evaluated by consideriag its values at N abscissae, {si),chosen at random with equal probabitity anywhere within the interval [0,1]. We discuss below methods for generating such "randomn numbers, but for now it is sufident to suppose th& there is a computer function that provides as anmy of them as are required? one after the other, Note thia't these is n s such FOETRAN-"7 function, but many compilers provide their own (e.g., RAN in VAX FORTRAN) and we provide function RANNOS (found in the file UTIL.FOR and listed at the end of Appendiv D.3). To estimate the uncertainty agsoeiated with this quitdrature fornufa, we can consider fi ziii f ( z i ) as, a random variable and invoke the central limit theorem for large N. From the usud laws of statistics, we have
where o; is the variance in f ; i.e., a measure of the extent to which f deviates from its average value aver the region af integration,
8.1 The basic Monte Carlo s t r a t ~ g
Equation (8.3) reveals two very important aspects of Monte Carlo qudratun;. Rrst, the uncertainty in the estimate of the integd, 01, decreases as Hence, if more points are used, we will get a more precise ansarer, although the error decreases very slovvly with the number of points (a factor of four more numericd work is required to halve the uncertainty in the answer). This is to be contrasted with a method like the trapezoidal rule, where Eqs. (1.8,1.9) show that the error scales like N m 2 , which affords a much greater accuracy for a given amount of numerical work. (T6is advantage vanishes in multi-dimensional cases, as we discuss below.) The second important point to realize from (8.3) i s that the precision is greater if of i s smaller; that is, if f is as smooth as possible. One Irimit o f t E s i s when. f i~ is aconstant, in which cwe we need its vdue at only me point to define its aver%@. T"a see the other limit, consider a situation in whi& f i s zero except for a very narrow peak about gome vdue of 2, If the 86 have an equd probabiliv to lie anywhere between 0 and 1, it is probable that a;U but a few of them will lie outslide the peak of f , and that only these few of the fi will be non-zero; this will lead to a poorly defined estimate of I. As an example of a Monte Carlo evaluation of an integral, consider
The following FORTRAN program calculates this integral for the value of N input, together with an estimate of the precision of the quadrature. G cbp8a.lBor XITEGER S m DATA SEm198765432g/ DATA E;ZIACT/, 78640/ NgG(X)=CEI./(1 .+X*+2) C
10
!seed 203:
amber generator
!aaPytic aawer t fmct;ioar t o int e p a t e
PRTBfT *, "%er nmber of posts (Q to stop) B REAII) *, M XP (I .EQ, 0) STOP
C SUW=O.
!zero s w s
5VW2=01
DO 20 IX=Z,lil
!loop over s w l e s
F X = W C (EkBI(SEm))
SGW=SMF+FX
!&d con$ribations to s m s
199
200
8. Monte Carlo Me&
Table 8.1 Monte Carlo evaluation of the integral (8.4) using two digerent wei&t functions, ~ ( 8 ) .The exact vdue i s 0.78540.
Results of running this program fur various values of N are given in the first t h ~ e ecolumns of Table 8.1, The cdculated result, is eqnd to the exact value within a few (usually less than one) standard deviations and the quadratare becomes more predse as N increases. Since Eq. (8.3) shows that the uncertainty in a Monte Carlo quadratare is proportional to the variance of the integrand, it is easy to devise a general scheme fur reducing the variance and improving the efficiency of the method. Let us imagine multiplying and dividing the integrand by a positive weight function w(z), normalized so that
8.1 The bosic Monte Carlo utmb-egy
The integral can then be written as
If we now make a Change of variable from z to
then the integral becomes
The Monte Catlo eduation of this integral proceeds as above, namely ayeraging the values of f /w at a random sampling of points uniformly distributed in y over the interval [0,1]:
The potentiat benefit of the change of &able should now be clw. If we choose a m that behaves approurimately as f does (i-e., it is lage where f is large md small where f is small), then the integrand in (8.7), f /w, can be made very mooth, with a consequent reduction in the variance of the Monte Carlo estimate (8.8). This benefit is, of coarse, contingent upon being able to find an appropriate w and upon being able to invert the relation (8.6) to obtain z(y). A more general way of understanding why a change of variable is potentially useful is to realize that the nnifonn distribution of points in y implies that the distribution of points in x is d y l d x = w(s). This means that points are concentrated about the most "importantn values of x where w (and hopefully f ) is large, and that little computing power is spent on calculating the integrand for "unimportantn values of s where PD and f are small. As an example of how a change of variable can improve the efficiency of Monte Carlo quadrature, we consider again the integral (8.4). A good choice for a weight function is
201
202
8-Monte Carto Mei;ho&
which is positive definite, decreases monotonicdly over the range of integration (as does f), and is normalized correctly. Moreover, since f l w = 314 at both s == O and a: =I I, W well appraimat;es the behavior of f . According to (8.6), the new integration variable i s
WE&can be inverted to &ve
The following FORTRAN code then evaluates I according to (8.8). G ch@b. for IETEGER S W DATA Sm18878543221
!seed f a r radom &-&er
gaerator
78640/ !=aytic vazua !imctfon to i n t e ~ a t s mMC(X)==:./(i,+X**2) WEZGBT(X)= (4, -2+X)13, !neigh%f a c t fon !X as a imcdion of P XX
DATA =ACT/.
C $0
PRIIT
*,
mm
+, l4
P
&tax
nwber of p o h t s ( 0 t a srop)
IF' (R *EQ*01 STOP C
SUm=o. s~m2=0. DO 20 III=I,B Y=RAE(SEa)
?~eZ?a SW8
!Isop ovax smp2ss
x=xx (Y) F X = F ~(X) C /%IEILGET(X) ? i ~ r e g ~ ~ d SWW=SWF+m !adcl contritnrtions ts s m 2=mW2+FX*+2 COlJTfl U E FAVE=SW/I ? averages F21VE=SUMF2/1 SXGMA=S~RTC(F~AVE-FAVE**~]/I) !emox
28
PRXsfT
+
8
*,
i n t ~ e a f=PrFAVEr8 +- ',SLGldhr)
GOTO 10
EHD
ttrrof
"EXACT-FAVE
8.1 Tbe Zta&t"cMonte Carlo stmlegg
Results of running this code for various values of N are shown in the last twa colurns of Table: 8.1, where the improvement over the zo = 5, case
treated previously is evident, The one-dimensional discussion above can be readily generazed to d-dimensional integrals of the form I = j d d z f (X). The analog of (8.2) is
with the severat components of the random points xi to be dosea independenlf y, Thus, the following FORTRAN proe;~amcdedat;es
that is, it eolnpares the area of a quadrant of the unit eirde to that of the unit square (B is the unit step function): C c;hp8c*fox
XmEGm
!seter& fox r d o n nmber gsnera%or
SED
DATA SEm/3274927/
.
EXbm=4.*ATAP 1 ) C
20
!pi
PRIHT *, heer srubsr af p h % s(0 %a atop)" RErn *, P IF (H .EQ. 0) STOP
C
!zero comt $loop over santplsa
IGQWT=O DQ 20 XX=1,B X=MlCSErn) U=MlaT($Em>
10
.
SF ( (X**2+V**2) LE 1. ) XCOWT=ICOVET+ 1 COITXrnB v r a = m ~ ( z c o v ~ ~ ) / ~ ?pa/?r SICM=SQRTCPI4*(1, .-PZrlr)/I] f emor faRXlT *, e B pi = 4*PX4,"p",4+S3C;MiA,hrxar = ',EXACT-WPI4 GOTO 20 EEL)
When run, this program generatc3d the satisfactory result of 3.14241= 0.0232.
203
Exercise 8.1 verify that the error estimate used (two Enes &er line 10) of this program is that given by Eq. (8.3).
U
The & a g e of vwiable discusmd above can dso be generdized $0 many dimensions. For a weight function w(x) normalized so that its integrd over the re@on of integration is unit& the approp~atenew mriable of integration is y, where the Jacobian is = w(x). It is generally very difficult (if not impossible) to construct x ( y ) explicitly, so that it is more convenient to think about the &an@ of variable in the multi-dimensiond c a e in the Ben- discussed above; i.e., it distributes the points xi(yi) with distribution W. Various practical methods for doing this fof a r b i t s q w will be discussed below, Although the results were satisfactory in the examples given above, Monte Carlo quadmure does not wpear to be pasticulaly efficient, Even with the "pod" choice of W ,the rc3sdts in Table 8.1 show a precision of only about 10-' for N = 5000, whereas the conventional trapezoidal formula with 5000 points is accurate to better than 1 0 ~ However, ~ . consider evaluating a multi-dimensional integral sueh as (8.1). Suppose that we are willing to invest a given amount of numerical work (say to evaluate the integrand N times), and wish to compare the effieiencies of conventiond arid Monte Carlo quadratuma. In a conventioaiaf quadrature, say a mdti-dimension4 analog of the trapezoid4 rub, if $here are a totd af IV points, then e x h dimeadon of a d-dimensiand intern& is braken up . analog of (1.9) shows into ~ ' intervds 1 ~ of spwing h N - I ~ ~ The that the emor in the integral over eaeh cell of volume hd in the integration region is o(hd+l),so that the total error in the conventional quadrature i s for large d, this decreases very slowly with increasing N. On the other hand, Eq. (8.3) above shows that the uncertainty of a Monte Carlo quadratare decreases as N - ' / ~ ,independent of d. Assuming that the prefactors in these estimates we dl of order unity; we see that Monte Cwlo quadratare is more eficient when d 2 4. Of course, this estimate depends ia detail upon the conventional quadrature scheme we use or how good a weight function is used in the Monte Carlo scheme, but the basic point is the very different way in which the two errors scale with increasing N for large d
8 3 Generating rcrtlciom variables wi& a $pi$~iecl dzstr-s"bul;iots 205
8.2 Generating random variables with a specified distribution
The discussion above shows that Monte Cm10 qndratnre involw two basic operations: generating abscissm randomly distributed over the integration volume with a specified distribution w(x) (which may perhaps be unity) and then evdaating the function f l w at these abscissae. The second operation is straightforward, but it is not obvious how to generate "random" numbers on a deterministic computer. In this section, we will coyer a few of the stmd;asd method8 umd. The generation of uniformly distributed random numbers is the computer operation that underlies any treatment of a more complicated distribution. There we numerous methods for pedoming tkis bwic task and for cheching that the results do indeed correspond to the uniform random numbers required. One of the most common algorithms, and in fact that used in the VIAX FORTMM RAN function, is a '"near cmgruential" method, which "grows" a whole sequence of random numbers fram a, nsr?ed" n u b e r . The cunent member of the sequertee is rauftiplied by a first "magic" number, incremented by a second magic number, and then the sum is t&en moduk, a third magic number. Thus,
where i is the mquerrce label and, a , c, and m are the magic numbers, The littder me often very h g e , with their precise values depending upan the word length of the c-ornputer being used. Note tha%the zi cmnot be truly "random" W they aise from the swd in a well-defined, deterministic algorithm; indeed, two sequences g r w n from the the s m e seed are identical. Fbr this remoa, they are often termed "'pseudo-random", Nevertheless, for m a y practicd purposes pseudo-random numbers generated in this way can be used as if they were truly random. A good discussion of uniform random number generators and of the tests that can be applied to determine if they are working properly can be found in [Kn69]. We have dready seen how to choose one-dimensional random variables distributed as a specified weight function W(%). According to the discussion in the previotxs section, the procedure is to choose y, the ineomplete iaf;egra-l of W , u n i h d y , and then to find z by inwrting Eq, (8.6). Thus, if we are faced with evduating the integrat
with g a relatively smooth function, it is sensible to generate z between 0 and oo with distribution and then to average g over these d u e s . According to (8.5), we have
The followi~~g FORTRAN subroutine generates values of X with the required distribution, c chap8d.for
suBRawrm WCDST(X) XBTEGm S E D
DATA SEm C
/88341927/
.
X=-LOG ( I-UIEI(SEm) )
REmm EID
Excsreim 8.2 Verjfy that the code above generatea X with the reqlrired distribution, for example by generating aad h i s t o g r m ~ n ga large number of vdues of X. Use these v d u e ~to evitluii;te 1 and its uncertainty for 9(2) = 5, zZ,md z3 and compare your results with the analytical vdueg. Can you understand the trend in the uncertainties cdcdaled?
m
WMe the method of generating the incaqlete integral is infdfible, it requires that we be able to find + ( g ) , which can be done analytically only far it relilrtively s m d class of functions. For example, if we had wmted to US@
in our efforts to evaluate Eq. (8.4), we would have been faced with solving a cubic equation to find g(%). While this is certainly possible, choices of w that might follow more closely the behavior of f generally will lead to more complicated integrals that cannot be inverted analytically. However, it is possible to do the integral and inversion numerically. Let us imagine tabulating the values for which the incomplete integral of w takes on a series of uniformly spaced values y(j)zz j / M , j = 0, 1,... ,M that span the interval [Q,l]. Thus,
8.2 aneratin@r a n d ~ mvariables with a specified distribution
Figwe 8,1 fllmtration of the von Nemmann rejection method fox generating raindom numbers distributed =carding to a gven di~triba$ion w(a;).
...
Values of z(j) with j an integer chosen from the set 0, 1, ,M with equd probability will then approximate the required distribution. (Some special treatment is required ta handle the end-point6 g' = 0 and j = M properly.) To generate the d , is, of course, the problem. This can be done by integrating the differential equation dyldz = w(z) through the simple discret;ization,
Since
-
= 1/M, we have the convenient recursion relation
which can be used with the starting vdue I(@)= 0. Another convenient method for generating one- (or hulti-) dimensional random variables i s von Neurnann rejection, whose geometrical basis ia illustrated in Figure 8.1. Suppose we are interested in generading a: between O and 1 with distribution W(%) and let cul(z) be a positive function such that W'($) > W ( $ ) over the region of integration. Note that this
307
means that the definite integral of W' is greater than 1. A convenient, but not always useful, choice for w f is any constant greater than the maximum value of W in the region of integration. If we generate points in two dimensions that uniformly fill the area under the curve W'(%) and then "accept" for use only those points that are under zu(z), then the accepted points will be distributed according to W. Practically, what is done is to chohse two random variables, gi and q, the former distributed proportional to W' and the latter distributed uniformly between O and 1. The value zi is then wcepted if q is less than the ratio w ( z i ) / w f ( s i )if; a point is rejected, we simply go on and generate another pair of and ? , I . This technique is dearly @%dentonly if zuf is close to W throughout the entire range of integration; otherwise, much time is wasted rejecting useless points. Exercise 8.3 Use von Neumann rejection to sample points in the and evaluate the inteinterval [Q,l] distributed as w ( z ) = $(l- !p2) gral (8.4) and its uncert$nty with these points. Compare the efficiency af your cdculation far vmious choices af W'.
The Gaussian (or normal) distribution with zero mean and unit variance, w(g) = (2r)-'/2e-"'/2 , plays a central role in proobablliity thwry and so is often needed in Monte Carlo cdcdatims* It, is possible, but not too efficient, to generate this distribution by inverling its incomplete integrd using pofynonaial approximations to the emor function, A more ""clever" method is based an the central L i ~ theorem, t which states th& the sum of a large number oE uniformly distributed r a d m numbers will appraach a Garnssian distribution. Since the mem and varianm of the unifom distribution on the disinterval [0,1] are 1/2 and 1/12, respectively, the sum of 12 unifo* tributed numbers will have a mean value of 6 and a v%sianee of 1 and will very dosely approximate a Gaussian distribution. Hence, the following FORTRAN subroutine returns a Gaussian random variable, GAUSS, with zero mean md unit w i w c e : C chafle, %or G apubrowt;ine to gsllnsraeer the n o m a l y distrih%ed amber GAUSS SUBBQWIEBIIIST(GAUSS1
xaJmem s m DATA SEEf)/39249287/
c
8.8 Generating mndom variable&with a specified distribution
Exercise 8.4 By histagramming a large number of the values of GAUSS produced by the subroutine above, convince yourself that their distribution is very close to normat. Can you derive a quantitative esti-
m
mate of the extent to which this di~txibutiandeviates from a Gaussian? Compare with the results of summing 6 or 24 uniformly distributed random numbers. (Note that these latter sums have means of 3 and 12 and varimces of and 2, respectively.)
4
Another efficient method for @witting normally distributed vmiables is to consider a Gaussian distribution in two dimensions (gI, zz), for which the number of points in a diRerentiail area is pmportional to Zn. terns of the usual polar coordinates
the distribution is
e - * P ~ dr d@,
or, if u = ) r a y the distribution is Hence, if we generate u between 0 and m with an exponential distribution and B uniformly between O and 2 1 then ~ ~ the corresponding values of 21
= (2u)'i2 COS B , 1 2 = ( 2 ~ ) ' /gin ~ B
will be distributed normally. Thus, the following FORTRAN subroutine returns two normdy distributed random variables, GAUSS1 m d GAUSS2:
209
Monte Carlo Methda
210
DATA 53B/39249181/ ~~13.24159261
C
TWoU=-2.*LoG(i.-R4E(SEED)> RADIUS=SQBT(T~~~OUI
TWETA=2*PX*RAI(SEEf)) GAUSSI=RADIUS*CflS (T13:ETA)
GAUSS2=RUXUS*SIl(mETA) RETUM
END
To generate a Gaussian distribution with mem 3 and variance c2,
we need only take the vdues pnerated by this subroutine, mdtiply them by a,and then increment them by g.
8.3 The algorithm of Metropolis et al. Prltbugh the methods we have discussed above for generating rmdom numbers according to a specified distribution can be very efficient, it is cliEcdt ar impossiMe to generalize them to s m p l e a complicated weight function in many dimeagions, and so can &ernative approach is required. One vary generd way to produce random vasiables tvith a given probability distribution of arbitrary form is known as the Metsopofis, Rosenbluth, Rosenbluth, Teller, and Teller algorithm [Me53]. As it requires only the ability to calculate!the weight function for a givcln vdue of the integration vwiablest the allgorithm has been appliecl widely in statisticall rnechanies problems, where the weight &netion of the eanoaicd ensemble can be a very complicated function of the coordinates of the system [see Eq. (8.l)] and sa carrot be sampled conveniently by ather methods, Howevm, it is not without its drawbacks, Although the dgorithm of Metrc)pOXi~et laE, can be ixapiemen~edin a variety d ways, we begin by describing one simple realization. Suppose that we want to generate a set of points in a (possibly multi-dimensional) space of variables X distributed with probability density w(X). The Metropolis algorithm generates a sequence of points, X@,XI,. .. , as those visited successivefy by a randam w&er moving through X space; as the wdk become8 longer asld longer, the points it connects a p p r o ~ m a t e more closerly the desired Bistribution. The rules by whieh the randam wdk proceeds through canfiguratlm space are as follows. Suppose that the wdker i s at a pojnt X, in the
8.8 The algorithm of Metropofs'set d.
sequence. This new uniform about X,. the ratio
To $emrate X,+1, it makes a trial step to a new paint X,. point caa be chosen in any convenient manner, for example at random within a multi-dimensional cube of small side 6 This triaf step is then "aecepted" or @reJlectednaccording to
If r is larger than one, then the step is aecepted (i.e., we put X,+1 = Xt), while if r is less than ane, the step is wcegted with probability r . This latter is conveniently accomplished by comparing r with a random number q uniformly distributed in the interval [0,1] and accepting the step if q < r If the trial step is not accepted, then it is rejected, and we put X,+x = X,. This generates X,+x, and we may then proceed to generate Xnf by the same process, making a trial step from X,+1. Any arbitrary point, Xo, can be used as the starting point for the random walk. The following 8ubrout;ine illustrates the app1ieat;ion of the Metropolis dgarithm to s a n k a two-dimensioad distribution in the vmiables X1 m d X2. Each edE do the subroutine executes mother step aif the raadam wdk and retarns the n a t vduw of X1 and X2; the m ~ progrm n mast irritidze these variables, as well as set the vdue of DELTA and define the distribution WEIGHT(XI,X2).
.
C chap8g.f"~~ C subroatlne to %&B
i n Ihs Watropolis algorith SWROWZIE MEmOF(Xl,X2,UEIGRT,D&T&) EXTEWAL WEIGBT a slap
ICITEGER SEED
DATA SEm/39249%87/ !%as a trial stevp in squme aben% [X1,X2) XIT==XI+DELTA+(2*RAI(SaD)-J,) X2T=X2+DaTA* (2*RAB (S-)1) RATEO=WIEXGmf XIT ,X22")/GifFSTGHT(X%, X2) SF (RATLO GT. RAB(SEED)) THEE !s2ep accctpled
.
Xi=X1T X2=X2T
EEB LF"
REwm EHD
This code cauld be made more efficient by saving the weight function at the current point of the random walk, so that it need not, be computed
21l
212
8. Monte Carlo Methds
again when deciding whether or not to xcept the trial step; the e d u a t i o n of W is often the most time-consuaaing part of a Monte Cm10 cdcdation. using the Metropolis algofithm. To prove thatr the dgorithm described above dow indeed generate a sequence of points distributed according to W, let us consider a large number of wdkers starting from diRerent initid points and moving independently through X space. If N , ( X ) is the density of these walkers at X &er rs steps, t b a the ne%number of wdkers moving from paint X to point Y in the next step is
Here, P ( X -r Y) is the probability that a walker will make a transition to Y if it is at X, This equation shows that there is equi2ibrium (no net change in population) when
and that changes in N ( X ) when the system is not in equilibrium tend to drive it toward equilibrium (i.e., A N ( X ) is positive if there are @too many" walkers at X, or if N,(X)/N,(Y) is greater than its equilibrium value). Hence it is plausible (and can be proved) that, after a lmge number of steps, the population of the wdkers will settle dawn to its equiEbrirxm distribution, l&, It rennalns to show that the transition probabilities of the MetropoEs aigorithm lead to an equilibrium distribution of walkers N , ( X ) u ( X ) . The probability of maEng a, s$ep f r m X to Y is;
where T is the probability of making a trial step from X to Y and A is the probability of accepting that step. If Y can be reached from X in a single step (i.e., if it is within a cube of side 6 centered about X), then
T ( X + Y) = T(Y -r X ) , so that the equilibrium distribution of the Metropolis random walkers satisfies
If w ( X ) > w(Y), then A(Y 4 X) = 1 and
while if w (X) < w (Y) then
and A(X -r Y )= 1. Hence, in either case, the equilibrium population of Metropofis walkers satisfies
so that; the wdkers axe isrdwd distributed with the correct distribution. Note that although we made the discussion concrete by choosing Xt in the neighborhood of X,, we can use any transition and acceptance mles that; satisfy
Indeed, one limiting choice is T ( X -r Y )= w(Y), independent of X, and A = 1. This is the most efficient choice, as no trial steps me '%.wtzstedn through rejection. Hawewer, tkis doice is sonnewhat impractical, because if we knew haw to sample W to take the trial step, we wouldn't wed to use the dgodthm. to be@n with. An obvious que~tioni s "If trial steps are to be t&n within a nei&borhood of X,, bow do W choose the step size, S?" To answer this, suppose that X, is at a maximum of W, the most likely place for it to be. If 6 is large, then w(Xt) will likely be very mu& smaller than w(X,) and most t r i d steps will be rejected, Leading to an ineficient s a p l i n g of W . E 6 is very s m d , most trial steps will be accepted, bnt the rmdom w d h r will never move very fm, and so &so lead to a poor smpfing of the distribntion. A good r d e of thumb i s that the size af the trial &ep shodd be chosen so th& about half of the t ~ gteps d me accepted. One bme of applying the Metropolis dgorithm. to sampfe a distribution is that the points that m&e up the random walk, Xo,XI , .. are not independent of m mother, simply from the way in wEch they were is likely to be in the n4ghborhood of Xpbe T~us, generated; fhat is, while the points might be cfistributed properly W the walk becomes very long, they are aot statidicay independed of one another, and some w e
.
214
8,Monte Carlo Methd8
must be taken in using them to calculate integrals. For example, if we cdculate w ( X ) f(X) I= S S w(X) by averaging the vdues of over the pojnts of the raadom wdk, the usual estimate of the variance, Eq. (8.3), is invalid because the f ( X i ) are not statistically independent. This can be quantified by cdculating the auto-corrdation. function
Here, (
...) indicates average over the random walk; e.g.,
Of course, C(O) = 1, but the non-vanishing of C for k
+ 0 means that the
f 's me not independent. Whal can be done in practiw is ta compute the i n t e p d and its variance using psints dong the raxrdam wdk separated by a fixed intervd, the intervd being chosen so that there is eRecliveiy no cofrelation between the points used, Aa appropriate sampliag intervd the vdue of k: for which C becomes smaa;l (say can be estimated O.I)* Another issue in. applying tbe Metrapofis algorithm is where to stmt the random walk; i.e., what to t h e for X @ ,In prindple, w y location is suitable and the rehs~ft~ wiU be independent of tEs choice, m tbe wdker will ""term&zc?" after some number of steps. In practice, an appropriate starting point i s a probable one, whefe w i s large. Some number of" themalization steps then can be taken before actual sampling be@ns to remove m y depeadence on the starting point. E x e r c i ~8.5 Use the dgorithm of Metropolis et al. to sample the norrmd ddistribntion. in one dimension. For various erid step sizes, study the acceptance ratio (fraction of trial stepa accepted), the correlation function (and hence the appropriate sampling frequency), and the overall computational efficiency, Use the randam vasiables you generate to
R
and estimate the nncestainty in youf ansarer. Study how your resdts depend upon where the random wdker is started afzd on how many thermalization steps you take before beginning the sampling. Compare the efficiency of tbe Metropolis algorithm with that. of a cdcuhtim that uses one of the methads discussed in Section 8.2 to geaerate the narxnd distribution. directly, 8.4 The Ising model in two dimensions Models in which the degrees of freedom reside on a lattice and interact locally arise in several areas of condensed matter physics and field theory. The simplest of these is the Ising model [Hu63], which can be taken as ;z crude description of a magnetic materid or a binary d o y , h this example, we will use Monte Carlo methods to calculate the thermodynamic properties of t;his model, Xf we spe& in the magnetic laaguage, the rsing model consists of a set of spin degrees of freedom interacting with each other and with an external mqnetic field. These might represent the magnetic xnonzents of the &oms in a solid, We will consider in particular a model in two spatial dimensiws, where the spin mriablee are locat;ed on the sites of an N, x Ny square lattice. The spins can therefore be labeled as Sij, where i ,j are the indices for the two ~ipittiill,directions, or as S,, where a is a generic site label. Each of thme spin variables can be either "up" (S, = f l) or "down7' (S, = - 1). This mimics the spin-1/2 situation, although note that we take the spins to be c l ~ s i c degrees d of freedom and do not impose the angular momentum earnmutat ion rules characteristic of a quantum description. (Doing so would correspond t o the Heisenberg model.) The Bmiftoaian. for the system is conventionalfy written as
Here, the notation (up) means that the sum is over nearest-neighbor pairs of spins; these interact with a strength J (see Figure 8.2). Thus, the spin at site i j interacts with the spins at i f U and i j f 1. (We %same periodic boundary conditions on the lattice, so that, far example, the l m r neighbars of the spins with i == IV, are thaw with i = 1 m d the left-hand neighborn of those with j = 1 are those with j = Ng; the lattice therefore has the topology of a torus.) When J is positive, the energy is lower if a spin is in the same direction as its neighbors (ferromqnetism), while when J is negative, a spin wifl tend to be mti-aligned with its
226
8. 2Monl"e Carlo Me?&&&
* Figure 8.2 Schematic illu;stCratianof the tww&mea~ionaJ. hing mad$,
neighbors (anti-ferromagnetism). The term involving B represents the iaterwtion of the spins with an extern& magnetic field, which tends to align aU. spins in the s m e dimc$ian. We will be interested in the therxnodynmics of this system. In this case, it is convedent da measure the coupling energies J md B in units of the temperature, so that heating the system corresponds to decreasing these couplings. Configurations of the system axe spedfied by gjving the values of all N, x N, S N, spin variables md the weighting of any one of the 2N8 spin configurations, S, in the canonical ensemble i s
where the partition function is
8.4 The fsing model in two dimensions
c quantities we will be intertlsted are the nzagnetizal;ion
the susceptibility
the energy
E=
E~(s)H(s) V
(8.21~)
S
and the specific heat %t constant field,
In the limit of an infinitely large lattice (N,,, -+ m), it is possible to sdve the Ising modd exactly; discussions of the solution, origindy due to Onsager, can be found in [Hu63] and [Mc73]. The expressions are sinnpled at B == 0, In this limit, the - e r g is dven by
and the specific heat is
wMfe the mapetization i s given by
for J
r Jc m d vanishes for J < JC.In these expressions,
the complete elliptic integrals of the first and second kinds are
237
228
8,Monte Cark Methods
= 0.4406868 is the critical value of J for which K = 1, where Kl has a logilrithmie singdwity, Thus, a& thermodynmic Tune tians are singular at this caupli~g,strondy sugesting a phase transition. Tbis is confirmed by the behavior of the mametization, which vanishes below the critic4 coupling (or above the critical temperature), and can take on one of two equal and opposite values above this coupling. A numericat solution of the fsiag model is usefd both W an illustration of the techniques we have been discufjsingand because it can be generalized readily to more complicated Hamiltonians [Fo63]. Because of the la-rgt, number of terms invoked, a direct evaluation of the sums in Eqs. (8.21) i s out of the question. (For even a modest 16 x 16 lattice, ~ ~ configurations.) Hence, it is most eEthere are 2256M 1 0 different cient to generate spin configurations S with probability w(S) using the Metropous algorithm and then, to average the required observables over these configurat;ims. Z'o impjeraent the Metropolis dgorithm, we could make our %ridstep from S to St by chan@ng a l l of the spins randomly. This would, howenr, brine; us to a canfiguration very &Rerent from S, and so there vvould be a, high probability of rejection. It is therefore better ta take smdler steps, and so W consider tnid confipratioas that differ from the previous one only by the fiipping af one sjpin. This is done by sweepiing systemalIcally through the l&tic@and considering whether or not to flip each spin, one at a t h e . Hence, we emsider two configurations, S and S t , differing only by the Aipping of one spin, S, E Sa. Acceptance of this trid s t q depends upon the ratio of the w&ght functions, z = em2', and J,
Spedficdy, if r > 1 or if r < 1 but larger than a nniformiy distributed random number bet;ween O and 1, then the spin S, is flipped; othervvise, it is not. From (8.18), it is dear that only terns involving Sij will contribute to F , so that after some algebra, W have Here, f is the sum of the four spins neighboring the one being flipped. Because f can take on only 5 different values, 0,352, f 4, only 10 different values of r can ever arise (there are two possible values of S,); these can be convenient?y calculated and stored in a table before the calculation begins so that exponentials need not be calculated repeatedly. Note that if we had used trial configurations that involved flipping several spins, the cdculation of r would have been much more cormplic;zted.
VIII. Quantum Monte Cads for the H2 molecub
The program for Example 8, whose source listing is given in Appendix B and in the file EXMPL8.FOR, performs a Monte Carlo simulation of the Ising model using the algorithm just described. An initially random configuration of spins is used to start the Metropolis random walk and the lattice is s h m d t e r eltery WREQ @weep,if requested. Thermalization sweeps (no calculation of the observables) are allowed for; these permit the random w d k to "settle d o w " before abservables are aecumdated, Values of the energy, mametization, susceptibility; and speeigc heat per spin are displayed as the calculation proceeds, as is the fraction of the trial steps mcepted, One hatare of this p r a g r a requires further explmatian. This is a simple technique used to monitor the sweep-tosweep correlations in the observables inherent in the Metropolis algorithm. The basic obsenrables (energy and magnetization) are computed every )IFRW sweeps. These v&ues are then binned into L"groupswwith HSIZE members. For e ~ goup, h the means and standard deviations of the e n e r o and m~gaetiz&ionme ca-lcdated, As more groups are generaled, their means are combined into a p n d aver%@, One wa;v 80 campute the uncert&nty in this grand average is to treat the grwp means as independent measurments and to use Eq. (8.3). Alternatively, the uncertainty can be obtained by averaging zGhe standard deviatians of the goups in quadrature, If the s a p l i n g frequency is sufficiently large, these two estimates wiU agree. However, if the sampfing frequency is toa snnafl and there are significant correlations in the suecessiw measurements, the vdues witbin each group will be too narrowly distributed, and the second estimate of the uncertainty win be considerably smdler t h m the first. These two estimates of the uncertainty for the grand average of the energy and magnetization per spin are therefore displayed. Note that this technique is not so easily implemented for the specific heat and susceptibility, as they are themselves Auctuations in the energy and magnetization [Eqs. (8.21b,d)], and so only the uncertainties in their grand averages computed by the first method are displayed, The following exercises will be useful in better understanding this example: Exercise 8.6 When J = 0, the Hamiltonian (8.18) reduces to that for independent spins in an external magnetic field, a problem soluble by elementary means. For this ease, obtain analytical expressions for the thermodynamic observables and verify that these are reproduced by the program.
S
219
220
8. Monte earls Meth&
Exercise 8.7 Use Eqs. (8.22) to calculate and gfaph the e x x t energy, spedfic heat, m d mqnetization per spin Ior an infinite latticc? at B ==; 0 and far J running from O to 08.
m
Exercise 8.8 Modify the code to compute the sweep-to-sweep correlation functions for the energy and the magnetization using (8.17). Using runs far a 16 X 16 lattice far B == Q a d for severd d u e s af 9 between 0.1 and 0.6, estimate the proper sampling frequency at each coustrength. S h m that the two estimates of the ancert&nties in the energy and magnetization wewhen a proper sampling frequency is used and that they disagree when the samples are taken too often (a reasonable group size is 10). Also show that the sweep-$*sweep correlations become stronger when the system is close to the phase transition (critical slowing down).
m
Exereim 8.9 Run the code to obtdn rwdds for 8 X 8, l6 X 16, and 32 x 32 lattices at B = O for a sequence of ferromagnetic couplings from 0.1 to 0.6; pay p&ieulw attention to the region new the expected phwe trmsition. Compare youf results with the exact behavim of the infinite lattice and show that the finite size smooths out the singularitim in the c obsermbles. Notice that the size of the mqnetic dom&n~i\ becomes very 1mge new the critical coupling.
m
Urn %hecode to explore the themodynmics of the model for finite B and for mti-ferromagnetic couplings ( J < 0). Also consider simdations of a model in which a given spin Sij interacts with its neighbors ferromagnetically and with its diagonal neighbars SiWlj-l,
rr Execiee 8,20
Exercise @.l2 The ""heat bath" adgarithan is an dtemative to the Metropolis dgori%hmfor saxnpliq the citnodcd ensemble. h this method, the particular spin being considered is set to -1 with probability l/(l+ g ) and to f 1with probability #/(l + g ) , where g = exp[2(Jf B)]. This can be interpreted as plitcina; the spin in equiiPibriurn with a heat bath at the s p e d e d te:mpera;ture. Verify that this d p i t h m comsponda to putting A f and t&ng
m
+
-
T(S -+ S') = w(sl) w(S') w ( S ) in Eq. (8.16) and so leads to a correct sampling of spin configurations. Modify the code to use the heat-bath dgorithm and compare its efficiency with that of the convention& Metropolis dgorithm.
+
VJlJ, Quantum Hontt? Carlo for the If2 molecule
Project VIII: Quantum Molite Carlo for the H2 molecule In this project, we will consider Monte Carlo methods that can be used to edculate the ezaeb p~opertiesof the graund states of qua~ltunrmanybody systems. These methods are based on the formal similarity between the Schmedinger equation in imaginary time afld a multi-dinzeasional diffusion equation (recall Section 7.4). Since the latter can be handled by Monte Carlo methods (ordinary diffusion arises as the result of many random microscopic collisions of the diffusing partides), these same techniques can also be applied to the Schroedinger equation. However, the Monte Carlo method i~ no panacea: it can make exact sta;tements about only the ground state energy, it requires an already well-chosen vafiationd wave function for the ground state, and it is generally intractable for f e r ~ o nsystems. Hawever, them have been successful appfications of these techniques to liquid 4 ~ [Ka81], e the electron gas [Ce80], small molecules [Re82],and lattice gauge theories [Ch84]. More det d e d diseussions can be found in these references, as well as in [Ce'TS], which contains a good e n e r d overview. VIII.1 Statement of the problem The specific problem we will treat is the sdmcture of the H2 molecule: two protoas baund by two electrons. This will be done within the context of the =curate Born-Oppenheimer approximation, which is based on the notion that the heavy protons move slowly compared to the much li&ter electrons. The potential governing the protons' motion at a separation S, U(S),is then the sum of the inter-proton electrostatic repulsion and the eigenvalue, &(S), of the two-electron Schroedinger equation:
The electronic eigenvdue is determined by the Schroedinger equation Here, the electronic wave function, !Po, is a function of the space coordinates of the two electrons, r1,2 and depends parametricdy upon the inter-proton separat;im. If we are interested in the electron;ic gound stitte of the molecule and are willing to neglect small interactions involving the eleedro~shspin,then we e m =same that the electrons are in m mtisymmetric spin-singlef;state; the PauE principle then =quires tfta$ !Po be symmetric under the interchange of rl and r2. Thus, even though the electrons are two femims, the spakid equation sart;i&ed by their wave
221
222
8*lMorsle Caris Methods
Figure TJ1l;I.l Coordhate~used in de~ribingthe E2 maEecuEe,
firnetion is andogous to that for two bosans; the ground state wave function !Po will therefore have no nodes, md can be chosen to be positive everywhere. The electron kinetic energy appearing in (VIn.2) is
where m is the efeetron mass, while the potentid V involves the attraction
of the e l w t m s by each nudeas and the inter-.electron repalsion:
If we place the protons at locations rt f S on the z-axis, then the distance betwen eleetmn I tznd the left or right proton is 1
and the dktances betwwn electron 2 and the protons, r ~ haxe , ~$jven * (See Figure VIII.1.) % sirnilwly, The interelectmn distmce is ~ 1 = Our goal in this project is therefore to solve the six-dimensional partial differential eigenvdue equation (VIII.2) for the lowest eigenvalue E. at each S, and so trace out the potential U ( S ) via Eq. (VIII.1). This potential should look much like the 6-12 or Morse potential8 studied in Chapter 1; the depth and location of the minimum and the curvature of U &out this minimum are related to observable properties of the NIz spectrum. We will also be able to calculate the exact ground state energies of two-electron atoms, Eo(S = 0). (These same systems were treated in the Hastree-Fock apprasmation in Projject ID.)
VIII. Quantum Monte Carlo for the H2 molecule
WIf.2 Vargwtional Monte Carlo and the trial wave function We begin by discussing a variational Monte Carlo solution to the eigenvalue problem. If @(r)is any trial wave function (which we can choose to be real) not orthogond to the exact ground state qo,then an upper bound to the electronic eigenvalue is the variational energy
where we have used r as a shorthmd notation far the six coordinates of the problem, rl,z, and have written (VIIIAb) in a somewhat unconventional way. Note that this last equation can be interpreted as giving the variation4 energy as the average of a 'local energy",
over all of the six-dimensional F-space with weighting w(r) m e2(r). Hence, to evdnale the vaGalioad energy by a Monte Caslo quadrature;, all we need do is generate configurations (values of r l , ~ distributed ) according to (by the Metropolis algorithm, for example), and then average E wer these configurations. It should be clem thaL this method can be generalized readily to spterns invofving a l m p r number af coordinates. The choice of QF is crnstr.iZined by the requirements that it be ~imple enough to allow a convenient evaluation of e2 and E , yet dso be a good approximation to tht? true gound state, go. hdeed, if we are fortunate enough to choose a @ that is the exact solution, then E is independent of r, so that; the, Monte Carlo quadratare gives the exact e w r a with zem variance. Thns, not only will the v;triadiond baand become better as Q[, better approdmates P,but the vasimee in tlxe Monte Carlo quadra;t;ure will become smauer. The trid wave function should &so be symnaetdc under the interchange of the t w electrons' sspatid coordin&es, but it need not be normatized properly, as the normalization cancels in evaluating (VIII.4). One plausible choice far the drid wave functian ie a correlated product of molecdar orbitds:
223
224
8. M~rateCarlo Me&
Here, the first two factors are an independent-particle wave function placing each electron in a molecular orbital in which it is shared equally between the two protons. A simple choice for the molecular orbital is the symmetric linear combination of atomic orbitals centered about each proton, (V I I I ,6b) (b(ri)= empi&/" + e - p i ~ / a with the variationd parmeter a to be determined below. The find factor in the trid wave function, f , =presses the correlation between the t w electrons due to their Coulomb repulsion. That is, we expect f to be smd when rl2 is smdl and to approach a large constant value as the electrons become well separated. A. convenient and reasonabk choice is
where a and p asle additional positive variaLional parmehrs. Note that ,8 controls the distace over which the trid wave function @healsR$0 its uncofrelfated vdue as the two electrons mpwate, The s i n d ~ i t yof the Coulomb pstentid at short distances places addition& constraints on the trial wave function. ff one of the electrons (say 1) approwhes one of the nudei (say the left one) while the other electron remains fixed, then the potential t e r n in c becomes large ands negative, since T ~ Lbecomes smdl. This must be cancelled by a corresponding positive divergence! in the kinetic energy term if we are to keep E smooth a d have a smax variance ia the Monte Carlo quadratare. Thus, ~ 0, which means the trial wave function shoald have a C k u s p * b rt l = that the molecnlar orbit& shotlfd satisfy e2
V ~ $ ( ~IL G~ = finite tefnrs.
(VIIl.7)
Similar conditions must dso be sat;isfied whenever any one of the distmces va~lishe~. Using (VIII.6) and a bit of algebra, it is easy FZR,L, or to see that these constraints imply that a satisfies the transeendentd equation
and that a = 2ao, where a0 = h2/mez is the Bohr radius. Thus, P is the only variational parameter at our disposal. Note that these Coulomb cusp conditions would not have been as important if we were to use some other quadrature method to evaluate the variational energv, as then each
VIII* QetanGttm Mante Carla for the
H2 molecule
of the divergences in E would be cancelled by a geometrical rZ weighting in the associaLIed dis;tanee. With the trial wave fundion specified by Eqs. (VZ11.6), explicit expressions can be worked out for ~ ( rin) terms of the values and derivatives Bf: cfZ and f . Note that; this form of the trid function is not appropriate for very large proton separations, as it contains a finite amplitude to find the two eleetrans close to the same proton.
VIII.3 Monte Carlo evaluation of the exact energy We now turn to a hrlo~teCwla method for evduatiag the egaet electronic eigenvalug, [email protected] is baged upon evolution of the imaginary-time Schroedinger equation to refine the trial wave function to the exact ground state. In particular, the latter can be obtained by applying the operator exp(-at/&) to the trial state @ and considering the long-time limit t -+ W. (See the discussion concerning eigenvdues of elliptic operators given in Section 7.4 for further details.) Thus, we define
where E,(tf) is an as-yet-undetermined c-number function. Note that as long as (Po/@) 0, @(t)wig approach the (un-normalized) exact ground state !Ifoas t becomes large. Our method (Path IRtegsal Monte Carlo) is equivalent to evaluating the path integral representation of (VI1I.S) numericdy. An alternative method (Green's Function Monte Carlo, [Ce79]) would be to filter with the inverse of the skif'ted Hamiltonian, instead of the exponential in (VIII.9). To compute the exact ground state energy &, we consider a slight generalization of the variational energy (VIII.4) using the hermitidty of
+
It should be clear that E(t = 0) = E,, the variational energy associated with m, that E($ --. m) = Eo, and that E ( t ) is independent of the function E,(tt). Equatian (VIIZ.10) expresses the exact enerlir;l)"in a form suitable for Monte Carlo evaluation. To see this, we define G(r, t ) = @(r)@(r, t), so that (VIXL. 10) becames
225
236
8,Monte CarloMethods
The exact energy E ( t ) is thus the average of the local energy E over the distribution G(r, t). (Note that for the problem we are considering, G is positive definite since neither @ nor has any nodes.) A Monte Carlo evduation of E therefore mquires an "ensemble" of N configura tions (rl ,.. ,rN) distributed according to G(r, l ) , through which E($) can be estimated by
.
, N
with an expression for the variance in analogy with (8.3). Note that if @(r)is in fact the egaet ground state go,then ~ ( r = ) E@,independent of
r, and so E($)= E. with zero variance. Of course, the expressions above are of no practical use withoat a way to generate the ensemble of configurations. At t = 0, G(r, t ) = ao th& a method like that of Metropolis et al. can be used to generate the initial ensemble, typiea3ly having N ss: 30 members, To evolve the ensemble in tim% note that since dlJL!
a--at = (E, - H ) @ ,
G satisfies the evolutiorr equation
We have used here an obviaus notation far the spatid derivatives, Equation (VIII.13b) em be interpreted as a diffusion equation for G, with a drift function
It shows that the kinetic energy acts to diffuse G, that D tends to keep G confined to regions where i s large, and that the Usource'' increases G where e(r) is smallest. The evoftttiorr of G over a short time from t to t At can be repreaented thmugh order At by the integrd ktzrncll
+
W1II. Quantum Monte Car20 for the
molecule
whem P(,, r'; At) = exp{ -[ ~ ( r-)~ , ( t ) ] ~ t / h . )
This kernel (which is positive definite) can be interpreted as the conditional probability for a configuration to evolve from r' at time t to r at time At. This probability contains a factor associated with the kinetic energy, whieh, acts to diffuse the system about r' through a normalized Gaussian probability distribution wit h variance &At/ m and mean DA2. The other fxtor in B is associated with the locd energy, which acts to keep the system in regions of space where e is most negative by enhancing the probability for jumps to occur to such locations. The quantum mechanical structure of the exact ground state is thug determined by the balazlce between these t~vocompeting tendmcies, The algorithm for evolving the ensemble should now be evident. A configuration at time 1 at the point r' generates a contribution to G(r, t f At) equd to P(r, r'; At). This is realized by placing in the new ensemble a eonfipration, r chosen according to the distribution
+
and then weieting the importance of this configuration by
One way of effecting this weighting in prwtiec? is to replicate or delete the configuration in the new ensemble with probabilities given by this latter function. In this case, N fluctuates from time step to time gtep but can be held roughly constant by continuous adjustment of E,. Indeed, to keep drG(r, t ) (and hence N ) constant, E,(t) should be equal to E(t), so that E, also furnishes an estimate of E(t). An alternative way of effecting the weighting is to assign an importance (i.e., a weight Wi) to each configuration in the ensemble when aver&ng E. to compute the energy. Th& is, the aummand in (VIII.12) is modified to W i ~ ( r iAt ) . each time step, Wi for each c0nfiguril;tion is multiplied by the first f w b r in (VII1.f 61, with E, readjusted to keep average weight of ewb configuration in the easemMe equd to 1, This latter method requires less bookkeeping than does that of rqlicating and deleting, but can be heficient, as a ~0nfigurat;ion thag lzappents to acquire a very small weight is stiU. followed during the evolution,
227
228
8. Monte Carlo Hethdg
h summay, the method is aa fonows. The system is described by an ensemble of coniipratians, each having a relative might in desmibing the propertie8 of the system and initiaUy distributed in r aecarding to the trial function l@(r) The overall efficiency of the method is clhse?y related to the akccuracy af this trial function. To evolve the ensemble in, time, each member is moved in r with a shifted Gaussian probabgity function [the second factor in Eq. (VIII.IG)] and its weight is multiplied by the first fwtor in Eq. (VlII.15). The quantity En(t),wU& is ad;jnsted after each time step to keep the average vveight of the ensemble equd to 1, provides an estimate of the energy, as does the ateighted aver%@af ~ ( rover ) the ensemble at any time. Furthermore, once the total evolution time is sufficiently large to filter the trial wave function, continued evolution generates independent ensembles distributed according to the exact ground state wave function, which allows the statistics to be improved to any required accuracy. Note that since the e n s e d l e move8 through c d g u m t i a n space ed by At, which must be sufficiently s m d so that Eqs. (VIII.I5,16) are accurate, the estimates of the energy at successive time steps will not be statistically independent. Therefore, in forming averages and computing variances, care must be taken to use ensembles only at intervals of t sufficiently large that the values are uncorrelated. SuGh i n t e r d s are cenveniently d e t e r ~ n e dby e x a d ~ n g the ; autocomeldion fumtions of the estimate. Alternatively, one can use the method af binning the values into groups, as discussed in connection wit h the Ising cdcalation in. Section 8.4, It shodd dso be noted that the finite time step requires that calculations be done for several different values of At and the results extrapdaed to the At = O li&t. A useful way to set a scale for At i s to note that the average step the Gaussian distribution ~ ; must be s m d compared to the in (VIII.16) is roughly ( h ~ t / m ) ' /this length se&s in the wave function. Expectation values of observables other than the energy in the exact ground state are not simply given by this method. To see this, consider the gound state expectation value of some observable A that does not commute with the H
VlIl. Quantum Mmte Carlo for the H2 molecule
Evaluation of this integral requires an ensemble of configurations &S@ 1'. However, the diffusion process described above generates an ensemble astributed as G = g?@, wKch is not what is required, Although this ensemble can be used, through a rather complicated dgorithxn, to cdcdate ex& gfound st& expectation values, a good estimate can be had by using it directly to cdculate the first term in
the second term being evduated easily with an ensemble distributed Wcording to g2.Thus, this expression provides a way of perturbatively carrecting the expectation value in the trial state; some algebra shows that -- @, it is accurate to secand order in the emor in, the trial function,
VIII.4 Solving the problem The Monte C a l o methods described above can be applied to solve for the properties of the H2molecde throagh the faaowing sequence of steps. S h p I Verify that Eq. (VII1.8) and thechcsicecu = 2ao imply that the wave fnnction (VTT1.6) satl~fiesthe Coulomb cusp condition. Derive explicit analytical expressions for ~ ( r[Eq. ) (VIII.5)] and D(r) [Eq. (VIII.I.I)] for the wave function (VIII.6).
r
Step 2 Write a code that uses Moate Cm10 quadrature to cdculate the mriat;iond e m r g estimate associ%ted with the trial wave hnction (VIII.6). You will need subroutines to evaluate m2 and E for a given configuration. Sample Q' using the Metropolis algorithm. Study the mto-cornelation funceSon of E t a deternnine the minimum acceptable sampling frequency along the random walk, r
Step 3 For various inter-proton separations, S, find the parameter P that minimizes the electron eie;envdae and so determine the variatianal p o t a t i d for the Mz molecule. Verify t h t the nnce;rtaint;iesin your results behave with P as expected. Your vdue at S = O can be compared with the variational results obtained in Project III using scaled hydrogenic and fttl.1.XIEartrw-Fack wave functions. Step 4 Verify the validity of Eqs. (VIII.15,16) by making a Taylor expansion of G(rt,t)about r and then doing the resulting Gaussian r' integrals. (You will also have to make the approximation D(rt) E;: D(r), which is accurate to O(ht).)
229
=
Sdep 5 Test the Path I n t e e d Monte Carlo scheme for finding the exact graund state enerw of a Eamiltonian an the simple situation of a particle in a one-dimeneion-ali hamonic-oscif2ator potentid. Write a p r o g r a that assumes a Gaussisur trial functian with an incorrect; width and verify that the time evolution refines the m e r w in the expected way. An ensemble of 20-30 members &odd be snseient;, hvestigate how the y & t y of your reslllts vmies with the error in the trid wave funclion and with the time step you use,
Step f3 Carrrrbine the progrms you wrote in Sttlrps 2 and 5 into one that d e t e r ~ n e sthe exact eigenvdue of the ground state elf the twoelectron prablem and so determine the exact Kz nildeculm potentid ad vaious separations. In particular, deterdne the location of the minimum in the paentiitl and coaapae with the empirical vdnes @wn in Section 1.4, Use the trid functions deterdned in Step 2 and verify that your exaet ener@es are always lower thaa the vasiatimd vdues. Also verify that your exact r e d t e are independent of the preciae choice of P and that they extrapolate srnootlrly as a fuflction of Bt. Determine the binding energy of the He &om by considering S = 0 and eompme urith the exact vdue given in the di8cus~ionof Project 111.
m
Appendix A
How to Use the Programs This appendix contains the information needed to execute the Computational Physics codes. To foEow the instructions below, you must be familia with your computer's operating system, FORTRAN compiler, linker, editor, and graphics package. If you are unfamiliar with any of these, consult your computer system documentation before proceeding. You may also find it useful to have a FORTRAN language reference (e.g., [Ko87]) handy.
A.1 Ixrstdf&iomz Before anything else can be done, you must install the codes by downloading them from diskette to your computer or transferring them over the Internet network. Network transfer is much quicker and free (see Appendix E for details), but requires software and network connections that; are not uxriversdy avdable. The other modes of distribution are fBM-PC or Macintcssh fomatted diskettes; m order farm for these is in the b x k of tEs book. For those users who purchase the disketta md astj glmning to run the codes on an IBM-PC as Mac the irhstallatim proseduse is simply $0 copy the codes into a directory on the hard drive. Mwever, if you are not planning to run. the codes on m IBM compatible or Mac, then downloadipg may not be simple. and will depend on the details of yaur hardwme. The general scheme i s to find a PC or MW connected via modem or net-urork to your machine, and then to use a file trmsfer p r o ~ r m(e.g., KERMIT) to trafzsfer the Computaliclnal Physics files. Yatr &ght even find it necegsary to go through. one or more intermediate machines to get to yaurs. If you are inexperienced with file transfer, consult a locd expert, Once you download the files on your machine, we suggest you back them up immediate& on media that caa be read directly by that machine.
232
A, How to &7ðe Progranas
A,% Fifes There me five categories af file8 included on the fimpzrtatio~aalPh~lsics diskette: t e e codes, common utilie programs, physics p r ~ p a m s data , aes, and indude files. These were written in xeordance with FORTRAN77 stmctmds (with two exceptions noted below) and therefore should run on my ma&ine with a FORTRAN-77 compiler. The Estings for the examples are in Appeadix B, the projects in Appendix C, and the conamon uf;ifity codes in Appendix D. 1) The text codes are the short codes that appear in the text. They are n m e d CHAPnx.FOR, where 6x1' indicatles, the &apter nuaaber, m d 'X' is a letter to digereatiate codes within the s m e chaplter. Due to l a d of space on tbe diskette, only the longer of these codes we induded; the others; cm be entered from yovr keyboard. These =quire no editing to m, with the exception of those in Chapter 8 wfiich requipe a random nunber generator that is non-standard FORTRAN-77, E your compibr does not provide one, use the function RAHH~S,wh_ichis in file T7TXL.I"OR. 2) The first five common utiiity FORTRAN codes are called by, and therefore must be Enked with, each of the physics p r q r m s , UTIL.FOR contains the routines for menuing, 110, file opening/dosing, etc. SETTJP.FOIR contdns xl'l the vadables a d routines that are hmdwwe and compiler dependent, e.g., sereen length m d terminal unit m m Ber. Uou may need to edit this file to get the motst eacient and attrmtive output. (See section A.3.) The three remaining utility codes are graphics files: GRAPHIT.EI1, GUPHIT,XIO, m d GRAPEIXT,BLK, which, provide the interface between the physics code and your grapKcs pacbge, These three files contajxl the same subroutines, but for digerent typeer of grapucs packages. You will nee