Numerical Solution of Harmonic Oscillator

16

description

Solving the quantum mechanical harmonic oscillator numerically, using the finite difference method

Transcript of Numerical Solution of Harmonic Oscillator

Page 1: Numerical Solution of Harmonic Oscillator

Assignment 3: Eigenvalue problems I

Project Report for FK8002, Computational Physics

at Stockholm University

Author: Sebastian Arnoldt

April 15, 2013

Page 2: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 1

Contents

1 Introduction 2

2 Set-Up 3

3 Results 5

3.1 Analytical and Numerical Eigenvalues . . . . . . . . . . . . . . 6

3.2 Orthonormality . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.3 Accuracy of Solutions . . . . . . . . . . . . . . . . . . . . . . . 10

3.4 performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4 Disucussion 14

Page 3: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 2

1 Introduction

The goal of this lab is to compute the eigenpairs of the one-dimensional

harmonic oscillator, which can be expressed by the reduced Schroedinger

equation (− d2

dx2 + x2)

Ψ(x) = 2EΨ(x) (1)

.

In order to treat the system numerically, I construct the matrix H of the

Hamiltonian by using the �ve-point formula given in lab instructions [2], to

arrive at the system of linear equations

Hx = λx (2)

, which is the classical eigenvalue problem. To �nd the eigenpairs of eq. 2, I

use a standard method from an existing library and compare its behaviour

to a self-written Inverse Power Shift (IPS) routine that follows [3, pp.493]

Page 4: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 3

2 Set-Up

All computations are implemented using SciPy's sparse format for arrays.

The standard method of my choice is eigsh(), which uses the ARPACK library

and the Implicitely Restarted Lanczos Method (IRLM) therein [1]. The

corner-stone of the self-written IPS-routine is computing the sequence:

Yk = (A− αI)−1Xk (3)

Xk+1 =Yk||Yk||

(4)

, where A is the matrix to be diagonalized, α is the so-called shift and the

sequence is started of by an initial guess X0, which in this implementation is

a vector with randomly chosen elements [3, pp.493].

The self-written IPS-routine incorporates two convergence criteria: the

di�erence of two subsequent eigenvalues must be less than the user-de�ned

tolerance and the norm of the di�erence of two subsequent solution vectors

Y must be less than the same user-de�ned tolerance. For the computations

below, the tolerance is set to 10−8. Moreover, the computationally intensive

part of solving the above system of equations in each iteration is done by

sparse LU factorization, which is also sourced from ARPACK via Python's

SciPy package.

The eigenvalues computed with both methods are checked against the

well-known analytical eigenvalues of the one-dimensional harmonic oscillator.

Note that due to eq. 1, the analytical eigenvalues here are 2En = 2(n+ 12) =

1, 3, 5, ... . This comparison, however is not valid for the entire spectrum of

the eigenpairs. The reason for this is that in the computations below the

matrix H spans a �nite space, which is de�ned by the choice of the grid, i.e.

a �nite interval on the x-axis. All computations below are done on a grid

that discretizes the x-interval [-10,10]. However, as shown in �g. 1 below,

the analytical solutions of the harmonic oscillator are de�ned well outside

−10 ≤ x ≤ 10 already for values of the main quantum number n as low as

n = 50. Thus both methods will produce eiganpairs that do not match the

Page 5: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 4

physical expectation starting at roughly n = 50 for the given x-interval.

Figure 1: Harmonic Oscillator for quantum number n = 50: the red regionsshow the probability density; the blue curve shows the analogous classicalprobability distribution. [4]

Page 6: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 5

3 Results

The plots below show the results of the computations on the x-interval [-

10,10] that is discretized in N = 100 points. The discretization is done such

that the endpoints of the interval lie at x = −10 + h and x = 10− h, whereh is the step-size. Both methods are set to the same tolerance, tol = 10−8

for all computations. Having completed all computations, N and the x-

interval are varied. Moreover, the approximation is changed from the �ve-

point rule to the midpoint rule. Those variations, however, do not reveal

any unexpected behaviour and are therefore not reported below. Moreover,

a quick comparison of the performance of both methods is done.

Page 7: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 6

3.1 Analytical and Numerical Eigenvalues

