# FYS3150/FYS4150 Project 2 Eigenvalue problems, from the equations of a buckling beam to Schroedinger’s equation for two electrons in a three-dimensional harmonic oscillator well solution

$29.99 Category: ## Description 5/5 - (4 votes) ### Introduction The aim of this project is to develop your own code for solving eigenvalue problems. The matrix to diagonalize is the same as the one we encountered in project one, a so-called tridiagonal Toeplitz matrix. This matrix has analytical eigenpairs (eigenvalues and eigenvectors) and gives us an excellent testing ground for our algorithms. In this project we will develop an eigenvalue solver based on Jacobi’s method. The project will also introduce you to units tests and we will compare our results against other eigenvalue solvers (from LAPACK and/or numpy). This project aims also at introducing to you the concept of scaling of equations. This means often either making various variables dimensionless or introducing units which are more convenient. We will start with the two-point boundary value problem of a buckling beam or a spring fastened at both ends. This is one of the problems which has analytical solutions. Thereafter, by simply adding a new variable along the diagonal elements, we can study quantum mechanical problems. In particular, we will study the harmonic oscillator problem in three dimensions, with one or two electrons. For the latter case we can study the role of the repulsive Coulomb interaction and extract interesting physics results. For selected frequencies, this interacting two-electron problem exhibits analytical solutions, one of the few cases of an interacting system where wecan find analytical solutions. See M. Taut, Phys. Rev. A 48, 3561 (1993) for the derivation of analytical expressions for the eigenpairs.. Electrons confined in small areas in semiconductors, so-called quantum dots, form a hot research area in modern solid-state physics, with applications spanning from such diverse fields as quantum nano-medicine to the contruction of quantum gates. The article on quantum computing with quantum dots by Loss and DiVincenzo is an excellent read for those interested in this exciting topic. ### The buckling beam problem, a classical wave function problem in one dimension We start with the following differential equation, namely γd2u(x)dx2=Fu(x),γd2u(x)dx2=−Fu(x), where u(x)u(x) is the vertical displacement of the beam in the yy direction. The beam has length LLx[0,L]x∈[0,L] and FF is a force applied at (L,0)(L,0) in the direction towards the origin. The parameter γγ is a constant defined by properties like the rigidity of the beam. We apply again so-called Dirichlet boundary conditions and set u(0)=u(L)=0u(0)=u(L)=0. In this specific case two of the parameters γγFF and LL are known. As an example, assume we know FF and LL. Then the eigenvalue problem we set up below will allow us to find γγ. We define a dimensional variable ρ=xL,ρ=xL, meaning that we have ρ[0,1]ρ∈[0,1]. By reordering the equation as d2u(ρ)dρ2=FL2γu(ρ)=λu(ρ),d2u(ρ)dρ2=−FL2γu(ρ)=−λu(ρ), with λ=FL2/γλ=FL2/γ we have an equation that when discretized, becomes an eigenvalue problem. We use the same expression for the second derivative of a function uu as we did in project 1, namely u′′=u(ρ+h)2u(ρ)+u(ρh)h2+O(h2),(1)(1)u″=u(ρ+h)−2u(ρ)+u(ρ−h)h2+O(h2), where hh is our step. Next we define minimum and maximum values for the variable ρρρmin=0ρmin=0 and ρmax=1ρmax=1, respectively. With a given number of mesh points, NN, we define the step length hh as, with ρmin=ρ0ρmin=ρ0 and ρmax=ρNρmax=ρN, h=ρNρ0N.h=ρN−ρ0N. The value of ρρ at a point ii is then ρi=ρ0+ihi=1,2,,N.ρi=ρ0+ihi=1,2,…,N. We can rewrite the differential equation for a value ρiρi as u(ρi+h)2u(ρi)+u(ρih)h2=λu(ρi),−u(ρi+h)−2u(ρi)+u(ρi−h)h2=λu(ρi), or in a more compact way as ui+12ui+ui1h2=λui.−ui+1−2ui+ui−1h2=λui. Following our approach from project 1, we can rewrite this equation in a more a general form, but now as an eigenvalue problem, that is ⎡⎣⎢⎢⎢⎢⎢⎢⎢⎢da000ada0ad00a0a00da000ad⎤⎦⎥⎥⎥⎥⎥⎥⎥⎥⎡⎣⎢⎢⎢⎢⎢⎢⎢⎢⎢u1u2u3uN2uN1⎤⎦⎥⎥⎥⎥⎥⎥⎥⎥⎥=λ⎡⎣⎢⎢⎢⎢⎢⎢⎢⎢⎢u1u2u3uN2uN1⎤⎦⎥⎥⎥⎥⎥⎥⎥⎥⎥.(2)(2)[da00…00ada0…000ada0…0…………………0………ada0…………ad][u1u2u3…uN−2uN−1]=λ[u1u2u3…uN−2uN−1]. As in project 1, we have not included the endpoints u0u0 and uNuN. We have defined d=2/h2d=2/h2 and the non-diagonal ones as a=1/h2a=−1/h2. This eigenvalue problem has analytical eigenpairs, with eigenvalues given as (note that we define the matrix to run from i=1i=1 to i=N1i=N−1) λj=d+2acos(jπN),j=1,2,N1.λj=d+2acos⁡(jπN),j=1,2,…N−1. The eigenvectors are uj=[sin(jπN),sin(2jπN),...,sin((N1)jπN)]T,j=1,2,N1.uj=[sin⁡(jπN),sin⁡(2jπN),…,sin⁡((N−1)jπN)]T,j=1,2,…N−1. The lecture notes of Tom Lyche provide an excellent description of this matrix. Chapters 1.2 and 1.3 of this text present a thourough discussion of tridiagonal matrices and two-point boundary value problems. ### Project 2 a): Mathematical intermezzo A unitary transformation preserves the orthogonality of the obtained eigenvectors. To see this consider first a basis of vectors vivi, vi=⎡⎣⎢⎢⎢vi1vin⎤⎦⎥⎥⎥vi=[vi1……vin] We assume that the basis is orthogonal, that is vTjvi=δij.vjTvi=δij. Show that an orthogonal or unitary transformation wi=Uvi,wi=Uvi, preserves the dot product and orthogonality. ### Project 2 b): Setting up a code for tridiagonal Toeplitz matrix Your task now is to write a function which implements Jacobi’s rotation algorithm (see Lecture notes chapter 7) in order to solve Eq. (2)(2). However, the first simple check is to set up the matrix to diagonalize for a given NN and use either armadillo’s or numpy’s functions for diagonalizing a matrix. You can then check that you obtain the analytical eigenvalues. For Jacobi’s method, we define the quantities tanθ=t=s/ctan⁡θ=t=s/c, with s=sinθs=sin⁡θ and c=cosθc=cos⁡θ and cot2θ=τ=allakk2akl.cot⁡2θ=τ=all−akk2akl. We can then define the angle θθ so that the non-diagonal matrix elements of the transformed matrix aklakl become non-zero and we obtain the quadratic equation (using cot2θ=1/2(cotθtanθ)cot⁡2θ=1/2(cot⁡θ−tan⁡θ) t2+2τt1=0,t2+2τt−1=0, resulting in t=τ±1+τ2−−−−−√,t=−τ±1+τ2, and cc and ss are easily obtained via c=11+t2−−−−−√,c=11+t2, and s=tcs=tc. How many similarity transformations are needed before you reach a result where all non-diagonal matrix elements are essentially zero? Try to estimate the number of transformations and extract a behavior as function of the dimensionality of the matrix. Compare your results with the analytical ones. Plot also the eigenvector for the lowest eigenvalue and compare this eigenvector with the analytical solution. You can check your results against the Armadillo function for solving eigenvalue problems. The armadillo function eig$_\$sym can be used to find eigenvalues and eigenvectors. A Python program which solves this part of the project is available under the project writing slides.

