Numerical Methods in Quantum Mechanics by Paolo Giannozzi - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Lecture notes

Numerical Methods in

Quantum Mechanics

Corso di Laurea Magistrale in Fisica

Interateneo Trieste – Udine

Anno accademico 2012/2013

Paolo Giannozzi

University of Udine

Contains software and material written by

Furio Ercolessi1 and Stefano de Gironcoli2

1Formerly at University of Udine

2SISSA - Trieste

Last modified May 23, 2013

Contents

Introduction

1

0.1

About Software . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1

0.1.1

Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . .

1

0.1.2

Visualization Tools . . . . . . . . . . . . . . . . . . . . . .

2

0.1.3

Mathematical Libraries

. . . . . . . . . . . . . . . . . . .

2

0.1.4

Pitfalls in C-Fortran interlanguage calls . . . . . . . . . .

3

0.2

Bibliography

. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4

1

One-dimensional Schr¨

odinger equation

5

1.1

The harmonic oscillator . . . . . . . . . . . . . . . . . . . . . . .

5

1.1.1

Units

. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6

1.1.2

Exact solution

. . . . . . . . . . . . . . . . . . . . . . . .

6

1.1.3

Comparison with classical probability density . . . . . . .

8

1.2

Quantum mechanics and numerical codes: some observations . .

9

1.2.1

Quantization . . . . . . . . . . . . . . . . . . . . . . . . .

9

1.2.2

A pitfall: pathological asymptotic behavior . . . . . . . .

9

1.3

Numerov’s method . . . . . . . . . . . . . . . . . . . . . . . . . .

10

1.3.1

Code: harmonic0 . . . . . . . . . . . . . . . . . . . . . . .

12

1.3.2

Code: harmonic1 . . . . . . . . . . . . . . . . . . . . . . .

13

1.3.3

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

15

2

Schr¨

odinger equation for central potentials

16

2.1

Variable separation . . . . . . . . . . . . . . . . . . . . . . . . . .

16

2.1.1

Radial equation . . . . . . . . . . . . . . . . . . . . . . . .

18

2.2

Coulomb potential . . . . . . . . . . . . . . . . . . . . . . . . . .

18

2.2.1

Energy levels . . . . . . . . . . . . . . . . . . . . . . . . .

20

2.2.2

Radial wave functions . . . . . . . . . . . . . . . . . . . .

20

2.3

Code: hydrogen radial . . . . . . . . . . . . . . . . . . . . . . . .

21

2.3.1

Logarithmic grid . . . . . . . . . . . . . . . . . . . . . . .

21

2.3.2

Improving convergence with perturbation theory . . . . .

22

2.3.3

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

24

3

Scattering from a potential

25

3.1

Short reminder of the theory of scattering . . . . . . . . . . . . .

25

3.2

Scattering of H atoms from rare gases . . . . . . . . . . . . . . .

27

3.2.1

Derivation of Van der Waals interaction . . . . . . . . . .

27

i

3.3

Code: crossection . . . . . . . . . . . . . . . . . . . . . . . . . . .

28

3.3.1

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

30

4

The Variational Method

32

4.1

Variational Principle . . . . . . . . . . . . . . . . . . . . . . . . .

32

4.1.1

Demonstration of the variational principle . . . . . . . . .

32

4.1.2

Alternative demonstration of the variational principle . .

33

4.1.3

Ground state energy . . . . . . . . . . . . . . . . . . . . .

34

4.1.4

Variational method in practice . . . . . . . . . . . . . . .

35

4.2

Secular problem . . . . . . . . . . . . . . . . . . . . . . . . . . . .

35

4.2.1

Expansion into a basis set of orthonormal functions

. . .

36

4.3

Plane-wave basis set . . . . . . . . . . . . . . . . . . . . . . . . .

38

4.4

Code: pwell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

39

4.4.1

Diagonalization routines . . . . . . . . . . . . . . . . . . .

40

4.4.2

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

41

5

Non-orthonormal basis sets

42

5.1

Non-orthonormal basis set . . . . . . . . . . . . . . . . . . . . . .

42

5.1.1

Gaussian functions . . . . . . . . . . . . . . . . . . . . . .

44

5.1.2

Exponentials . . . . . . . . . . . . . . . . . . . . . . . . .

44

5.2

Code: hydrogen gauss . . . . . . . . . . . . . . . . . . . . . . . .

44

5.2.1

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

46

6

Self-consistent Field

47

6.1

The Hartree Approximation . . . . . . . . . . . . . . . . . . . . .

47

6.2

Hartree Equations . . . . . . . . . . . . . . . . . . . . . . . . . .

48

6.2.1

Eigenvalues and Hartree energy . . . . . . . . . . . . . . .

49

6.3

Self-consistent potential . . . . . . . . . . . . . . . . . . . . . . .