Fig. 2 and �g. 3 below show plots of the numerically computed eigenvalues

λnum in the order of increasing value and compare them to the analytical

eigenvalues λana of the harmonic oscillator for the eigsh() and the IPS meth-

ods. In both cases, λnum start to diverge from λana between 40 ≤ n ≤ 50.

Interestingly, the eigsh()-method produces degenerate eigenvalues around

n = 60. The self-written IPS method does not �nd 100 eigenvalues, whereas

the eighs()-method does. Moreover, the eigsh()-method �nds the highest

eigenvalue, which is not found by the IPS-method.

Figure 2

Page 8: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 7

Figure 3

Page 9: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 8

3.2 Orthonormality

The orthonormality of the computed eigenvectors can be checked by putting

all eigenvectors into a matrix O and checking that O · OT = Id. Due to

numerical artefacts, however, the resulting matrix will not contain only val-

ues of exactly one or zero. Therefore �g. 4 and �g. 5 below show heat-maps

of the thus computed matrices, which reveals that both methods return or-

thonormal eigenvectors in the numerical limit. This is expected, since the

eigenvectors are normalized in each iteration in both methods.

Figure 4

Page 10: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 9

Figure 5

Page 11: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 10

3.3 Accuracy of Solutions

The accuracy of the solutions of both methods is checked by computing the

norm of the residue:

||res|| = ||λnumi · xi −H · xi|| (5)

for each eigenpair. Fig. 6 and �g. 7 below show plots of ||res|| as a function

of n for both methods and reveal that the results produced by eigsh() are

several orders of magnitude more precise than the results computed by the

IPS-method. Moreover, the values for ||res|| vary much more for the IPS-

method (2 orders of magnitude) than for the eigsh()-method (below one order

of magnitude). This explains why it does not make a di�erence here whether

we use the midpoint or �ve-point approximation for the second derivative in

eq. 1, since the changes in accuracy produced by using the midpoint instead

of the �ve-point method are hidden by the relatively large variations in the

residues.

Page 12: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 11

Figure 6

Page 13: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 12

Figure 7

Page 14: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 13

3.4 performance

Lastly, a qualitative performance comparison is carried-out. Varying N be-

tween 1000 and 50000, the following observations are made. When comput-

ing only the smallest �ve eigenvalues, IPS is a factor 100 faster than eigsh().

However, when computing all eigenvalues: eigsh() is a factor 10 faster than

IPS. A comparison between this Python code and Jesper's C++ code has

also been done. The results are presented in Jesper's report.

Page 15: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 14

4 Disucussion

There is a trade-o� between the two methods insomuch as eigsh() always

produces more accurate results than IPS-method, however for large matrices

the IPS-method is faster. Moreover, a lesson to learn from this project is

that when analysing physical systems numerically, one needs to keep in mind

the restrictions that arise by treating such systems numerically, as opposed

to treating them analytically. In the present case, the boundary conditions

set a limit to the usefulness of results, i.e. only low eigenvalues are com-

puted in good agreement with the analytical expectations. Interestingly, the

results do not di�er perceivably between using the midpoint and �ve-point

approximation for the second derivative. The fact that eigsh() returns de-

generate eigenvalues for high n is interesting in itself and may be attributed

to the break-down of the Lanczos-Algorithm that forms the basis for the

eigsh-method.

Page 16: Numerical Solution of Harmonic Oscillator

SU - Computational Physics - Sebastian Arnoldt 15

References

[1] ARPACK Software. ARPACK. Available at: http://www.caam.rice.

edu/software/ARPACK/. Accessed on 12.04.2013.

[2] Stockholm University. Assignment 2: Alpha Decay. Available at: http:

//www.atom.physto.se/~lindroth/comp08/comp_phys_13.html. Ac-

cessed on 1.04.2013.

[3] W.H. Press et. al., 1992. Numerical Recipes in C. 2nd ed. Cambridge

University Press.

[4] N. Walet, Wolfram Demonstration Project. Quan-

tum/Classical Correspondence for the Harmonic Oscilla-

tor. Available at: http://demonstrations.wolfram.com/

QuantumClassicalCorrespondenceForTheHarmonicOscillator/.

Accessed on: 12.04.2013.