Comment your results (here you could for example compute the time needed for both algorithms for a given dimensionality of the matrix).

### Project 2 c): Implementing tests in your code

In this project (and later ones as well) we will implement so-called unit tests. Our unit tests are mainly meant to test mathematical properties of our algorithm. During the development phase of a program it is useful to devise tests that your program should pass. One of these is to make sure that for a given simple test matrix (say a 5×55×5 matrix) our algorithm for searching for the largest non-diagonal element always returns the correct answer. Furthermore, for a known simple matrix, irrespective of changes made, we should always get the same and correct eigenvalues. Another test is to make sure that the orthogonality shown in exercise (a) is preserved. Try to figure out other tests your code should pass, based either on the mathematical properties of the algorithms or more program specific tests. Implement at least two unit tests in this project.

### Extending our machinery to quantum mechanics

Here we will assume that these electrons move in a three-dimensional harmonic oscillator potential (they are confined by for example quadrupole fields) and repel each other via the static Coulomb interaction. We assume spherical symmetry. You don’t need to think of quantum mechanics when solving this project, look at it as another diagonalization problem.

We are first interested in the solution of the radial part of Schroedinger’s equation for one electron. This equation reads

22m(1r2ddrr2ddrl(l+1)r2)R(r)+V(r)R(r)=ER(r).−ℏ22m(1r2ddrr2ddr−l(l+1)r2)R(r)+V(r)R(r)=ER(r).