50

6.3.1

Self-consistent potential in atoms . . . . . . . . . . . . . .

50

6.4

Code: helium hf radial . . . . . . . . . . . . . . . . . . . . . . . .

51

6.4.1

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

52

7

The Hartree-Fock approximation

53

7.1

Hartree-Fock method . . . . . . . . . . . . . . . . . . . . . . . . .

53

7.1.1

Coulomb and exchange potentials . . . . . . . . . . . . . .

55

7.1.2

Correlation energy . . . . . . . . . . . . . . . . . . . . . .

56

7.1.3

The Helium atom . . . . . . . . . . . . . . . . . . . . . . .

57

7.2

Code: helium hf gauss . . . . . . . . . . . . . . . . . . . . . . . .

57

7.2.1

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

59

8

Molecules

60

8.1

Born-Oppenheimer approximation . . . . . . . . . . . . . . . . .

60

8.2

Potential Energy Surface . . . . . . . . . . . . . . . . . . . . . . .

61

8.3

Diatomic molecules . . . . . . . . . . . . . . . . . . . . . . . . . .

62

8.4

Code: h2 hf gauss

. . . . . . . . . . . . . . . . . . . . . . . . . .

63

8.4.1

Gaussian integrals . . . . . . . . . . . . . . . . . . . . . .

63

8.4.2

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

64

ii

9

Electrons in a periodic potential

66

9.1

Crystalline solids . . . . . . . . . . . . . . . . . . . . . . . . . . .

66

9.1.1

Periodic Boundary Conditions

. . . . . . . . . . . . . . .

67

9.1.2

Bloch Theorem . . . . . . . . . . . . . . . . . . . . . . . .

68

9.1.3

The empty potential . . . . . . . . . . . . . . . . . . . . .

68

9.1.4

Solution for the crystal potential . . . . . . . . . . . . . .

69

9.1.5

Plane-wave basis set . . . . . . . . . . . . . . . . . . . . .

70

9.2

Code: periodicwell . . . . . . . . . . . . . . . . . . . . . . . . . .

72

9.2.1

Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

73

10 Pseudopotentials

74

10.1 Three-dimensional crystals . . . . . . . . . . . . . . . . . . . . . .

74

10.2 Plane waves, core states, pseudopotentials . . . . . . . . . . . . .

75

10.3 Code: cohenbergstresser . . . . . . . . . . . . . . . . . . . . . . .

76

10.3.1 Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

78

11 Exact diagonalization of quantum spin models

79

11.1 The Heisenberg model . . . . . . . . . . . . . . . . . . . . . . . .

79

11.2 Hilbert space in spin systems . . . . . . . . . . . . . . . . . . . .

80

11.3 Iterative diagonalization . . . . . . . . . . . . . . . . . . . . . . .

81

11.4 Code: heisenberg exact . . . . . . . . . . . . . . . . . . . . . . 82

11.4.1 Computer Laboratory . . . . . . . . . . . . . . . . . . . .

83

A From two-body to one-body problem

85

B Accidental degeneracy and dynamical symmetry

87

C Composition of angular momenta: the coupled representation 88

D Two-electron atoms

90

D.1 Perturbative Treatment for Helium atom . . . . . . . . . . . . . .

91

D.2 Variational treatment for Helium atom . . . . . . . . . . . . . . .

92

D.3 ”Exact” treatment for Helium atom

. . . . . . . . . . . . . . . .

93

D.3.1 Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . .

95

E Useful algorithms

96

E.1 Search of the zeros of a function

. . . . . . . . . . . . . . . . . .

96

E.1.1

Bisection method . . . . . . . . . . . . . . . . . . . . . . .

96

E.1.2

Newton-Raphson method . . . . . . . . . . . . . . . . . .

97

E.1.3

Secant method . . . . . . . . . . . . . . . . . . . . . . . .

97

iii

Introduction

The aim of these lecture notes is to provide an introduction to methods and

techniques used in the numerical solution of simple (non-relativistic) quantum-

mechanical problems, with special emphasis on atomic and condensed-matter

physics. The practical sessions are meant to be a sort of “computational lab-

oratory”, introducing the basic ingredients used in the calculation of materials

properties at a much larger scale. The latter is a very important field of today’s

computational physics, due to its technological interest and potential applica-

tions.

The codes provided during the course are little more than templates. Stu-

dents are expected to analyze them, to run them under various conditions, to

examine their behavior as a function of input data, and most important, to

interpret their output from a physical point of view. The students will be asked

to extend or modify those codes, by adding or modifying some functionalities.

For further insight on the theory of Quantum Mechanics, many excellent

textbooks are available (e.g. Griffiths, Schiff, or the ever-green Dirac and Lan-

dau). For further insight on the properly computational aspects of this course,

