Sei sulla pagina 1di 16

Assignment 3: Eigenvalue problems I

Pro ject Report for FK8002, Computational Physics at Stockholm University Author: Sebastian Arnoldt

April 15, 2013

SU - Computational Physics - Sebastian Arnoldt


Contents
1 2 3 Introduction Set-Up Results

2 3 5

3.1 3.2 3.3 3.4


4

Analytical and Numerical Eigenvalues . Orthonormality . . . . . . . . . . . . . Accuracy of Solutions . . . . . . . . . . performance . . . . . . . . . . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. 6 . 8 . 10 . 13
14

Disucussion

SU - Computational Physics - Sebastian Arnoldt


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 2 (x) = 2E (x) 2 +x dx

(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]

SU - Computational Physics - Sebastian Arnoldt


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: (3) (4)

Yk = (A I )1 Xk Yk Xk+1 = ||Yk ||

, 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 dierence of two subsequent eigenvalues must be less than the user-dened tolerance and the norm of the dierence of two subsequent solution vectors Y must be less than the same user-dened tolerance. For the computations below, the tolerance is set to 108 . 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 + 1 2 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 dened 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 dened 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

SU - Computational Physics - Sebastian Arnoldt physical expectation starting at roughly n = 50 for the given x-interval.

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

SU - Computational Physics - Sebastian Arnoldt


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, where h is the step-size. Both methods are set to the same tolerance, tol = 108 for all computations. Having completed all computations, N and the xinterval are varied. Moreover, the approximation is changed from the vepoint 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.

SU - Computational Physics - Sebastian Arnoldt


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 methods. 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

SU - Computational Physics - Sebastian Arnoldt

Figure 3

SU - Computational Physics - Sebastian Arnoldt


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 values 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 orthonormal eigenvectors in the numerical limit. This is expected, since the eigenvectors are normalized in each iteration in both methods.

Figure 4

SU - Computational Physics - Sebastian Arnoldt

Figure 5

SU - Computational Physics - Sebastian Arnoldt


3.3 Accuracy of Solutions

10

The accuracy of the solutions of both methods is checked by computing the norm of the residue:
||res|| = ||num xi H xi || i

(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 IPSmethod (2 orders of magnitude) than for the eigsh() -method (below one order of magnitude). This explains why it does not make a dierence 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.

SU - Computational Physics - Sebastian Arnoldt

11

Figure 6

SU - Computational Physics - Sebastian Arnoldt

12

Figure 7

SU - Computational Physics - Sebastian Arnoldt


3.4 performance

13

Lastly, a qualitative performance comparison is carried-out. Varying N between 1000 and 50000, the following observations are made. When computing 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.

SU - Computational Physics - Sebastian Arnoldt


4 Disucussion

14

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 computed in good agreement with the analytical expectations. Interestingly, the results do not dier perceivably between using the midpoint and ve-point approximation for the second derivative. The fact that eigsh() returns degenerate 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.

SU - Computational Physics - Sebastian Arnoldt


References

15

[1] ARPACK Software.

Available at: http://www.caam.rice. edu/software/ARPACK/. Accessed on 12.04.2013. Available at: http: //www.atom.physto.se/~lindroth/comp08/comp_phys_13.html. Accessed on 1.04.2013.
Numerical Recipes in C. 2: Alpha Decay.

ARPACK.

[2] Stockholm University. Assignment

[3] W.H. Press et. al., 1992. University Press. [4] N.


tor.

2nd ed. Cambridge


QuanOscilla-

Walet, Available

Wolfram at:

Demonstration
for the

Project.
Harmonic

tum/Classical

Correspondence

http://demonstrations.wolfram.com/ QuantumClassicalCorrespondenceForTheHarmonicOscillator/.

Accessed on: 12.04.2013.

Potrebbero piacerti anche