In our case V(r)V(r) is the harmonic oscillator potential (1/2)kr2(1/2)kr2 with k=mω2k=mω2 and EE is the energy of the harmonic oscillator in three dimensions. The oscillator frequency is ωω and the energies are

Enl=ω(2n+l+32),Enl=ℏω(2n+l+32),

with n=0,1,2,n=0,1,2,… and l=0,1,2,l=0,1,2,….

Since we have made a transformation to spherical coordinates it means that r[0,)r∈[0,∞). The quantum number ll is the orbital momentum of the electron. Then we substitute R(r)=(1/r)u(r)R(r)=(1/r)u(r) and obtain

22md2dr2u(r)+(V(r)+l(l+1)r222m)u(r)=Eu(r).−ℏ22md2dr2u(r)+(V(r)+l(l+1)r2ℏ22m)u(r)=Eu(r).

The boundary conditions are u(0)=0u(0)=0 and u()=0u(∞)=0.

We introduce a dimensionless variable ρ=(1/α)rρ=(1/α)r where αα is a constant with dimension length and get

22mα2d2dρ2u(ρ)+(V(ρ)+l(l+1)ρ222mα2)u(ρ)=Eu(ρ).−ℏ22mα2d2dρ2u(ρ)+(V(ρ)+l(l+1)ρ2ℏ22mα2)u(ρ)=Eu(ρ).

We will set in this project l=0l=0. Inserting V(ρ)=(1/2)kα2ρ2V(ρ)=(1/2)kα2ρ2 we end up with

22mα2d2dρ2u(ρ)+k2α2ρ2u(ρ)=Eu(ρ).−ℏ22mα2d2dρ2u(ρ)+k2α2ρ2u(ρ)=Eu(ρ).

We multiply thereafter with 2mα2/22mα2/ℏ2 on both sides and obtain

d2dρ2u(ρ)+mk2α4ρ2u(ρ)=2mα22Eu(ρ).−d2dρ2u(ρ)+mkℏ2α4ρ2u(ρ)=2mα2ℏ2Eu(ρ).

The constant αα can now be fixed so that

mk2α4=1,mkℏ2α4=1,

or

α=(2mk)1/4.α=(ℏ2mk)1/4.

Defining

λ=2mα22E,λ=2mα2ℏ2E,

we can rewrite Schroedinger’s equation as

d2dρ2u(ρ)+ρ2u(ρ)=λu(ρ).−d2dρ2u(ρ)+ρ2u(ρ)=λu(ρ).

This is the first equation to solve numerically. In three dimensions the eigenvalues for l=0l=0 are λ0=3,λ1=7,λ2=11,.λ0=3,λ1=7,λ2=11,….

We define minimum and maximum values for the variable ρρρmin=0ρmin=0 and ρmaxρmax, respectively. You need to check your results for the energies against different values ρmaxρmax, since we cannot set ρmax=ρmax=∞.

With a given number of mesh points, NN, we define the step length hh as, with ρmin=ρ0ρmin=ρ0 and ρmax=ρNρmax=ρN,

h=ρNρ0N.h=ρN−ρ0N.

The value of ρρ at a point ii is then

ρi=ρ0+ihi=1,2,,N.ρi=ρ0+ihi=1,2,…,N.

We can rewrite the Schroedinger equation for a value ρiρi as

u(ρi+h)2u(ρi)+u(ρih)h2+ρ2iu(ρi)=λu(ρi),−u(ρi+h)−2u(ρi)+u(ρi−h)h2+ρi2u(ρi)=λu(ρi),

