Monte Carl o Modelin g fo r Electro n Microscopy an d Microanalysis
OXFORD SERIE S IN OPTICA L AND IMAGING SCIENCE S ...
22 downloads
887 Views
23MB Size
Report
This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
Report copyright / DMCA form
Monte Carl o Modelin g fo r Electro n Microscopy an d Microanalysis
OXFORD SERIE S IN OPTICA L AND IMAGING SCIENCE S EDITORS
MARSHALL LAP P JUN-ICHI NISHIZAWA BENJAMIN B . SNAVELY HENRY STAR K ANDREW C . TA M TONY WILSO N
1. D . M . Lubma n (ed.) . Lasers and Mass Spectrometry 2. D . Sarid . Scanning Force Microscopy With Applications to Electric, Magnetic, and Atomic Forces 3. A . B . Schvartsburg . Non-linear Pulses in Integrated and Waveguide Optics 4. C . J. Chen . Introduction to Scanning Tunneling Microscopy 5. D . Sarid . Scanning Force Microscopy With Applications to Electric, Magnetic, and Atomic Forces, revised edition 6. S . Mukamel. Principles of Nonlinear Optical Spectroscopy 1. A . Hasegaw a an d Y . Kodama. Solitons in Optical Communications 8. T . Tani. Photographic Sensitivity: Theory and Mechanisms 9. D . Joy . Monte Carlo Modeling for Electron Microscopy and Microanalysis
Monte Carlo Modelin g for Electro n Microscop y and Microanalysis DAVID C . JO Y
New York
Oxford
OXFORD UNIVERSIT Y PRES S 1995
Oxford Universit y Pres s Oxford Ne w Yor k Athens Aucklan d Bangko k Bomba y Calcutta Cap e Tow n Da r e s Salaa m Delh i Florence Hon g Kon g Istanbu l Karach i Kuala Lumpu r Madra s Madri d Melbourn e Mexico City Nairob i Pari s Singapor e Taipei Toky o Toront o and associate d companie s i n Berlin Ibada n
Copyright © 199 5 b y Oxfor d Universit y Press , Inc . Published b y Oxfor d University Press, Inc. , 200 Madiso n Avenue , New York , New Yor k 1001 6 Oxford i s a registered trademar k o f Oxfor d Universit y Press All right s reserved. N o par t o f thi s publication ma y b e reproduced , stored i n a retrieval system , or transmitted , in an y for m o r b y any means , electronic, mechanical , photocopying, recording , o r otherwise , without th e prio r permissio n o f Oxfor d University Press. Library o f Congres s Cataloging-in-Publicatio n Dat a Joy, Davi d C, 1943 — Monte Carl o modelin g for electro n microscop y an d microanalysi s / David C . Joy. p. cm. — (Oxfor d series in optica l and imagin g sciences : 9) Includes bibliographical references . ISBN 0-19-508874- 3 1. Electro n microscopy—Compute r simulation . 2 . Electro n prob e microanalysis—Computer simulation . 3. Mont e Carlo method . I. Title . II . Series . QH212.E4J67 199 5 502'.8'25—dc20 94-3564 2 A disk , 3!/2-inc h MS-DO S format , containing al l th e sourc e cod e i n this boo k i s availabl e b y mail fro m Davi d C . Joy, P.O . Bo x 23616 , Knoxville, T N 37933-1616, U.S.A . The cost , includin g postage an d handling, i s $10.00 (U.S. and Canada ) o r $15.00 (elsewhere) . Payments accepte d i n the for m o f a check o r a mone y order .
135798642 Printed i n th e Unite d State s o f Americ a on acid-fre e pape r
PREFACE Electron microscop y an d electron bea m microanalysi s are techniques tha t are now in dail y use i n many scientifi c disciplines an d technologies. Thei r importanc e de rives fro m th e fac t tha t the information they generat e comes fro m highl y localize d regions of the specimen, the data produced are unique in scope, an d the images and spectra produced can be quantified to give detailed numerical data about the sample. For quantification to be possible, however , it is necessary to be able to describe how a bea m o f electron s interact s wit h a soli d specimen—an d suc h a descriptio n i s difficult t o provide because of the very varied and complex nature of the interactions between energeti c electron s an d solids . The purpose of this book i s to demonstrat e ho w thi s interactio n ca n be accu rately simulate d and studie d on a personal computer , b y applyin g simpl e physica l principles an d th e mathematica l techniqu e o f Mont e Carl o (o r random-number ) sampling. Th e ai m is t o provide a practical rathe r tha n a theoretical guid e t o this technique, and the emphasis is therefore on how to program and subsequently use a Monte Carl o model . Th e bibliography list s other books that cover the mathematics of Monte Carlo sampling an d the physical theory of electron scatterin g i n detail. To make the programs develope d her e a s accessible a s possible, a disk—for us e with MS-DOS-compatible computers—ha s bee n mad e available ; i t contain s al l o f th e source code described in this book together with executable (i.e., runnable) versions. To order se e facin g copyrigh t page. This book woul d not have been possibl e withou t the generou s cooperatio n o f many othe r people . I a m especiall y gratefu l t o Dr . Dale Newbur y of N.I.S.T. , fo r first introducin g me to Monte Carlo models, an d to him and Dr. Robert Myklebust, also o f N.I.S.T. , fo r sharin g thei r cod e wit h me . Dr . Hug h Bisho p o f A.E.R.E . Harwell, whos e Ph.D . wor k produce d th e firs t electro n bea m Mont e Carl o pro grams, kindly lent me a copy of his thesis and provided some invaluable background information. Dr . Peter Duncumb , of the University of Cambridge an d Tube Investments Ltd., whose pioneering wor k on Monte Carlo modeling usin g minicomputers ultimately made thi s book possible , len t me copies o f his earl y reports an d paper s and has bee n unfailingl y helpful i n answerin g man y questions abou t the develop ment o f the technique . Th e program s give n i n thi s volum e hav e bee n refine d an d improved through the efforts o f many colleagues wh o have used them over the past few years . Vita l improvements i n science , substance , an d style have been mad e by
Vi PREFAC
E
Drs. John Armstrong (California Institute of Technology), Ed Cole (Sandia), Zibigniew Czyzewsk i (Universit y of Tennessee) , Raynal d Gauvi n (Universit e d e Sher brooke), Davi d Howit t (Universit y o f California) , Davi d Hol t (Imperia l College , London), Pegg y Moche l (Universit y of Illinois) , Joh n Rus s (Nort h Carolin a Stat e University), an d Oliver Well s (IBM) . T o them, to my student s Suichu Luo, Xinle i Wang, an d Xia o Zhang , an d t o man y other s wh o hav e give n o f thei r tim e an d expertise, I am deeply grateful. An y errors and problems tha t remain ar e strictly my own responsibility. Finally, I dedicat e thi s boo k t o m y wif e Carolyn , withou t whos e lov e an d encouragement thi s manuscrip t woul d hav e remaine d jus t anothe r pil e o f flopp y discs. Knoxville D August 1994
. J.
CONTENTS 1. An Introduction to Monte Carlo Methods
3
1.1. Electro n Bea m Interaction—The Problem 3 1.2. Th e Monte Carl o Method 4 1.3. Brie f Histor y o f Monte Carl o Modelin g 5 1.4. Abou t This Boo k 7
2. Constructing a Simulation 2.1. Introductio n 9 2.2. Describin g th e Problem 9 2.3. Programmin g th e Simulatio n 1 2.4. Readin g a PASCAL Program 1 2.5. Runnin g the Simulatio n 2 3
3. The Single Scattering Model
9
2 3
25
3.1. Introductio n 2 5 3.2. Assumption s o f the Singl e Scatterin g Mode l 2 5 3.3. Th e Single Scattering Mode l 2 6 3.4. Th e Singl e Scatterin g Mont e Carl o Cod e 3 7 3.5. Note s on the Procedures an d Functions Use d in the Program 4 3.6. Runnin g the Program 5 0
4. The Plural Scattering Model
6
56
4.1. Introductio n 5 6 4.2. Assumption s o f the Plural Scatterin g Mode l 5 6 4.3. Th e Plural Scatterin g Mont e Carl o Cod e 6 2 4.4. Note s on the Procedures an d Functions Use d in the Progra m 7 4.5. Runnin g the Program 7 5
5. The Practical Application of Monte Carlo Models 5.1. Genera l Consideration s 7 7 5.2. Whic h Type of Monte Carl o Model Shoul d Be Used? 7
1
77 7
viii CONTENT
S
5.3. Customizin g the Generi c Programs 7 8 5.4. Th e "All Purpose" Progra m 7 9 5.5. Th e Applicabilit y of Mont e Carl o Technique s 7 6. Backscattered Electrons
9
81
6.1. Backscattere d Electron s 8 1 6.2. Testin g th e Mont e Carl o Models o f Backscattering 8 6.3. Prediction s o f the Mont e Carl o Model s 9 0 6.4. Modelin g Inhomogeneou s Material s 9 7 6.5. Note s o n the Progra m 10 5 6.6. Incorporatin g Detector Geometr y an d Efficienc y 11
1
1
7. Charge Collection Microscopy and Cathodoluminescence 114 7.1. Introductio n 11 4 7.2. Th e Principles o f EBIC and C/ L Imag e Formation 11 4 7.3. Mont e Carl o Modelin g o f Charge Collectio n Microscop y 11 8. Secondary Electrons and Imaging 8.1. Introductio n 13 4 8.2. Firs t Principles—S E Model s 13 8.3. Th e Fast Secondar y Mode l 14 8.4. Th e Parametri c Mode l 15 6
2
134
6
9. X-ray Production and Microanalysis
174
9.1. Introductio n 17 4 9.2. Th e Generatio n o f Characteristi c X-ray s 17 4 9.3. Th e Generatio n o f Continuum X-rays 17 5 9.4. X-ra y Production i n Thin Film s 17 7 9.5. X-ra y Production i n Bul k Sample s 19 1 10. What Next in Monte Carlo Simulations?
199
10.1. Improvin g the Mont e Carl o Mode l 19 9 10.2. Faste r Mont e Carl o Modelin g 20 2 10.3. Alternative s t o Sequentia l Mont e Carl o Modelin g 20 10.4. Conclusion s 20 5 References 20 Index 21
3
7
3
9
Monte Carl o Modelin g fo r Electro n Microscopy an d Microanalysi s
This page intentionally left blank
1 AN INTRODUCTION TO MONTE CARLO METHODS 1.1 Electron beam interaction—the problem The interaction o f an electron bea m with a solid i s complex. Within a distance o f a few ten s t o a fe w hundred s o f angstrom s o f enterin g th e target , th e electro n wil l interact wit h th e sampl e i n som e way . The interactio n coul d b e th e resul t o f th e attraction between the negatively charged electron and the positively charged atomic nucleus (and equally the repulsion between the negatively charged atomic electrons and negativ e charg e o n th e inciden t electron) , i n whic h cas e th e electro n wil l b e deflected throug h som e angl e relativ e t o it s previou s directio n o f travel , bu t it s energy wil l remain essentially unaltered. This i s called a n elastic scattering event . Alternatively, the incident electron could cause the ionization of the atom by removing a n inner-shell electro n fro m it s orbit, s o producing a characteristic x-ra y or an ejected Auger electron; it could have a collision wit h a valence electron to produce a secondary electron ; it could interac t wit h the crystal lattice of the solid to generat e phonons; or , i n on e o f severa l othe r possibl e ways , i t coul d giv e u p som e o f it s energy t o the solid. These type s of interactions i n which the electron changes both its directio n o f trave l an d it s energ y ar e example s o f inelastic scatterin g events . After travelin g a further distance , the electro n wil l then agai n b e scattered , eithe r elastically o r inelastically a s before, and this process wil l continu e until either the electron gives up all of its energy to the solid and comes to thermal equilibrium with it o r until it manages to escap e fro m th e soli d i n som e way. While at a sufficiently atomisti c leve l this train of scattering events is presumably quit e deterministic—give n sufficien t informatio n abou t th e electro n an d th e parameters describin g it—t o a n observe r abl e t o watc h th e electro n a s i t travel s through th e solid , th e sequenc e o f events makin g up th e trajector y fo r an y give n electron woul d appear t o b e entirel y random . Ever y electro n woul d experience a different se t of scattering event s and every trajectory woul d be unique. Since, i n a typical electron microscope, ther e are actually about 1010 electrons impinging on the sample each second, it is clear that there is not likely to be any simple or compact way t o describ e th e spatia l distributio n o f th e innumerabl e interaction s tha t ca n occur or the various radiations resulting from these events. At best it will be possible to assig n probabilitie s t o specifi c events , suc h a s the chanc e o f a n electro n bein g 3
4 MONT
E CARL O MODELING
backscattered (i.e. , bein g scattere d throug h more tha n 90°) o r of being transmitte d through the target; but any more detailed analysis of the interaction will be impossible. The Monte Carlo method described here uses such probabilities, together with the idea of sampling by using random numbers, to compute one possible set of scattering events for an electron as it travels into the solid. By repeating this process many times, a statistically valid and detailed picture of the interaction process can be constructed.
1.2 The Monte Carlo method One of the very earliest publishe d paper s o n "Monte Carlo" methods (Kahn , 1950 ) provides a n excellent statement of the basis o f the method—"By applyin g random sampling techniques t o the problem [o f interest] deductions about the behavior o f a large numbe r o f [electrons ] ar e mad e fro m th e stud y o f comparativel y few . Th e technique is quit e analogous t o public opinion polling of a small sample t o obtain information concernin g th e populatio n o f th e entir e country. " Th e us e o f rando m sampling to solve a mathematical problem can be characterized a s follows. A game of chance is played in which the probability of success P is a number whose value is desired. If the game i s played N time s with r wins then r/N i s an estimate of P. The "game o f chance" will be a direct analogy , or a simplified version, of the physical problem to be solved. To play the game of chance on a computer, the roulette wheel or dice are replaced b y random numbers. The implication of a "random" number is that any number within a specified range (usually 0 to 1 ) has an equal probability of being selected , and all the digits that make up the number have an equal probability (i.e., 1 in 10 ) of occurring. Thus to take a simple and relevant example, conside r a n electron tha t ca n b e scattere d elasticall y o r inelastically , th e probabilit y o f eithe r occurrence being determined by its total cross section. If the probability that a given scattering even t i s elasti c i s ps an d pi i s th e probabilit y o f a n inelasti c scatterin g eventoandityaoiueabet a two alternatives by picking a random number RND (0 < RN D < 1 ) and specifying that i f RN D ^ pe, the n a n elasti c even t occurs , otherwis e a n inelasti c even t i s assumed to have occurred. I f this selectio n procedur e i s applie d a large number of times, then the predicted rati o of elastic t o inelastic event s will match the expecte d probability derive d fro m th e give n probabilitie s p e an d p ;, sinc e a fractio n pe of th e rando m number s will be ^pe. Rando m number s can als o b e use d t o mak e other decisions . For example , i f the probability p(%) o f the electron bein g scattere d through som e angl e 6 i s known , eithe r experimentally o r fro m som e theoretica l model, then a specific scattering angl e a ca n be obtained o r picking another random number an d solving fo r a th e equation:
INTRODUCTION T O MONT E CARL O METHOD S 5
which equate s RN D t o th e probabilit y o f reachin g th e angl e a give n th e know n distribution o f p(Q). B y repeatin g thes e random-numbe r samplin g processe s eac h time a decision must be made, a Monte Carlo simulatio n of one particular electro n trajectory throug h the soli d ca n be produced. Th e result o f suc h a procedure i s not necessarily o r eve n probabl y a trajectory representin g on e tha t could b e observe d experimentally unde r equivalent conditions . However , b y simulatin g a sufficientl y large numbe r of suc h trajectories , a statisticall y significan t mixture of al l possible scattering event s will have been sample d an d the composite result will be a sensibl e approximation t o experimenta l reality .
1.3 A brief history of Monte Carlo modeling The firs t publishe d exampl e o f th e us e o f rando m number s t o solv e a problem i s probably that of Buffon, who—i n his 177 7 volume Essai d'Arithmetique Morale— described a n experiment i n which needles of equa l length wer e throw n a t random over a shee t marke d wit h paralle l lines . B y countin g th e numbe r o f intersection s between lines an d needles, Buffo n wa s abl e t o deriv e a value for TT . Subsequently, other mathematician s an d statistician s followe d Buffon' s lea d an d mad e us e o f random number s a s a wa y o f testin g theorie s an d results . Becaus e man y o f th e phenomena o f interest t o physicists in the early twentieth century , such a s radioactive decay or the transmission o f cosmic rays through barriers, displaye d a n apparently random behavior, it was also an obvious step to try to use random number s to investigate suc h problems. Th e procedure wa s to model, fo r example, a cosmic ray interaction b y permittin g th e "particle " to play a game o f chance, th e rule s o f the game being suc h tha t the actua l deterministi c an d random feature s of the physica l process wer e exactl y imitated , ste p b y step , b y th e gam e an d i n whic h rando m numbers determine d th e "moves." During the Manhattan Project, which led to the development o f the first atomic bomb, John von Neumann, Stanislav Ulam, and others made innovative use of both random-number samplin g an d game-playing situation s involvin g rando m number s as a wa y o f studyin g physica l processe s a s divers e a s particl e diffusio n an d th e probability of a missile strikin g a flying aircraft . It was during this period tha t these techniques wer e first dubbe d "Monte Carlo methods " (Metropoli s an d Ulam, 1949 ; McCracken, 1955) . Because th e Mont e Carlo metho d need s a large suppl y o f random number s a s wel l a s muc h repetitiou s mathematica l computation , th e late r development of the technique was closely geare d t o the development of "automatic computing machines. " A s firs t mechanica l an d the n electroni c machine s becam e available durin g the 1950s , the technique foun d increasin g applicatio n t o problem s ranging i n scop e fro m diffusio n studie s i n nuclea r physic s t o th e modelin g o f population growt h by th e Burea u of the Census . A valuable bibliograph y o f thes e early paper s an d techniques ca n be found i n Meye r (1956) . Although Monte Carl o methods ha d been applied to many other phenomena, it was no t unti l th e wor k o f Hebbar d an d Wilso n (1955 ) tha t th e metho d wa s sue -
O MONT
E CARL O MODELIN G
cessfully employe d for charged particles. Later work by Sidei et al. (1957) and Leiss et al . (1957 ) le d t o a majo r paper b y Berge r (1963 ) tha t lai d th e groundwor k for future developments . Simultaneously , in England , M . Green , a physic s graduat e student in Cambridge workin g for V . E. Cosslett , wa s persuaded t o investigate th e application of von Neumann's Monte Carlo method, and the university's EDS AC II computer, t o th e scatterin g o f electro n beams . Takin g experimenta l dat a o n th e scattering of electrons in a 1000- A film as a starting point, Green (1963) and later Bishop (1965 ) wer e abl e t o deriv e th e electro n backscatterin g coefficient , an d th e depth dependenc e o f characteristi c x-ra y production , fro m a bul k sampl e an d t o demonstrate good agreemen t wit h measured values . However, whil e this approac h showed th e validit y o f th e technique , i t wa s limite d i n it s applicatio n t o thos e situations where the suitably detailed initial experimental data were available. At the 4th Internationa l Conferenc e on X-ray Optics an d Microanalysi s i n Paris i n 1965 , however, two independent papers (Bishop, 1966; Shimizu et al., 1966) demonstrated how theoretically based electron scattering distributions could replace and so generalize experimental distributions; within a short time, groups in Europe, Japan , and the United States had produced working programs based on this concept. One of the most important of these was the one produced by Curgenven and Duncumb (1971) working a t the Tube Investments Laboratory i n England. Thi s progra m introduce d several ne w concepts , includin g th e so-calle d multipl e scatterin g approximatio n discussed i n Chapter 4 of this book, and was optimized t o run on a relatively smal l scientific computer . Copies of the FORTRAN code were generously made available to intereste d laboratorie s throughou t the worl d for thei r own use ; a s a result , thi s program came into widespread use and made a significant contribution to popularizing th e ide a tha t electron-soli d interaction s coul d b e modele d convenientl y an d accurately b y computer . By 1976 , th e us e o f this technique wa s sufficientl y commo n fo r a conferenc e entitled "Us e o f Mont e Carl o Calculation s i n Electro n Prob e Microanalysi s an d Scanning Electro n Microscopy " t o b e hel d a t th e Nationa l Burea u o f Standard s (NBS) in Washington, D.C. The proceedings o f that meeting (Heinrich et al., 1976 ) still for m on e o f th e basi c resource s fo r informatio n i n thi s field , an d programs , algorithms, an d procedures develope d b y th e NBS grou p have formed the startin g point fo r man y o f th e program s i n curren t use , includin g thos e describe d i n thi s volume. Apart from th e very earliest examples , which were run by hand, using random numbers generated b y spinning a "wheel o f chance" (Wilson, 1952) o r on mechanical desk calculators (e.g., Hay ward and Hubbell, 1954), Monte Carlo programs were designed t o be run o n the main-frame computers the n becoming availabl e in most government an d industria l laboratories an d universities . Althoug h suc h machine s were both large and expensive, their capabilities were very limited, and considerable ingenuity was necessary to produce workable programs within the limits set by the available memory (often as little as 2000 words) and operating time between crashes
INTRODUCTION T O MONT E CARL O METHOD S 7
of th e system . Nevertheles s Mont e Carl o program s wer e ofte n cite d a s a prim e example of the new analytical power made available throug h electronic computing . With the advent of personal computers (PCs), this power is now available to anyone who needs it. Monte Carlo programs are, in most cases, relatively short in length and can readily be run on any modern P C without encountering any problems with the lack o f memory. The programs are also computationally intensive, i n the sens e that once th e progra m ha s obtaine d al l th e necessar y data , i t perform s calculation s continuously until its task i s finished. This is not the ideal situatio n for a program that is run on a time-shared main-fram e compute r because it means that the actual computing time will depend directly on the number of users working on the machine at any given time (unlike programs such as word processing, where the majority of the computer's tim e is spent in waiting for the operator t o enter the next character and multipl e users produce littl e apparen t drop i n response speed) . Consequently , even o n relativel y powerfu l time-shar e systems , the computationa l spee d experi enced by a user when running a Monte Carlo program ca n seem very slow ; thus to calculate a sufficient numbe r of trajectories to produce an accurate result can cost a lot o f both time an d money. While PCs d o not, in general , perfor m the individual computations a s rapidl y a s th e mai n frame , the y are dedicate d t o on e task ; a s a result, their effective throughpu t can easily rival that of much larger machines. Also, since access to PCs is often fre e or at least very cheap, over-lunch or even overnight runs are no financial burden to the user. Finally, the interactive nature of PCs and the ready acces s t o graphical presentation tha t they provide offer s th e chance to make programs that ar e both mor e accessibl e an d more immediatel y useful .
1.4 About this book This volume is not intended t o replace standard textbooks on the general theory of Monte Carlo samplin g (such as those by Hammersley, 1964 , and Schreider, 1966) , nor i s it a substitut e for a comprehensive guid e to electro n beam microscopy an d microanalysis (suc h a s Goldstei n e t al. , 1992) . Rather , i t i s intende d t o provid e electron microscopists , microanalysts, and anyon e concerned wit h the behavior of electrons i n solid s wit h ready acces s t o the power o f th e Mont e Carl o method . I t therefore provide s workin g Mont e Carl o simulatio n routines fo r th e modelin g o f electron trajectorie s i n a soli d an d discusse s procedure s t o dea l wit h associate d phenomena suc h as secondary electron and x-ray production. These procedures can then be added to the basic simulatio n as required to produce a program customized to tackle particular problems in image interpretation o r microanalysis. The goal is to make availabl e simulation s whos e accuracy is at least a s good a s that likely t o be achieved in a comparable measuremen t or experiment o n a n electron microscope . The programs have been develope d an d have been designe d to be run on persona l computers rather than on scientific minicomputers or full siz e main-frame machines. Even given th e advanced PC designs no w available , thi s has occasionally mad e it
8 MONT
E CARL O MODELIN G
necessary t o compromise betwee n th e completenes s o f the model an d the spee d of execution. In most cases the choice has been for the version tha t is fast in operation, since a goo d approximatio n availabl e rapidl y i s muc h mor e usefu l tha n a n exac t result that takes a day to compute. N o claim is made that these programs represent the bes t o r eve n th e onl y wa y t o d o th e job . Indeed , a larg e numbe r o f othe r approaches ar e cited in the text. This book wil l have achieved it s purpose if you— the user—feel ready , willing , and abl e t o use th e printed program s give n here , o r those availabl e on the accompanyin g disk, as the basis fo r your own experimenta tion an d development .
2
CONSTRUCTING A SIMULATION 2.1 Introduction In thi s chapter , w e wil l develo p a Mont e Carl o simulatio n o f a rando m wal k (sometimes calle d a "drunken walk, " afte r it s most popular mode o f experimental investigation), Although this particular problem is only loosely related to the studies of electron beam interactions that follow, the model that we will develop provides a convenient wa y o f establishin g a framewor k fo r thos e subsequen t simulations . I t also illustrate s th e genera l principle s o f programming to b e followe d in thi s boo k and introduces some of the important practical detail s associated wit h constructing and running suc h models on a personal computer.
2.2 Describing the problem The random walk problem can be stated as follows: "How far from the starting point would a walke r b e afte r takin g N step s o f equa l lengt h bu t i n randoml y chose n directions?" In order to simulate this problem, we must break it down to a sequence of instructions, or algorithms, that allow us to describe it mathematically. Figure 2.1 shows the situation for one of the steps making up the walk. It commences fro m th e coordinate (x, v) reached a t the conclusion o f the previous step and is made at some random angl e A wit h the X-axis, so that:
where RND is a random number between 0 and 1 . The coordinates xn, yn of the end of th e ste p are then :
Equations (2.2 ) an d (2.3 ) ca n be cast in a more symmetrica l for m b y writing
9
10 MONT
E CARL O MODELIN G
Figure 2.1. Coordinat e syste m fo r th e random wal k simulation .
so that
cos (A) and cos (B), the cosine s o f the angle s between the vecto r representin g th e direction of the step and the axes, are called the direction cosine s an d will in futur e be abbreviate d t o CA an d CB . Although Eqs. (2.1) , (2.5), and (2.6) give an accurate mathematical descriptio n of on e ste p o f th e random walk , the axe s o f th e coordinat e syste m ar e constantl y changing as the walker moves from one step to the next. It would intuitively be more satisfactory t o describe th e progress o f the walker with respect t o a fixed referenc e frame o f axe s (suc h a s th e wall s o f th e room) , because thi s make s i t possibl e t o predict when , fo r example , a collision migh t occur . Wit h thi s descriptio n then , a s shown in Fig. 2.2 :
where X, Y are the angles described b y the direction cosines CX, CY for the previous step, an d A, B ar e the angles fo r the new direction cosine s CA, CB. As befor e
CONSTRUCTING A SIMULATIO N 1
1
Figure 2.2. Modifie d coordinat e description usin g fixe d axe s for th e random walk .
and fro m th e usua l trigonometri c expansion s we get
using the result that sin (X) = co s (Y) and sin (Y) = co s (X). Equations (2.7), (2.10), (2.11), (2.12) , an d (2.13 ) no w describ e ho w t o calculat e th e en d poin t o f a step , given its starting point. The next step can similarly be computed using the identical equations bu t resetting th e coordinate s s o that the ol d end point becomes the new starting point and the exit direction cosine s becom e the entry direction cosines :
The recipe fo r simulatin g the random walk is therefore a s follows: Given a starting point (x0, y0) an d a starting direction (CX, CY), the n Repeat the sequence Find th e deviation angl e 6 [Eq . (2.7)] Calculate the new directio n cosine s CA,CB [Eqs . (2.12) an d (2.13)] Calculate the new coordinates xn,yn [Eqs . (2.10 ) an d (2.11)] Then reset the coordinate s fo r the next step x = xn, y = yn, CX = CA, CY = CB until the required number of steps has been taken Then distanc e s from startin g point is s = V(* — x0)2 + ( y - y0)2
12 MONT
E CARL O MODELIN G
2.3 Programming the simulation To carry out the simulation on a computer, the recipe given above must be expresse d in a for m tha t th e compute r ca n understand . Thi s require s tha t w e choos e on e computer language , fro m amon g th e man y no w available , i n whic h t o cod e ou r program. Unfortunately , any discussion of programming language s is liable t o lead to acrimony , becaus e anyon e wh o regularl y use s a particula r languag e an d ha s become use d to its syntax an d particular strengths an d weaknesses ca n always fin d sufficient reason s t o prove that any other languag e is deficient i n power o r conve nience. However , stripped o f the theological overtone s s o often accompanyin g this sort of debate, the truth is that any of the languages now in common use on persona l computers coul d b e used t o cod e thi s an d the following , Monte Carl o simulation s without a noticeabl e effec t o n th e qualit y of th e fina l product . But sinc e i t i s no t practical t o provid e equivalen t cod e fo r al l possibl e languages , i t i s necessar y t o choose jus t one arbitrarily, fo r whateve r reasons see m appropriate , an d wor k with that. Even though it might not have been your firs t o r even your second choice, th e decision her e ha s been t o use PASCAL. The reasons fo r this decision wer e princi pally a s follows: 1. PASCA L is a good exampl e o f a modern language . I t allow s for structure d an d modular programming ; i t has a powerful ye t simpl e syntax ; and—since i t i s a compiled language—i t i s fas t i n execution . 2. Th e styl e o f a PASCA L program , i n particula r th e us e o f indentin g an d th e availability of long descriptiv e variabl e names , leads to code tha t is easy to read and understand . 3. Variant s of PASCA L ar e commerciall y availabl e fo r al l computer s likel y t o b e encountered i n current use. Although there ar e slight difference s betwee n them , the origina l definitio n o f the languag e wa s sufficientl y precis e that these varia tions rarel y pos e a proble m i f a progra m mus t b e move d fro m on e versio n o f PASCAL to another . 4. Finally , i f yo u canno t tak e PASCA L a t an y price , then—sinc e othe r moder n languages such as QUICKBASIC, ADA, MODULA-2, o r C now share s o many of the features of PASCAL—conversion from PASCAL to any other language of your choice i s straightforward. I n fact, softwar e is available tha t can effec t suc h transformations automaticall y in many cases . The program s i n thi s boo k ar e writte n i n TURB O PASCAL ™ (versio n 5.0) , which i s perhaps th e most widel y use d form o f PASCAL for MS-DOS computers . These programs wil l also compile an d run, without any changes being necessary, in
CONSTRUCTING A SIMULATION
13
Microsoft QUICK PASCAL™ version 1.0 and higher. Other variants of PASCAL and other types of computers may require some modifications to the code, especially for the graphics commands. A disk (IBM/MS-DOS format) containing all of the code discussed in this text, as both source code and as compiled and executable code, is available from the author. Ordering details are given on the copyright page of this book.
2.4 Reading a PASCAL program The PASCAL program that implements the mathematical description derived above for the random walk simulation is as follows: Program Random—walk ; {this stimulates a simple random walk with equal-length steps} uses CRT,DOS,GRAPH ; {resource s required }
var CA,CB,CX,CY:extended; {directio n cosines } x , x n , y , y n , t h e t a , d i s t a n c e : e x t e n d e d ; {ste p variables } step:extended; {displa y variables } hstart,vstart:integer; {scree n center } i , t r i e s : i n t e g e r ; {counte r variables } GraphDriver:Integer; {whic h graphic s card? } GRAPHMODE:Integer; {whic h displa y mode? } ErrorCode:Integer; {i s ther e a problem? } Xasp,Yaspiword; {aspec t rati o o f screen } cons twopi = 6 .28318;
{2TT constant}
Procedure set—up—screen; {gets the required input data to run the simulation} begin {ensures screen is clean} ClrScr; GoToXY(10,5) ; writeln('Random Walk Simulation'); GoToXY(33, 5) ; {get number of steps} write ('.............hhow many steps?'); readln(tries); end;
Procedure initialize; {identify which graphics card is in use and initialize it}
14
MONTE CARLO MODELING
var
InGraphicsMode: Boolean ; PathToDriver:String; begin DirectVideo: =False; PathToDriver: = ' ' ; GraphDriver: =detect; InitGraph(GraphDriver,GRAPHMODE,PathToDriver); SetViewPort (0, O.GetMaxX,GetMaxY,True) ; [clip viewport} hstart: =trunc (GetMaxX/2) ; vstart: =trunc(GetMaxY/2); step: = (GetMaxX/50) ;
{horizontal midpoint of screen} {vertical midpoint of screen} {a suitable increment}
GetAspectRatio(Xasp,Yasp);
{find aspect ratio of this display}
end;
Procedure initialize—coordinates; {set up the starting values of all the parameters} begin
x:=0; y:=0; CX:=1.0; CY : = 0 . 0 ; randomize; {and reset the random-number generator}
end;
Procedure new_coord ; {computes the new coordinates xn,yn given x,y, var
VI,V2:extended ; begin VI : =c o s ( t h e t a ); V2: =s i n ( t h e t a ); CA:=CX*V1 - CY*V2 ; CB:=CY*V1 + CX*V2 ; xn:= x + step*CA ; yn:= y + step*CB ; {ne
end;
{new direction cosines}
w coordinates }
CX,CY and theta}
CONSTRUCTING A SIMULATION Procedure plot_xy(a,b,c,d:extended); {plots the step on the screen. Since all screen coordinates are integers, this conversion is made first. The real X,Y coordinates are separated from the plotting coordinates, which put X=Y=0 at the point hstart,vstart} var
ih, iv, ihn, ivn: integer;
{plotting variables}
begin ih:=hstart + trun c (x*Yasp/Xasp) ; {correc iv:=vstart + t r u n c ( y ) ;
t fo r aspect ratio}
ihn:=hstart + trun c (xn*Yasp/Xasp) ; {ditto ivn:=vstart + t r u n c ( y n ) ;
}
line (ih, iv, ihn, ivn) ;
{and draw the line}
end;
Procedure reset—coordinates ; {shifts coordinat e reference X, Y to new coordinates XN,YN and resets the direction cosines} begin x:=xn; y:=yn; CX:=CA; CY:=CB; end;
Procedure how—far ; {computes the distance traveled in the walk} label hang ;
var a,b:integer; s:string; begin distance:=sqrt((x-hstart)*(x-hstart) + distance:=distance/step;
(y-vstart)*(y-vstart) ) ;
{in step-lengt h units }
15
16
MONTE CARLO MODELING
a: =t r u n c ( G e t M a x X * 0 . 2 ); {adjus b:=trunc (GetMaxY*0 . 9) ; {ditto Str (distance : 3 : l , s) ; {conver
t for your screen} }
t nutnber to text string}
s : = c o n c a t ( s , 'step s fro m o r i g i n ' ) ; OutTextXY(a,b,concat ( ' T h e walke r traveled ' s ) ) ; hang:
{label for goto Call}
if (no t keypressed) the n got o hang ; closegraph; {tur
{keep display on screen} n off graphics}
end;
****mainatahe*****
begin set—up—screen; initialize; {fin
d graphics card and set it
up}
initialize—coord loop starts here
for i : = l t o trie s d o begin theta: =twopi*RANDOM;
{get deviation angle}
new_coord; {comput
e new position}
plot^xy(x,y,xn,yn);
{plot
reset—coordinates;
{move origin to XN, YN position}
d e l a y ( l O O ) ; {t
this step on screen}
o slo w down
display}
CONSTRUCTING A SIMULATION
17
end;
*
loop ends here
how—far;
*
{find out distance traveled}
end.
All PASCAL programs have exactly the same layout, which aids in following the code even though the format itself seems , at first, rather unusual. To further hel p the reade r t o follo w th e structur e an d logi c o f th e program , thi s boo k wil l als o employ a consistent se t o f typeface conventions whe n listing th e program s in th e text. If you decide t o type any of these programs int o your computer t o run them , then these bold and italic effects should , of course, be ignored. The program will be set i n Courie r typeface ; quote s fro m th e progra m code , procedure , an d function names , etc., will also b e se t i n the sam e typeface to identif y the m i n th e text. The firs t lin e in the listing alway s identifies the program name, here RANDO M WALK. Th e keyword PROGRAM will be printed in bold type to identify it . Note that this statement , lik e al l PASCA L statements , end s i n a semicolo n (;) . This i s th e "delimiter" tha t separate s on e progra m statemen t fro m th e next . Th e PASCA L compiler ignore s spaces and line breaks, following the program logic only from th e delimiters. I f desired , furthe r detail s abou t th e progra m ca n the n b e adde d a s a comment. In PASCAL, this is done by enclosing the text within {. . .} brackets. Fo r clarity i n the printed listings, comments wil l be shown in italics. Next, the resources require d b y the program ar e listed. Th e keyword uses, here printe d bold , i s followe d b y a lis t o f th e librarie s require d b y th e cod e tha t follows. I n thi s cas e th e CRT , DOS, an d GRAP H librarie s ar e needed . O n othe r computers or in other variants of PASCAL, the list of resources may be different o r missing altogether . The keywor d var , whic h wil l b e i n bold , introduce s a listin g o f al l th e variables use d in th e program, groupe d b y their type . Every variabl e i n PASCA L must b e define d befor e i t i s use d an d b e o f a typ e (e.g. , integer , longinteger , extended, real , Boolean , etc. ) recognized b y th e program . Onc e a variabl e i s "typed," its properties are fixed; s o if for some reason a particular numbe r is needed in mor e tha n one for m (fo r example , a s both a real numbe r and a n integer) , tw o variables must be defined an d the value converted fro m on e type to the other, using one of the special functions provided fo r this by the language. Variables listed at the start o f a program ar e GLOBA L variables ; that is , ever y part o f the progra m ca n read and write these quantities. Variables can also be defined within the procedures
18 MONT
E CARL O MODELIN G
and functions use d by the program (see below). In this case, the variables are local, or private, to the particular procedure or function i n which they appear an d are not available to other parts of the program. Note that PASCAL does not distinguish the case o f letters , s o dummy , DUMMY , an d Dumm y woul d al l refe r t o th e sam e quantity. CONST identifie s a lis t o f parameter s tha t wil l b e o f constan t valu e i n th e program, suc h as the length o f the ste p taken by the walke r and the coordinates o f the center o f the display screen. Onc e defined here, thes e quantities are also globa l in their effect. Constant s appearing in the CONST list do not appear in the VAR list, and their type is determined by the format assigned to them when they first appear. Thus CONST dumm
y=
5 ;
will defin e a constant o f integer type , while the statemen t CONST dumm
y=
5.0 ;
would defin e one wit h properties o f a real number . Onc e assigned , th e valu e of a constant canno t be changed; any attempt to do so will lead the compiler t o produce an error statement. Temporary constants—that is, ones whose values may be altered if required—are obtaine d b y a normal progra m lin e equatin g tw o variables : new-dummy : =5 .15 ; Note that assigning the value on the left-hand side of a statement t o value given on the right-hand sid e requires a ":=." The simple "=" implies a logical operation , a s in "i f A= B, " not th e ac t o f equatin g tw o values . Sinc e i t has bee n estimate d tha t 95% of all errors in PASCAL come from omissio n of the ";" and confusion betwee n " =" and ": =," care in copying these jots and tittle will be repaid by a reduction in the tim e it takes t o ge t a program running . Following thes e definitions , th e listin g contain s cod e fo r FUNCTIO N an d PROCEDURE routines. These pieces o f code play the role assigned to subroutines in some other languages . A function ha s the specifi c job o f performing som e defined mathematical operation . I t therefor e return s t o th e progra m lin e tha t calle d i t a n output o f som e type , an d this typ e mus t appear i n the definition . Thu s Function SUM: real; tells us that this is a function whos e output is a real number—fo r example , the sum of tw o o r mor e othe r numbers . I f th e functio n i s supplie d wit h dat a o n whic h t o
CONSTRUCTING A SIMULATIO N 1
9
work, the n bot h th e typ e of th e dat a supplie d an d o f th e outpu t returned mus t be given, so FUNCTION
black—box(a,b:integer):real;
takes i n data defined as integer but produce s as output a real number. Many func tions, such as sin or cosin or log, are already included in the language itself; but by writing the necessary code, as many new and specialized function s a s required can be added. A procedure, by comparison, can perform any legal set of operations and so has n o "type" of it s own. In either case , th e procedures an d function s mus t b e defined befor e they ar e calle d b y th e program , s o all o f th e cod e associate d with these items appears before the main body of the program. As far as possible, al l of the detai l i n a program i s carried ou t by procedure s an d functio n calls . Th e main program then simpl y lists the order i n which these ar e carried out . Thi s makes the logic of the program easy to follow, particularly if descriptive names are used for the functions an d procedures. Sinc e PASCA L imposes n o limitations o n the lengt h of names, it is worth choosing ones whose meaning will still be evident 6 months after a program is written (i.e., set_to_zero is descriptive and helpful, ST Z is not). Laying out program s i n thi s wa y als o make s i t eas y t o subsequentl y construc t ne w programs, sinc e th e components can be reused. The main program runs between the key words BEGIN and END, set in bold type. Fo r clarity , th e star t wil l als o usuall y b e identifie d b y a suitabl e lin e o f comment. In reading a program for the first time , therefore, the main program code should be identified, remembering that it is always at the end of the listing; then the procedures and functions should be studied as they are called b y the program. The program starts by calling th e procedure set_up_screen . which , as can be see n from the code for it, first clears the display screen, presents the program name ready for th e simulatio n to begin, an d asks for th e number of step s to be modeled . Since the purpose of this program is to plot the random walk on the screen, the next step is to set up the graphics display of the computer. This is complicated by the fact tha t MS-DO S machine s com e with a wid e variety o f graphica l displa y hardware. Th e procedure initializ e (take n directl y fro m th e TURB O PASCA L reference book s supplie d by Borland Inc.) determines automaticall y whic h type of graphics display (i.e., CGA, EGA, VGA, Hercules, etc.) is present in the computer at the time the program is run. I t then selects a "graphics driver program" (file s o n the dis k wit h th e extensio n .BGI ) tha t wil l interfac e th e compute r cod e t o th e hardware i n use. Provide d tha t our softwar e is written carefully enough, the sam e code will produce an acceptable output on any of the possible displays, even though these wil l differ i n parameters suc h as their resolution an d the shape of the screen . The starting point of the random walk is to be placed at the center of the screen, but th e coordinates o f this point will var y from on e type of display to another . We
20 MONT
E CARL O MODELING
therefore ask the machine to tell us how many picture points ("pixels") it can plot in the X (or horizontal) direction, using the call GetMaxX, an d how many in the Y (or vertical) direction, using GetMaxY. Th e center o f the scree n i s then, quite generally, a t th e coordinate s (GetMaxX/2 , GetMaxY/2) . I n plottin g o n th e screen , th e coordinates mus t b e give n a s intege r number , s o th e procedur e convert s th e rea l numbers (GetMaxX/2, GetMaxY/2 ) to integers (hstart, vstart) using the ' trunc ' function define d in PASCAL. Similarly, the step length is set to be one-fiftieth o f the width o f the screen i n the horizontal direction (i.e., GetMaxX/50). A final touc h is to fin d th e "aspec t ratio " o f th e display—tha t is , th e rati o o f a uni t ste p i n th e horizontal direction to a unit step in the vertical direction. This is obtained from th e call GetAspectRatio ( ) , whic h gives us the ratio Xasp/Yasp for the display in use. B y correcting for the aspect ratio of the screen, w e can ensure that the displays on the screen will look simila r for all the graphics card s supported by the software. The next procedur e used , initialize_coordinates , set s th e position variables x,y and the direction cosines CX,CY t o the desired startin g values. In some computer languages (e.g. , BASIC), all variables are automatically reset to zero each time the program i s run; bu t in PASCAL, the value assigned to a variable when the program start s is quite arbitrary, so it is necessary to explicitly set each to the value required. The procedure also resets the random number generator with the statement "randomize." The quality of a Monte Carlo simulation depends to a great extent on the quality of the random numbers with which it is supplied, since if these exhibit any patterns in their behavior or if a given number repeats within a limited number of calls, the output data will be flawed. The random-number generators i n TURBO PASCAL (and QUICK PASCAL) , summone d b y th e cal l RANDO M ar e quit e wel l behaved provide d tha t th e generato r i s periodicall y rerandomize d usin g th e cal l RANDOMIZE. Althoug h it is not a documented feature, it can also be noted that if the initial RANDOMIZE statemen t i s omitted (o r placed withi n {. .} comment brackets), the n th e sam e strin g o f rando m number s wil l b e generate d ever y tim e th e program i s run. This can, in some cases, b e usefu l fo r debuggin g a simulation and also i n examining th e effec t o f changing a singl e paramete r i n a simulation . The program now calls the procedure new_coord, which calculates the new coordinates xn, yn give n the startin g coordinate s x, y; the initial directio n cosine s CX, CY; th e deflectio n angl e 0 ; an d th e ste p length , using th e formula s derive d above. Because all of these variables have been declared to be global by being listed at the start of the program, no variables need be passed t o the procedure. Th e effec t of this step is then displaye d on the screen, usin g the procedure plot_xy, whic h draws the step on the screen. Note that since the graphics routines that place pixel s on th e scree n nee d intege r number s a s input , the procedure mus t first conver t th e actual rea l numbe r coordinates x, y, xn, yn t o loca l intege r variables ix, iy, ixn, iyn using the trunc function supplie d in TURBO PASCAL . Th e origin o f the simulation (x = 0 , y = 0) is plotted at the center of the screen (hstart,vstart) and the coordinat e system is suc h tha t a positive x valu e moves the point t o the right an d a positive y
CONSTRUCTING A SIMULATIO N 2
1
value moves the point downward. As discussed in the procedure Initialize , th e distance plotted in the x direction (horizontal ) is corrected fo r the aspect ratio of the display screen i n use, so that all screens will give roughly equivalent displays. Note that if the line being drawn has coordinates tha t would place it off the screen (tha t is if ih or ihn does not lie between 0 and GetMaxX, or if iv or ivn does not lie between 0 and GetMaxY), then the command SetViewPort, whic h appears in the procedure initialize, wil l automatically "clip" the plot at the edges of the CRT. The program will continue to run, but plotting wil l not resume until the line again lies in the visibl e regio n o f th e screen . Th e plot-xy procedur e i s on e o f the buildin g blocks tha t w e wil l b e usin g agai n i n late r chapters . Next , th e progra m call s th e procedure reset^coordinates, whic h shifts th e origin of the calculation fro m x t o xn, and y t o yn, an d reset s th e directio n cosines . A standar d TURB O PASCA L command Delay () i s then called. The purpose of this is simply to slow down the action of the loop so that it can be watched more easily on the screen. The delay time is approximately equal to the parameter passed to the function i n milliseconds, thus Delay (100) wil l hold u p the loop for about one-tenth o f a second . Th e loop i s then repeated unti l th e desired numbe r o f step s has bee n calculated . The program the n exits fro m th e loop, an d the distance between th e start and finish coordinate s i s computed using the procedure how_ f ar. Thi s use s Pythagoras's theore m t o find th e distanc e o f the walke r from th e startin g point in units a step i n length. Sinc e th e compute r i s now i n graphics mode , thes e dat a canno t b e simply printed to the screen bu t must be drawn on the CRT as if it were a piece of a graph. First, the numerical valu e is converted to a string (i.e., a list of letters, digits , or symbols ) usin g th e standar d TURB O PASCA L command St r ( ) . Th e ":3:1" which follows the distance variable formats the result as three digits, one of which is after the decimal point. The string is assigned to a variable s, which is declared at the start o f th e procedure ; i t i s therefor e a loca l variabl e (existin g onl y withi n thi s procedure). Th e string s is then concatenated (i.e. , added ) to other string s of text to form th e messag e draw n o n th e scree n b y th e comman d OutTextX Y ( ). Th e message i s draw n startin g a t th e coordinate s a,b, whic h are , again, loca l t o thi s procedure. Sinc e w e wis h on e piec e o f cod e t o serv e fo r al l types o f display , th e values of a and b are chosen a s fractions of GetMaxX and GetMaxY. Since personal preferences abou t th e appearanc e o f th e displa y ma y vary , however , th e actua l values can readily b e changed to place the text at any other desired position o n the screen. In fact, changing the values of a and b and then recompiling an d rerunning the program t o se e the result is a n excellent wa y for users withou t much practical experience wit h computer s t o gai n proficienc y i n modifyin g th e cod e an d s o t o overcome an y fear of the dire results of "interfering" with the program. Note that if a and/o r b ar e chose n t o b e large r tha n GetMax X o r GetMaxY , th e tex t ma y disappear becaus e th e comman d SetViewPort , i n th e procedur e initialize , "clips" the displa y a t th e edge s o f the screen . I n orde r t o hol d th e displa y o n th e screen so that it can be examined or printed out, this procedure finishes with a loop.
22 MONT
E CARL O MODELING
The command keypressed call s a standard function tha t checks whethe r o r not any key has been touched. The output o f the function i s a Boolean (i.e., it has the value tru e or false). In PASCAL, the code statemen t if (function) then (operation) will lea d t o th e operatio n bein g performe d i f th e functio n evaluate s to a positiv e number or produces a Boolean variabl e wit h the value "true" (i.e., +1) . If, on the other hand , th e functio n evaluates t o zer o o r to a negative numbe r o r produces a Boolean variable with the value "false" (i.e. , 0) then the operation is not performed. Here, i f keypressed i s "false" (i.e. , n o key wa s touched) the n th e expression no t keypressed has the value "true," so the program goes back to the label hang and continues t o cycle around until eventually some key on the keyboard is struc k and the procedure i s exited . It may seem to be overelaborate t o present a simple program in this structured way, bu t adherenc e t o thi s forma t produce s cod e tha t i s eas y t o follow . A s th e programs in this book become longe r and more complex, the benefits of its use will be mor e evident . Debuggin g th e progra m i s als o mad e easie r becaus e a whol e procedure o r function ca n b e dropped out by simply placing {. . .} brackets around the call t o it, allowing th e errant region o f the program to be quickly identified. In addition, by doing all of the real work in a program in the procedures an d functions, a librar y o f progra m module s i s buil t u p tha t make s i t possibl e t o pu t togethe r a special-purpose program wit h the minimum of effort. Onc e a procedure or function has been debugge d and tested i n one program, i t can safel y b e moved into anothe r program wit h the certai n knowledg e tha t it will wor k as expected . Finally i t must be pointed ou t that the code, a s given here, doe s violate on e of the accepte d principle s o f "good programming" i n that global variable s (i.e. , variables declared at the beginning of the program and so visible to all of the procedures and function ) ar e used . "Good " practice trie s t o avoi d th e possibl e sid e effect s o f global variables, suc h as the inadvertent corruption of a variable by a faulty proce dure, by only passing copies o f the variables to the procedures a s they are required. However, in the electron bea m simulations that follow, as many as 15 or 20 differen t variables ma y be required t o describ e th e current statu s of the electron , an d al l of these may be needed b y an y given procedure o r function. Writin g the code t o pass this number of variables t o a procedure is cumbersome and the resulting operation i s also slow, so the code give n here respects th e spirit of the injunction against globa l variables bu t use s them anywa y in th e interest s o f convenienc e an d speed . Fo r a more detailed discussion o f this topic, for other questions related to programming in PASCAL, o r fo r informatio n o n compiling , editing , o r runnin g TURB O PASCA L programs, see the documentation supplied with the program or read one of the many books o n this language.
CONSTRUCTING A SIMULATIO N 2
3
2.5 Running the simulation If the programs ar e available on disk, then this simulation ca n be run by booting the computer in the usual way from either a hard disk or a floppy disk and obtaining the ">" prompt. I f th e computer wa s booted fro m a floppy, then remove thi s syste m disk and insert the disk with the Monte Carlo programs on and type Randomwalk. at the ">" prompt. Be sure that the disk (if it is a copy) has the .BGI graphics driver files o n it or else th e progra m wil l crash. I f the compute r wa s booted fro m a hard disk, then put the program floppy in the first available drive (usually labeled A:) and type A:Randomwalk. I f th e progra m ha s bee n type d int o th e compute r fro m th e listing, the n sav e i t t o dis k before compilin g an d running it , usin g the instructio n provided b y th e relevan t manua l for th e languag e chosen . I f yo u ar e plannin g t o make an y changes t o th e program, always wor k fro m a copy rathe r tha n fro m a n original. When th e welcom e scree n appears , ente r th e numbe r o f step s required , hi t return, an d the simulatio n wil l run. To generate anothe r run , hit retur n (t o get th e ">" prompt onc e more) . I f your keyboard ha s function keys , then hittin g F l wil l redisplay th e origina l instructio n (i.e. , "A:Randomwalk") , an d hitting Retur n will cause th e progra m t o restart . Otherwis e repea t th e proces s a s describe d above . Figure 2.3 shows some typical results for 200-step simulations. Every run will give a different track , and each will give a different distanc e between the start and finish of the walk. As is evident fro m Fig . 2.4, whic h plots distances recorded for severa l
Figure 2.3. Si x random walks , each o f 200 steps .
24 MONT
E CARL O MODELIN G
Figure 2.4. Summar y o f random wal k data .
successive run s a t a give n numbe r o f steps , the radia l distanc e travele d fro m th e starting poin t ca n var y ove r a wid e range . Thi s i s t o b e expected , becaus e th e simulation is, in effect, takin g samples of a random walk and there will therefore be a statistica l scatte r i n th e dat a point s obtained . I f th e sample s ar e assume d t o b e independent, whic h implies among other things that the random numbers used in the simulation are really random and not in any way related, the n the relative precisio n of the result will be proportional t o the inverse of the squar e root of the number of samples taken. Thus a relative precision of 10 % would be achieved o n 100 samples, while t o reac h a 1 % precision woul d requir e 10,00 0 samples . S o whil e a singl e simulation of a random walk of a given number of steps would produce little usefu l information, a serie s o f suc h simulations , whe n averaged , woul d giv e u s a mea n distance traveled an d an estimate of the relative precision o f this mean value. Thus plotting (see Fig. 2.4) the average value of the distance traveled, determined fro m all the simulations using the same number of steps, as a function o f the number of steps taken give s a series o f values that falls clos e to the predicted theoretica l resul t that the distanc e travele d i s equa l t o th e squar e roo t o f the numbe r o f step s taken. A n essential requiremen t o f any Mont e Carl o simulation , therefore , i s the necessit y t o repeat the simulatio n a sufficientl y larg e numbe r o f times to obtain a statisticall y meaningful result .
3
THE SINGLE SCATTERING MODEL
3.1 Introduction In thi s chapte r w e wil l develo p a Mont e Carl o mode l fo r th e interactio n o f a n electron beam with a solid using the "single scattering " approximation . Withi n the limits discussed below, this model is the most accurate representation of the electro n interaction that we can construct, an d it is capable of giving excellent result s over a wide range of conditions and materials. Thi s program , together wit h the faster but less detailed "plura l scattering" mode l developed in the following chapter, will form the framewor k aroun d whic h specifi c application s o f Mont e Carl o modelin g t o problems in electron microscop y an d microanalysis will be generated i n subsequent chapters.
3.2 Assumptions of the single scattering model The single scatterin g Monte Carl o simulation calculates the passage of the electron through the solid by tracking it from on e interaction to the next. In principle, these interactions coul d b e eithe r elasti c o r inelastic , s o th e resultan t change s i n th e direction of motion and the energy o f the electron would be computed o n the basis of the specific sequenc e o f scattering event s that each electron suffered . Whil e this is a feasible way of tackling the problem, it has the disadvantage that because not all scattering events are equally important—in terms of their effect o n the trajectory or energy—or probable , th e amoun t o f computatio n require d become s excessivel y large. Th e procedure described her e makes two significant assumptions to provid e an accurat e simulatio n while minimizing the amoun t of calculation required . 1. Only elastic scatterin g events ar e considered i n determining th e path taken by an y given electron. Elasti c scatterin g i s the net deviation that the incident elec tron undergoe s a s a resul t o f th e coulombi c attractio n betwee n th e negativel y charged electro n an d the positively charge d atomi c nucleus and the correspondin g repulsion betwee n th e orbitin g electron s an d th e inciden t electron . Thi s process , which is described mathematicall y by the screened Rutherford cross section, results in angular deflections of from typicall y 5° to 180° . (For an excellent concis e discussion o n electron scatterin g phenomen a se e Egerton, 1987. ) Inelasti c scattering , on the othe r hand , produces deflection s o f the orde r A£/ £ [i.e. , the rati o o f AE , th e 25
26 MONT
E CARL O MODELIN G
energy los t i n the event , to E, th e energy o f the electro n (Egerton , 1987)] . Thus a 10-keV electron whic h deposits 1 5 eV in an inelastic collisio n i s deflected throug h an angl e o f abou t (15/10,000 ) radian s (i.e. , 1. 5 milliradian s o r abou t 0.1°) . A n electron that loses more energy in an inelastic event is, of course, deflected through a larger angle, but the probability o f these events is proportional t o about 1/AE , so only a smal l fractio n o f inelasti c event s wil l produce significan t deviations of th e trajectory. Consequentl y elasti c scatterin g event s ar e th e one s tha t dominat e i n determining th e spatia l distributio n o f th e interaction ; ignorin g th e effect s o f th e inelastic scatterin g produce s littl e error . 2. The electron i s assumed to lose energy continuously along its path at a rate determined b y th e Beth e relationshi p rathe r tha n a s th e result o f discret e inelasti c events. While some energy loss mechanisms are continuous, such as the production of Bremsstrahlung ("brakin g radiation" ) b y the slowin g down of the incident elec tron a s a consequenc e o f electron-electro n interactions , mos t energ y losse s ar e associated wit h a specific event such as the production of an inner shell ionization . However, th e averagin g o f al l suc h effect s alon g th e pat h take n b y th e electron s leads to a convenient simplificatio n in which all possible types of inelastic event are taken accoun t of b y on e simpl e expressio n involvin g onl y a singl e variable . Thi s model of continuous energy loss i s therefore in almost universal use—although, as discussed later , significan t modifications to its functional form ma y become neces sary a t lo w bea m energies .
3.3 The single scattering model The basic geometry for the simulation (Fig. 3.1) assumes that the electron undergoes an elastic scatterin g even t at some point Pn, having traveled t o Pn fro m a previous scattering even t at Pn~l. The fundamental tas k of the simulation is to compute th e coordinates o f th e poin t Pn+l t o whic h th e electro n travel s a s a resul t o f th e scattering event at Pn. The parameters that describ e the instantaneous situatio n o f the electron ar e its energy E and the direction cosine s o f the trajectory segmen t that brought it from Pn-1 to Pn. The direction cosine s ex, cy, cz are defined in the same way as the direction cosine s employed in the random walk simulation except that in this three-dimensiona l situatio n ther e ar e no w thre e rathe r tha n tw o axe s t o b e considered. Th e X, Y, and Z axes in all the simulations in this book are defined with the conventio n tha t th e positiv e Z axi s i s norma l t o th e specime n surfac e an d directed int o the specimen, the X axis is parallel t o the tilt axis, and the X-Y plane is the surfac e plane o f th e untilte d sample . Whe n th e sampl e i s tilted , th e positiv e direction o f the Y axis i s down the surfac e o f the specimen . To calculate th e position o f the new scatterin g poin t Fn+1, we first requir e t o know th e distance , o r "step, " betwee n Pn+l an d the precedin g poin t Pn. A s dis cussed above , a n assumption of this particular model is that only elastic scatterin g events are explicitly considered. Th e distance between successiv e scattering events
THE SINGL E SCATTERIN G MODE L 2
7
Figure 3.1. Definitio n o f coordinate system use d i n the Monte Carl o simulation progra m i n this chapter .
is therefore related to the elastic mea n free path—which, in turn, is a function o f the elastic cros s sectio n a £. The total screene d Rutherfor d elasti c cros s sectio n cr £ is given by the relation (Newbur y an d Myklebust, 1981) :
where E is the electron energy i n kilo-electron volts , Z is the atomic number of the target, an d a i s a "screenin g factor " tha t account s fo r th e fac t tha t th e inciden t electron does not see all of the charge on the nucleus because of the cloud of orbiting electrons, a i s usuall y evaluate d usin g a n analytica l approximation , suc h a s that given by Bisho p (1976) :
28 MONT
E CARL O MODELIN G
The cros s sectio n crB define s a mea n fre e pat h X , which i s give n b y th e formula :
where Na i s Avogadro's number , p is the density of the target i n g/cm3, and A is the atomic weigh t o f th e targe t i n g/mole . X represents th e averag e distanc e tha t a n electron wil l travel between successiv e elastic scatterin g events . Calculating X from the formulas above fo r a selection of elements show s (Tabl e 3.1 ) that X is typically of the orde r o f a few hundre d angstrom s a t 10 0 keV an d abou t one-tenth o f that at 10 keV. Material s wit h highe r atomi c number s caus e mor e elasti c scatterin g tha n elements o f lower atomi c number , therefor e the y hav e a shorte r mea n fre e path . The actual distance that a n electron travels betwee n successive elastic scatterings will , of course , var y in a random fashion . Th e probabilit y p(s) o f a n electro n traveling a distance s whe n th e mea n fre e pat h i s X is
An estimat e fo r th e distanc e actuall y travele d ca n the n b e foun d b y choosin g a random numbe r RN D an d solving Eq . (1.1 ) i n the for m
which give s
Table 3.1 Elastic mean free paths Element
Z
Carbon 6 Silicon 1 Copper 2 Gold 7
131 4 111 9 29 98
X at 100 keV 0 A 17 2 A 12 7A 3 9A 1
X at 10 keV 0A 7A 5A 0A
THE SINGL E SCATTERIN G MODE L 2
9
Figure 3.2. Variatio n o f step length, in units of the mean fre e path, wit h the random numbe r chosen.
and hence
(since RN D i s a rando m numbe r betwee n 0 an d 1, 1 — RND i s als o a rando m number i n the sam e rang e an d s o can be replaced b y ye t anothe r random number RND). Figure 3.2 plots the variation of step length, in units of X , as a function o f the random number chosen, using the result of Eq. (3.7). Since the random numbers are uniformly distribute d betwee n 0 an d 1 , there is , fo r example , a 10 % chanc e o f drawing a number suc h tha t RND s 0. 1 and so (from Fig . 3.2 ) o f getting a step length such that s ^ 2. 3 X. Equally there is a 10% chance of drawing a number such that RND 3: 0.9, in which case the step length s < 0.1 X. The step lengths therefor e vary ove r a wide range o f values, depending o n the random number picked by th e computer. However, as is readily shown from Eq. (3.7), the average value of the step length s resulting from a large number of tries will be X, as would be expected fro m the definitio n o f X as th e average distance betwee n successiv e scatterings . In th e scatterin g even t a t Pn, which marks th e star t o f th e step , th e electro n is deflecte d throug h som e angl e (j > relativ e t o it s previou s direction o f trave l (se e Fig. 3.1) . Th e wa y i n whic h thi s scatterin g occur s i s describe d b y o-' , th e angu lar differentia l for m o f th e Rutherfor d cross sectio n (e.g. , Reime r an d Krefting , 1976):
30 MONT
E CARLO MODELING
where a i s the screenin g paramete r discusse d above . A n appropriat e functio n t o select a scattering angl e using a random number can then be obtained from a further application o f Eq. (1.1 ) in the form :
This integration, using the result for <JE given in Eq. (3.1), yields the relation for the scattering angl e (Newbur y an d Myklebust, 1981) :
This equatio n generate s a uniqu e scatterin g angl e i n th e rang e 0 < 4 > < 180° , producing a n angula r distributio n tha t matche s th e on e obtaine d experimentally . Although the full range of angles between 1 and 180 ° is available, th e great majority of scatterin g event s are predicted b y Eq. (3.10) to be low-angle—that is, less than about 10° . Figure 3.3 plots the probability o f obtaining a scattering angle 4 > greate r than some minimum value $ for the particular case of a silicon targe t irradiated at 100 keV. Note tha t whil e there i s onl y a 1 in 10,00 0 chance o f a n electro n bein g scattered by an angle in excess of 110°, more than 50% of all electrons are scattered through at least 1.5° . The electron ca n scatte r freel y t o any point on the base o f the cone show n in Fig. 3.1 . The azimutha l scattering angl e \\i i s then given a s
Figure 3.3. Probabilit y o f elastic scattering angl e exceeding some specified minimu m value .
THE SINGL E SCATTERIN G MODE L 3
1
where RND i s an independent random number selected by the computer. Since <}> , i|<, and the step length are now determined, the relationship o f Fn+1 to Pn can now be found. Th e procedur e i s simila r t o that used i n Chap. 2 , except that the motion is now i n thre e rathe r tha n tw o dimensions . A s before , th e pat h i s describe d usin g direction cosines, ca, cb, and now cc. The coordinates at the end of the step at Pn+1, xn, yn, an d zn, are then related t o the coordinates x, y, z at Pn b y the formula s
The direction cosines ca, cb, cc are, as previously, found from the direction cosine s ex, cy, and c z with which the electro n reache d Pn. The derivatio n o f the require d transformation fro m ex, cy, and cz to ca, cb, and cc is similar in outline to that given in Chap. 2 but is more complex because of the extra dimension. The result (modified from th e derivatio n of Myklebust et al., 1976 ) i s
where
and
32 MONT
E CARL O MODELIN G
Note tha t the su m of the square s o f the directio n cosine s i s alway s equa l to unity,
As th e electro n travel s throug h th e specimen , i t lose s energ y continuousl y because o f th e dra g exerte d o n th e negativel y charge d electro n b y th e positivel y charged nuclei surrounding it; it also loses energy during discrete inelastic scatterin g events such as the horizon or production of a plasmon. The most complete approac h to accounting for these energy losses would be to incorporate the m individually into the simulation , bu t thi s is a relatively lengthy procedure becaus e o f the number of different possibilitie s available . Instead , w e make th e assumptio n that the effec t o f both th e electrostatic dra g o n the electron an d the discrete energ y losse s occurrin g during inelastic scatterin g event s can be combined an d approximated by a model in which the inciden t electro n i s slowin g dow n continuously as it travels. Th e rate at which energy is lost by the incident electro n wa s shown by Bethe in a classic pape r (1930) t o be expressibl e i n the form :
where (dE/dS) i s sometimes referre d t o a s the "stoppin g power " o f the target , E i s the energ y o f electro n (i n kilo-electron volts ) Z an d A are respectively th e atomi c number and atomic weigh t of the target, and S is the product of p the density of the target (i n g/cm3) and the distance travele d alon g the trajectory s. J, whic h has units of kilo-electro n volts , i s calle d the mean ionization potential an d represent s th e effective averag e energy los s per interactio n betwee n th e incident electron an d th e solid. Thi s singl e parameter incorporate s int o its value all possible mechanism s fo r energy los s tha t th e electro n ca n encounter , thu s allowin g th e Beth e equatio n t o provide a convenient and compact way of accounting for the variety of energy losses experienced. / ha s been measure d experimentally , usin g nuclea r physic s techniques , fo r a wide rang e o f material s an d compound s (see fo r exampl e ICRU , 1983) . Table 3. 2 gives value s for some common element s (i n solid form) , an d it can be see n that , in general, there is a monotonic and almost linear increase of/ wit h the atomic number of the element. Berge r an d Seltzer (1964 ) showed that this variation could be fitte d with good accurac y by th e relatio n
and a comparison o f this expression wit h the data in Table 3.2, for example, for silicon (Z = 14 ) and gold (Z = 79), shows that the fitted value and the experimental value are
THE SINGL E SCATTERIN G MODE L 3
3
Table 3.2 Measured values of mean ionization potential J Element
/(eV)
H 21. Li 40. Be 63. B 76. C 78. Na 14 Al 16 Si 17 Ca 19 Sc 21 Ti 23 V 24
8C 0M 7F 0C 0N 9C 6Z 3G 1G 6Z 3N 5M
Element r 25 n 27 e 28 o 29 i 31 u 32 n 33 a 33 e 35 r 39 b 41 o 42
J(eV) 7P 2A 6C 7S 1G 2T 0W 4P 0A 3P 7U 4
Element d 47 g 47 d 46 n 48 d 59 a 71 72 t 79 u 79 b 82 89
/(eV) 0 0 9 8 1 8 4 0 0 3 0
within a few electron volts of each other. For compounds, th e appropriate value of/ can again be found usin g Eq. (3.18), but replacing Z by Zav, the mean value of Z for the compound. So, for example, if a material has the composition AB 2 (i.e., 33 atomic % of A an d 66 % o f B), the n
where ZA an d ZB ar e th e atomi c weight s o f A an d B respectively . Thi s simpl e average in most cases produces a value for Zav, and thus for /, whic h is of accept able accuracy. I n the case o f complex materials, however, th e composition ma y not be known. Table 3. 3 therefore give s /values, again derived fro m th e ICRU (1983 ) report, fo r som e compound s likel y t o b e encountere d i n electro n microscopy . Al though thi s lis t i s fa r fro m exhaustive , i t doe s giv e a usefu l guid e a s t o probabl e values fo r generi c type s o f materials . Table 3.3 Measured values of mean ionization potential J Material JT(eV Nylon 63. Teflon 99. Paraffin wa x 48. PMMA 74. Polyethylene 57. Polystyrene 68. Plastic 64. scintillator emulsio
)
Material J(eV
)
Material J(eV
9 Aluminu m oxid e 14 5 Adipos e tissue 6 1 Calciu mffluoride11111166 pbone 1107 3 Lithiu mffluoride 94 4Muscle 75 0 Silico n dioxid e 13 9 Ski n7 4 Sodiu m iodide 45 2 Ai r ( 1 atm.) 8 7 "Pyrex " glass 13 4 Bloo d7 7 Photographi c 64. 7 Liqui d water 7 n
) 3 4 6 5 5
34 MONT
E CARL O MODELIN G
Figure 3.4. Stoppin g powe r fo r copper compute d fro m Beth e expression.
Using eithe r th e measure d o r compute d valu e o f /, Eq . (3.17 ) ca n no w be evaluated fo r a give n electro n energ y E. Figur e 3. 4 attempt s t o plo t th e rat e o f energy loss , (-dE/ds), o r p(dE/dS), fo r coppe r ( p = 7. 6 g/cm 3) ove r th e energ y range 10 0 eV to 10 0 keV. The predicted energy-los s values show a steady increas e from abou t 0.1 eV pe r angstro m a t 10 0 keV u p t o almos t 1 0 eV pe r angstro m a t beam energies of a few kilo-electron volts. These values ar e typical of those found in all materials. However at an energy of about 2 keV, the curve reaches a maximum value before starting to fall rapidly as the energy is further reduced. This behavior is obviously no t physicall y realistic bu t come s fro m th e chang e i n sig n o f th e log arithmic term in Eq. (3.17) when £ < /. Therefore , while the Bethe stopping-power formula is an excellent approximation for energies such that E > /, it cannot be used at lowe r energie s withou t encounterin g problems . I n particular , sinc e / i s o f the order o f 0. 3 t o 0. 6 ke V fo r mos t materials , th e simulatio n o f th e trajector y o f electrons traveling with initial energies of 1 to 1 0 keV (i.e., typical energies encoun tered in a scanning electron microscope ) will be difficult, sinc e a significant part of the trajector y wil l occu r i n th e energ y rang e wher e th e Beth e relatio n canno t b e applied. This problem can be overcome wit h a method due to Rao-Sahib and Wittry (1974). This is a parabolic extrapolation fro m th e tangent to the Bethe curve at the energy E = 6.4 J, where the curve has an inflection, down to E - 0 . Thus for E < 6.4 /, Eq. (3.17) is replaced b y the expression :
THE SINGLE SCATTERING MODEL
35
Figure 3.5. Compariso n of stopping power for copper from Bethe expression, Rao-Sahib and Wittry extrapolation , and Tung e t al. calculation.
This expression provides a convenient extrapolation tha t is well behaved ove r the lo w energ y range , an d s o this approximatio n has bee n widel y used i n Mont e Carlo simulations . I t is not, however, either physically realistic o r accurate. Figure 3.5 compares the rate o f energy loss , (-dE/ds), o r p(dE/dS), fo r copper ( p = 7. 6 g/cm3) ove r the energy range 10 0 eV to 10 0 keV, obtained using the Bethe mode l and the Rao-Sahib-Wittry extrapolation, wit h the results o f detailed computation s by Tun g e t al . (1979) . Th e agreemen t betwee n th e composit e Bethe-Rao-Sahib Wittry profile and the Tung et al. data is satisfactory at energies down to a few kiloelectron volts . However , onc e th e energ y fall s belo w 1 keV, neithe r th e original Bethe curve nor the Rao-Sahib-Wittry extrapolation is close to the Tung et al. value, the error being a factor of two to three times at an energy of a few hundred electron volts. Th e sam e sor t o f resul t i s foun d fo r al l othe r elements , wit h th e error s becoming wors e for high atomi c numbers , sinc e thes e hav e a larger / value [Eq . (3.18)]; consequently th e Bethe expression becomes unusable a t energies a s high as a 4 or 5 keV. We ca n simultaneousl y escap e th e mathematica l singularit y o f th e origina l Bethe expression , eliminat e th e nee d t o us e th e Rao-Sahib-Wittr y extrapolation , and improve the accuracy of the stopping power as compared to the Tung et al. data by using a modified version of the Bethe equation suggested by Joy and Luo (1989). We write the stoppin g power as:
36 MONT
E CARL O MODELIN G
Figure 3.6. Compariso n o f stoppin g power fo r coppe r fro m modifie d Beth e law , wit h dat a from Tun g e t al .
At high energies E> J, this expression converge s t o the original Beth e expressio n of Eq . (3.17 ) bu t th e additio n o f th e extr a ter m 0.8 5 / i n th e numerato r o f the logarithmic term ensures that for all positive values of E the log term evaluates to a positive quantity. As shown in Fig. 3.6 , this modified expression is now a very good fit to the Tung et al. data for all energies above 50 eV. It can be shown that this result is equally applicabl e t o al l other element s an d compounds o f interest, producin g a stopping powe r valu e whic h agree s wel l wit h mor e detaile d calculation s fo r al l energies abov e a few tens of electron volts . This expression [Eq . (3.21)] is therefore used i n this book . The sequence o f operations neede d t o simulate the electron trajector y through the specime n ca n no w b e writte n schematicall y i n a n algorithmi c form . Conven tionally th e electro n i s allowe d t o penetrat e th e firs t ste p lengt h int o th e sampl e before bein g scattered . Thu s the procedure is : Calculate initial entr y dept h int o sampl e [Eq . (3.7) ] then repeat Get startin g energ y E o f the electro n Determine initia l coordinates x, y, z for this ste p Find th e directio n cosine s ex, cy, cz of its motio n relative t o th e axe s Compute the mean free pat h \ fo r this material and energy E [Eq . (3.3) ] Calculate th e ste p lengt h [Eq . (3.7) ] Find th e scatterin g angle s 4> , fy from Eqs . (3.10 ) an d (3.11 )
THE SINGLE SCATTERING MODEL
37
Find finis h coordinate s xn, yn, zn for this ste p [Eqs . (3.12) to (3.15)] Compute final energ y for thi s step E' = E — step*p*(dE/ds) Reset coordinates x = xn, y = yn, z = zn Reset directio n cosines ex — ca, cy = cb, cz = cc Reset energy E *= £ " until the electron leaves the sample or falls below some minimum energy The PASCA L code tha t implement s this outlin e i s se t ou t below , usin g the conventions introduce d in the previous chapter. Note that, by design, the program eliminates pleasing but unessential features like the use of color, or windows, so as to keep the cod e a s clear an d easy to follo w a s possible.
3.4 The single scattering Monte Carlo code Program SingleScatter; {a single scattering Monte Carlo simulation which uses the screened Rutherford cross section] {$N+} {$E+}
{turn on numeric coprocessor] {turn on emulator package]
uses CRT,DOS,GRAPH;
{resources required]
label
exit;
const
two_pi = 6.28318; e_min=0.5;
{2ir} {cutoff energy in keV in bulk case}
var at_num,at_wht,density,inc_energy,mn_ion_pot:extended; al_a,bk_sct,cp,er,ga,lam_a,sp,sg_a,:extended; ca,cb,cc,ex,cy,cz,x,y,z,xn,yn,zn:extended; del_E,m_step,m_t_step,s_en,step:extended; hplot_scale,m_f_p,plot—scale,thick:extended; count,k,num,traj—num:integer; bottom,center,top:integer; thin:Boolean; GraphDriver:Integer; GRAPHMODE:Integer; ErrorCode:Integer; Xasp,Yasp:word; Function power(mantissa,exponent:real):real; {because PASCAL does not have an exponentiation function}
38
MONTE CARLO MODELING
begin if mantissa< = 0 then power:=0 else power :=exp(In(mantissa)*exponent) ; end; Function stop_pwr(energy:real):real; {this computes the stopping power in keV/g/cnt2 using the modified Bethe expression of Eg. (3.21)} var temp:extended; begin if energy<0.05 then energy: =0 . 05 ; {just in case} temp: =ln(l .166* (energy+ 0 . 85*mn_ion^>ot) /mn_ion_pot) ; stop_pwr: =temp*78500*at_num/ (at_wht*energy) ; end; Function lambda(energy:real):real; {computes elastic MFP for single scattering model} var al,ak,sg:real; begin al: =al_a/energy; ak:=al*(l.+al); {giving sg cross-section in cm2 as] sg:=sg_a/(energy*energy*ak); {and lambda in angstroms is} lambda: =lam_a/sg; end; Function yes:Boolean; {reads the keyboard for 'y' or 'Y'} var ch.-char; begin read(ch); if ch in ['Y', 'y'] then yes:=true else yes: =false; end; Procedure get—constants; {computes some constants needed by the program} begin al_a:=power (at_num, 0.67) *3.43E-3; {relativistically correct the beam energy for use up to 500 keV\ er: = (inc_energy+511.0) / ( i n c _ e n e r g y + 1 0 2 2 . 0 ) ; er:=er*er; lam_a:=at_wht/ (density* 6 . OE23 ) ; {lambda in cm}
THE SINGLE SCATTERING MODEL
39
lam_a:=lam_a*1.0E8; {pu t into angstroms} sg_a:=at_num*at_num*12. 56*5.21E-21*er; end;
Procedure set—up—screen; {gets the input data to run this program} begin ClrScr; {erases all previous data from screen} GoToXY(22,1); Writeln ('Single Scattering Monte Carlo Simulation'); {Having set up the screen, now get input data} GoToXY(1,5); Write ('Input beam energy in keV ) ; Readln(Inc_Energy); GoToXY(1,7); Write('Target Atomic Number is'); Readln(at-num); {Calculate J the mean ionization potential mn—ion—pot using the Berger-Selzer analytical fit} mn_ion_pot: = (9 .76*at_num + (58 . 5 /power (at_num, 0 .19 ) ) ) *0 . 001 ; GoToXY(1,9); Write('Target Atomic Weight is'); Readln(At-wht); GoToXY(1,11); Write('Target density in g/cc is'); Readln(Density); GoToXY(40,5); write('Is this a bulk specimen (Y/N)?'); if ye s the n {it' s thick} begin {s o estimate the beam range for graphics t h i c k : = 7 0 0 . 0*power(inc—energy,1.66)/density; if thick<1000. 0 the n thick : =1 0 0 0 . 0; thin: = false;; end else {it' s thin } begin GoToXY(40,7);
scale}
40
MONTE CARLO MODELING
write('Foil thickness (A)') ; readln(thick); thin:=true; end; {get the number of trajectories to be run in this simulation} GoToXY(40,9); write('Number of trajectories required'); readln(traj_num); end; Procedure initialize; {sets up the graphics drivers for version 5.0 TURBO PASCAL}
var InGraphicsMode:Boolean; PathToDriver:String; begin Directvideo: =False; PathToDriver: = ' '; GraphDriver: =detect; InitGraph(GraphDriver,GRAPHMODE,PathToDriver); SetViewPort(0,0,GetMaxX,GetMaxY,True); {clips display area} center: =trunc (GetMaxX/2) ; {beam entry coordinate} top: =trunc(GetMaxY*0.1); {beam entry coordinate} end; Procedure xyplot(a,b,c,d:real); {this displays the trajectories on the pixel screen} var iy,iz,iyn,izn:integer; begin iy:=center + trunc(a*hplot_scale); iz:=top + trunc (b*plot_scale) ; iyn:=qenter + trunc(c*hplot_scale) ; izn:=top + trunc(d*plot_scale); if d=99 then izn:=top-2; if d=999 then izn: -bottom+2; {and now plot this vector on the screen} line(iy,iz,iyn,izn); end;
{plotting coordinate #1} {plotting coordinate #2} {plotting coordinate #3} {plotting coordinate #4} {BS plotting limit} {transmitted plotting limit}
THE SINGLE SCATTERING MODEL
Procedure set_up_graphics ; {draws i n th e surface(s), var
41
beam location, and action thermometers}
a,b:integer;
begin
a: =GetMaxX-20; {adjus b : = 2 0 ; {ditto
t t o sui t you r screen } }
Line (b, top, a, top) ; {plo t i n to p surface } {find positio n of bottom surface } bottom:=top + trunc(thick*GetMaxY/1000) ; if bottom>GetMaxY-4 0 the n bottom : =GetmaxY-40 ; plot_scale:=(bottom-top)/thick; {henc e ge t pixels/angstrom } GetAspectRatio(Xasp,Yasp); hplot—scale : = (Yasp/Xasp) *plot_scale; {fo r .aspec t ratio } if thi n the n {als o plo t i n exi t surface } Line(b,bottom,a,bottom); {plo t botto m surface } Line(center,1,center, top) ; {plo t incident beam} if no t thi n the n {pu t u p micron markers } if thick>500 0 the n begin Line(b,bottom+10,trune(b+5000*plot_scale),bottom+10); OutTextXY(b,bottom+20,'0.5 microns') ; end else begin Line(b,bottom+10,trune(b+500*plot_scale),bottom+10); OutTextXY(b,bottom+20 ' 5 0 0 A ' ) ; end; {put u p a thermomete r fo r th e trajectories
completed}
OutTextXY(trunc(center-80) ,bottom+15'0 %.........................50%,................... 100%' ); OutTextXY(trunc(center-78) ,bottom+28'Trajectories completed'); end; Procedure reset—coordinates; {resets coordinates at start of each trajectory} begin
42
MONTE CARLO MODELING
s_en:=inc_energy; x:=0; y:=0; z:=0; ex : =0 ; cy: = 0 ; cz:=l; end;
Procedure zero_counters; {since PASCAL does not zero variables on start-up we must do this} begin
end;
bk_sct:=0; num:= 0;
Procedure s_scatter(energy:real); {calculates scattering angle using screened Rutherford cross section} var Rl,al:real; begin al:=al_a/energy; Rl: =random; cp:=1.0-((2.0*al*Rq) /(1.0+al-Rl)); sp:=sqrt (1. 0-cp*cp) ; {and get the azimuthal scattering angle} ga: =two_pi*random; end; Procedure new_coord(step:real); {gets xn,yn,zn from x,y,z and scattering angles} var an_n,an_m,vl,v2,v3,v4:real; begin {find the transformation angles} if cz=0 then cz:=0.000001; an_m:=(-cx/cz); an_n: = l. 0/sqrt (1+ (an_jn*an_m) ) ; {save computation time by getting all the transcendentals first} vl:=an_n*sp; v2 : =an_m*an_n*sp; v3 : =cos (ga) ; v4 : =sin(ga) ; {find the new direction cosines} ca: = (cx*cp) + (vl*v3) + (cy*v2*v4);
THE SINGLE SCATTERING MODEL
cb: = (cy*cp) + (v4* (cz*vl - cx*v2)); cc: = (cz*cp) + (v2*v3) - (cy*vl*v4); {and get the new coordinates] xn:=x + step*ca; yn:=y + step*cb; zn:=z + step*cc; end; Procedure straight—through; (handles case where initial entry exceeds thickness} begin num:=num+1; xyplot (0,0,0,999) ; end;
Procedure back—scatter; {handles case of backscattered electrons} begin num:=num+l; bk_sct: =bk_sct + l; xyplot (y,z,yn,99); end; Procedure transmit—electron; {handles case of transmitted electron} var 11:extended; begin num:=num+l; 11: = ( t h i c k - z ) / c c; {lengt h o f pat h fro m z t o botto m face } yn:=y+ll*cb; {henc e th e exi t y-coordinate } xyplot(y,z,yn,999); end; Procedure reset—next—step; {resets variables for next trajectory step} begin xyplot(y,z,yn,zn); ex:=ca; cy:=cb; cz:=cc; x:=xn; y:=yn; z:=zn; {find the energy lost on this step} del—E: =step*stop_pwr(s_en)*density*IE-8;
43
44
MONTE CARLO MODELING
{so the current energy is} s_en:=s_en — del_E; end; Procedure show_traj_nuin; {updates thermometer display for % of trajectories done} var a,b:integer; begin a: =trunc(center-80); b:=bottom+23;
{adjust to suit your screen} {ditto}
line (a, b, a + trunc (165* (num/traj_num) ) , b) ;
end; Procedure show_BS_coeff; {displays BS coefficient on thermometer scale} label hang; var
a,b:integer;
begin a: =GetMaxX-180; screen} b: =bottom+23;
{adjust to suit your {ditto}
OutTextXY(a,b-8, '0 . . . . 0.25 . . . 0.5 . . . 0.75'); OutTextXY(a+5,b+5, 'BS coefficient'); Line(a,b, trunc(a+ (bk_sct / trajjium) *220) ,b) ; hang: {this loop freeze the display on the screen } If (not keypressed) then goto hang; CloseGraph; {shut down graphics driver} end;
*
this is the start of the main program
*
begin
set—up—screen; {ge t inpu t data and find J value}
THE SINGLE SCATTERING MODEL
45
get—constants; {and parameters needed later} { reset the random number generator} randomize; {set up the graphics display for plotting} Initialize; set_up_graphics;
*
the Monte Carlo Loop
*
zero—counters ; while num < traj_num do begin reset—coordinates ; {allow initial entrance of electron} step: =- lambda (s_en) * In (random) ; zn:=step; if zn>thick then {this one is transmitted} begin straight—through; goto exit; end else {plot this position and reset coordinates} begin xyplot (0,0,0, zn) ,y:=0; z:= zn; end; {now start the single scattering loop} repeat step: =-lambda (s_en) * In (random) ; s_scatter(s_en); new_coord(step); {problem-specific cod e will go here } {decide what happens next }
46
MONTE CARLO MODELING
if zn < =0 the n {this one is begin back—scatter; goto exit ; end;
backscattered}
if zn> = thick then {this one is transmitted] begin t ransrni t_e 1 ec t ron ; goto exit; end;
{otherwise we go round again} reset_next_step; until s_en < = e_min; {end of repeat loop — the energy drops below e —min}
exit: {en
* en
num:=num+l; {incremen t counter } d o f got o jumps}
d o f th e Mont e Carl o Loop *
show_t raj _num; if num mod 100 = 0 then randomize; {reset generator}
end; s how_B S_c o e f f;
end.
3.5 Notes on the procedures and functions used in the program The progra m start s wit h tw o specia l statements , {$Af+ } an d {$£+} , whic h ar e known as pragmas or compiler directives. These tell the TURBO PASCAL compiler to choose certai n options whe n it runs the program. The firs t pragm a instructs th e compiler t o generat e th e cod e necessar y t o mak e us e o f a numerical coprocesso r chip (fo r example, a n 8038 7 devic e i n a persona l compute r runnin g MS-DOS) . While computer s can rapidl y perfor m arithmeti c operation s o n integers , the y ar e typically slowe r b y a facto r o f fift y o r mor e time s whe n manipulatin g rea l o r floating-point number s (i.e. , number s suc h a s 10.2 3 or 1.5*10~ 3). Floatingpoin t
THE SINGL E SCATTERIN G MODE L 4
7
coprocessor chips , suc h as the 80387, ar e optimized to perform arithmetical opera tions o n real numbers an d greatly spee d u p the computation. However , in order t o use the chip, the compiler mus t be instructed to generate the necessary specia l code, hence the pragma {$Af+}. Unfortunately, code produced in this way would not then run o n another machin e withou t the math coprocessor. Th e secon d pragm a {$£+} tells to compiler t o test the compute r a t the star t o f the program t o determine i f a math coprocesso r i s present . I f i t is , the n th e chi p i s used ; i f n o coprocesso r i s detected, then the compile r "emulates " the chi p i n software , using the sam e cod e instructions an d performing the sam e operations a s the chip , althoug h much more slowly. Together, these two instructions allo w the program to configure itself s o as to run without modification on any suitable machine . Sinc e Mont e Carlo programs depend exclusivel y o n floating-point calculations , a mat h coprocesso r chi p i s th e cheapest an d most efficient wa y o f upgrading th e performanc e o f the computer . As in the simpler example given in Chap. 2, the program then continues with a declaration o f the resources required. The n LABE L collects th e names of all of the labels use d i n th e program . A labe l i s th e targe t o f a "GoTo " instruction , which causes the execution o f the program to jump to the specifie d location . Finally, we give a definitio n o f an y constant s used . Her e th e constant s ar e two_p i (2ir) , an d e_min th e minimu m energy belo w whic h th e electro n wil l n o longe r b e tracked . Defining as constants quantities, which are often used, saves time when the program is runnin g because th e compute r doe s no t hav e t o initializ e eac h quantit y many times. Next comes the list of variables used. Those declared in this list are available to all parts of the program and so are called global variables, whil e those declare d inside a procedure o r function ar e private an d only available t o that procedure . The firs t functio n called , POWER , illustrate s ho w function s ca n b e use d t o extend the PASCAL language itself. Most versions of the language do not include an operator t o fin d th e valu e o f th e quantit y xy; th e functio n o f POWE R therefor e provides this ability. Note that the simpl e code supplie d here does not contain any tests to avoid possible problems , such as attempting to take the logarithm of a zero or negativ e number . A versio n o f thi s functio n wit h proper erro r trappin g would therefore be necessary if the function wer e to be used in a more general context. The functions mn_ion_pot , stop_pwr , an d lambd a calculat e th e quantitie s sug gested by their names, using the equations discussed earlier i n this chapter. In each case th e functio n i s supplie d wit h a parameter, suc h as the atomi c numbe r of th e sample or the electron energy , in order to compute the appropriate value. The other data needed by the functions is taken from th e global variables declared at the start of th e program. Th e fina l functio n YE S wait s for inpu t from th e keyboard . If thi s input is a "y," or a "Y," then the answer to the question is assumed to be yes and a Boolean variable is set to true. If the input is any other letter or number, the variable is se t to false. In PASCAL, the code statement : If (function) then (operation)
48 MONT
E CARL O MODELIN G
will lea d t o th e operatio n bein g performe d i f th e functio n evaluate s t o a positiv e number or produces a Boolean variabl e with the value "true" (i.e., +1) . If, o n the other hand , th e functio n evaluate s t o zero o r t o a negative numbe r or produces a Boolean variable with the value "false" (i.e., 0), then the operatiori is not performed and the program moves to the next statement. Thus when the program a t some later point encounter s code suc h as: If ye s the n else
the functio n ye s i s called an d th e progra m wait s until inpu t from th e keyboar d i s received, I f this inpu t is a "y" or "Y" then yes is set to true and the "if" statement will b e performed. Otherwis e th e program wil l move on to the next line . The first procedure get-constant s computes a variety of quantities needed for othe r part s o f th e program , includin g the relativisti c correction t o the incident beam energy, and preconstants in the elastic cross section . Next set_up_screen allows fo r th e entr y o f th e parameter s describin g th e specime n an d experimenta l conditions. Th e operator i s asked if the sample is bulk (that is, one not sufficientl y thin to be electron-transparent). I f the answer , as determined b y the YE S functio n discussed above , i s ye s the n thick , th e rang e o f th e electron s i n th e specime n i s estimated fro m a simple analytical approximation :
and thi s i s late r use d t o se t u p th e scal e fo r plottin g th e trajectories . A Boolea n variable thin is also se t to false. If, on the other hand, the operator say s that the specimen is thin, then the Boolean variable is set to true, and thick is set equal to the actual thicknes s an d use d t o se t u p th e plottin g scale . Thi s i s als o th e thicknes s against whic h th e positio n o f th e inciden t electro n wil l b e teste d t o determin e whether o r no t i t ha s bee n transmitte d throug h th e foil . Finally , th e numbe r o f trajectories t o be run i n the simulatio n is obtained . The next procedure, initialize , i s identical to that used in the previous chapter. A s before , i t identifie s th e typ e o f graphic s displa y car d fitte d t o th e computer, initializes the card ready for use, determines the plotting size of the screen (GetMaxX, GetMaxY ) , an d sets itself u p to clip any image feature s lying off the screen. A t the sam e time tw o variables—center the horizontal midpoin t o f the screen and top the position at which to draw the entrance surface of the specimen— are defined. The procedure xyplot i s similar to that used in the previous chapter. Here w e use separate plottin g scale s plot_scale an d hplot_scale t o set up the aspect ratio. We also check for two special values of the last plotting paramete r passed to the procedure. If d — 99, then the electron ha s been backscattered an d the
THE SINGL E SCATTERIN G MODEL 4
9
plotting line is terminated 2 pixels abov e the entrance surface ; if d = 99 9 then the electron has been transmitted through th e specimen and the plotting line is finishe d 2 pixels belo w th e exit surface . These step s help keep th e displa y lookin g tidy. set_up_graphics is the procedure which draws the entrance surface of the specimen an d mark s th e entranc e positio n o f th e electro n beam . I f th e Boolea n variable thin is true, then an exit surface is also draw n at a spacing fro m th e top surface whic h is proportional t o the foil thickness. If this exceeds 100 0 A , then the bottom surfac e i s draw n a t 4 0 pixel s fro m th e botto m edg e o f th e screen . Th e plotting scal e plot-scale in pixels/angstroms is then determined an d the aspect ratio of the screen is found t o give a horizontal plottin g scal e hplot_scale such that equa l distance s i n either directio n wil l plo t a s lines o f equal length . N o scal e marker i s neede d fo r a thi n foil , sinc e th e specifie d thicknes s o f th e specime n provides a built-in scale, but fo r bulk samples a micron marke r mus t be provided . The program tests the value of the estimated electro n rang e thick to decide what length the marker should be. Finally we draw in, using the OutTextXY procedure , a "thermometer" scal e labeled fro m 0 % to 100% , which will be used to monitor the progress o f the simulation. Whil e this is in no way essential to the program, it does add a nice touch to the display. Note that in order to make the same code run equally well on all types of graphics systems, we define all positions o n the screen i n terms of the size (GetMaxX , GetMaxY ) o f the screen, using two local variables a and b. A s before, however, a and b may be varied, if desired, to customize the display to individual taste. Since PASCAL does not initialize variables when it starts running a program, the procedure zero_counter s does thi s for the quantities bk_sct an d num , which count the number of backscattered electrons and the total number of electrons respectively. Similarl y reset-coordinate s ensure s that , a t th e star t o f eac h new trajectory, all of the conditions ar e properly initialized, an d zero-counters resets eac h o f th e counter s use d t o chec k th e numbe r o f electron s ru n an d th e number backscattered. Th e procedure s_scatter calculate s the scattering angles , using th e relationship s give n i n Eqs. (3.10 ) an d (3.11) . Thes e values , the startin g electron coordinate s x, y, z, an d the step length are then used by new_coord to determine th e fina l coordinate s x n , y n , z n a s wel l a s th e directio n cosine s ca, cb, c c relativ e to the fixed axi s system. It is at this point in the program that code specific to the task of interest will usually be inserted, sinc e all of the information about the previous and present position and energy of the electron ar e available. Once thi s has been handled , the n the program calls reset_next_step , whic h plots th e trajector y step , determine s th e amoun t o f energ y los t b y th e electro n as it traveled this step, and equates th e now current coordinates, directio n cosines , and energ y wit h th e startin g value s fo r th e nex t step . Th e fina l procedure s straight_through, transmit_electron , back_scatter , and show_BS_coef f handl e th e variou s way s i n whic h th e electro n ca n exi t fro m the specimen , cal l th e plo t routin e wit h th e appropriat e parameters , an d coun t
50 MONT
E CARL O MODELIN G
the events . show_traj_nu m draw s a lin e i n th e thermomete r representin g th e percentage o f trajectorie s completed , an d th e procedur e show_BS_coe f f use s very simila r cod e t o dra w a thermometer representin g th e percentag e o f electron s backscattered. I n eac h cas e loca l variable s a an d b ca n b e altere d t o adjus t th e display to personal preference . Because o f al l th e wor k handle d b y th e procedure s an d functions , the actua l program section , startin g at begin and finishing at end, i s short and simple. Afte r the initia l setup , th e Mont e Carl o loo p i s entere d an d th e electro n i s allowe d t o penetrate int o the sampl e b y som e distanc e equa l t o the ste p lengt h [generate d by applying Eq. (3.7)]. If this distance is greater tha n the thickness o f the sample, then the even t i s plotte d an d counte d an d th e loo p starte d agai n wit h a ne w electron . Otherwise th e position o f the electron i s plotted an d then, at the label repeat, a second loo p i s starte d i n whic h the electron i s scattered , it s ne w position i s calcu lated, an d it s energ y los s compute d t o giv e it s ne w energy . Th e positio n o f th e electron i s then tested t o see whether it has been eithe r transmitte d throug h the foi l or backscattere d fro m it , i n whic h cas e th e progra m leave s th e loo p an d goe s t o the appropriat e procedur e t o handl e thi s even t befor e commencin g a ne w trajec tory. Finally , th e instantaneou s energ y s_e n o f th e electro n i s checke d b y th e repeat . . . until s_en < = e_min statemen t t o see whether o r not the energy i s abov e th e cutof f valu e e_min . I f i t i s not, the n th e loo p i s exited , th e electron i s counted, and a new trajectory is started. Otherwise the loop i s repeated . This sequenc e continue s unti l a tota l numbe r o f trajectorie s equa l t o traj_nu m have been calculated. Whe n the full numbe r of trajectories has been completed, th e program displays the fractional yield of backscattered electron s and then terminates .
3.6 Running the program The program ca n be run directl y fro m th e disk, if this is available, o r typed in and compiled. I n additio n th e .BG I file s provide d b y Borlan d mus t be presen t fo r th e graphics routines to operate. If a printed copy of the screen displa y is required when running MS-DOS 5.0 or higher, then at the ">" prompt type "graphics" and hit the return key. Anything appearing o n the scree n can now be transferred to the printer by using the key combination "Contro l + PrintScr. " When the ">" prompt returns, type "SS_MC" and hit return. The computer then requests th e parameters require d to run the simulation . Value s of atomic numbers, atomi c weights, an d densities fo r the elements ca n be found, fo r example, i n Goldstein e t al. (1992). For compounds, the usual procedure is to compute an effective atomi c number by using Eq. (3.19). The atomic weight is then approximated as being twice the effective atomi c number, and the appropriate density value is entered when requested. (Ideally, the procedure would b e t o us e a Mont e Carl o metho d t o decid e whic h o f th e atom s i n th e compound was being scattere d fro m eac h time . This method has been use d (Murata et al. , 1971 ; Kyser , 1979) , bu t i t is no t clea r tha t the benefits are wort h the added
THE SINGL E SCATTERIN G MODE L 5
1
complexity). Fo r some very complex materials and compounds, it may be impossible to derive an effective valu e for Z, since the chemistry is not known. However, if the substanc e of interest appear s i n Table 3. 3 [o r is listed i n the ful l ICR U (1983 ) tables], the n a n invers e procedur e ca n b e used . Fo r example , fo r photographi c emulsion, th e mean ionizatio n potentia l / i s given i n Table 3. 3 as 64.7 eV . /is approximately 10.Z eff [Eq . (3.18)], where Zeff is the effective atomi c number of the material. Hence Zeff is taken as 6.5 and the effective atomi c weight as 13. While this is clearly onl y an approximation, in practice i t produces sensible and useful results . To illustrate the applicatio n o f this program, let us first conside r th e case o f a high-energy electro n bea m an d a specime n tha t i s thi n enoug h t o b e electron transparent (i.e . th e situatio n foun d i n th e transmissio n o r scannin g transmissio n electron microscope) . Figur e 3. 7 show s th e trajectorie s calculated fo r a 100-ke V beam an d 1000- A thick foils o f carbon, copper , silver, an d gold. I n each case, 25 0 trajectories wer e run, and in response to the question "I s th e sampl e bul k ( y / n ) ?" th e answe r wa s "n." A s the atomi c numbe r an d the densit y o f the foi l
Figure 3.7. Mont e Carlo trajectory plot s for 100-ke V electrons incident on 1000- A films of carbon, copper, silver, and gold. Number of trajectories pe r plot: 250.
52 MONT
E CARL O MODELING
increase, the amount of lateral scatterin g in the beam can also be seen to increase. In the cas e o f th e carbo n sample , th e trajectorie s for m a smoot h con e tha t i s closel y confined around the incident beam axis, and it can be seen from inspection while the program is running that the average electron is only scattered zero or once during its passage through the foil. In the case of the copper foil , however, the typical electron is scattere d a t least onc e o r twice, and the beam profil e becomes bot h broader an d less well defined as the occasional electro n i s scattered throug h a large enough angle to travel almos t horizontall y throug h th e foil . I n the gol d foil , ther e ar e almos t n o unscattered electrons and , i n fact, th e scattering i s now s o high that a few electron s are actually seen t o be backscattered fro m th e foil. Thus while 1000 A of carbon at 100 keV represent s a specimen that is truly thin, the sam e thickness of gold a t the same energ y i s beginnin g t o tak e o n th e characteristic s o f a bul k (non-electron transparent) sample. These changes clearly have important implications for electro n microscope technique s suc h as x-ray microanalysis, in which the spatia l resolutio n depends on the magnitude of the beam scattering . I n a later chapter, thi s simulation will be extended to give a quantitative model of the magnitude of these effect s a s a function o f the experimenta l condition s used . Experimenting wit h the progra m b y trying the effect o f various choices of material, foil thickness, and beam energies i s a good wa y t o star t t o build up a fee l fo r th e wa y i n which electrons interac t wit h a solid. When th e sampl e i s thi n an d th e bea m energ y i s high , a s i n th e situatio n discussed above, then eac h trajector y consists o f only a small number of scatterin g events. Consequentl y th e program run s rapidly an d many trajectories ca n be computed in a relatively short time. On a 386-class MS-DOS machine fitted wit h a math coprocessor, i t shoul d b e possibl e t o comput e th e 25 0 trajectorie s fo r an y o f th e cases give n i n no more tha n 3 0 sec. However, i f in response t o the question "I s the sampl e bul k ( y / n ) ?" w e choose th e option "y , " then th e situation becomes ver y different. Eac h trajectory will now continue until the electron is either backscattered o r fall s belo w th e minimu m energy e_min , whic h i n th e progra m above is 0.5 keV. Since th e electro n i s typicall y losing energ y a t the rat e o f abou t 1 eV per angstrom (see Fig. 3.4), and since the mean free pat h for elastic scatterin g events is a few hundred angstroms (from Table 3.1), this suggests that even for a 20or 30-keV incident electron, it will be necessary to compute several hundred scattering events to complete one trajectory. This is indeed the case, and it may take as long as 1 min t o compute a singl e trajectory under the wors t conditions . Figure 3. 8 show s 250 trajectorie s plotte d fo r bul k sample s o f carbon, copper , silver, an d gold wit h incident beam energie s o f 20 keV. On an IBM P S 2/70, each plot took fro m 2 to 5 min to calculate. Th e shap e of the interaction volume s in the solids i s seen t o vary, with the choice o f material, fro m a "teardrop" hanging fro m the surfac e for th e carbo n t o a "squashed egg" shape presse d agains t th e inciden t surface fo r the gold. While the siz e of this volume will vary with the chosen bea m energy, the shap e stay s about the same , s o that the interactio n volum e a t 2 keV i s simply a scaled dow n version of the equivalen t volume at 20 keV. Observations o f
THE SINGL E SCATTERIN G MODE L 5
3
Figure 3.8 . Trajectorie s i n bulk C , Cu, Ag, an d Au a t 2 0 keV.
the trajectorie s whil e th e progra m i s running sho w that a disproportionatel y larg e fraction o f the time is devoted to computing the last portion of each trajectory. This is because, as the energy falls to just 1 or 2 keV, the mean free path becomes short, typically 50 A or less, and the step length [Eq. (3.7)] is only a few tens of angstroms. Although the rate of energy loss [Eq. (3.21)] is now higher than it was at the original incident energy , i t ha s no t rise n a s quickly a s th e mea n fre e pat h ha s fallen , an d hence the averag e energ y los s per ste p i s only a few tens o f electron volts . Consequently, each successive trajectory ste p moves the electron by only a few angstroms and decreases its energy by a few electron volts, and a large number of computations is needed t o make a relatively insignificant addition to the overall trajectory. Since the perceived utility of a Monte Carlo model is at least somewhat dependent on how fast i t ca n produc e th e require d information , thi s leisurel y leve l o f performanc e makes the single scattering model rather unsatisfactory in many cases. One possible solution i s t o choos e a higher cutof f energ y e_min , s o a s t o eliminat e man y of these calculations . However—althoug h whe n th e inciden t energ y i s sufficientl y high (say 10 keV and above) e_jnin could be set to 1 keV or more with little loss of accuracy—when th e initia l energ y i s onl y 2 o r 3 keV , terminating th e trajector y calculation at an energy only 50% below the incident value would represent a rather drastic oversimplificatio n an d a valu e o f 0. 1 ke V fo r e_mi n woul d see m mor e appropriate. One practical solution to this dilemma is to use a model originally described by
54 MONT
E CARLO MODELING
Archard (1961) . I n this w e allow an electron tha t has reached th e cutof f energ y t o diffuse fo r a total distance equal to its estimated range [obtained from Eq. (3.22)] at an energ y e_min . Thi s i s don e i n tw o stages . First , i t i s allowe d t o continu e t o travel in the same direction (a s defined by the direction cosine s ex, cy, cz) in which it had bee n travelin g whe n it lef t th e Mont e Carl o loo p for a distance equa l t o 40 Distance = — ; : : — * estimated rang e (3.23 7 * atomic numbe r
)
Setting the step distance equal to this value, the new coordinates ca n now be foun d as usual, using the procedure new_coord. Th e new z coordinate z n i s then tested to se e i f th e electro n ha s backscattered . I f i t has , then i t i s counte d an d a ne w trajectory started . Otherwise we set reset the coordinates as usual and then allow the electron t o scatte r throug h randomly chosen angle s <j > an d i|j , wher e cp:=2.0*RND - 1.0 ; {cosin e of scattering angl e 4> } sp:-sqrt(l - cp*cp) ; {sin e of scattering angl e 4> } ga:=two_pi*RND; {azimutha
l angle if }
The distance traveled i n the final segmen t is then a fraction ( 1 - (40/7Z) ) of the original estimated range . Using this step length and the scatterin g angle s give n above, th e ne w coordinates ar e then found , usin g new_coord, an d the electro n position is again tested to see if it has backscattered. I f it has, then it is counted and a new trajector y i s started ; i f not, then the trajector y i s terminated an d a new on e i s begun. This modification can be implemented by adding one function an d procedure to the program give n above an d then calling the procedure a t the appropriate point: Function archard_range:extended ; [estimates Archard diffusionon range at e_)minin microns} begin archard_range:=0.07*power(e_min, 1.66) /density; end; Procedure end_of—range; {apply the Archard model for electrons with energies below e_min } begin if s_en< = e_min then begin [travel (40/7*at—num) *archard—range in same direction] step: =Archard_range*40/(7*at_num) ; new_coord(step) ; if zn< = 0 then {this one is backscattered} back—scatter;
THE SINGLE SCATTERING MODEL
55
{now let
it scatter isotropically and travel residual fraction of range} reset_next_step; {rese t variables and plot it} cp: =2 . 0 * R N D - 1 . 0; sp: =sqrt (l-cp*cp) ; ga: = two_p i * RND ; step:=(1-(40.07(7.0*at_num)))*archard_range.new—coord(step) ; if zn < =0 the n {thi s one is backscattered)d) back—scatter; reset_next_step; {t o plo t fina l segment } end; {of the Archard diffusioionmodel stepp} end;
The function computes the estimated range and the procedure then carries out the sequence of steps discussed above. The procedure end_of_range is called just after the end of the loop repeat . . . until s_en<e_min, so that it is only entered by electrons below this energy cut-off: reset—next_step; {otherwise perform another trajectory step} until s_en<=e_min; {end of the repeat until loop} end—of_range; {optional Archard diffusion step added here} num:=num+l; {then add one to the trajectory total} etc. . . .
The effect of this addition to the program is not dramatic, but it does provide a more physically realistic model of the beam interaction in the important low beam energy regime. For beam energies greater than a few kilo-electron volts, the diffusion model adds little to the result and can safely be dispensed with.
4
THE PLURAL SCATTERING MODEL
4.1 Introduction We will develop i n this chapter a second Monte Carlo simulation of the interaction s of an electron wit h a solid. This new model is based on the same physical principles as th e singl e scatterin g approac h discusse d abov e bu t make s certai n simplifyin g assumptions tha t greatl y reduce th e computation tim e required. Thus , wherea s th e single scatterin g mode l discusse d i n Chap . 3 attempt s t o tak e int o accoun t ever y elastic scatterin g even t encountered by the incident electron , th e "plural scattering " model described her e trie s onl y to compute the net effec t produce d b y a number of successive scattering events. In addition, we average and precalculate other parameters o f th e trajector y wit h th e objec t o f minimizin g th e amoun t o f computatio n required during the simulation. Although these simplification s have some effec t o n the resultan t accurac y o f th e model , th e error s are , whe n th e mode l i s correctl y applied, insignificant , whil e th e savin g o f tim e i s considerable . Thi s mode l is , therefore, widely used, especially for problems where the incident beam is traveling into a bulk (i.e. , not thin an d s o not electron-transparent ) specimen .
4.2 Assumptions of the plural scattering model We sa w a t th e en d o f Chap . 3 tha t th e singl e scatterin g model , whil e certainl y appropriate t o th e tas k o f modelin g electro n interaction s i n a bul k solid , i s rathe r slow becaus e a great numbe r o f step s i n the trajectory are required t o advance th e electron a smal l distanc e a s it s energ y decreases . Consequently , i n application s where th e majorit y o f electron s deposi t al l o f thei r energ y i n th e target , a singl e scattering Mont e Carlo simulation is, for many users, too slow to be either enjoyabl e or very useful. Th e procedure tha t we describe her e follow s the outline of a method that was first described b y Curgenven and Duncumb (1971), an d which was specifi cally designe d t o produce good data in short computing times on small computers . The first assumptio n that distinguishes this model from th e previous one is that we make ever y electron trave l exactl y th e sam e tota l path lengt h withi n the speci men befor e comin g t o rest . Thi s distanc e i s foun d b y numericall y evaluating th e integral: 56
THE PLURA L SCATTERIN G MODE L 5
7
which computes the total distance measured along the trajectory that is required for an electron startin g wit h energy £ t o give up all of its energy. Here (dE/ds) i s the stopping powe r give n b y th e modifie d Beth e equatio n [Eq . (3.21)] ; therefor e th e total distance RB is often called , in the literature, th e Bethe range, or the csda-range (continuous slowin g dow n approximatio n range) . Becaus e scatterin g i s a statis tically rando m process, i t i s clea r tha t thi s i s onl y a n average d valu e fo r a given beam energy and material, but RB is nevertheless a convenient parameter with which to characteriz e th e genera l scal e o f th e electro n interactio n wit h th e specimen . In practice, it is not possible to perform the integration from zero energy as required by Eq. (4.1 ) because eve n the modified form o f the Bethe equation is not valid belo w about 50 eV. The procedure stop_pw r tha t calculates (dE/dS) therefor e check s to see whether o r not the energy is below thi s value. If it is, then the stopping power value calculated i s that for a 50 eV electron rather than the actual energy involved. This results in a small underestimation of the range (since, as shown in Chap. 3, the stopping powe r fall s fo r electron s o f ver y lo w energy) , but th e erro r fo r inciden t energies above a few hundred volts is negligible. Th e integration is carried ou t by the procedure range. Figur e 4.1 plots the variation of RB as a function o f incident energy fo r som e common materials , an d it can be see n that at 1 0 keV, the range is
Figure 4.1. Variatio n o f Bethe range with energy .
58 MONT
E CARL O MODELING
typically severa l micrometers an d varies by a factor o f 5 or s o between th e a lowatomic-number low-densit y elemen t suc h a s aluminu m and a high-atomic-numbe r high-density elemen t suc h as gold . A s th e bea m energ y falls , however , th e Beth e ranges converg e i n valu e an d al l becom e essentiall y th e same , abou t 10 0 A, fo r energies belo w a few hundred electro n volts . This i s because, fo r the lowes t ener gies, th e magnitud e of th e stoppin g powe r i s almos t independen t o f th e choic e o f material. The Bethe range is now divided into steps. In the code discusse d here, 50 steps of equa l lengt h wil l b e used . Thi s i s a compromis e betwee n th e improvemen t i n accuracy that results from a large (e.g., 100 ) number of steps (Bishop, 1974 ; Love et al., 1977) , an d the increase i n speed to be gained fro m a small (e.g., 20) number of steps. An alternativ e approac h is to limit the number of step s bu t vary their lengt h with the energy of the electron (Myklebus t et al., 1976) , s o that for high energies th e step length i s of the order o f the instantaneous elastic mea n fre e pat h but for lowe r energies th e ste p lengt h i s relativel y large . Th e tota l lengt h o f al l th e step s is , however, alway s kep t equa l t o th e Beth e range . I n eithe r cas e th e effec t o f thi s procedure i s to place a fixed uppe r limit on the number of computations required t o complete th e trajectory and avoid the problem, discussed in Chap. 3, of dealing with the incident electron whe n its energy becomes s o low that the mean free path is only a few nanometers an d the distance traveled in any scattering interval is an insignificant fractio n o f the tota l range . Computer time is also saved by precalculating th e energy E[n] o f the electron a t the star t of each o f the n steps. Sinc e th e length o f each ste p is known i n advance , E[n] ca n b e found by numericall y solvin g th e equatio n
where (dE/dS) i s again obtained fro m the modified Bethe equation [Eq. (3.21)]. £[1] is define d a s the inciden t electro n energ y E0, s o a solutio n o f Eq. (4.2 ) wil l giv e E[2], which , in turn, can be used to find E[3] an d so on until, at the end of the 50t h step, we set £[51] = 0 . This calculation i s carried ou t by the procedure p r o f i l e . The electro n scatterin g i s onc e agai n describe d b y th e screene d Rutherfor d cross section , bu t it is formulated in a different way . Using the notation o f Chap. 3 , as show n in Fig. 4.2, th e scatterin g angl e ca n be writte n as :
where p i s th e impac t paramete r (i.e. , th e projecte d neares t distanc e o f closes t approach of the electron t o the scattering nucleus if no scattering was to occur) and b
THE PLURA L SCATTERIN G MODE L 5
9
Figure 4.2. Definition o f parameters used i n the plural scatterin g model.
is 0.0144 Z/E wit h b in angstroms when E is in kilo-electron volts . This expressio n is for a single scattering event and ignores th e effect o f nuclear screenin g by orbital electrons (Curgenve n and Duncumb, 1971). However, since at every energy our step length is now considerably greater tha n the mean free path , each electro n could be scattered severa l time s durin g eac h step , producin g a ne t deviatio n tha t coul d b e either larger or smaller than any of the individual deflections. This random variation is accounte d fo r b y writin g
where RND is the usual pseudo-random number lying in the range 0 to 1 and p0 i s now the maximum impact parameter . Electrons ar e assumed to arrive at the nucleus placed randomly within the circle of radius pa. The square-root function weights the distribution i n such a way a s to increase th e probability o f large p values . The simplifications introduced into this plural scattering model, compared with those o f the singl e scatterin g mode l of Chap. 3 , are clearly fairl y drastic i n nature. However, th e cumulativ e erro r du e t o thes e approximation s ca n b e reduce d b y choosing th e valu e o f p0 s o tha t th e Mont e Carl o calculatio n give s th e correc t backscattering coefficient. This quantity is chosen because its value is readily available fo r a wid e rang e o f material s an d experimenta l condition s (Bishop , 1966 ; Heinrich, 1981). Two different approache s to this have been successfully used. Love et al . (1977 ) rewrite Eqs. (4.3 ) an d (4.4) i n the for m
60 MONT
E CARL O MODELIN G
where, a s before , E0 i s the inciden t bea m energy an d
<])0 thu s represent s th e minimu m scatterin g angl e fo r th e inciden t electro n wit h energy E0. As ca n b e see n fro m th e for m o f th e Beth e equatio n [Eq . (3.21)] , th e variation o f (E/E 0) i s substantially independent o f the atomi c number Z (th e varia tion comin g onl y fro m th e mea n ionizatio n potentia l / , whic h occur s insid e th e logarithmic term) and the random number RND will average to a mean value of 0.5 when a large numbe r of trials i s made. I t therefore follows that the backscattering coefficient T | mus t depen d onl y upo n co t ($0/2). Lov e e t al . (1977 ) sho w tha t cot (4>o/2 ) ca n b e writte n i n the for m
This metho d eliminate s th e nee d t o kno w p0 provide d tha t th e valu e o f T | fo r th e target materia l bein g modele d i s available . I n particular , a t lo w (<1 0 keV ) bea m energies, wher e th e valu e o f T | ma y b e varyin g wit h energ y (see , fo r example , Reimer an d Tolkamp, 1980) , thi s approach has the benefit that realistic data may be generated withou t th e need t o use mor e accurat e scatterin g cros s sections . The Lov e e t al . approac h ha s distinc t advantage s an d wil l b e considere d i n detail i n Chap . 6 . However , fo r thi s initia l stud y w e follo w th e suggestio n b y Duncumb (1977 ) an d writ e
This expression, whe n used in the Monte Carlo simulation , lead s t o a reasonable prediction o f the variation of backscattering coefficien t wit h atomic number for both elements an d [using Eq. (3.19)] compounds. [ A similar expressio n i s given by Myklebust et al. (1976); but note, however, that their paper contain s a typographical error and that E0 should appear in the numerator rather than the denominator o f their variable F,.] While this approach essentially treat s pQ a s a fittable parameter t o yield the correct backscatterin g coefficient , i t has the advantage that no prior knowledg e of th e valu e of f\ i s required . Either of these two approaches enable s the Monte Carl o simulatio n to back scatter the correct fraction o f incident electrons . However, a closer inspection of the predictions o f thes e calculation s (Myklebus t e t al. , 1976 ) show s tha t whil e th e backscattering yiel d i s correct , th e energ y distributio n o f thes e electron s i s no t i n
THE PLURA L SCATTERIN G MODE L 6
1
good agreemen t wit h experimental data . This i s becaus e th e origina l for m o f th e scattering equation s [Eqs . (4,3 ) and (4.4)] i.e. ,
does no t allo w fo r a sufficien t amoun t o f small-angl e scattering . Thu s th e largest possible valu e of cot(c|>/2 ) fro m Eq . (4.9 ) i s 2 p/b, which , for silico n a t 1 5 keV, corresponds t o a minimum scattering angl e of about 3°. All electron s wil l be scat tered by at least this angle, an d 95% of all electrons will be scattered throug h 5° or more. For materials with higher atomic numbers, the minimum angle will be greater and th e averag e scatterin g angl e highe r still . I n orde r t o allo w fo r a t leas t som e fraction o f the electrons to be scattered through very small angles, we can adopt the suggestion o f Myklebust et al . (1976 ) an d writ e
so that, as RND tends to unity, the scattering angle can fall to zero and a fraction of the scatterin g events will be o f th e orde r o f a few degree s o r less . As in the previous chapter, the scattered electron can travel to anywhere on the base o f th e con e define d b y th e angl e 4> , s o w e mus t als o choos e a n azimutha l scattering angl e (jj » whic h wil l be give n b y [Eq . (3.11) ] a s
The flo w o f th e progra m the n closel y follow s tha t fo r th e singl e scatterin g model, but with the difference that each trajectory is restricted to 50 steps or less:
for n ~ 1 to 50 begin Get th e startin g energy E[n] o f th e electro n Get the startin g coordinates x,y,2 for the n th step Get the direction cosine s cx,cy,cz relativ e to the initia l axe s Find th e scatterin g angle s 4>,v| j from Eqs . (4.10 ) an d (4.11 ) Compute final coordinate s xn,yn,zn from Eqs . (3.12 ) t o (3.15 ) Check if the electron ha s bee n backscattere d if yes , exi t the loop an d ad d 1 to backscatter tota l otherwise Reset coordinate s x = xn, y - yn, z ~ zn Reset directio n cosine s ex ~ ca, cy — cb, cz — cc end
62 MONT
E CARLO MODELING
The PASCAL code that implements this sequence is set out below, again using the conventions established in Chap. 2.
4.3 The plural scattering Monte Carlo code Program PluralScatter ; {this programs performs a Monte Carlo trajectory simulation using a screened Rutherford cross section and a plural scattering ap~ proxima t i on} {$N+} {tur n on numeric coprocessor} {$E+} {install emulator package} uses CRT,DOS,GRAPH ; label exit const two_p
;
{resources required}
{target address for goto jumps} i = 6 . 28318 ;
[2 constant}
var at_num,at_wht,density,inc_energy,mn_ion_pot:extended; an, an_m, an_n,bk_sct, cp, c-^tilt, ga nu, tilt, sp, s_tilt:extended; ca,cb,cc,ex,cy,cz,vl,v2,v3,v4,x,y,z,xn,yn,zn:extended; h_scale,m_t_step,rf,step,v_scale:extended; E:array [1 . .51] of real;
bottom,b_point,center,k,num,traj_num,top:integer; GraphDriver:Integer; GRAPHMODE:Integer; ErrorCode:Integer; Xasp,Yasp:word; s :string; Function power (mantissa, exponent:real) .-real; [because PASCAL has no exponentiation function} begin power: =exp (In (mantissa) * exponent) ; end; Function stop_pwr(energy:real):extended; {calculates the stopping power using the modified Bethe expression of Eq. (3.21) in units of keV/g/cm2} var temp:real; begin
THE PLURAL SCATTERING MODEL
63
if energy<0. 5 the n {t o avoid problems as energy approaches zero} energy:=0.05; temp: =l n (l .166* (energy + 0. 85*mn_ion_pot) 7mn_ion-43Ot ) ; stop_pwr: =temp*78500*at_num/ (at_wht*energy ) ; end;
Procedure set—up—screen ; {gets initialization for random number generator and the input data required to run the program} begin ClrScr;
{Erases any data on screen display}
GoToXY(25,l); writeln('Plural scattering Monte Carlo simulation'); GoToXY(1,5); Write('Input beam energy in keV); Readln(Inc—Energy); GoToXY(1,7); Write('Target atomic number is'); Readln(at_num); GoToXY(1,9); Write('Target atomic weight is'); Readln(At_wht); {compute the mean ionization potential J using the BergerSelzer analytic fit in units of keV} mn_ion_pot: = (9.76*at_num + (58.5/power(at _num'0.19)))*0.001; GoToXY(1,11); Write('Target density in g/cc is'); Readln(Density); {get the beam tilt data} GoToXY(40,5); Write('Tilt angle in degrees'); readln(tilt); s_tilt: =sin (tilt 757 . 4) ; {convert degrees to radians} c_tilt:=cos(tilt757.4) ; {get the number of trajectories to be run in this simulation}
64
MONTE CARLO MODELING
GoToXY(40,7) ; write('Number of trajectories required'); readln(traj_jium) ;
end; Procedure Rutherford—Factor;
{computes the Rutherford scattering factor for this incident energy} var pO:extended; begin pO : =0 , 394*power (at_nuin' 0 . 4) Vine—energy; {Duncurrtb's function} rf:=0.0072*at_num/(pO); {scattering constant b/2 in Eq. (4.3)}
end; Procedure range;
{this calculates the range in microns assuming the modified Bethe stopping power, Eg. (3.21)} var energy,f,fs,Bethe—range:extended; l,m:integer; begin
fs:=0,; for m:=l to 21 do
{initialize variable to be sure} {a Simpson's rule integration}
begin energy: = (m-1) *inc—energy/20; {20 equal steps} f : =l/stop_pwr(energy);
1:=2; if m mod 2 = 0 then 1:=4; if m=l then 1:=1; if m=21 then 1:=1; fs:=fs+l*f;
end;
{now use this to find the range and step length for these conditons}
THE PLURAL SCATTERING MODEL
65
Bathe—range: = f s*inc_energy/60 . 0; (i ra_t_step: =Bethe_jrange / 5 0 .0 ;
n g/cm2]
Bethe—range:—Bethe—.range*10000.0/density; {a
n microns}
{and displa y thi s fo r informationa l purposes } GoToXY(40,11) ; writeln('........Rangeis 'Bethe_range:4:2, 'mi crons ' ) ; step: =Bethe—range 750.0; end;
Procedure profile; {compute 50-ste p energy profil e fo r electro n beam} var Al,A2,A3,A4:extended ; m:integer; begin E 11]:= inc_energy; for Hi : =2 t o 5 1 d o
begin
Al: =m_t^step*stop_pwr(E[m-l]); A2 :=m_t~step*stop_pwr(Etm-1]-Al/2); A3 :=m_t_step*stop_pwr(Etm-1]-A2/2); A4:=nu-t^.step*stop_pwr (e[m-l] -A3) ;
E [ m ] : = E [ m - l ] - (A l +2*A 2 +2*A 3 + A 4 ) / 6 .
;
end;
E ( 5 1 ] : = ± : 0 . ; {ensur e electro n finishes with zero energy } for m : = 2 t o 5 0 d o { a little smoothing of the profile} begin e[m] : - ( E [ m ] + E [m+1] ) /2 . ; end;
end;
66 MONT
E CARL O MODELING
Procedure initialize;
{sets u p the graphics drivers for 1/5. 0 TURBO PASCAL}
var InGraphicsMode:Boolean; PathToDriver:String; begin DirectVideo: =False; PathToDriver: = ''; GraphDriver: =detect; InitGraph(GraphDriver,GRAPHMODE,PathToDriver); SetViewPort(0,0,GetMaxX,GetMaxY,True); (clips the display} center:=trunc(GetMaxX/2); top: =trunc{GetMaxY*0.1) ; bottom: =trunc(GetMaxY*0.75) ;
{adjust to suit your screen} {ditto}
end;
Procedure set_up_graphics; {sets up the plotting scales, surfaces, etc., for display using the size of the screen as found by the initialize routine to scale the display properly} var
a,b,c,d:integer;
begin
a: =GetMaxX-20; b:=20;
{adjust to suit your screen} {ditto}
Line (b, top, a, top) ; {plot in top surface}
{now plot in the incident beam allowing for tilt} b_point:=center - trunc(38*s_tilt/c_tilt) ; Line(b_point,1,center,top) ; {plot beam}
{find the aspect ratio of this display} GetAspectRatio(Xasp,Yasp); {set up the plotting scale} h_scale : =GetMaxX/(100.*step); [in pixels per micron} v_scale:=h_scale*(Xasp/Yasp); c : =GetMaxY-43 ; d:=10;
{adjust for your screen} {ditto}
{set up to draw the trajectories completed thermometer} OutTextXY(trunc (center-80) ,bottom+15, '0%............50%......... . 100%');
THE PLURAL SCATTERING MODEL
67
OutTextXY(trunc(center-78),bottom+28,'Trajectories completed'); If h_scale < = 3 0 0. the n {dra w a bar 1 micron long} begin Line{d, c, d+trunc(h_scale) , c) ; {micro n b a r ) ; OutTextXY ( d + t r u n c ( h _ s c a l e / 3) , d + c, '1 (Jim' ) ; {label the bar] end else {draw a bar 0.1 microns long} begin L i n e ( d , c , d + t r u n e ( 0 . l * h _ s c a l e ) , c) ; OutTextXY (d+trunc ( 0 .0 3 *h_scale) , d + c, ' 0 . lOjun' ) ; end;
end; Procedure xyplot(a,b,c,d:real) ; {this displays the trajectories on graphics screen} var iy,iz,iyn,izn:integer; begin iy: =center+trunc (a*h_scale) ;
{plotting coordinate #1}
iz:=top + trunc(b*v_scale);
{plotting coordinate #2}
iyn: =center + trunc(c*h_scale) ;
{plotting coordinate #3}
izn:=top + trunc (d*v_scale) ;
{plotting coordinate #4}
if d=99 then izn:=top-2;
{BS plotting limit}
{now plot this vector on the screen} line(iy,iz,iyn,izn);
end; Procedure init_counters; {initialize each counter since PASCAL does not do this} begin bk_sct: =0; num: = 0 ;
end; Procedure reset—coordinates ; {reinitialize all the electron variables at start of each new trajectory}
68
MONTE CARLO MODELING
begin x: = 0 ;
y:=0; z:=0; cx:=0; cy:=s_tilt; cz : =c _ t i l t;
end; Procedure p_scatter; {calculates scattering angles using the plural scattering model with the small angle correction as given in Eg. (4.10)} begin (first call the random number generator function} nu: = sqrt(RANDOM) ; nu: = ( (1/nu) -1.0) ; an:=nu*rf/E[k] ;
{and use this to find the scattering angles} sp: = (an + an) / (1+ (an*an) ) ; cp: = (1- (an*an) ) / (1+ (an*an) ) ; {and the azimuthal scattering angle] ga:=two_pi*random; end;
Procedure new_coord(step:real); {gets xn,yn,zn from x,y,z and scattering angles using figs. (3.12) to 3.15)} var an—n,an_m,vl,v2,v3,v4:extended; begin {the coordinate rotation angles are} if cz-Q then cz : =0.000001; {avoid division by zero} an_m: = (—cx/cz) ;
an_n: =1. 0/sqrt (1+ (an_m*an_in) ) ; {save computation time by getting all the transcendentals first} vl: =an_n*sp; v2 : =an_m*an_n*sp; v3 : —cos (ga) ; v4: =sin(ga) ;
THE PLURAL SCATTERING MODEL
69
{find the new direction cosines} ca: = (cx*cp) + (vl*v3 ) + (cy*v2*v4) ; cb:=(cy*cp) + (v4*(cz*v l - cx*v2)) ; c c : = ( c z * c p ) + (v2*v3 ) - ( c y * v l * v 4 ) ; {and get the new coordinates} xn:=x + step*ca; yn:=y + step*cb; zn:=z + step*cc; end; Procedure reset_next_step; {rests variables for next trajectory step} begin x y p l o t ( y , z , y n , z n ) ; {plot s thi s step } ex:=ca; cy:= cb; cz:=cc; x:=xn; y:=yn; z:=zn;
end; Procedure back—scatter; {handles special case of a backscattered electron} begin bk_sct: =bk_sct + l; {add one to counter} num: =nurn+l; {add one to total} xyplot (y, z,yn, 99) ; {plot BS exit} end; Procedure show_traj_num; {update the thermometer display} var a,b:integer; begin a: =trunc (center-80) ; b: =bottom+23;
{to match position of thermometer} {ditto}
line (a,b,a+trunc (165* (num/traj_num) ) ,b) ;
{draw it in}
end;
Procedure display_backscattering; {draws a thermometer to display the backscattering coefficient}
70
MONTE CARLO MODELING
label han g; var a , b : i n t e g e r
;
begin a: =GetMaxX-180; {adjus b: =bottom+23; {ditto
t to suit your screen} }
O u t T e x t X Y ( a , b - 8 ' ' 0 . . . . 0 . 2 5 .. . 0. 5 . . . OutTextXY(a+18,b+5 'B S c o e f f i c i e n t ' ) ;
0.75');
L i n e ( a , b , t r u n c ( a + ( b k _ s c t / t r a j _ n u m ) * 2 2 0 ) ,b ) ; {draw it } hang: if (no t keypressed) the n got o hang ; {freezee displlay on screen} CloseGraph; {shut down the graphics unit}
end; {
*
this is the start of the main program
*
} begin set_up_screen;
{get input data}
Rutherford—factor;
{and screening factor}
{now get the range and step length in microns for these conditons} range; profile; initialize; {initialize the graphics screen} set_up_graphics; {an d draw on it} randomize; {resee
* th
d random number generator}
e Mont e Carl o loo p *
init_counters; {reset while nu m < traj_nu m d o begin
counters}
THE PLURAL SCATTERING MODEL
71
reset—coordinates ; for k : = l t o 5 0 do
begin p_scatter;
{find the scattering angles]
new_coord(step);
{find where electron goes}
{program specific code will go here] {now test for the electro nposition in the sample} if zn<=0, then {this one is backscattered} begin back—scatter; gotoexit; end else {it is still in the target} reset—next—step; end;
{of the 50-step loop}
num:=num+l;
end;
*
{add one to trajectory total}
'exit:
{end of goto jumps}
show—traj—num
{update the trajectory number display}
{of the Monte Carlo loop}
end of the Monte Carlo loop
*
display—backscattering; {show the computed BS coefficient}
end.
4.4 Notes on the procedures and functions used in the program The program starts, as in the case of the single scattering model , with the pragmas {$Af+} and {$£+}, which select th e use o f the math coprocessor an d the emulato r package. The resources, labels, constants, an d variables follow . The first tw o func tions in Plural Scatter, POWER , whic h provides an exponentiation capability
72 MONT
E CARL O MODELIN G
for PASCAL , an d gTOP_PWR , whic h calculate s th e electro n stoppin g powe r i n units of keV/g/cm2 using Eq. (3.21), are identical to those in SingleScatter, since, wherever possible, it is advantageous to reuse program code. Next , set ja p _screen, allow s for the input of the various pieces of data to describe the experimental conditions t o be modeled. I n addition t o the usual data about the specime n (atomic number, atomic weight, and density) and the beam energy, the option is given to change the angle of incidence o f the beam to the specimen. Th e variable T i l t, which describes this angle, is given in degrees, s o the procedure must first convert it to radians . Usin g th e conventio n fo r th e Cartesia n axe s describe d i n Chap . 3 , th e three direction cosines for the incident beam will then be CX = 0, CY = sin(Tilt), CZ = cos(Tilt) . The procedure calculate s an d stores thes e values. The procedur e Rutherford-Facto r calculate s th e energy-independen t quantities tha t appea r i n th e scattering-angl e Eqs . (4.3) , (4.4) , an d (4.10) . Th e variable pO is Duncumb's suggested fitting functio n t o the backscatter data as given in Eq. (4.8); rf the n represents the quantity (b/2pQ), wher e b is 0.0144 Z, which is used i n Eqs , (4.3 ) and (4.10) . Th e rang e o f th e electro n i s no w calculate d i n th e procedure rang e usin g Eq . (4.1) . W e firs t divid e th e tota l energ y rang e o f th e electron, fro m it s starting value inc_energy to zero, into 20 equal steps. At each of thes e 2 1 energ y values , the quantit y l/(dE/dS) i s the n foun d fro m Eq . (3.21) , calculated usin g th e functio n stop_pwr . Finally , Simpson' s rul e (Pres s e t al. , 1986) is used to evaluate the integral, giving a result in units of mass per unit area (g/cm2). T o obtain th e Beth e range , thi s quantit y is divide d b y th e densit y o f th e specimen (g/cm 3) and the result is converted t o micrometers an d printed out on the input displa y screen . Th e step-length i s the n se t equal t o one-fiftiet h o f thi s range. The variatio n o f energ y o f th e electro n ca n no w b e precalculate d usin g th e procedure profile, whic h solve s Eq . 4.2 using a Runge-Kutta method (Pres s et al., 1986 ) to obtain the electron energ y at the end of each of the 50 steps into which the trajector y ha s bee n divided . Startin g fro m th e inciden t bea m energ y a t th e beginning o f th e firs t step , th e procedur e obtain s fou r differen t estimate s fo r th e energy lost in traveling on e step length, Sinc e the stopping power itself varie s with energy, th e firs t estimat e get s th e energ y los s A£ t alon g th e step , assumin g th e stopping power appropriate to the starting energy inc_energy. Th e next estimate subtracts half of the calculated energ y loss A£ t fro m th e starting energy and, using this energy value (i.e., inc_energy- AE t/2), finds the stopping power and hence a second estimate A£ 2 for the energy loss along the step. This value is, in turn, used to fin d th e stoppin g powe r a t th e energy (inc_energy - A£ 2/2) an d the energ y loss A£ 3 along the step. Finally, the stopping power at the energy (inc_energyAE3) is found and the energy loss A£4 is computed. The actual energy at the end of the first ste p is then the starting energy inc_energy minu s the weighted average of th e various energy-loss estimates . This valu e is then used as the startin g energ y for th e next step, and the proces s i s repeated unti l the en d o f the 50t h step , which
THE PLURA L SCATTERIN G MODE L 7
3
Figure 4.3. Variatio n o f electron energy wit h step number for 20-ke V incidence. sets the energy equal to zero. Figure 4.3 plots E[n], the energy at the start of the nth step, a s a function o f n for 20-keV electrons inciden t o n carbon and gold. It can be seen that, when plotted as a function o f the fraction o f the range traveled, electrons in both materials lose energy at about the same rate and that the rate of energy loss is quite nonlinear (i.e., the electrons travel about two-thirds of their range before losing half of their initial energy but lose the last 25% of their energy in the last 10% of the steps). The procedure initializ e i s identica l t o tha t used previousl y an d again determines the plotting siz e of the screen and the location of center, th e horizontal midpoint of the screen, and top, th e location at which the entrance surfac e of the specimen is to be drawn. The procedure set_up~graphic s uses these value s to plot in the top surface an d the incident beam, allowing for this beam to be tilted relative to the surface normal. The horizontal plotting scale h_scale is set equal to the widt h o f th e scree n (GetMaxX ) divided b y twic e th e Beth e rang e (pixel s pe r micron), and the corresponding plottin g scale v_scale in the vertical directio n i s found b y multiplyin g h_scal e b y th e aspec t rati o o f th e scree n t o ensur e a correctly proportione d display . Finally, a micron marke r an d a "trajectorie s com pleted" thermometer ar e constructed. As before, whil e the code provide d wil l correctly position these for any type of graphics screen that is used, their exact locatio n can b e varie d t o sui t individua l preferenc e b y adjustin g th e value s o f th e loca l variables c an d d. Procedure p_scatte r use s Eq . (4.10 ) t o calculat e tan(4>/2) , wher e 4 > i s the scatterin g angl e define d i n Fig . 4.2. The value s o f sin(((> ) an d cos(4> ) a fe then obtaine d b y standar d trigonometri c formula s fro m th e valu e o f tan(<j>/2) ,
74 MONT
E CARLO MODELING
Figure 4.4. Trajectorie s i n bulk carbo n an d copper at 20 keV. and th e azimutha l angl e \\i i s foun d fro m Eq . (3.11) . Thes e angle s ar e the n passed t o th e procedure new_coord , identica l to the versio n i n Chap. 3 , which determines th e coordinate s o f th e en d poin t o f thi s step . Th e fina l procedure s reset_next_step, back_scatter , show_traj_num , an d display -backscattering handle the various bookkeeping details for each of the trajectories an d update the screen display . The main body of the program, starting at begin and finishing at end simpl y calls th e procedure s a s the y ar e required , loopin g unti l th e require d numbe r o f trajectories hav e been computed . In th e cente r o f thi s loo p i s th e place , afte r th e new positio n of the electron ha s been determined, where code to compute specific features o f th e electro n interaction (suc h as x-ray s or secondar y electrons ) ca n b e placed. The electron is then be tested to see whether it has been backscattered and , if so, the back_scatter procedur e is called; otherwise, the electron proceeds to the next step . After completion , th e program display s the fractional yiel d of backscat tered electron s an d then terminates.
THE PLURA L SCATTERIN G MODE L 7
5
Figure 4.4. (continued)
4.5 Running the program The program can be ran directly fro m th e disk if this is available by typing PCLMC at th e ">" prompt an d the n hittin g return . Onc e th e require d inpu t dat a (atomi c number, atomi c weight , density , and bea m energ y a s before) hav e bee n provided , the program wil l start running. A comparison o f the speed o f this program wit h the equivalent computatio n fo r a bul k specime n usin g SingleScatte r wil l sho w that PluralScatte r i s 1 0 to 2 0 times faster , becaus e a maximu m of onl y 5 0 steps i s calculated fo r eac h trajectory . Figure 4. 4 show s computed trajector y plot s for 20-ke V electron s i n carbon, copper, silver, and gold to correspond wit h those in Fig. 3.7 . Despit e th e simplifyin g assumption s introduce d b y th e plura l scatterin g model, it is evident that the basic details of the interaction ar e well accounted for . In later chapters, we examine in more detail some verifiable predictions of both models and fin d that , whe n use d wit h prope r precautions , eithe r ca n giv e result s o f goo d accuracy. It should be noted that one consequence o f the model used here is that the shape o f the interactio n volum e is independent o f the actua l inciden t bea m energ y and depends only the material of the target. The form of the interaction volume does, however, depend on the angle of incidence o f the beam, as shown in Fig. 4.5, which plots trajectorie s fo r 30 ° an d 60 ° angle s o f incidenc e i n copper . Not e tha t th e
76 MONT
E CARL O MODELIN G
Figure 4.5. Trajectorie s i n copper a t 20 keV fo r inciden t angle s o f 30 ° and 60° .
maximum extension o f the interaction follows th e general directio n o f the incident beam, s o tha t th e volum e becomes elongate d i n th e directio n o f th e beam . Th e lateral extent of the interaction is therefore quite different i n the plane containing the incident bea m an d in the directio n norma l to this, and this will be eviden t in both imaging an d microanalysis performed under these conditions .
5
THE PRACTICAL APPLICATION OF MONTE CARLO MODELS 5.1 General considerations The remainder of this book is devoted to the application of Monte Carlo models to a variety of problems in electron microscopy an d microanalysis. The programs developed in Chaps. 3 and 4 provide only the framework tha t models the basic details of the electro n interaction . W e will now develo p a variety o f algorithm s that , whe n implemented a s PASCAL procedures and functions, can be used to transform these generic Mont e Carlo model s int o programs customized t o solv e a particular prob lem. Befor e proceedin g t o thes e applications , however , ther e ar e a fe w practica l considerations tha t are wort h discussing.
5.2 Which type of Monte Carlo model should be used? We have developed two types of Monte Carlo model, the singl e scatterin g model , which attempt s t o accoun t fo r ever y elasti c interactio n suffere d b y th e inciden t electron, an d the plural scattering model, which considers only the resultant effect of scattering events occurring within some specified segment of the electron trajectory . These mode l shar e much of the same physics, and so, whe n properly used, can be expected to give comparable results. It is, however, necessary t o decide what constitutes proper usage . An important general property of these models is what we shall call, by analog y wit h photographic film , their granularity. Thi s concep t expresse s the ide a tha t th e Mont e Carl o mode l i s takin g wha t i s i n realit y a continuou s sequence o f scatterin g event s an d modeling i t a s a discret e serie s o f independen t events, just as a piece o f film take s a picture an d breaks it down into fragments th e size of the grains making u p the emulsion. The finer th e grain siz e of the film, th e higher the resolution of the image; and the finer the granularity (i.e., the step size) of the Mont e Carlo simulation , th e better th e qualit y of the mode l generated . I n th e case of the single scatterin g model , th e step size is of the order o f the elastic mean free pat h and thus (depending o n energy) i s between a few nanometer s an d a few tens of nanometers, whil e for the plural scattering model, th e step size is a fractio n of the Bethe range and varies from ten s of nanometers to fractions of a micrometer . In modeling som e effect, i t is therefore necessary to ensure that the granularity 77
78
MONTE CARLO MODELING
of th e mode l i s sufficien t t o resolv e th e kin d o f effec t tha t i s bein g studied . I t i s obvious that a plural scattering model, which at an energy of 10 0 keV would have a step lengt h o f clos e t o a micron , woul d no t b e suitabl e fo r studie s o f electro n scattering i n a thi n foi l onl y a fe w hundre d angstroms thick—th e dat a woul d b e excessively "grainy." But care mus t also be taken to se e that the granularity is not too small. For example, at low beam energies, the step length in the single scatterin g model is only a few angstroms and so is approaching atomistic dimensions. Caution must be exercised in this condition, because a fundamental assumption of the Monte Carlo method is that the sampl e can be considered t o be a structureless continuum (sometimes calle d a "jellium"), an d this wil l only b e tru e whe n the ste p lengt h i s much greate r tha n eithe r atomi c o r crysta l lattice dimensions . Conclusion s draw n about electro n behavio r unde r thes e extrem e condition s ma y therefore b e i n error , and it would actually be better t o use a more granular model. An appropriate test is to determin e th e critica l dimension s o f th e phenomen a o r experimen t t o b e simu lated an d ensur e tha t th e mode l chose n ha s sufficien t granularit y t o resolv e th e effect. A t the same time we must also ensure that the scale is not so far below that of the problem that excessive time is wasted in computation. For example, th e modeling of backscattered signal s fro m bul k specimens can usually be done with a plural scattering model, because the dimensions of the sample and its features or inclusions are usuall y larg e compare d t o th e ste p size . Bu t i n modelin g secondar y electro n production fro m th e sam e specimen , it may be necessary to use a single scatterin g model, becaus e th e scal e o f th e secondar y emissio n (se t b y th e escap e dept h o f secondary electrons ) is only a few nanometers. Usin g a single scatterin g mode l in the first cas e would probably give the same result, but at the expense o f much extra computing time; while using a plural scattering model in the second case might give a result that is accurate on the scale of the step length (i.e., fractions of a micron) but inaccurate o n the scal e o f a few ten s of angstroms .
5.3 Customizing the generic programs The aim of the subsequent chapters of this book is to develop a library of procedures and functions that , when coupled with one or other of the basic Monte Carlo models, will realisticall y an d accuratel y simulat e th e physica l proces s o f interest . Thes e procedures ca n either be added to the basic programs by typing them in, or the code fragments o r complet e program s ca n b e take n fro m th e disk . I n mos t cases , th e customization requires onl y the addition o f the procedure o f interest to the body of the program together with the declaration at the start of the program o f any additional globa l variables , th e additio n o f a call t o thi s procedur e (o r procedures ) a t th e appropriate poin t within the Monte Carlo loop, and the addition o f any special tests (for example , determinin g th e positio n o f th e electro n relativ e t o som e featur e or surface) that are require to model the specific event of interest. As a practical matter, it is usually most convenient t o modify program s in a three-step process . First, add
PRACTICAL APPLICATIO N 7
9
the procedures an d their associated global variable s to the program an d check that it still compile s correctly . Next , ad d the cod e tha t perform s an y specifi c test s mad e prior to the calling o f the procedure an d again check that the program compiles an d runs. Finally, ad d the call(s) to the procedure itsel f an d see that the program func tions as expected. Breakin g the process int o these steps greatly eases the problem of debugging th e program i n the event of an error, becaus e onl y one change ha s been made t o the program a t each iteration .
5.4 The "all purpose" program An apparentl y irresistibl e temptatio n i n Monte Carl o modelin g i s the urge to construct an all-purpose simulation that can answer any question about any effect fro m a specimen o f arbitrary geometr y and inhomogeneity. The problem wit h producing such an oracle is that the more general a program must become, the more convoluted must be its logic, and the difficulty o f debugging a program rises exponentially with its complexity. It is not just that a general program is longer but that it has built into it a multiplicity o f options (i.e. , i f ....... . .en...........elsee.........statement that ca n (and , perversely, quit e ofte n do ) interac t wit h one anothe r i n unexpected ways. Thus, while a program may function quit e normally and correctly for one set of conditions , anothe r an d apparentl y equall y reasonabl e se t o f condition s ma y cause a malfunction or , worse, a subtl e error i n the outpu t data. The most reasonable advic e is to construct a new simulatio n for each proble m that is to be solved . For example, if we are interested i n the x-ra y production fro m features i n the shap e of either sphere s or cubes, it is best to write one program that tackles the case o f a spherical sampl e an d another separat e progra m that consider s the case of the cube. Since a high fraction of the code will be identical i n both cases, the additional time taken in constructing a second program is small. But the elimination o f complicate d an d messy test s relate d t o th e specime n shap e wil l make th e code easie r t o writ e an d follow , muc h easie r t o debug , an d (ver y likely) faste r i n execution becaus e som e additiona l shortcuts , simplifications , an d optimization s may becom e possible . I n summary , a Mont e Carl o mode l i s mos t efficien t an d effective whe n it is constructed a s a special too l t o solv e a particular problem .
5.5 The applicability of Monte Carlo techniques It ha s bee n sai d tha t "fo r a two-year-ol d chil d wit h a hammer, everythin g i n th e world is a nail." Monte Carlo users can occasionally b e guilty of the same restricte d vision. Whil e th e techniqu e i s o f ver y wid e an d genera l applicability , ther e ar e problems tha t cannot be solved b y this type of approach. Specifically , th e methods discussed her e canno t be applied t o problems tha t violate th e basic assumption s of the models ; fo r example , electro n channelin g an d mos t problem s associate d wit h imaging i n th e transmissio n electro n microscop e canno t b e investigate d becaus e
80 MONt
E CARL O MODELIN G
they involv e th e crystallin e natur e of a sampl e that the Mont e Carl o simulatio n i s treating a s structureless. No r can Monte Carlo methods be applied to problems tha t rely on effects, suc h as electron diffractio n o r the effect o f electron spin polarization, which ar e no t accounte d fo r i n th e physic s buil t int o th e programs . Finally , th e programs ma y b e of onl y limite d value at very lo w (belo w say 0.5 keV) and very high (abov e 50 0 keV) beam energie s becaus e importan t physica l effects—suc h a s the consequences of relativistic or nuclear interactions—have been omitted from th e physics. Ther e ar e als o occasions—suc h a s scannin g electro n microscop e (SEM ) operation a t low magnifications, where the details o f the electron bea m interaction are less significant than purely geometrical effects—wher e a Monte Carlo approach is simpl y no t a s appropriat e a s a simple r an d faste r analytica l mode l migh t be . Within these boundaries, however, the scope for the use of Monte Carlo simulation techniques i s wid e and , as demonstrated i n the subsequen t chapters, th e program s developed her e ca n b e use d effectivel y t o answe r man y question s abou t t o solv e many commonl y encountere d problem s i n microscopy an d microanalysis.
6
BACKSCATTERED ELECTRONS 6.1 Backscattered electrons In this chapter, we will concentrate on simulations associated with various aspects of backscattered electrons . W e wil l defin e backscattere d electron s a s thos e inciden t electrons tha t are scattered ou t of the target after sufferin g deflection s throug h such an angl e tha t the y leav e th e materia l o n th e sid e b y whic h the y entere d (i.e. , fo r normal incidence , the minimu m scattering angl e require d i s 90°). I n practice, i t is often mor e useful t o defin e backscattere d electron s a s those inciden t electrons that are scattere d i n the target i n suc h a way a s to be collectibl e b y a suitable detecto r placed o n the incident beam side of the specimen. This , of course, implie s tha t the apparent magnitude of the backscattering will be affected b y the size and position of the detector relative to the specimen and incident beam. To avoid confusion, we will separate thes e case s b y callin g th e tota l numbe r o f backscattere d electron s pe r incident electro n th e backscattering yiel d TI and the number per incident electro n a s measured by som e specifie d detecto r the backscattered signal . Since ever y Mont e Carl o mode l track s eac h inciden t electro n i n it s passag e through the target, the determination o f whether or not a given electron is backscattered i s inherent in the simulation. At the same time, the backscattering yiel d TI is a convenient macroscopi c measur e o f th e interactio n o f th e electro n bea m wit h th e target an d form s a usefu l experimenta l tes t o f th e prediction s o f a Mont e Carl o model. Befor e attemptin g t o simulat e detail s o f backscattere d imagin g fro m com plex an d inhomogeneous samples , w e must therefore demonstrat e tha t the models developed i n th e previou s chapter s correctl y matc h experimenta l value s fo r th e backscattering yiel d fro m plana r an d homogeneous materials .
6.2 Testing the Monte Carlo models of backscattering The variatio n o f backscatterin g yiel d wit h atomi c numbe r wa s firs t establishe d nearly a century ag o (Starke, 1898 ; Campbell-Swinton , 1899) . Figur e 6. 1 show s a compilation of some modern backscattering yiel d data plotted agains t atomic number for an incident beam energy of 1 0 keV using results taken fro m Bisho p (1966), Drescher e t al . (1970) , Hunge r an d Kuchle r (1979) , Neuber t an d Rogaschewsk i (1980), Reimer and Tolkamp (1980), and Heinrich (1981). T I is seen to vary consid 81
82 MONT
E CARL O MODELIN G
Figure 6.1. Experimenta l BSE yield data at 1 0 keV and corresponding Monte Carlo values.
erably acros s the periodic table , increasing fro m abou t 0.06 fo r carbon to about 0.5 for uranium . Th e variation wit h atomic number i s generally smooth, although—a s pointed ou t b y Bisho p (1966)—th e slop e o f th e curve changes discontinuousl y a t about Z = 3 0 and again at about Z = 60 . These changes have been associated wit h the binding energies o f the atomic electrons. However , while the general form of the variation i s evident , i t i s clea r tha t ther e i s significan t scatte r betwee n differen t pieces of data. Although most of the cited authors claim measurement accuracies of better than 5%, variations between comparabl e values are as much as 20% in some cases. Thes e discrepancie s probabl y aris e from th e variety of methods employe d to measure t\ an d i n particula r fro m th e succes s wit h whic h th e effec t o f secondar y electrons ca n be remove d fro m th e data. A complete se t of experimental backscat tered dat a measurement s i s available in Joy (1993) . The backscatterin g coefficien t T\—computed usin g eithe r th e singl e o r th e plural scatterin g Monte Carlo models (1000 trajectories per point)—is seen to be in good agreement wit h the experimental data , either valu e lying within the spread of measured values . Th e singl e scatterin g values , especiall y fo r Z > 40 , ten d t o be slightly on the high side of the best-fit tren d line through the data, but the sense and magnitude of the deviation i s not systematic . The excellent agreemen t fo r either of the model s is , o f course , gratifying , bu t i t i s no t unexpected , sinc e bot h model s contain a parameter that can be selected s o as to match the experimental backscatter ing yields. In the case of the single scattering model, the screening paramete r a can be adjusted t o ensure a good fi t to measured data. The expression fo r a a s given in Eq. (3.2) and used in our model is that suggested by Bishop (1976). Similarly, in the plural scatterin g model , the minimu m impact paramete r p0 [Eqs . (4.3 ) an d (4.4)] , when use d i n th e for m give n in Eq . (4.8) , agai n allow s th e compute d backscatte r data t o b e fitte d t o th e experimenta l values . In bot h models , th e paramete r t o b e
BACKSCATTERED ELECTRON S 8
3
Figure 6.2. Variatio n o f BS yield fro m gold/coppe r solid solution an d corresponding Mont e Carlo simulate d dat a usin g various models .
adjusted is a simple function of the atomic number Z; hence improving the fit to one chosen dat a valu e will usuall y worsen th e fi t a t som e othe r value . The suggeste d values represent th e bes t overal l fi t t o the measure d values a t 1 0 keV. It is also necessary to consider i n somewhat more detail the variation of T| with composition whe n the targe t i s no t a pure elemen t (Herma n an d Reimer, 1984. ) Figure 6.2 plots the variation of the backscattering coefficient for a solid solution of gold i n coppe r (dat a taken fro m Bishop , 1966) . A s the atomi c percentag e o f gol d increases fro m 0 % to 100% , the measured backscattering coefficien t increase s lin early from the expected value for pure copper to the expected value for pure gold. If we have a materia l wit h th e chemica l formul a S^jX , wher e th e Xt ar e element s of th e periodi c tabl e wit h correspondin g atomi c weight s A,- , an d th e ai ar e thei r valences i n the chemical formula (e.g., i n H2O, al - 2 , a2 = 1 , Xl = H, X2 = O, Al = 1 , A2 = 16) , the n w e can defin e a mass concentratio n ci fro m th e formul a Cj = (djAiltpjA^, wher e £,-c, - = 1 . The data shown in Fig. 6. 2 represents a specia l case o f a genera l resul t (Castaing , 1960 ; Heinrich , 1981) , whic h state s tha t th e backscattering coefficien t T| mix for a mixture of elements i s given by the relation :
In simpl e situations , i t i s clearly possibl e t o fin d th e valu e of -n mix b y findin g th e individual values of if y fo r the components, usin g the simulation s alread y described and the summing them using Eq. (6.1). As Fig. 6.2 shows, this provides a very close fit to the experimental data. This procedure is, however, rather tedious if the chemis-
84 MONT
E CARL O MODELIN G
try o f th e targe t i s comple x (excep t fo r th e cas e o f th e HKLC S model , discusse d below); instead , we migh t try t o obtain th e correc t valu e of T) mix b y makin g som e assumption abou t a n effectiv e o r averag e atomi c numbe r fo r th e compoun d o f interest. Th e simplest suggestio n (Miiller, 1954 ) is to use the mean valu e of atomic number Z mix fo r the compound—i.e.,
The effective atomi c weight Amix is found i n a similar fashion , and the value of the density used is the measured value for the compound. Figure 6. 2 shows the results of employing this assumption and the plural scattering Mont e Carlo model o f Chap. 4 to mode l th e copper-gol d system . The agreemen t betwee n th e experimenta l an d computed dat a i s adequat e t o goo d ove r th e ful l rang e fro m 0 % t o 100 % gold, indicating that the accuracy of this simple approximation is likely to be adequate for most purposes. Alternatively , because electro n stoppin g powers computed from th e Bethe equation are additive, Everhart (1960) suggested that a more physically exact expression for Zmix woul d b e
However, a s show n in Fig. 6.2, application o f this rul e t o th e copper-gol d syste m produces a considerabl e deviatio n betwee n th e predicte d an d experimenta l data , suggesting tha t Eq. (6.2) is a mor e usefu l expression . Simila r result s ar e foun d i n more complex systems. Figure 6.3 plots the experimentally determined backscatter ing coefficien t fo r th e ALpa^^A s syste m a s a functio n o f th e mol e fractio n o f aluminum (Sercel et al., 1989) . Superimposed o n this plot are the computed predic tions fo r th e backscattering, usin g Eqs. (6.2) and (6.3) . I n this example, fo r which the differences betwee n the atomic numbers are relatively small and the composition range i s limited, th e differenc e betwee n th e tw o models i s not a s marked, but i t is clear tha t th e simple r expressio n o f Eq . (6.2 ) is stil l a t leas t a s goo d a s th e mor e complicated expressio n o f Eq . (6.3) . I n th e res t o f thi s volume , therefore , compounds wil l be computed eithe r assumin g the use of Eq. (6.2) or from th e HKLC S procedure, discusse d below. The backscatterin g coefficien t T I i s not constan t wit h energy, a s is often state d in introductor y textbooks , bu t varie s i n a manner tha t depend s o n both th e energ y
BACKSCATTERED ELECTRON S 8
5
Figure 6.3. Variatio n o f B S coefficien t fo r A l i n AlGaA s syste m (Serce l e t al. , 1989 ) and simulated MC data usin g different models . and the atomic number, Figure 6.4 plots data from Hunger and Kuchler (1979) for f] as a function o f Z at 4 and 40 keV. It can be seen that while the general for m o f the variations at the two energies i s similar, the absolute values change significantly. On moving from 4 to 40 keV, the backscattering coefficient of the lightest elements fall s by a factor of up to two times, while that for the heavier elements rise s by as much as 25% . The plots fo r 4 and 40 ke V actuall y cross a t about Z = 40 . The detaile d form of this variation is shown more clearly in Fig. 6.5 , which plots the variation of
Figure 6.4. Variatio n o f B S yiel d wit h energy ,
86 MONT
E CARL O MODELIN G
Figure 6.5. Variatio n o f B S yiel d wit h energy .
r\ for carbon, silicon, copper, silver , and gold as a function o f beam energy. It is clear that at the lowest beam energies (i.e. , <1 keV), the bulk backscattering coefficient s for al l elements ten d to converge to values between 0.2 and 0.4. Fo r higher energie s (>50 keV ) th e backscatterin g coefficient s fo r ligh t element s ten d t o decreas e b y about 10 % for eac h facto r o f 1 0 increase in bea m energy , while thos e fo r heavie r elements remai n abou t constan t (Antola k an d Williamson , 1985) . Hunge r an d Kiichler (1979) have derived an analytical expression that predicts, fairly accurately , values of T I as a function o f both the atomic number Z and the incident energ y E (i n kilo-electron volts) :
where
Neither of the two Monte Carlo models discussed in the previous chapters can predict thi s type of behavior . I n fact , a plot o f T\ versus energ y usin g eithe r o f ou r models wil l show that, over the energy range 5 to 40 keV, the predicted backscatter ing coefficient is , to within the expected statistical error, independent of energy. (For lower energies , th e value s fro m th e singl e scatterin g mode l ma y vary , but thi s i s because th e computation of trajectories i s terminated a t an arbitrary cut-off energy , which i s a significan t fractio n o f th e inciden t bea m energy) . Ther e ar e severa l
BACKSCATTERED ELECTRON S 8
7
reasons fo r this disagreemen t betwee n experimenta l an d computed data . First , th e parameters in both models that adjust the backscattering values to match experimental data a t some nominal energ y ar e designe d t o hold th e valu e of r\ constan t with beam energy , since , unti l quite recently , low-energy electro n interaction s wer e of little interest ; therefore , th e assumptio n tha t T | wa s constan t wit h energ y wa s a reasonable simplification . Second, a s noted in discussing the data in Fig. 6.1 above, the qualit y of the experimental dat a on backscattering coefficient s i s rather mixed, and th e magnitud e o f the variatio n of -r\ wit h energy for most elements i s less than the sprea d betwee n differen t publishe d value s a t th e sam e energy . Consequently , many workers have preferred to take T| as constant until more accurate experimental values were determined. Finally , an d of more fundamental significance, both models use the screene d Rutherfor d cross sectio n as the basis for the model of electro n scattering. For a wide range of conditions—that is, for elements o f low and medium atomic number, electron energie s greater than 10 keV, and small scattering angles— the Rutherfor d cros s sectio n i s a goo d approximation ; bu t fo r heav y elements , energies below 1 0 keV, and large scattering angles, the Rutherford cross section can be significantl y in error . I t must , instead , b e replace d b y th e Mot t cros s section , which takes into account spin-orbit coupling in the solution of the relativistic Dirac equation (Reime r an d Lodding, 1984) . I n general terms , th e Mot t cros s sectio n i s essential in applications wher e the interaction of interest consist s of a single elastic large-angle scattering event (e.g., in backscattering fro m thi n foils or in calculations of th e energ y spectru m o f backscattere d electrons ) an d i s desirabl e fo r al l low energy applications . But for effect s cause d by electron diffusio n an d plural scatter ing (e.g. , backscatterin g fro m bul k samples, x-ra y production, an d secondary elec tron generation) , th e Rutherfor d cros s sectio n give s rathe r goo d agreemen t wit h experimental data except at low beam energies. The Mott cross section is considered in more detail in the final chapte r of this book, but elsewhere th e Rutherford mode l will b e use d because , unlik e th e Mot t model , whic h require s th e generatio n o f extensive table s o f data, it can be expresse d analytically . With th e increase d interes t i n low-energ y scannin g microscop y an d micro analysis, it would , however, be desirabl e t o try an d modif y th e models develope d earlier to correctly predict the variation of T| with energy so as to obtain som e of the benefits of the Mott cross section without the extra effort tha t is required. This is not readily possibl e for the single scatterin g mode l because of the necessity, discussed in Chap . 3 , of terminating the electrons' trajectorie s a t som e predetermine d cutof f energy, usually 0.5 keV. At low energies, thi s cutoff i s a significant fraction o f the incident energ y an d henc e th e precisio n o f th e computatio n i s doubtful . Fo r th e plural scattering model, however, a variation of Z with E can readily be achieved. As discussed in Chap. 4, the scattering angl e $ can be written in the form [usin g Eqs. (4.5) an d (4.10)]:
88 MONT
E CARLO MODELING
Figure 6.6. B S yiel d vs , ta n ( 0/2). Love et al. (1977) reasoned that since, from the form of the Bethe equation, the variation o f (EQ/E) i s substantially independent of atomic number, the backscattering coefficien t T ) must depend only on the value of tan (cj> 0/2). As shown in Fig. 6.6 , this assumption is correct. Using the code of Chap. 4, we find that the backscattering coefficient t ) depend s o n th e valu e of ta n (4>o/2 ) i n a monotonic fashio n bu t i s t o within statistica l erro r independent o f the atomi c number and density o f th e target and o f th e electro n energy . Fro m a curv e fi t o f th e dat a i n Fig . 6,6 , w e fin d th e relation:
These coefficients diffe r slightl y from thos e originally given by Love e t al . (1977 ) and quoted in Eq. (4.7) because of the effect o f the small angle-scattering correctio n included in our program [Eq . (4.10)]. To obtain the necessary estimat e of TI , we can now us e th e Hunger-Kiichler relation [Eqs . (6.4 ) t o (6.6) ] discussed above . Give n the atomic number of the target and the beam energy E, this gives us the value of TI and hence of tan (4>o/2). This value can now be used in place of the original estimat e [Eqs. (4.6 ) an d (4.8)] , wit h th e advantag e tha t the backscatterin g coefficien t pre dicted by the Monte Carlo program will vary correctly with incident beam energy. It should be clear that this Hunger-Ktichler-Love-Cox-Scott (HKLCS) model is not a radical revisio n o f th e plura l scatterin g schem e bu t simpl y th e replacemen t o f Duncumb's one-parameter fi t to the minimum scattering angle [Eqs. (4.4), (4.8), and (4.9)] with a more comple x fit. To incorporat e thi s modificatio n int o th e plura l scatterin g code , i t i s onl y
BACKSCATTERED ELECTRON S 8
9
necessary to replace one procedure (hence the value of writing the code in a modular fashion). The revised procedure listed below replaces the original procedure of the same name and implements Eqs. (6.4) , (6.5), (6.6), and (6.8). It is stored on the disk as HKLCS.PAS. To replace th e ol d procedure wit h the new one using the TURBO PASCAL editor, g o into EDIT mode and load PSJVIC.PAS; then scroll through the program until the start of the procedure Rutherford—Factor . Type (Control K R) and a smal l windo w wil l appea r askin g fo r a file name . Typ e i n HKLCS(return) . This block of code will then be read in from the disk and be placed at the cursor position. Now delet e th e old procedure an d recompile th e program. Procedure Rutherford—Factor; {computes the Rutherford scattering factor for this incident energy using the Love, Cox, Scott model and the Hunger-Kiichler backscatter equation} var hkbs,hkc,hkl,hkm:extended; begin {compute the Hunger-Kuchler backscattering coefficient}}} htan:=0,1382-0.9211/sqrt(at_num) ; hkl: =l n ( a t _ n u m ); hkc:=0.1904-0.22236*hkl+0.1292*hkl*hkl -0.01491*hkl*hkl*hkl; hkbs : =hkc*power (inc_energy' hkm) ; [now compute the Love, Cox, Scott parameter from Eg.
(6.8)}
rf : =0.016697 + 0. 55108*hkbs-0.96777*hkbs*hkbs+l.8846*hkbs*hkbs*hkbs; r f : =rf*inc_energy; end;
Figure 6. 7 plots the backscattering coefficient , computed using this version of the plural scatterin g program , fo r carbon, silver , and gold a s a function o f inciden t beam energy . Th e variatio n o f T ] wit h energy i s clearl y eviden t belo w 1 0 keV, th e yield fo r carbo n risin g a s th e energ y fall s whil e that for silve r remains essentiall y constant and that for gold falls, ultimately to a value lower tha n that for silver. The predicted value s agre e wel l wit h the dat a plotte d i n Fig. 6.5 excep t a t th e lowes t energies, where the Hunger-Kiichler fit is probably inaccurate. Althoug h this revised model i s not a substitut e for th e mor e accurat e Mot t scatterin g cros s section , i t is often a sufficiently goo d approximatio n to make the use of the more complex Mott model unnecessary . A n additiona l advantag e o f thi s approac h i s that , sinc e a n estimate fo r th e backscatterin g coefficien t i s produced o n th e basi s o f th e atomi c number o f th e targe t fro m th e Hunger-Kiichle r model , w e coul d us e Eq . (6.1)
90 MONT
E CARL O MODELIN G
Figure 6.7. compute d variatio n o f B S yiel d wit h energy i n HKLCS model .
directly to treat the case of a multicomponent material. Without coding this example in detail, the procedure woul d be a s follows : Get the number n_comp of components in the compound For i = 1 to n_comp Get atomic number Z[i] Get corresponding concentration c[i] Calculate BS coefficient % from Egs. (6.4) through Next i Calculate mean BS coefficient as S^iii Find Rutherford factor from equation 6.8
(6.6)
6.3 Predictions of the Monte Carlo models We can now investigate some of the predictions tha t the Monte Carlo model s make about the properties o f backscattered electrons . Thes e ar e parameters o f the back scattering tha t are not, in either a direct o r a hidden way , built into the models we have developed . 6.3.1 Variation of ^ with angle of incidence The plural scattering models allow us to input the angle of incidence of the electro n beam relative to the surface normal of the specimen. We can therefore calculate how the magnitude of the backscattering coefficient varie s with the specimen tilt . Figure 6.8 show s som e dat a fo r iro n compare d wit h a n experimenta l measuremen t (My klebust e t al., 1976 ) fo r Fe—3.2% Si . In bot h cases th e backscattering coefficien t T](0) at some angle 0 is normalized by the corresponding backscattering coefficien t at normal incidence T|(0) , and th e calculated an d experimental data a s obtained fo r
BACKSCATTERED ELECTRON S 9
1
Figure 6.8. Experimental an d computed variatio n o f B S yield wit h tilt .
an incident energ y of 30 keV. It can be seen that the amount of backscattering rise s rapidly a s the angl e o f incidenc e i s increased, wit h both th e experimenta l an d the Monte Carlo data showing an increase o f around 50% for a tilt angle of 45°, while for a tilt of 60°, the backscattering double s i n magnitude. These number s will vary somewhat with both the incident beam energy an d the atomic number of the target, although th e genera l for m o f th e Ti(0)/^(0 ) variatio n remain s fairl y clos e t o tha t illustrated i n Fig. 6. 8 except fo r the higher atomi c number s ( Z > 50 ) an d for low energies (E < 3 keV). The examination of such phenomena b y running a series of simulations is an excellent wa y of becoming familiar with the use of a Monte Carlo model. Simila r calculation s can, of course, b e performed with the single scatterin g model, but the relative slownes s o f this model make s obtainin g a sufficiently goo d statistical accuracy a rather tedious affair. The actual data obtained ar e close to those of th e plura l scatterin g approximation . 6.3.2 Energy distribution and mean energy of backscattered electrons The energ y distributio n o f th e backscattere d electrons , o r a t leas t thei r averag e energy fo r a given set of conditions, is an important parameter, becaus e the output from a backscattered detecto r depend s o n both th e numbe r o f backscattered elec trons (i.e., the value of -n) and the energy of these electrons. Any measurement o f the backscattered signa l is therefore a convolution o f the backscattering yiel d an d the energy distribution from th e sample, and consequently ther e wil l not be, in general, a simpl e relationship betwee n thi s signa l an d the atomic number of the target. The energy distributio n an d mean energy ca n readily b e found b y modifying th e back -scatter and display_backscattering procedures in the plural scatterin g model. W e simpl y not e o n whic h ste p ( 1 t o 50 ) o f th e trajector y th e electro n i s
92 MONT
E CARLO MODELING
traveling whe n i t i s backscattere d an d ad d 1 to th e & th bo x o f a n arra y bs_e [ ] . Since the energy for all electrons o n the k-th step is the same, i.e., E[k], the average backscattering energ y wil l be :
because th e total number of electrons backscattered i s bk_sct. The modified proce dures below implement these steps and plot the mean-energy value on a thermome ter scal e a s a percentage o f the inciden t bea m energy . Remember: ad d to the va r lis t at the top o f th e program th e entry: bs_e:array[l . . 50] of integer ; Procedure back—scatter ; {handles specia l case of a backscattered electron} begin bk_sct: =bk_sct + l; {ad d one to counter} num: =num+l; {ad d one to total} bs_e[k] :=bs_e[k]+1; {electron backscattered at k-th xyplot (y , z , y n, 99 ) ; {plot BS exit} end;
step}
Procedure display—backscattering; {draws a thermometer to display the backscattering coefficient and another to indicate the mean energy of the backscattered electrons} label var
hang; a,b,c,k:integer; mean—energy:extended;
begin a: =GetMaxX-180; b:=bottom+23; c:=20;
{adjust to suit your screen} {ditto} {ditto}
OutTextXY(a,b-8,"0 . . . . 0.25 . . . 0.5 . . . 0.75"); QutTextXY(a+18,b+5,"BS coefficient" ) ; Line ( a , b, trunc ( a + ( b k _ s e t / t r a j — n u m) * 2 2 0 ) ,b ) ; {dra w it } {now compute the mean backscattering energy value} mean—energy: =0; {initializ e th e value}
BACKSCATTERED ELECTRONS
93
for k:*=l to 5 0 d o
begin {add up number at step k*energy at step k} mean—energy: =mean_energy+E[k] *bs_e[k] ; end; mean—energy : =mean_energy/bk—set; {averaged over total BS] {draw a thermometer to plot up this data value }
O u t T e x t X Y ( c , b - 8 , ' 0 %....................................50%..................................1000%) ;; OutTextXY(c+2,b+5,'% of incident energy'); line (c, b, c + trunc (165* (mean—energy/ inc —energy) ) ,b) ;{{{{draw itn in } hang: if (not keypressed) then goto hang; {freeze display on screen} CloseGraph; {shut down the graphics unit} end;
Figure 6. 9 plot s th e valu e o f mean-energ y a s a functio n o f th e atomi c number for 1 5 keV incident electrons, showing that as Z increases, the value climbs steadily from carbo n to gold. These values are seen to be in good agreement with the experimental data measured by Bishop (1966). From a curve fit of the Monte Carlo data, we can express the value of mean-energy as : mean-energy = £ 0[0.55612 + 3.163*1Q- 3*Z - 2.0666 * IQ-^Z2] (6.10 )
Figure 6.9. Variatio n o f mea n B S energy wit h Z.
94
MONTE CARL O MODELING
Figure 6.10. Compute d energy spectr a o f backscattered electrons .
This variatio n is significan t because backscattere d detector s usuall y respond mor e efficiently t o electrons of higher energy; therefore, as we move through the periodic table, the output from the detector will increase both because of the higher backscattering coefficien t an d becaus e o f th e highe r averag e mean energy . Th e reaso n fo r this variation in mean energy can be seen by plotting the histogram of the bs_e [k ] array, compute d above , whic h measures th e numbe r of backscattered electron s a t each trajector y ste p k. As show n in Fig . 6.10 , whic h plots dat a for E0 = 1 5 keV beam energy, for carbon this histogram is more or less symmetrical about the energy 0.5£0; but for copper, the maximum in the curve has shifted upward in energy, while for gol d th e curv e has n o maximu m but increase s monotonicall y a s th e backscat tered energ y approache s th e bea m energy . Th e for m o f th e energ y distributio n predicted b y th e Mont e Carl o simulatio n i s i n generall y goo d agreemen t wit h experimental dat a (Bishop, 1966 ; Mykelbus t et al., 1976 ) excep t fo r the top end of the distribution clos e to th e inciden t beam energy, where the numbe r of backscat tered electrons is overestimated somewhat . These particular electrons ar e those that are scattere d i n a singl e high-angl e even t clos e t o th e entranc e surface , an d th e scattering o f suc h electron s i s accuratel y described onl y by the Mot t cros s sectio n rather than by the screene d Rutherfor d model use d here. However, sinc e these are only a smal l fractio n o f th e tota l numbe r o f backscattere d electrons , th e erro r i s insignificant. Although we will not pursue it here, this same code fragment ca n also be used to estimate the information depth o f the backscattered electrons—tha t is, the depth
BACKSCATTERED ELECTRONS
95
beneath the surface reached by an electron before it is backscattered. If an electron is backscattered o n the k-th step, the n the maximum possible dept h to which it could have traveled beneath th e surface is k*step, wher e step is the step length in the simulation, whic h i s usuall y one-fiftiet h o f th e Beth e range . A n analysi s o f th e bs_e [k ] distributio n therefore provides an upper bound on the information depth in th e backscattere d image . Typicall y thi s i s abou t 0. 3 o f th e Beth e range . Th e program JustBS on the disk incoporates thi s and the other modification s discussed above to give a detailed mode l of the backscattering effect , includin g an estimate of the surfac e area fro m whic h the electron s ar e emitted . 6.3.3 Variation of backscattering with density In addition t o comparing th e predictions o f our simulations with experimental data , we ca n us e th e Mont e Carl o mode l t o predic t effect s tha t migh t no t b e easil y observable althoug h they migh t also be important. A n example o f such an applica tion i s t o as k th e question : "Ho w doe s th e backscatterin g coefficien t o f a sampl e vary with density?" This question is of particular interest because of attempts to use the backscattered signal as a means o f performing chemica l composition analysis. While suc h a method migh t wor k for a homogeneous material , i t seem s natural to ask whethe r changes i n the densit y o f th e target , cause d perhaps b y differen t pro cessing methods , might not lead to a systematic error. Running the plural scatterin g simulation fo r coppe r a t 1 5 keV, leaving al l o f the physica l parameter s unchange d except for the density an d using 5000 trajectories for each value , produces th e data shown i n Fig. 6.11 . To within th e statistical error of the simulation, it can be seen
Figure 6.11. Compute d variation o f BS yield with sampl e density.
96 MONT
E CARL O MOD
that changing the density over a wide range o f values does not change th e backscattering coefficien t fo r a n otherwis e homogeneou s material . W e als o fin d tha t th e mean energy o f the backscattered electrons , althoug h not plotted, is independent o f the density . While a t first sigh t it might seem tha t this result is counterintuitive, a n examination of the equations in Chaps. 3 and 4, which determine electron scattering , shows tha t the densit y appear s onl y in the stoppin g powe r equation . Consequentl y varying the densit y changes onl y the Beth e rang e o f the electrons , an d this woul d not b e expecte d t o have an y effec t o n t) . If , however, the materia l i s no t homoge neous bu t contain s region s o f differen t density , change s migh t b e expected ; thi s situation i s examine d late r i n this chapter. 6.3.4 Variation of backscattering with thickness A final demonstratio n of the models is to use them to compute how the backscatter ing coefficient migh t vary with the thickness of the target. Clearly, if the specimen is very thin , then the amoun t of backscattering i s small ; while for a sufficientl y larg e thickness a t a given inciden t energy, the backscatterin g coefficient shoul d b e con stant. Our interest her e i s to simulat e the variatio n of i q betwee n these two limitin g conditions and to compare thi s with experimental data. It is immediately clear that, in this case, we cannot use the plural scattering approximation because, as discussed in Chap . 5 , th e granularit y o f thi s mode l i s prese t t o b e one-fiftiet h o f th e Beth e range. When the target is a thin foil, eac h ste p of the plural scattering mode l would be a substantial fraction of the thickness of the foil and the quality of the approximation woul d be very poor. Instead, w e must use the single scatterin g model, becaus e the ste p lengt h her e i s o f th e orde r o f th e elasti c mea n fre e pat h (e.g. , a fe w nanometers at 1 0 keV), and is thus much smaller than the thickness being modeled . Figure 6.12 plots the predicted backscattering coefficien t o f films of carbon, copper , and gold a s a function o f their thickness a t an incident bea m energy o f 1 5 keV. For convenience i n comparison, th e thicknesses i n each cas e hav e been expresse d a s a fraction o f the appropriate Bethe range RB calculated from Eq . (4.1). The backscatter yield varies almost linearly with the specimen thicknes s (Niedrig, 1982 ) right up to the point where the backscattering yield reaches it s "bulk" value. The thickness at which thi s occurs , however , varies significantl y fro m on e materia l t o another , a s would be expected fro m a n examination o f the interaction volume s pictures show n in Fig. 4.4 . I n carbon, th e scatterin g o f the electrons is weak, giving a n interactio n volume tha t hang s lik e a teardro p downwar d from th e entranc e surface . Conse quently th e specime n ha s t o b e almos t 0. 5 RB thic k befor e th e backscatterin g saturates. In the case of gold, the electrons ar e strongly scattered, givin g an interaction volume that is squashed u p against the surface. As a result, the backscatterin g yield reaches it s bulk valu e a t only abou t 0.1 RB. Since th e Bethe range i n gold i s only a small fractio n of that in carbon, thi s show s that the information depth o f the
BACKSCATTERED ELECTRONS
97
BS Yield v s Thickness
Figure 6,12. Variatio n of B S yield wit h specime n thickness .
BS signal, (i.e., th e extent of the volume sampled by the backscattered electrons) is much les s in gold than i n carbon.
6.4 Modeling inhomogeneous materials So far every application o f Monte Carlo modeling w e have considered assume s the specimen to be a infinite half-plan e of uniform composition . I n practice, o f course, samples o f suc h a restricted natur e ar e o f littl e interest , sinc e i n th e real worl d of microscopy our specimens are finite in size; have edges, shape, and surface topography; and sho w wide variations of chemical compositio n fro m on e point to another. Fortunately, Mont e Carl o simulations , whic h trac k th e electro n ste p b y ste p a s it moves through the specimen , are ideally suite d to this type of situation, so we can now start to develop the necessary tools to model such systems. In the simplest case , the sample might consist of a layer of material 1 on top of a substrate of materials 2. If the depth of the interface between these materials occur s at a depth boundary, we can then determin e which material th e electron i s in by testing the value of z .
98
MONTE CARLO MODELING
{the sample consists of two materials i = l and i = 2} i : = l ; {reache s to player first} if z>= boundar y the n i : = 2 ;
The program below implements this example of a thin film on a substrate to illustrate how the original program of Chap. 4 is modified to deal with two materials. In order to save space, functions and procedures that have been discussed already, either in this chapter or earlier chapters, are not listed but simply identified as required. A further generalization to three or more materials, or to the situation where a single scattering model is required, is a simple matter; a program of this type is given in the chapter on x-ray generation. Program BINARY; {this code performs a plural scattering Monte Carlo trajectory simulation for the case where a layer of material A is placed on top of a bulk substrate of some other material B. There is no graphical display in this program} {$N+} {$E+} uses
{turn on numeric coprocessor} {install emulator package}
CRT, DOS;
{resources required}
label
back—scatter,abort;
const
two_pi = 6.28318;
{2 constant}
var
inc_energy,boundary,tilt,s_tilt,c_tilt:extended; nu, sp, cp, ga, an, an__m, an_n: extended; x,y,z,xn,yn,zn,ca,cb,cc,ex,cy,cz,vl,v2,v3,v4:extended E:array[l . . 2,1 . . 51] of extended; at_num:array[1 . . 2] of extended; at_wht:array[1 . . 2] of extended; mn_ion_pot:array[1 . .2] of extended; m_t_step:array[1 . .2] of extended; density:array[1 . .2] of extended; step:array[l . . 2] of extended; rf:array [1 . .2] of extended; bk_sct,num,traj_num,i,k:integer; Function power(mantissa,exponent:real):extended; Function stop_pwr(i:integer;energy:extended):extended; {calculate stopping power for material i using Eg. (3.21)} var temp:extended;
BACKSCATTER
99
begin if energy<0.05 then (to avoid problems as energy goes to zero] energy:=0.05; temp:=ln((1.166*energy+0.85*mn_ion_pot[i])/mn_ion^>ot[i] ) ; stop_pwr: =7.85E4*at_num[i]*temp/(at_wht[i]*energy) ; end;
Procedure ranged: integer) ; {calculates range assuming Bethe continuous energy loss} var energy,f,fs,bethe—range:extended;: 1,m:integer; begin fs:=0.; for m:=l to 21 do begin
{initialize variable to be sure} {siinpsons rule integration}
energy: = (m-1)*inc_energy720; f : = 1/stop_pwr(i,energy); 1:=2;
if m mod 2 = 0 then 1:=4; if m=l then 1:=1; if m=21 then 1:=1; fs:=fs+l*f;
end; {now use this to find tions}
the range and step length for these condi-
bethe_range: = fs*inc_energy/60 . 0; {i n g/'cm2} m_t_step[i] : =bethe_range/50.0; bethe_range: =bethe_range*10000.0/density[i] ; {i n mi crons} G o T o X Y ( 4 0 * ( i - l ) +1,13) ; {displa y 1 o n LHS, 2 on RHS of screen} w r i t e l n l ' R a n g e in ' i , 'i s bethe_range:4:2 ' ' m i c r o n s ' ) ; s t e p [ i ] : =bethe_range/50 . 0 ; {uni t ste p o f simulation} end; Procedure p r o f i l e ( i : i n t e g e r ) ; {compute 50-ste p energy profile for electron beam} var A l , A 2 , A 3 , A 4 , e m : r e a l ; m:integer; begin
100
MONTE CARLO MODELING
E [ i, 1 ] : =inc_energy ; for m : = 2 t o 5 1 d o begin Al: =m _ t _ s t e p [ i ] * s t o p _ p w r (i , E [i , m - l] ) ; A2 :=m_t_step[i] *stop_pwr (i , E [ i , m - l] - A l / 2) ; A3 : =m _ t _ s t e p [ i ] * s t o p _ p w r ( i , E [ i , m - l ] - A 2 / 2 ); A4:=m_t_step[i]*stop_pwr(i,E[i,m-l]-A3); E[i,m]:=E[i,m-l] -
( A l +2*A 2 +2*A 3 + A 4 J / 6 . ;
end; E[i,51]:=0; {now smooth thes e profiles
out a
little bit}
for m : = 2 t o 5 0 d o begin E [ i , m ] : = ( E [ i , m ] + E [ i , m + l] } /2 . ; end;
end; Procedure Rutherford—Factor(i:integer); {find the screened Rutherford scattering parameter b using the HKLCS method} var hkbs,hkc,dum,hkm:extended; begin hkm: = (0.1382 - 0.9211/sqrt(at_num[i] ) ) ; dum: = In (at_num [ i ] ) ; hkc:=0.1904-0.2236*dum+0 .1292*dum*dum-0.01491*dum*dum*dum; hkbs : =hkc*power (Inc_Energy,hkm) ; {then the scattering factor for material i is} rf [i] : =0.016697 +0.55108*hkbs-0.96777*hkbs*hkbs +1.8846*hkbs*hkbs*hkbs; end; Procedure set—up—screen; {gets necessary input data to run the program} begin ClrScr; {tidy up the display screen}
BACKSCATTERED
101
GoToXY (25,1) ;
Writeln('*A on B MC Simulation in Turbo Pascal*'); {Having set up the screen now get input data} GoToXY(1,5);
Write ('Input beam energy in keV ) ; Readln(Inc—Energy); GoToXY(1,7);
Write('Boundary depth (microns)'); Readln(boundary); GoToXY(1,9);
Write('Tilt angle in degrees'); readln(tilt); s_tilt: =sin(tilt/57 .4) ,{convert degrees to radians] c_tilt:=cos(tilt/57.4) ; ClrScr; {again-to set up for two column input of data} for i:=l to 2 do {get materials data} begin if i = l then {surface layer} begin GoToXY(1,5); writeln('Surface Layer'); end else {we are in the substrate} begin GoToXY (40,5);
writeln('Substrate'); end; [now get the materials information that is needed} GoToXY(40* (i-1) +1,7) ,{LHS of screen for 1 = 1, KHS for 1 = 2}
Write('.. .. ..Atomic Number ig'); Readln(at—num[i]); GoToXY(40* (i-1) +1,9) ;
Write('. . . . . Atomic Weight is'); Readln(At_wht[i]); GoToXY(40* (i-1) +1,11) ; Write ( ' . . . . . density in g/cc is'); Readln(Density[i]); {Calculate th e Berger-Selze r Mean ionization potential inn_ion_pot } mn_ion_pot[i]:=(9,76*at_num[i] + _num[i],0.19)))*0.001;
(58.5/power(a t
102
MONTE CARLO MODELING
{now get the Rutherford factor b using the HKLCS method} Rutherford—factor(i); [now get the range and step length in microns for these conditons} range ( i) ; {and calculate a 50-step energy profile
E[i,k]
using this result]
profile(i); end;
{of
the input
loop}
{get the number of trajectories to be run in this simulation} GoToXY(18,15); write("Number of trajectories required"); readln(traj_num); {and set up the display for output of data}
GoToXYfl,16); writeln GoToXY(1,17); writeln('Number of trajectories'); GoToXY(40,17); writeln('Backscattered fraction'); end;
Procedure init_counters; Procedure reset-coordinates; Procedure p_scatter(i:integer); {calculates scattering angles using plural scattering model of Chap. 4} begin {call the random number generator function} nu:=sqrt(RANDOM) ; nu: = ( ( l / n u ) - 1 . 0) ; an: =n u * r f [ i ] * i n c _ e n e r g y / E [ i , k ]; {and use this to find the scattering angles} sp: = (an+an) / (1 + (an*an ) ) ; c p : = ( l - ( a n * a n ) ) / (1 + (an*an ) ) ;
BACKSCATTERED ELECTRONS
103
{and the azimuthal scattering angle} ga: =two_pi*RANDOM;
end; Procedure new_coord(i:integer);
{calculates new coordiantes xn,yn,zn from x,y,z and scattering angles} begin {the coordinate rotation angles are] if cz = 0 then cz:=0.000001; an_m:=-cx/cz; an_n:=1.0/sqrt(1+(an_m*an_m) ) ;
{save computation time by getting all the transcendentals first] vl: =cos(an_m)*sp; v2:= cos(an_n)*sp; v3 : =cos (ga) ; v4 : =sin (ga) ; {find the new direction cosines} ca =(cx*cp) + (vl*v3) + (cy*v2*v4); cb =(cy*cp) + (v4*(cz*vl - cx*v2)); cc =(cz*cp) + (v2*v3) — (cy*vl*v4);
{and get the new coordinates—using the appropriate step} xn =x + step[i]*ca; yn =y + step[i]*cb; zn =z + step[i]*cc; end;
Procedure**
s thisisthestartofthemainprogram
set_up_screen; init_counters; randomize; {reseed random number
generator}
{
*
104
MONTE CARLO MODELING
}
while num < traj_num do begin reset—coordinates; for k:=l to 50 do begin {first find out where the electron is now i = l or 2. In the simplest case this is done by checking whether or not the electron z coordinate places it below the boundary layer} if z>=boundary then i:=2 else i:=l; {in other situations a different test would be inserted here}
{now allow the electron to be scattered} p_scatter(i) ; new_coord(i); {test for electron position within the sample} if zn< = 0 then begin bk_sct:=bk_sct+l; num:=num+l; goto back—scatter; end else reset_jiext—step; end;
{of the 50-step loop} num:=num+l; {add one to the trajectory total} back—scatter; {end of goto branch for BS} {update the screen displays} GoToXY(25,17); writeln(num); {display trajectory total} GoToXY(65,17); writeln((bk_sct/num):4:3); {display BS coefficient} {to escape from the program press any key} if keypressed then goto abort;
{
*
BACKSCATTERED ELECTRON S 10
}
end;
5
{of the Monte Carlo loop} abort: {escap e from the program} GoToXY(21,21); w r i t e l n l ' . . . h t a t 's al l f o l k s ' ) ; readln; {freeze the display}
end.
6,5 Notes on the program The program starts in the sam e way as for the previous examples b y settin g up the pragmas that select the use of the math coprocessor o r the emulator package. Sinc e this program does not generate any graphical display, the uses declaration include s only th e call s fo r th e function s CR T an d DOS , which ar e required . Th e variabl e declaration sectio n resemble s tha t use d befor e bu t wit h a n importan t difference . Instead o f there bein g a single valu e of , for example, the atomi c numbe r at_wt, there wil l now be one of two possible value s depending o n where within the target the electron i s situated. Therefore the original singl e value of at_wt i s replaced b y an arra y o f at_w t values . I n th e notatio n use d i n PASCAL , w e indicat e thi s by writing at_,w t [ i ] t o represent th e i-th value of at_wt. W e must thus modif y the list of variables in the program to indicate that at_wt, den s i ty, o r any of the other specime n parameter s ca n take two (or more general example s ri) different values. The VAR table woul d then contai n entrie s suc h as: at_wt:array [1 . .4] of extended; at_num:array [1 . .4) of extended; {and so on for every variable
that changes} where the [ . . .] brackets indicat e th e numbe r o f the firs t an d las t member s o f th e array and specify what type of variable it is f Not e that in PASCAL we must specify an actual number of members of the array; this cannot be done in terms of anothe r variable. Having now done this, we must also indicate to the various PROCEDURE S and FUNCTIONS that use these variables whic h of the n values they are to use. We do this by passing a parameter to the procedure, which tells it which particular value to use . In eac h case , wher e i n Chap . 4 w e ha d a single-value d variabl e (e.g. , density), we now have one specific value taken from th e array of possible value s densityD'[. The value of / to be used is passed t o the procedure o r function a t the time that we call it; therefore, instea d o f calling p r o f i le t o calculate th e energy profile E[k], w e cal l profile!)' ] t o tel l i t t o calculat e th e profil e fo r th e /-t h material b y substituting the appropriate value s of stopping_pwr, m_t_ste p etc. On e assumption in this program is that E[l,k] * » E[2,k]', i n other words, that the
106 MONT
E CARL O MODELING
instantaneous energ y of th e electron depend s onl y o n the number of the trajectory step k and not on the actual material. This approximation is, in fact, closel y correct , because—from th e form o f the Bethe equation—the instantaneous energy depend s only on the fraction of the Bethe range traveled and not significantly on the atomic number of the materia l itself. The rest of the program then follow s closel y on the original version given in Chap. 4 except that we now test at the top of the loop which of the two materials the electron i s in , /= ! o r i=2, befor e computin g th e scatterin g angle s an d findin g the new coordinates . Becaus e w e ar e not trying to displa y these dat a visually , the procedures fo r graphics setu p and plotting are missing, and if you run this program, you will notice how much faster it performs than the earlier version . While pictures of th e trajectorie s ar e interestin g an d quit e ofte n helpful , the y ar e ver y time consuming t o produce because o f the large tim e overhea d required i n calculating plotting coordinate s an d drawin g th e scree n displays . Therefor e the y shoul d b e omitted i f not strictl y necessary. Figure 6.1 3 shows an application of this program t o the case o f a thin carbo n film o n to p o f a gold substrat e a t 1 0 keV. Sinc e w e ar e usin g a plural scatterin g model here , th e dat a wil l no t b e reliabl e fo r fil m thicknesse s les s tha n abou t a thousand angstroms (i.e., three or four trajector y steps), but the trend is clear (Hohn et al. , 1976) . A t lo w fil m thicknesses , th e backscatterin g coefficient i s essentiall y that of gold; this then decreases wit h film thickness , eventuall y falling to the value
Figure 6.13. Variatio n of B S yiel d from thi n carbo n fil m o n gol d a t 1 0 keV.
BACKSCATTERED ELECTRONS
107
appropriate fo r bul k carbon . Th e fil m thicknes s a t whic h thi s occur s i s abou t th e same as that for which an unsupported thin film o f carbon attains its bulk scattering value (see Fig. 6.12). This thickness i s an estimate for the "depth of information" in the backscatter imag e at this beam energy (i.e., the maximum distance beneat h th e surface a t whic h w e coul d deduce—fro m informatio n in th e B S image—tha t th e sample was not soli d carbon) . Several othe r applications of this type of multilayer program are considered late r in this book—for example, in the chapters on electron beam induce d charge (EBIC ) an d x-rays. Depending on the problem, it is sometimes adequate to test the end point z n of a trajectory step to see which part of the specimen it is in, but in other cases cases it may b e bette r t o fin d th e midpoin t of th e ste p and test that instead : z_mid: = ( z + z n ) /2 ; if z_mid>= dept h the n i : = 2 ;
The firs t approac h i s quicker , bu t th e secon d make s mor e us e o f th e dat a i n th e simulation an d i s les s likel y t o caus e problem s an d confusio n whe n complicate d geometries are being considered. Car e must also be taken to properly error-tra p the test function; fo r example, if the electron i s backscattered zn<0 , the n the resultant value of z_mi d may be negative and lead to a problem. The safes t procedur e is to deal wit h the specia l case s o f backscattering an d transmission before othe r condi tions ar e tested for. Finally, i n any case wher e the regions bein g considere d i n th e problem ar e small in size compared to the Bethe range, the single scatterin g mode l must be used to avoi d errors . For complicated geometries, the problem of specifying the region of the sample i i n whic h th e electro n i s movin g als o become s mor e comple x becaus e i t wil l involve all three o f the coordiante s rather tha n just the z axis. Th e obviou s wa y to tackle the problem is to apply a string of suitably structured i f . .. the n tests to make th e decision. Fo r example, if x_midback_sid e then i : = 2 els e if z>botto m the n i : = 3 else i : =1; etc. but this is cumbersome and slow, as these tests have to be made on every step of every trajectory . For a completely arbitrar y geometry, however , suc h as a random steps on a surface, this is the only available way. One alternative is to divide up the entire volume of interest into an array of cubes of a size comparable wit h or smaller than the expected ste p length an d then to appl y the sor t o f test describe d abov e to preassign a value of i to each elemen t o f the arra y an d store it, s o that, give n the coordinates o f the electron, th e correct valu e of / can simpl y be looke d up . This i s
108
MONTE CARLO MODELING
fast and quite general but requires very large arrays of data in all except the simplest cases (Joy, 1989a). In one special case, however, there is a simple and elegant solution to this difficulty. If each of the regions of interest in a material is a closed volume that can be described by an equation of the form f(x, y, z) = 0, then we can immediately determine whether any given point p, q, r is inside, on the surface of, or outside the volume by evaluating/(p, q, r). lff(p, q, r) < 0, then the point is inside the volume; if/(p, q, r) = 0, then the point is on the surface; and iff(p, q, r) > 0, then the point is outside. For example consider the case of a sphere, radius r and centered at the coordinates (0, 0, Zc). We can find whether or not the point (x, y, z) is inside or outside the sphere by a simple PASCAL function, which can be called simply Outside. Function outside(xv,yv,zv:extended):Boolean; {tests whether or not the electron at xv,yv,zv is inside or outside the sphere of radius r centered at 0,0, Zc} var dum:extended;; begin dum:=xv*xv + yv*yv + (zv-Zc)*(zv-zc) — r*r; if dum< = 0 then outside : =false else outside:=true; end;
The start of the Monte Carlo loop in the program above would then be modified to read while num < traj_num do begin reset—coordinates ; for k:=l to 50 do begin {first find out where the electron is now-i=2 inside sphere or i = l outside the sphere}
if outside (x,y,z) then i:=l else i:=2; etc.
remembering that an if .(test) . . then statement is carried out if the test is true (or is a function that evaluates to a positive number). Figure 6.14 shows some data obtained from this version of the program. The
BACKSCATTERED ELECTRON S
109
Figure 6.14. B S yiel d acros s a 0.25-(xm coppe r spher e i n carbo n a t 1 5 keV.
matrix of material wa s carbon, containing a copper spher e 0.2 5 jji m i n radius, and the incident beam energy was 1 5 keV. The program was set to calculate the variation of r\ wit h th e positio n o f th e bea m relativ e t o th e cente r o f th e sphere—which , because of the cylindrical symmetry of the problem, we need only do along a single radius. An additional loop was therefore inserted into the program to move the value of the starting y coordinate o f the beam from 0 to some maximum value y_jnax. i n suitable steps . The data of Fig. 6.1 4 show how the apparent backscatterin g coeffi cient varies with the position of the beam an d the depth of the sphere . W e see that for Zc > 1. 0 (Jim, or about one-third the Bethe range, the sphere is not visible, so the "depth of information" i n this case is about 1 |j,m. As the sphere is brought closer to the surface, it s visibility increases an d its apparent width changes, the full widt h at half maximum of the profile being 0.25 (x m when the sphere is at a depth of 0.7 (x m but 0.4 n, m wide when the sphere is at 0.35 (x m depth. These values for the apparent width of the image are interesting because they indicate the sort of spatial resolution that can be achieved in the backscattered image mode. On a simple basis, we might expect tha t the apparen t siz e would be o f th e orde r o f th e actua l diamete r o f th e sphere plus a term to account fo r the beam interaction volume. However, as we see , the measured size is always less than the actual size. This is because th e mere fact that an electron reaches th e copper sphere doe s not guarantee that it will be backscattered b y it , sinc e i n orde r t o escape , th e electro n mus t firs t trave l throug h a significant amoun t of the carbon matrix. When the sphere i s deep or on the periph-
110
MONTE CARLO MODELING
ery of the interaction volume, the electrons reaching it are already low in energy and have little chance of reaching the surface even if scattered directly toward it. This method of testing the position of the beam relative to a closed surface is certainly a special case, but it is not as restrictive as it might at first appear, because a sphere can be generalized into an ellipse (i.e., the equation becomes of the form ax2 + by2 + cz2 - d), which can then, by an appropriate choice of major and minor axes, be turned into a disk or a plate in any chosen orientation. A search through books on analytical geometry will also reveal a few other closed surfaces (or effectively closed, as in the case of a hyperbola) that might also prove useful. A case of some practical importance occurs when the surface encloses not another material but a vacuum—i.e., when the material contains a void. As can readily be confirmed, this situation cannot be taken care of by expedients—such as representing the void as being a material of zero atomic number and density— because the stopping power and scattering expressions do not behave properly in this limit. Instead, we assume that an electron entering the void will neither be scattered nor deposit significant energy but will simply move in a straight line across the void until it once again leaves. Using the notation from the code given above, the program would be modified to read
while nu m < traj_nu m d o begin reset—coordinates; for k : = l t o 5 0 do begin {fir or 1=1 outside in the matrix" if o u t s i d e ( x , y , z ) the n i : = l else begin {extrapolate previous trajectory step] go_round_agin:{la£>el for next loop if needed} xn: =x + s t e p [ l) *cx; yn: =y+step [1] *cy ; zn:=z+step[l)*cz; if outsid e ( x n , y n , z n ) the n {its gone through} go t o escape d {so leave this loop} else {extend the extrapolation} x: =xn;y: =yn; z : =zn; {reset coordinates} go t o go—round—again ; {and do it again} end;
BACKSCATTERED ELECTRONS
111
escaped: {label for exit from loop] i : = l ; {remember to reset this on exit]
etc.
While th e programmin g style will wi n n o prize s becaus e o f it s us e o f go-t o statements, thi s fragmen t o f cod e correctl y handle s th e void . Th e visibilit y an d apparent siz e o f void s behave s i n a n approximatel y simila r wa y t o tha t fo r th e inclusions discussed above, except that the absence of a scattering material leads to a fall i n the backscattering coefficient rather than to a rise. For an interesting study of contras t fro m void s i n th e scannin g electro n microscop e (SEM ) usin g Mont e Carlo techniques of this type, see Gasper an d Greer (1974) .
6.6 Incorporating detector geometry and efficiency A final topic that must be discussed concerns the difference between the compute d backscattering coefficien t and the actua l signal collected i n the SE M by a suitable backscatter detector . I f the backscatter detecto r were perfect, that is, i f it collected every backscattered electron withi n the 2ir steradians above the sample surface and if ever y electron—regardless o f energy—produce d th e sam e magnitude of output pulse, the signal would be directly proportional to the backscattering coefficient. I n general, this is not the case, and circumstances usually require that the properties of the detector be taken into account when a Monte Carlo simulation is being made. As a rule, the position of the detector must be considered if the specimen to be modeled has anything other than a flat (i.e., planar) surface and, since all practical backscatter detectors hav e an output that varies directl y wit h the energ y o f the electron s collected, modelin g th e efficienc y o f th e detecto r fo r electron s o f differen t energ y is always likely t o be useful . In orde r t o incorporat e th e geometrica l propertie s o f th e detecto r int o th e program, i t i s onl y necessar y t o chec k whethe r o r no t an y give n backscattere d electron i s traveling in the right direction to impinge on the detector. If the detector is assume d t o b e annula r abou t th e inciden t beam—i f th e oute r diameter o f th e detector i s R0 and the distance from th e detector to the sample is D—then, with the coordinate conventio n bein g use d in this book, a n electron wil l be collecte d i f it s direction cosin e c c satisfie s the relation
note that the sign is negative because the positive z-direction is defined to be in the beam direction. Th e code o f Chaps. 4 and 6 would then be modified to read : if zn< = 0 then if cc<=—critical—angle then
112 MONT
E CARL O MODELING
begin bk_set: =bk_sct + l; num:—num+1; goto back—scatter ;
end
where critical-angle is set equal to the quantity o n the right hand sid e of Eq. (6.11). I n thi s wa y th e characteristic s o f a specifi c backscattere d detecto r ca n b e added t o the simulatio n by feeding in the values for R0 an d D a t a suitable point in the program. If the detector i s annular but split into two halves or four quadrants, the values o f the othe r directio n cosin e component s mus t als o be considered . Fo r ex ample, if zn< = 0 then begin if ( (cc< = — critical angle) and (cb> —0) ) then detector—A—Signal: =detector_A—signal+1 else detector—B_signal: =detector_B_signal + 1; num:=num+l; goto back—scatter; end
where for this split detector w e keep separate track of the electrons collecte d on the two halves A and B (remembering firs t to declare and initialize these variables). The extension o f this cod e to othe r mor e comple x arrangement s is obvious. All backscatte r detector s displa y som e energ y sensitivity . Typically, w e fin d that thei r i s som e minimu m energ y Emin belo w whic h the backscattere d electro n creates n o output signal , whil e abov e Emin a backscatter electro n o f energy E wil l produce a n output signal tha t varies linearl y a s (E—Emin). Th e code for our plural scatter model s woul d now loo k somethin g lik e this : if ((zn<=0) and (E[i,k]>E_min)) then begin if ( (cc< = -critical angle) and (cb> = 0) then detector—A_signal: =detector_A—signal+ (E[i,k] -E_min) else
detector_B_signal:=detector_£_signal+ ( E [ i , k ] -E-min) ; num:=num+l; goto back—scatter ; end
so that the detected signal now depends on the actual energy of the electron collected. Note that the variables detector_A_signal an d detector_B_signal mus t
BACKSCATTERED ELECTRON S
113
Figure 6.15. BS profile acros s sphere an d corresponding detected signal . now be declared as extended or real rather than integer and that the final result will no longer represent th e backscatter yiel d but instead a scaled representation o f the actua l signal detected . Figure 6.1 5 show s the effec t tha t this kind o f correctio n has. The datum is one of the traces from Fig . 6.14, but now corrected fo r a detector that has an Emin value of 5 keV. The two traces show the variation of the backscattered coefficien t an d th e outpu t signa l fro m th e backscatte r detecto r respectively . While th e form s o f th e profile s ar e essentiall y identical , not e tha t th e effec t o f including the energy sensitivit y of the detector i s to increase the apparent visibility of th e coppe r sphere , sinc e th e "peak-to-background " variatio n o f th e signa l i s increased by about 20%. There is thus no longer a direct proportionality between the backscatter coefficien t an d the detected backscatte r signal. This is of importance if the backscatte r signa l i s being use d fo r chemica l observations , sinc e i t canno t b e assumed tha t th e detecte d signa l an d th e emitte d backscatterin g coefficient—an d hence th e mea n atomi c numbe r of the target—ar e al l simpl y related together. Be cause th e detecto r respond s a s muc h t o change s i n th e energ y o f th e electron s i t receives a s it does to their actua l number, these two effects convolut e together and cannot simpl y be separated. Quantitativ e backscattered imagin g is therefore a diffi cult activity unless care is taken to account for all of these factors (e.g., Sercel et al., 1989).
7
CHARGE COLLECTION MICROSCOPY AND CATHODOLUMINESCENCE 7.1 Introduction Charge collection imagin g in the scanning electron microscope , ofte n know n by the acronym EBI C (electro n beam-induce d current) , has become a widely used tech nique fo r th e characterizatio n o f semiconducto r material s an d device s (Leamy , 1982; Holt and Joy, 1990). While there is a substantial literature on the use of EBIC methods t o measure semiconducto r parameters , suc h a s th e minority carrie r diffu sion length (Leamy , 1982) , the majority o f charge-collected image s ar e interprete d in a purely qualitative manner. Cathodoluminescence (C/L ) imaging of semiconductor materials , whic h i s i n essenc e ver y simila r t o EBIC , ha s similarl y bee n use d mostly i n a picture-taking rathe r tha n a data-producing mode . Th e proble m i s not that there are no good models to explain the image formation but rather that, in order to provide tractable analytical expressions fo r the calculation of contrast, it is invariably necessary t o make significantl y oversimplified assumptions about the interac tion of the electron beam with the specimen. In this chapter, we demonstrate how the Monte Carlo models discusse d earlie r ca n be used to overcome these problems and make EBIC an d C/ L mor e usefu l technique s fo r microcharacterization .
7.2 The principles of EBIC and C/L image formation When an electron beam impinges on a semiconductor, som e of the energy deposite d by the beam is used to promote an electron fro m th e filled valence band , across the band gap , t o th e empt y o r partiall y fille d conductio n ban d (Fig . 7.1) . Sinc e th e valence ban d wa s initially full , th e remova l o f a n electro n leave s behin d a "hole" that has all the physical properties o f an electron bu t carries a positive charge. For each electron promoted acros s th e band gap, one hole is formed, so it is convenient to conside r th e tw o component s togethe r an d tal k o f a n electron-hol e pair . T o generate th e electron-hole pai r requires a n amount of energy esh. Typically, esh is about three times the energy of the band gap (Table 7.1); so, for example, for silicon, eeh is 3.6 eV. If we assume that all of the energy deposited b y the incident bea m of energy E0 is ultimately unavailable for the generation of electron-hole pairs , then the number o f carrier pair s forme d n eh wil l b e 114
CHARGE COLLECTIO N MICROSCOPY/CATHODOLUMINESCENC E 11
5
Figure 7.1. Electron-hole pai r generatio n i n a semiconductor .
That is , a 10-ke V bea m inciden t o n silico n coul d produc e 10,000/3. 6 « 280 0 electron-hole pairs . Because th e electron an d hole hav e opposite charges , they are electrostatically attracted and will tend to drift togethe r through the lattice, maintaining local electrical neutrality. After onl y a few femptoseconds (10~~15 s), the electron will fall back across the band gap and recombine with the hole, giving up, as it does so, some of the energy used to form th e original carrier pair. It is this effect tha t may result i n th e productio n o f C/ L emission , sinc e th e exces s energ y ca n b e carrie d away by an emitted photon. I n any event, within a very short time after the passage of th e incident electron , th e syste m has returned to its origina l state . Since, unlik e a metal, a semiconducto r ha s significan t resistivity, a potential difference ca n be maintained across it, resulting in the generation of an electric fiel d imposed acros s the sampl e (Fig . 7.2A) . A n incident electro n o f energy E0 will , as before, produce some number of carrier pairs neh, but now, because the electrons and holes carry opposite charges, the electrons will tend to move toward the positive end of the sample while the holes will drift towar d the negative end. One result of this is Table 7.1 Electron-hole pair energies
Material C (diamond ) 13. CdS 7.
CdTe 4. GaAs 4.
GaP 7. Ge 3.9 InP 2. PbS 2. Si 3. SiC 9.
Electron-hole pair energy (eV) 1
5
8 6
8 5 2 0 6 0
116
MONTE CARL O MODELING
(a)
(b)
(c)
Figure 7.2 . Thre e configuration s for charge collectio n microscopy .
immediately apparent. Before the electron beam is turned on, the amount of current flowing throug h th e semiconducto r i s ver y smal l o r zero , becaus e ther e ar e n o electrons in the conduction band and hence there is no way to move charge. But with the beam striking the specimen, each electron produces n eh electron-hole pairs , and the presence of these free carriers will permit charge to flow. Thus the electron beam has induce d conductivit y in th e semiconductor . Thi s effec t i s know n a s electro n
CHARGE COLLECTIO N MICROSCOPY/CATHODOLUMINESCENC E 11
7
beam-induced conductivit y (an d s o give s anothe r interpretatio n o f th e acrony m EBIC) or (3-conductivity (Holt and Joy, 1990) . I f the beam is scanned, the resultant conduction signa l ca n be used to for m a n image. In practice , a mor e interestin g procedur e i s t o generat e th e fiel d internall y within the semiconductor. Fo r example, if a semiconductor tha t has been chemically doped to make it a p-type material (i.e., one containing a n excess of holes) is placed in contact with n-type material (i.e., one with an excess of electrons), the n a region is formed around the p-n junction where a potential and hence a field is present (Fig. 7.2B). This field arise s from the attempt of the electrons i n the n-type material to go to th e p-typ e region an d th e hole s i n th e p~typ e materia l to flo w int o th e n-type region. Within a short time, charge fro m uncovere d atomic nuclei produces a fiel d just sufficient t o prevent any further charg e motion. In this region of field, there can be no free charge carriers, so it is called a "depleted region," and it typically extends for a few micrometer s o n eithe r sid e o f th e physica l locatio n o f th e p- n junction (Leamy, 1982) . Alternatively, if a thin metal film is put into atomic contact with the surface o f a semiconductor (Fig . 7.2C) then this "Schottky barrier" again results in the appearanc e o f a depleted regio n extende d downwar d from th e Schottk y layer. Without a n inciden t electro n beam , ther e exists , i n eithe r case , a stati c potentia l between the p and n regions or between the metal and semiconductor; bu t if the pand n-type regions, o r the Schottky barrier and the semiconductor, were connecte d together b y a wire, then n o curren t would flow , becaus e th e fiel d exist s onl y i n a region fro m whic h all of the availabl e charg e carriers have alread y been removed . Now let us place the incident electron beam onto the p-n specimen in either the p- or n-type region but away from th e depleted zone. As before, electron-hole pairs will b e generated, but since the material in which they ar e produced is electrically neutral and has no field across it, they will quickly recombine an d no external effec t will be observed. If, however, the beam is placed in the depleted region, the carriers produced wil l se e the depletio n fiel d an d the carrie r pair s wil l b e separated . Thi s motion o f charge s withi n th e specime n wil l produc e a flo w o f curren t 7 CC i n th e external circuit give n by the relation
since eac h inciden t electro n ca n produce n eh carrie r parirs . This signal , which we will call the charge-collected curren t 7 CC, is seen to be substantially greater than the incident current /B. In the scanning electron microscope (SEM) , the current flowing around the external loop is measured and displayed as function of the beam position to produce th e charge-collected , o r EBIC, signal . Note that a n important practica l consideration i s tha t th e curren t w e wis h t o measur e i s actuall y a short-circui t current. Hence external resistance loa d /?L must be of as low a value as possible or else the ohmic voltage drop across it, which is in the opposite sens e to the potential at the depletion layer , will affec t th e signa l collection process .
118 MONT
E CARL O MODELIN G
In the standard theory of Donolato (1978), two steps are necessary t o compute /cc: first , w e mus t mode l th e generatio n o f carrier s b y th e electro n beam , and , second, we must model the transport and collection o f the beam-generated carriers . Typically the generation o f carrier pairs is described b y a function g(r), i n units of cm~ 3 s~ 1 , modele d a s a three-dimensiona l Gaussia n Distributio n (Fittin g e t al. , 1977) or a sphere of uniform generatio n (Bresse , 1972) , neither of which is a very realistic representatio n o f the beam interactio n wit h the solid . The transport o f the minority componen t o f th e electron-hol e pair s generate d i s a diffusio n proble m described b y the equation:
where p(r) i s the density o f the beam-generated minorit y carriers an d D an d T are, respectively, the minority carrier diffusion coefficien t and lifetime. Given the necessary boundary conditions onp(r) a s defined by the geometry of the problem at hand, Eq. (7.3 ) ca n b e solve d t o giv e p(r) an d th e induce d curren t 7 CC ca n b e foun d b y integrating the normal gradient ofpp over the collection plane. While this descriptionn of th e proble m i s rigorousl y correct , th e drawbac k i s tha t 7 CC canno t b e foun d without knowing p(r), which , in turn, requires a knowledge of g(r), and no realistic model o f g(r) yield s an equation tha t is analytically tractable . However, if we use the Monte Carlo procedures we have developed t o describe the incident bea m interactio n wit h the semiconductor , then , a t any instant alon g a trajectory, g(r) is effectively a point source whose strength is equal to the number of electron-hole pair s generate d i n tha t segmen t o f th e trajectory , whic h fo r th e £ th trajectory step is equal (Akamatsu et al., 1981) to the energy given up (E[k] - E[k + 1]) divide d b y th e energ y t o creat e on e electron-hol e pai r e eh. I f th e trajector y segment is at a distance .s from the collecting junction, then the probability of i|/(s) of these carriers diffusin g t o the collecting junction and producing a charge collecte d current is , (Wittr y an d Kyser , 1964) , fo r a point source:
where L i s the minority carrie r diffusio n lengt h (i.e. , L = vDi). It woul d thu s see m tha t w e coul d comput e 7 CC i n a sequentia l manne r b y summing up the charge-collection contributio n from eac h step of each of the trajectories tha t w e simulat e an d averagin g thi s t o fin d effectiv e charg e collecte d pe r incident electron (Joy , 1986). Although this looks, at first sight, to be quite differen t from actuall y solvin g th e diffusio n proble m o f eq . (7.4 ) an d the n computin g / cc, these two approaches are, in fact, functionally equivalent. A s shown by Possin and Kirkpatrick (1979), w e can generalize th e quantity \\>(s) an d defin e a quantity ij;(r), which describe s th e probabilit y tha t a minorit y carrie r generate d b y a n electro n
CHARGE COLLECTIO N MICROSCOPY/CATHODOLUMINESCENC E 11
9
beam a t r i s collecte d an d thus contribute s t o th e charge-collecte d curren t 7 CC. Donolato (1985,1988) showed that for the geometry of Fig. 7.2C, i|/(r) also satisfies Eq. (7.3) wit h the boundary condition i|;(r ) = 1 at the entrance surfac e (z = 0) . In this case, th e solutio n o f Eq. (7.3 ) reduces t o one dimension an d has th e for m
That is, it is identical with the result of Eq. (7.4), and the charge-collected curren t 7CC is then the su m o f the contributio n o f th e elementar y sources :
where h(z) i s the dept h distribution of the generation. Thu s we can quite generall y calculate the magnitude of 7 CC for a given specimen geometr y an d beam interactio n by first steppin g through the Monte Carlo simulatio n to produce h(z) an d then using Eqs. (7.4 ) o r (7.5 ) an d (7.6 ) t o fin d 7
7.3 Monte Carlo modeling of charge-collection microscopy 7.3.7 The generation function Either th e singl e o r plura l scatterin g model s coul d b e use d a s th e basi s fo r a simulation o f charge-collectio n microscopy , bu t sinc e th e sample s ar e invariabl y bulk, th e plura l scatterin g approac h wil l b e significantl y faste r an d s o wil l b e illustrated here. Th e first tas k is to compute eh, th e number of electron-hole pairs generated alon g each ste p of the trajectory . Working from th e cod e i n chap. 4, w e can easily inser t thi s as shown below. Sinc e i t is interesting t o be able to view the actual spatial distribution o f g(r), we can associate eac h element o f carrier produc tion with the coordinates o f the midpoint (xm, ym, zm) of the trajectory step . Since for norma l incidence th e distribution i s going to be radially symmetrica l about the beam axis, we can store this in an array g(r, zz) where r, the radius from the axis, and zz, th e depth , ar e bot h expresse d i n unit s o f one-fiftiet h o f th e Beth e rang e (i.e., th e ste p length) . D o no t forge t t o ad d t o th e variable s lis t th e extende d quantities xm,ym , zm, eh, th e integers r , z z , an d the array g [ 0 . . . 50 , 0 . . . 5 0 ] o f extended, an d remember t o initialize g [ r, z z ] befor e usin g it. p_scatter; {fin d the scattering angles} new_coord(step); {find where electron goes } {program-sped fie code will go here} {******** and here it is ******** }
120 MONT
E CARL O MODELIN G
{eh the number of carriers generated is} eh:= ( E [ k ] - E [ k + l] ) * 1 0 0 0 / 3 . 6; (E[] i s in keV\ {assuming that the pair generation energy for silicon is 3.6 eV} xm: = (x+xn) / 2 ; {x coordinate midpoint of step} ym: = ( y + y n ) /2 ; {y coordinate of midpoint} zm:=(z+zn)/2; [z coordinate o£ midpoint] {get radius of midpoint from axis in units of range} r: =round(sqrt (xm*xm+ym*ym ) / s t e p ) ; z z : =r o u n d ( z m / s t e p ); {} if zz > = 0 the n {put thi s carrier contribution into the array at r,zz} g[r,zz]:=g[r,zz]+eh; etc.
The array can be printed out at the end of the run to give the spatial distribution g [ r, z z ] . Becaus e th e dat a hav e bee n store d i n unit s o f a radia l variable , th e volume represented b y successive values of r increases steadily , so, in order to make the values directly comparable, i t is necessary t o divide g [ r , z z] b y ( 2 r+1) — i.e., th e are a betwee n th e rth an d ( r + l ) t h annuli . Figur e 7. 3 show s th e carrie r distribution calculated in this way for silicon, The profile has the familiar "teardrop" shape with a diameter of the order of the range, and with a maximum depth of about 0.75 of the range. It is clear, however, that the distribution of carrier generation is far from uniform , with nearly a quarter of the carriers being produced within a volume
Figure 7.3. Isogeneration contour s for electron-hole pairs i n silicon.
CHARGE COLLECTIO N MICROSCOPY/CATHODOLUMINESCENC E 12
1
that i s onl y abou t 0. 2 o f the rang e i n diameter . Th e isogeneratio n contour s ar e in good agreemen t wit h published experimenta l dat a (e.g. , Possi n an d Norton, 1975 ) confirming tha t the physical basis for the mode l i s good . 7.3.2 The gain of a Schottky barrier The specime n configuratio n most normally used for EBI C imaging i s that of Fig . 7.2C, the Schottky barrier geometry; consequently, it is this system that we will use the Monte Carlo method to analyze, although other arrangements such as that using a p-n junction can as easily be studied by obvious modifications to the development below. The Schottk y barrie r consist s o f a thin layer, typically 10 0 to 30 0 A, o f a metal, suc h a s gol d fo r n-typ e silico n o r titaniu m fo r p-typ e silicon , i n intimat e contact with the surface of the semiconductor. Although this film is thin, it may have a significant effect o n the electron beam interaction with the solid, especially at low beam energies, and so must ultimately be included in the simulation. We assume that the Schottk y produce s a depletio n regio n o f dept h zd. T o a firs t approximatio n (Leamy, 1982 )
where fl i s the resistivity (ohm.cm) and V b is the barrier height, (e.g., for Si V b = 0.7 V) plus an y applie d revers e bias . S o for 1 ohm.cm resistivit y silicon , wit h no external applie d bias , zd i s about 0.5 (Jim . The measurable parameter of a Schottky diode in charge-collection mod e is its gain G, which can be define d as:
where 7 CC is the measured short-circui t current collected fo r a given incident beam energy /b. From the discussion above , we can see that G is of the order of n eh, the number of electron-hole pairs generated per incident electron; but it will invariably be lower, because not all of these carriers will ultimately contribute to the signal. Let us consider a single step of a trajectory and calculate the incremental contribution to 7CC. As before, the number of electron-hole pair s e h produce d a t this ste p is eh = (£[*] - E[k + l]/eeh and these we take to be generated at the depth zm = ( z + z«)/2 , the midpoint of the trajectory step . I f zm < zd, the n al l of the carriers produce d ar e separated, s o the incremental charge collected c c i s increased b y eh. I f zm > zd, then the carriers must diffuse bac k to the depleted region before they can be separated and collected.
122
MONTE CARLO MODELING
The fraction of carriers collected coll_f rac is, from Eq. (7.5),
where L is the minority carrier diffusion length. In general, we want to know how the gain G depends on semiconductor parameters such as the depletion depth zd and diffusion length L. Because the collection of the carriers is totally independent of the generation process, we can conveniently do this by computing just a single set of trajectories but allowing zd and L to take a range of different values and calculating the gain in each case. If we define m values of the depletion depth zd[] and n values of the diffusion length L[], then we need a matrix m*n in size for the current values Icc[]. The code fragment from above would then look like this: p_scatter; new_coord(step);
{find {find
the scattering angles} where electron goes}
{program-specific code will go here} {******** an d here it is ******** } (eh the number of carriers generated is} e h : = ( E [ k ] - E [ k + l ] * 1 0 0 0 / 3 . 6 ; {E[] is in keV} {assuming that the pair-generation energy for silicon is 3.6 eV} zm: = (z + z n ) / 2; [z coordiante of midpoint} {compute the incremental current collected for each value of zd and L} for i : = l t o m do begin for j : = 1 t o n d o begin if zm < =z d [ i] the n {al l the carriers are collected} Ice[i,j] :=Icc[i,j]+eh e Ice [ i , j] : =Icc [ i, j] +eh*exp (- ( zzd[i])/L[j]); end; end; etc. . . .
Figure 7.4 shows the variation of the gain G computed in this way for silicon at 30 keV, as the depletion depth varies from 0.5 to 5 (Jim and as L varies from 0.1 to 5 (xm. When the depletion depth zd or the diffusion length L are small compared to
CHARGE COLLECTIO N MICROSCOPY/CATHODOLUMINESCENCE 12
3
Figure 7.4 . Variatio n o f current gain i n a silico n Schottk y diod e a t 3 0 keV .
the electro n rang e (i.e. , abou t 1 0 |xm) , the n th e gai n o f th e diod e i s a sensitiv e function o f thes e parameters ; bu t whe n either o r bot h becom e comparabl e t o th e range, then the gain depends only o n the beam energy. Note that the advantag e of using the same set of trajectories to calculate the gain for each of the variables is not just that of saving computational time. Using the sam e set of random numbers for each piec e o f data ensures that the difference s i n th e gain du e t o a change in th e diffusion lengt h o r depletion depth are not masked because of the statistical variations between one Monte Carlo run and the next. An interesting exercise is to try the effect o n these calculations o f changing the angle of beam incidence (Jakubowicz, 1982; Joy , 1986) . Fo r a given depletio n depth , diffusion length , and beam energy there is a range of angles over which the gain is constant. Since the angle of beam incidence can easily be varied—for example , by rocking the beam or mechanically tilting the sample—this provides a rapid experimental metho d for determining the diffusion lengt h of a diode. In general , w e canno t ignor e th e effec t o n th e inciden t electro n bea m o f th e Schottky barrier metal film. As the electrons pass through this, they lose energy and are scattere d laterally . I n addition , th e effectiv e backscatterin g coefficien t o f th e specimen i s changed . Whil e thes e effect s ar e smal l a t moderat e an d hig h bea m energies (1 5 ke V an d above) , the y ar e quit e significan t a t lowe r bea m energie s because th e meta l film , thoug h thin, i s the n a substantia l fraction o f th e electro n
124
MONTE CARLO MODELING
range. This situation can be modeled by slightly modifying the program BINARY discussed in Chap. 6. The physics is exactly the same as that described above, except that we only consider electron-hole pair generation in the substrate material (i.e., the semiconductor) and the distance that these have to diffuse before collection is measured to the bottom of the Schottky layer rather than to the surface. It is only necessary to add a few lines of code to BINARY to incorporate these calculations. That is, after the scattering calculation we write {now allow the electron to be scattered] p_scatter(i); new_coord(i); {test for electron position within the sample} if zn< = 0 then begin bk_sct: =bk_sct + l; num:=num+l; goto back—scatter; end else {compute the gain of the Schottky diode—energy of electronhole pair formation is e—eh—i.e., 3.6 eV for silicon etc.} begin e formed} if i = l then eh:=0; {no carriers generated in metal film} if zn<= zd then {all of these carriers are collected} i_cc:=i_cc + eh else {they have to diffuse back to depleted regi on} i_cc:=i_cc + eh*exp(-(zn-zd)/L); end; reset_next_step; {and so on . . .}
The only point to be careful of is to remember that, because this is a plural scattering simulation, the program cannot be expected to give accurate results above the energy for which the thickness of the barrier film becomes less than about onetenth of the range (e.g., about 12 keV for a 300-A gold film. Figure 7.5 shows the effect of including the Schottky barrier in attempting to compare experimental gain measurements with computed values, in this case for an indium phosphide (InP) diode. While the slope of the experimental data with energy is similar for both the case with no surface barrier and for the barrier thicknesses of 200, 300, and 400 A, it is clear that the absolute gain values are quite different. The best match between the experimental data and the computed figures is for a barrier layer of 300 A. If the gain can be measured over a sufficiently wide energy range (e.g., from a lower value where the gain is effectively zero because the beam is not penetrating the barrier to an upper value where the gain is at a maximum), then an iterative comparison
CHARGE COLLECTIO N MICROSCOPY/CATHODOLUMINESCENC E
125
Figure 7.5 . Experimenta l variatio n o f gain wit h beam energy in InP and computed variatio n including thicknes s o f Schottk y layer .
between the Monte Carlo data and the experimental dat a allows both the parameters of the device (i.e., the diffusion lengt h and depletion depth) and the thickness of the barrier t o be determined . 7.3.3 Contrast from crystallagraphic defects Contrast fro m electricall y activ e defect s i n semiconductor s wa s firs t observe d i n charge-collection image s by Lander e t al. (1963). Sinc e that time the technique has been widel y used (Leamy , 1982) , no t only because it allow s defects to be imaged without the need t o thin the material fo r transmission microscopy bu t also because, at th e ver y lo w dislocatio n densitie s tha t ar e typica l o f today' s semiconductors , EBIC imaging offers a much better chance of actually finding the defects in the firs t place. Contrast is seen fro m defects , because carrie r recombinatio n ca n occur at the defect, s o reducing the number that contribute to the detected current . As shown by Donolato (1978 ) an d using the notation show n i n Fig. 7.6 , a point defec t at som e depth Dd beneat h the surface of a Schottky diode causes a differential signal change in th e collected signa l fro m a distribution o f point source s g(x, y, z) given by
126
MONTE CARLO MODELING
Figure 7.6. Definition of parameter s use d to model defect s in a semiconductor .
where k i s a measur e o f th e recombinatio n strengt h o f th e defect , rl an d r2 ar e defined a s show n i n Fig . 7.6, L i s th e minorit y carrie r diffusio n length , an d th e integral is over the whole excited volume. This derivation assumes that the Schottky barrier ca n be represented a s a surface of infinite recombinatio n velocit y (i.e., any carrier reachin g th e surfac e contributes t o the measured current). As before , the Mont e Carl o approac h allow s us t o replac e thi s integra l b y a summation in which the distribution of point sources g(x, y, z) i s represented b y the carrier generatio n calculate d fo r eac h ste p o f th e trajectory . Fo r eac h ste p i n th e trajectory, the yield of carriers eh i s found from Eq. (7.8). In the absence of a defect, the incremental curren t contributed to the imaging signal would then be eh*coll _f rac, wher e coll_f rac i s given by Eq. (7.9) an d depends on whether or not the center point of the step z m lies in the depleted region. In the presence of a defect, the actua l collecte d signa l incremen t wil l b e eh*coll_frac*defect_term , where defect-term i s from Eq . (7.10)
and represents th e carriers lost to the defect and thus not contributing to the signal. In general, line defects are of more interest than point defects in EBIC imaging. A line defect can be treated as a linear array of point defects of equal strength, so in order to model a dislocation i t would be necessary to integrate Eq. (7.10) along the length o f the defect, or in our discrete Monte Carlo model, to sum Eq. (7.11) along the dislocation line . If the dislocation i s horizontal (i.e., parallel to the surface) and can be considered as infinite in length, then numerical integration (Joy, 1986) shows that th e for m o f Eq . (7.11 ) remain s unchange d except tha t k , representin g th e strength of the point defect, is now replaced by a term representing th e strength per unit length of the line defect. Thi s convenient simplification i s possible because the
CHARGE COLLECTIO N MICROSCOPY/CATHODOLUMINESCENCE 12
7
1/r multiplying factors o n each exponentia l in Eq. (7.11 ) greatl y restrict th e range over whic h th e expressio n i s significant . Fo r othe r defec t geometries—suc h a s inclined fault s o r loops—i t woul d b e necessar y t o evaluat e Eq . (7.11 ) fo r eac h trajectory ste p an d for each point defining the defect line. If the defect lies within the depleted region (i.e., Dd < zd), then the effect o f the carrier drift, caused by the depletion field, on the image must also be considered. As shown by Leamy (1982), this can be done by comparing the transit time of carriers across the excited volume with the lifetime of carriers in the vicinity of the defect. The field at the defect ED due to the sum of the barrier voltage V b and the applie d bias V a i s
where the depletion depth zd is given b y Eq. (7.7). The effectiv e strengt h per unit length of the defect is then reduced by a factor £0/(£D + ^o) > where E0 is the fiel d associated wit h the defec t itself, typicall y of the order of 5.10 3 V/c m (Mil'stein et al., 1984) . As before, the basis of the simulation will be the BINARY program, and again only a minor modification to the original code is needed to include the computation of th e effec t o f th e defect : {now allow the electron to be scattered} p_scatter(i); new_coord(i) ; {program-specific code will go here—so] {first test for electron position within the sample} if i = 2 then {the electron is in the silicon substrate} do—defect; {compute the current collected} {now we can proceed as normal} if zn< = 0 then {it's backscattered} begin bk_sct: =bk_sct + l; num:=num+l; goto back—scatter; end else reset—next—step; {and so on. . .}
As usual , al l o f th e actua l calculatio n i s don e i n a procedure , her e calle d do_def ect. This , in turn, relies on some data that we have set up ahead of time. First, w e must input at some convenient tim e the parameters tha t define the semi conductor an d then calculate a few constants ; fo r example :
128
MONTE CARLO MODELING
{input the semiconductors' physical parameters} write('Resistivity of sample in ohm.cm'); readln(resistivity) ; write('DC bias applied to Schottky (V)' ) ; readln(bias); write ('depth of defect (pun)'); readln(dd);
{now we can compute zd—the depletion depth of the material] {assume the material is silicon and use Eq. (7. 7)} zd : =0 . 5 3 * s q r t ( r e s i s t i v i t y * ( 0 . 5 + b i a s ) ); {we define the strength of the defect by giving it a "size" rO} rO = 0 . 3; {nominal radius in microns} {n if dd>z d the n ed:=0 {defec t is in neutral material} else begin e d : = 2 * ( 0 . 5 + b i a s ) / t h i c k ; {thic k i s thickness of metal film} ed:=ed*lE4* (1-dd) / z d ; end;
{arid r_crit:=rO*sqrt(5E3/(5E3+ed)); {a
Remember to add these variables to the var list at the start of the program— although, if you do not, the compiler will find them and warn you of their absence. Note that the constant k in Eq. (7.11), which represents the recombination strength of the dislocation, has the units of a length. So in the program, this has been called the "size" rO of the defect, and been assigned a value of 0.3 u-m. This value has been found to give contrast values that are in good agreement with those measured experimentally, and it is also consistent with the expected physical extent of the electrostatic field around a defect in silicon. For other materials or special conditions, such as a decorated defect, the value of rO may have to be adjusted. The presence or absence of the defect does not change the way in which the electron beam interacts with the solid. We can therefore again save time, and also improve our statistics, by simultaneously calculating the signal profile at many points across the dislocation for each trajectory step. If we place the dislocation so that it is parallel to the x axis and at y = 0, then for each trajectory step we can loop through the current calculation shifting the effective position of the beam by a series of values pos [ j ] and calculating the corresponding current i_cc [ j ] . Because the profile is symmetrical about the center of the defect, typically five to ten values in the array pos [ j ] are enough to produce a smooth profile. The chosen values for pos [ j ] can either be input by the user or preset in the program code itself. That is,
C H A
pos[0] : =0;
pos[l] :—0.25; {all values are in micrometers from defect center} pos[2]:=0.5; pos[3] :=1.0; {and so on}
A convenient rule of thumb is to set the maximum value of pos [ j ] to the sum of the electron range plus the diffusion length (i.e., typically in the range 5 to 15 ^m for most materials and usable beam energies) and to choose intermediate values of pos [ j ] with approximately a constant ratio between them (e.g., 0, 0.25, 0.5, 1, 2, 4, 8, 16), so as to give the best definition to the central portion of the profile. Procedure do—defect;
{this calculates the current gain of the Schottky including the effect of the electrically active defect} var begin [by computing number of e_h pairs generated} eh: = (E[i,k]-E[i,k+l])*1000/e_eh;
zval: = (z + zn)/2; {midpoint of trajectory} yval: = (y+yn) 12 ; {midpoint of trajectory} for j:=0 to 10 do
{a loop Shifting the defect position by pos[j]} begin {defect is at depth dd} rl: = (zval-dd)*(zval-dd) + (yval-pos[j])*(yval-pos[j]) ; {Fig. 7.6}
end; {o
r 2 : = r l + 4*dd; {by Pythagoras's theorem—see Fig. 7.6} {now apply Eg. (7.11)} d e l _ I : = ( e x p ( - r l / L ) / r l - e x p ( - r 2 / L ) / r 2 ); del_I:=l-(r_crit*del_I); if zval < =zd the n {al l o f the carriers are collected} i_cc[j] :=i_cc[j] +eh*del_I e l i_cc [ j ] : =i_cc [ j ] +eh*exp(- (zval-zd) / L ) ; e n
f this procedure}
Because computations for ten or so different effective beam positions are made for each step of every trajectory, the program will run more slowly than normal. However, because the data from each of these points come from the same set of random numbers, the precision of the computation is high, and good statistics can be achieved for as few as 400 to 500 electrons. A plot of i_cc [ j ] against pos [ j ] , possibly reflected about the position pos [0] = 0 so as to give a symmetrical profile, will now give the desired profile of the EBIC signal variation across the
130
MONTE CARLO MODELIN G
Figure 7.7 . Compute d EBI C profiles acros s a line defect a t various depths i n silicon .
defect. Thi s can be done either by having th e program output th e actual i_cc [ j ] values an d plottin g thes e i n som e othe r progra m o r b y writing th e necessar y fe w lines of code to have the program plot its own output. In either case a great deal can be learned abou t the behavior o f defect image s i n EBIC b y using this program an d trying th e effect s o f variou s set s o f semiconducto r an d defec t parameters . Figure 7. 7 show s the predicted signa l profile s arros s a line defect a t depths of 0.5, 1,1.5 , 2, and 2.5 |xm in silicon. To avoid cluttering the figure, only half profiles are shown . With the physica l parameters assume d here, a resistivity of lOOOft.c m and zero applied bias, the depletion depth is [Eq. (7.7)] about 1 5 |o,m, which is large compared t o bot h th e electro n rang e o f 3 (Ji m an d th e minorit y carrie r diffusio n length o f 1 (jum. Fo r all depths, the profile has the sam e general V-shape d form, but the details of th e profile vary from a narrow, high-contrast di p for a defect just 0.5 |xm below the surface to a broad and rather shallow profile for a defect 2.5 |xm below the surface . These prediction s ar e in excellent agreemen t wit h experimental obser vations. See , fo r example , figur e 3 3 in Leamy , 1982 . I t can als o b e note d tha t the contrast fro m a defec t effectivel y vanishe s i f th e dept h o f th e defec t exceed s th e range of the incident electrons. Thi s is because, as shown in Fig. 7.3, the majority of carriers ar e produce d clos e t o th e surface , an d i t i s eviden t fro m Eq . (7.11 ) tha t carriers generate d fa r from th e defect will contribute little contrast because th e two exponential terms will be about equal and opposite. Fo r good contrast to be observable fro m a defect , th e carriers ' generatio n maximu m mus t b e a t o r clos e t o th e defect. Th e depth at which a dislocation is situated can thus be estimated wit h good
CHARGE COLLECTIO N MICROSCOPY/CATHODOLUMINESCENC E
131
accuracy by noting the beam energy a t which it first become s visibl e and equating the electro n rang e to the depth (Leam y et al., 1976 ; Jo y et al., 1985) . Figure 7. 8 show s th e profile s predicte d fo r th e cas e wher e the defec t i s a t a constant depth , her e 0. 5 jjun , but th e bea m energ y i s varied. A t 5 keV, where th e beam range is also about 0.5 (Jim , the defect is just detectable, a s would be expected from the discussion above. As the energy is raised, both AS, the signal change across the defect, an d S, the total signal collected, increase, so the contrast AS/S also rises and reaches a shallow maximum at about 1 0 keV, at which conditio n th e electro n range, 1. 5 (Jim , i s abou t three time s th e defec t depth . A t stil l highe r energies , th e signal variatio n A S start s t o fal l whil e S slowl y increases , s o th e contras t falls . Simulations fo r a wide variety o f differen t defec t parameter s sho w that a contras t maximum can always be expected durin g a sweep of the incident beam energy and indicate that this maximum occurs