we refer to the specialized texts quotes in the Bibliography section, and in

particular to the book of Thijssen.

0.1

About Software

This course assumes some basic knowledge of how to write and execute simple

programs, and how to plot their results. All that is needed is a fortran or C

compiler and some visualization software. The target machine is a PC running

Linux, but other operating systems can be used as well (including Mac OS-X

and Windows), as long as the mentioned software is installed and working, and

if you know how to use it in oractise.

0.1.1

Compilers

In order to run a code written in any programming language, we must first

translate it into machine language, i.e.

a language that the computer can

understand. The translation is done by an interpreter or by a compiler: the

former translates and immediately executes each instruction, the latter takes

the file, produces the so-called object code that together with other object codes

and with libraries is finally assembled into an executable file. Python, Java (or at

1

an higher level, Matlab, Mathematica) are examples of “interpreted” language.

Fortran, C, C++ are “compiled” languages.

Our codes are written in Fortran 90.

This is a sophisticated and com-

plex language offering dynamical memory management, arrays operations (e.g.

matrix-vector products), modular and object-based structure. Fortran 90 how-

ever can be as efficient as Fortran 77 and maintains a wide compatibility with

existing Fortran 77 codes. It is worth mentioning that the first applications

of computers to physics go back to well before the birth of modern computer

languages like C++, python, or even C: there is still a large number of codes

and libraries written in Fortran 77 (or even Fortran 66!) widely used in physics.

Fortran 90 (or even Fortran 77, in this respect) is not a well known language.

There are however many available resources (see for instance the web page

mentioned in the bibliography section) and the codes themselves are very simple

and make little usage of advanced language features. In any case, there are no

objections if a student prefers to use a more widespread language like C. A

version of all codes in C is also available (no warranty about the quality of the

C code in terms of elegance and good coding practice).

In all cases, we need a C or Fortran 90 compiler. In PCs running Linux, the

C compiler gcc is basically part of the operating system and is always present.

Recent versions of gcc also include a Fortran compiler, called gfortran. If this

is absent, or it is not easy to install it, one can download the free and rather

reliable compiler, g951. It is possible to install on Mac OS-X and on Windows either gcc with gfortran or g95.

0.1.2

Visualization Tools

Visualization of data produced by the codes (wave functions, charge densities,

various other quantities) has a central role in the analysis and understanding

of the results. Code gnuplot can be used to make two-dimensional or three-

dimensional plots of data or of analytical expressions. gnuplot is open-source

software, available for all operating systems and usually found pre-installed on

Linux PCs. An introduction to gnuplot, with many links to more resources,

can be found here: http://www.gnuplot.info/help.html.

Another software that can be used is xmgrace2. This is also open-source and highly portable, has a graphical user interface and thus it is easier to use

than gnuplot, whose syntax is not always easy to remember.

0.1.3

Mathematical Libraries

The usage of efficient mathematical libraries is crucial in “serious” calculations.

Some of the codes use routines from the BLAS3 (Basic Linear Algebra Sub-programs) library and from LAPACK4 (Linear Algebra PACKage). The latter

1http://www.g95.org

2http://plasma-gate.weizmann.ac.il/Grace

3http://www.netlib.org/blas

4http://www.netlib.org/lapack

2

is an important and well-known library for all kinds of linear algebra oper-

ations: solution of linear systems, eigenvalue problems, etc. LAPACK calls

BLAS routines for all CPU-intensive calculations. The latter are available in

highly optimized form for many different architectures.

BLAS and LAPACK routines are written in Fortran 77. BLAS and LA-

PACK are often available in many operating systems and can be linked directly

by the compiler by adding -llapack -lblas. In the case of C compiler, it

may be needed to add an underscore ( ) in the calling program, as in: dsyev ,

dgemm . This is due to different C-Fortran conventions for the naming of “sym-

bols” (i.e. compiled routines). Note that the C compiler may also need -lm to

link general mathematical libraries (i.e. operations like the square root).

0.1.4

Pitfalls in C-Fortran interlanguage calls

In addition to the above-mentioned potential mismatches between C and For-

tran naming conventions, there are a few more pitfalls one has to be aware of

when Fortran 77 routines are called by C (or vice versa).

• Fortran passes pointers to subroutines and functions; C passes values. In

order to call a Fortran routine from C, all C variables appearing in the

call must be either pointers or arrays.

• Indices of vectors and arrays start from 0 in C, from 1 in Fortran (unless

differently specified in array declaration or allocation).

• Matrices in C are stored in memory row-wise, that is: a[i][j+1] follows

a[i][j] in memory. In Fortran, they are stored column-wise (the other

way round!): a(i+1,j) follows a(i,j) in memory.

An additional problem is that C does not provide run-time allocatable matrices

like Fortran does, but only