or in a more compact way

ui+12ui+ui1h2+ρ2iui=ui+12ui+ui1h2+Viui=λui,−ui+1−2ui+ui−1h2+ρi2ui=−ui+1−2ui+ui−1h2+Viui=λui,

where Vi=ρ2iVi=ρi2 is the harmonic oscillator potential.

We define first the diagonal matrix element

di=2h2+Vi,di=2h2+Vi,

and the non-diagonal matrix element

ei=1h2.ei=−1h2.

In this case the non-diagonal matrix elements are given by a mere constant. All non-diagonal matrix elements are equal. With these definitions the Schroedinger equation takes the following form

diui+eiui1+eiui+1=λui,diui+eiui−1+eiui+1=λui,

where uiui is unknown. We can write the latter equation as a matrix eigenvalue problem

⎡⎣⎢⎢⎢⎢⎢⎢⎢⎢⎢d1e1000e1d2e20e2d300e30eN300dN2eN2000eN2dN1⎤⎦⎥⎥⎥⎥⎥⎥⎥⎥⎥⎡⎣⎢⎢⎢⎢⎢⎢⎢⎢u1u2uN1⎤⎦⎥⎥⎥⎥⎥⎥⎥⎥=λ⎡⎣⎢⎢⎢⎢⎢⎢⎢⎢u1u2uN1⎤⎦⎥⎥⎥⎥⎥⎥⎥⎥.(3)(3)[d1e100…00e1d2e20…000e2d3e30…0…………………0…………eN−3dN−2eN−20…………eN−2dN−1][u1u2………uN−1]=λ[u1u2………uN−1].

Note here that we have not included the endpoints since we assume that they are knowm (as we did in project 1). The matrix is also symmetric in this case.

### Project 2 d): Quantum dots in three dimensions, one electron

Add the harmonic oscillator potential to your tridiagonal Toeplitz matrix from 2a-2c and diagonalize the matrix. Study the results as functions of the number of integration points NN and your approximation to ρmaxρmax. The analytical results with our scaling for the one-electron energies are λ=3,7,11,15,λ=3,7,11,15,…. How many integration points do you need in order to reproduce the analytical results with say four leading digits after the decimal point?

You can reuse the code you wrote for part (b), but you need to add the potential ρ2ρ2 to the diagonal elements.

### Project 2 e): Quantum dots in three dimensions, two electrons

Note: if you are not interested in the explicit quantum physics case here, you can replace this part with either 2g or 2h below. The latter ones are optional exercises if you do this.

We will now study two electrons in a harmonic oscillator well which also interact via a repulsive Coulomb interaction. Let us start with the single-electron equation written as

22md2dr2u(r)+12kr2u(r)=E(1)u(r),−ℏ22md2dr2u(r)+12kr2u(r)=E(1)u(r),

where E(1)E(1) stands for the energy with one electron only. For two electrons with no repulsive Coulomb interaction, we have the following Schroedinger equation

(22md2dr2122md2dr22+12kr21+12kr22)u(r1,r2)=E(2)u(r1,r2).(−ℏ22md2dr12−ℏ22md2dr22+12kr12+12kr22)u(r1,r2)=E(2)u(r1,r2).

Note that we deal with a two-electron wave function u(r1,r2)u(r1,r2) and two-electron energy E(2)E(2).

With no interaction this can be written out as the product of two single-electron wave functions, that is we have a solution on closed form.

We introduce the relative coordinate r=r1r2r=r1−r2 and the center-of-mass coordinate R=1/2(r1+r2)R=1/2(r1+r2). With these new coordinates, the radial Schroedinger equation reads

(2md2dr224md2dR2+14kr2+kR2)u(r,R)=E(2)u(r,R).(−ℏ2md2dr2−ℏ24md2dR2+14kr2+kR2)u(r,R)=E(2)u(r,R).

The equations for rr and RR can be separated via the ansatz for the wave function u(r,R)=ψ(r)ϕ(R)u(r,R)=ψ(r)ϕ(R) and the energy is given by the sum of the relative energy ErEr and the center-of-mass energy ERER, that is

E(2)=Er+ER.E(2)=Er+ER.

We add then the repulsive Coulomb interaction between two electrons, namely a term

V(r1,r2)=βe2|r1r2|=βe2r,V(r1,r2)=βe2|r1−r2|=βe2r,

with βe2=1.44βe2=1.44 eVnm.

Adding this term, the rr-dependent Schroedinger equation becomes

(2md2dr2+14kr2+βe2r)ψ(r)=Erψ(r).(−ℏ2md2dr2+14kr2+βe2r)ψ(r)=Erψ(r).

This equation is similar to the one we had previously in (b) and we introduce again a dimensionless variable ρ=r/αρ=r/α. Repeating the same steps as above, we arrive at

d2dρ2ψ(ρ)+14mk2α4ρ2ψ(ρ)+mαβe2ρ2ψ(ρ)=mα22Erψ(ρ).−d2dρ2ψ(ρ)+14mkℏ2α4ρ2ψ(ρ)+mαβe2ρℏ2ψ(ρ)=mα2ℏ2Erψ(ρ).

We want to manipulate this equation further to make it as similar to that in (a) as possible. We define a new ‘frequency’

ω2r=14mk2α4,ωr2=14mkℏ2α4,

and fix the constant αα by requiring

mαβe22=1mαβe2ℏ2=1

or

α=2mβe2.α=ℏ2mβe2.

Defining

λ=mα22E,λ=mα2ℏ2E,

we can rewrite Schroedinger’s equation as

d2dρ2ψ(ρ)+ω2rρ2ψ(ρ)+1ρ=λψ(ρ).−d2dρ2ψ(ρ)+ωr2ρ2ψ(ρ)+1ρ=λψ(ρ).

We treat ωrωr as a parameter which reflects the strength of the oscillator potential.

Here we will study the cases ωr=0.01ωr=0.01ωr=0.5ωr=0.5ωr=1ωr=1, and ωr=5ωr=5 for the ground state only, that is the lowest-lying state.

With no repulsive Coulomb interaction you should get a result which corresponds to the relative energy of a non-interacting system. Make sure your results are stable as functions of ρmaxρmax and the number of steps.

We are only interested in the ground state with l=0l=0. We omit the center-of-mass energy.

You can reuse the code you wrote for part (b), but you need to add the potential ω2rρ2+1/ρωr2ρ2+1/ρ to the diagonal elements.

Comment the results for the lowest state (ground state) as function of varying strengths of ωrωr.

For specific oscillator frequencies, the above equation has answers in an analytical form, see the article by M. Taut, Phys. Rev. A 48, 3561 (1993).

### Project 2 f): First optional exercise: Quantum physics analysis of the results

This exercise is a continuation of the previous and adds more quantum physics to the analysis. In this exercise we want to plot the wave function for two electrons as functions of the relative coordinate rr and different values of ωrωr. With no Coulomb interaction you should have a result which corresponds to the non-interacting case. Plot either the function itself or the probability distribution (the function squared) with and without the repulsion between the two electrons. Varying ωrωr, the shape of the wave function will change.

We are only interested in the wave function for the ground state with l=0l=0 and omit again the center-of-mass motion.

The eigenvectors are normalized. Plot then the normalized wave functions for different values of ωrωr and comment the results.

### Project 2 g): Second optional challenge: Smarter way of finding the eigenvalues

This exercise is also optional and is an algorithmic challenge. Your matrix is already tridiagonal. Can you devise a more efficient way to find the eigenvalues and eigenvectors instead of the brute force application of Jacobi’s method? Hint: Use the bisection method discussed in for example Barth, Martin and Wilkinson, Numerische Mathematik 9, 386 (1967).

### Project 2 h): Third optional challenge: Implementing Lanczos’ algorithm

This exercise is optional and is meant more as a challenge for those of you with an interest in other algorithms for solving eigenvalue problems. Implement the iterative Lanczos’ algorithm discussed in the lecture notes and compute the lowest eigenvalues as done in exercise (c) or (d) above. Compare your results and discuss faults and merits of the iterative method versus direct methods like Jacobi’s method.

## Introduction to numerical projects

Here follows a brief recipe and recommendation on how to write a report for each project.

• Give a short description of the nature of the problem and the eventual numerical methods you have used.
• Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.
• Include the source code of your program. Comment your program properly.
• If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
• Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.
• Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.
• Try to give an interpretation of you results in your answers to the problems.
• Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you’ve made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.
• Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don’t properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.

## Format for electronic delivery of report and programs

The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report: