Algorithm 777

Embed Size (px)

DESCRIPTION

Honestly I have no idea what this is.

Citation preview

  • Computer algorithms for solving

    the Schrodinger and Poisson equations

    Anders BlomDivision of Solid State Theory

    Department of Physics, Lund UniversitySolvegatan 14 A, S223 62 Lund, Sweden

    [email protected]

    December 2, 2002

    1 Introduction

    One of the most important tasks within modern physics is the solution of the Schrodinger equation,the fundamental equation of quantum mechanics. At the same time, this is a highly non-trivialtask, especially in more than one dimension. By reducing the problem, typically by symmetryconsiderations, to a single dimension, the problem is however manageable by numerical methods,and we shall in this short document discuss how the numerical calculations are carried out.

    The Schrodinger equations is actually closely related to another very important equation, thePoisson equation. These are both are both examples of second order partial differential equations,with the minor but highly important difference that the Schrodinger equation is an eigenvalueequation. Because the Schrodinger equation is an eigenvalue equation, it is not sufficient to simplyintegrate the differential equation over the interval of interest, since we do not know the eigen-value. Hence we need a way to solve both for the eigenvalue and the wavefunction (eigenfunction)simultaneously.

    In either case we need a method for integrating the differential equations, so these will bepresented first. In the one-dimensional case things are simplified in that we have ordinary dif-ferential equations instead of partial. Then we will go on to show how to use these methods tofind the eigenvalues. Finally, we will discuss what changes one has to introduce to handle caseswhere the mass changes with the coordinate, which represents the important case of semiconductorheterostructure systems.

    1

  • 2 Atomic units

    Before going into the numerical algorithms, we shall briefly discuss system of units. The standardsystem of units (such as CGS or SI) are developed for mechanics, not quantum mechanics. Ifone tries to calculate things using the CGS values of the Planck constant h or the electron massme, problems with numerical accuracy will quickly arise. For computer calculations it is thereforeconvenient to introduce so-called atomic units, in which the electron mass, the Planck constantand the electron charge e are all unity:

    me = h = e2 = 1.

    (In the case of MKSA units we replace e2 by e2/4pi0.) This will give us a whole new set of unitsfor almost all physical quantities. For the problem at hand, however, only the units of length andenergy are relevant.

    Unit of Name Expression Value in SI

    Length Bohr radius a0 =h2

    mee20.529 A

    Energy Hartree H =h2

    mea2027.712 eV

    The Hartree is defined alternatively as twice the ionization energy of the 1s ground state ofhydrogen, or the Coulomb interaction energy between two electrons separated by the Bohr radius,which in turn is the classical radius of the electron orbit in that same state.

    In these units, the Schrodinger and Poisson equations for an electron take the forms [1][12

    x

    1m(z)

    x+ V (x)

    ](x) = E(x), (2.1)

    d2V

    dx2= 4pi

    s(x), (2.2)

    where is the charge density and U(z) the position-dependent potential energy of the electron.Note the introduction of the relative effective mass m of the electron. At first we will set m to

    a constant, but later we shall return to the more general case when m may change discontinuouslyat certain points.

    3 Integrating the differential equation

    As mentioned in the Introduction, whether we are solving the Schrodinger or Poisson equation, weneed to integrate the differential equation first, before attempting to determine the eigenvalues (inthe case of the Schrodinger equation). In this section we therefore use the eigenenergy E merelyas a parameter. We also assume that we are integrating the equation over some interval [x0, xN ],using N steps so that the stepsize is dx = (xN x0)/N . This makes xi = i dx. (Note that thisrequires N + 1 storage spaces!)

    2

  • There are several general methods for integrating ordinary differential equations, which are allbased on reducing the problem to a system of first order differential equations [2]. However, forthe particular case of interest when there is no first order term, but only a second order weneed not follow that route, but can find specific algorithms. The more popular one seems to bethe Numerov algorithm [3], but there is also Stormers rule (refined by Henrici) [2].

    In theory, it seems the Numerov algorithm is more accurate, if we only look to the order of thefirst omitted term in the expansions. But due to the way we control the stepsize in the program (seeSection 4), the accuracy is controlled by other factors, and the Stormer rule turns out to producethe same (or even better) accuracy in much shorter time than the Numerov scheme (c.f. Section 8).Therefore the Stormer rule will be the method of choice, although both will be presented here forcompleteness.

    3.1 The Numerov algorithm

    The Numerov algorithm is based on a Taylor expansion of the function and its second derivative [3].Let us write the Schrodinger and Poisson equations in the following way:

    (x) = 2m [V (x) E](x) v(x)(x), (3.1)

    (x) = (x)

    v(x), (3.2)

    thus defining v(x) for the two different cases. In the following we focus entirely on the Schrodingerequation, since it contains more general features than the Poisson equation. Modifications for thePoisson equation should be obvious.

    Next we write down the Taylor expansions of the wavefunction and its second derivative ( isthe stepsize of the integration):

    (x) = (x)(x) + 22 (x) 3

    6 (x) +

    4

    24 (x) +O(5), (3.3)

    (x) = (x)(x) + 22 (x) +O(3). (3.4)Now add the equations (x+) and (x) from (3.4) and rearrange to get

    (x) =(x+) 2(x) + (x)

    2+O(2). (3.5)

    Inserting this expression into (3.3) and adding the equations in the same fashion, we get

    (x+) + (x) =

    = 2(x) + 2(x) +2

    12

    [(x+) 2(x) + (x)

    ]+O(6). (3.6)

    If we insert this into the Schrodinger equation (3.1) and rearrange terms, we get the final expression

    (x)[1

    2

    12v(x)

    ]=

    = (x)[2 +

    562v(x)

    ] (x 2)

    [(1

    2

    12)v(x 2)

    ]+O(6). (3.7)

    3

  • With this expression, given (x) at two adjacent points, we can reconstruct the entire wave-function. However, since the function v(x) is a function of the eigenenergy E, this must be known.We will return to this problem shortly.

    First, we write down, for reference, the most convenient way to implement (3.7). Let us definethree new quantities:

    Tn 2[V (xn) E]/6, (3.8)Fn (1 Tn)(xn), (3.9)Un (1 Tn)1(2 + 10Tn). (3.10)

    We may then write the Numerov algorithm as the following simple three-term recurrence relation

    Fn+1 = UnFn Fn1. (3.11)This form is especially useful when integrating the entire range in one step using a matrix repre-sentation of the lattice [3].

    As always when dealing with differential equations, the boundary conditions are important.Without going into detailed derivations, for the Numerov algorithm we may use the followinginitial conditions (boundary conditions are (x0) and (x0) specified at the starting point x0 ofthe integration interval1):

    T1 = 2[V (x0) E)/6T2 = 2[V (x0 +) E]/6F1 = (1 T1)(x0)F2 = (1 T2)

    [(1 + 6T1 + 6T 21 )(x0) + (1 + 2T1 +

    65 T

    21 )

    (x0)]

    3.2 Stormers rule

    A different, and as we will see superior, way to integrate an ordinary differential equation with onlya second order term is given by Stormers rule [2]. This is applicable to a wide class of problems,specified by

    y(x) = f(x, y) (3.12)

    with traditional boundary conditions y(x0) = y0 and the derivative y(x0) given. We use h for thestepsize in this section, since we will define a different soon; hopefully there will be no confusion.

    The rule for integrating the differential equation is

    yk+1 2yk + yk1 = h2f(x0 + kh, yk), (3.13)where the first step is performed in a slightly different way,

    y1 = y0 + h[y(x0) + 12hf(x0, y0)

    ]. (3.14)

    1 We will soon see how we enforce boundary conditions in both ends of the interval.

    4

  • Henrici showed how to reduce round-off errors by introducing k yk+1 yk, which makesthe rule

    k = k1 + h2f(x0 + kh, yk),yk+1 = yk +k.

    (3.15)

    Again the first step is taken differently to enforce the boundary conditions,

    0 = h[y(x0) + 12hf(x0, y0)

    ],

    y1 = y0 +0.(3.16)

    The derivative at the end-point xN of the interval we will soon show why it is necessary tocalculate this is given by

    y(xN ) = N1/h+ 12hf(xN , yN ). (3.17)

    4 Stepsize control

    In the previous section we specified the number of steps to use when integrating over the interval.But how do we determine what number of steps, or equivalently what stepsize, gives acceptableaccuracy? Of course, if we have access to a very fast computer, we can in principle set the stepsize tothe smallest number possible, but this may introduce truncation errors which reduce the accuracy.

    A very general method for reducing the errors in any numerically calculated quantity is calledRichardsons deferred approach to the limit [2]: perform the calculation for some stepsize h, thenextrapolate to the continuum limit h = 0. Without going into any details, we shall now describea method to solve the problem of the unknown ideal stepsize, and at the same time get anydesired accuracy (within machine precision, obviously) of the wavefunction and its derivative atthe endpoint of the integration interval.

    We state that the error series for both the Numerov algorithm and Stormers rule only containseven powers of h, i.e. is a polynomial in h2. This should be obvious from the derivation forthe Numerov case, but we do not give any detailed proof for either method. The reason this isimportant, is that with simple polynomial interpolation, we remove two orders in the leading errorterm for each step. Details are given in [2] (Sections 4.24.3), and we just state the algorithm here.

    Integrate the differential equation with N=4 (ridiculously low, of course), and save the result,viz. (xN ) and (xN ). Repeat for N=8, 16, 32, . . . , and save the results in each step. After eachstep, interpolate the results as polynomials of h2, and extrapolate to h = 0. The extrapolationalgorithm should return the extrapolated values and an estimate of the error of the extrapolation.We repeat this until these errors are smaller than some desired level of relative accuracy.

    This way we get some Nfinal which is the number of steps necessary for the desired precision.Note however that the accuracy of the extrapolated values of (xN ) and (xN ) is higher than ifwe just performed the integration with this number of steps, since those values are based on allintegrations (with all values of N).

    5

    JoyeeHighlight

  • 5 Finding the eigenvalues

    Now it is time to discuss how to find the eigenvalues of the Schrodinger equation, and also howto apply boundary conditions at both endpoints of the integration interval. We assume that wehave a good method for integrating the differential equation over some interval [x0, xN ], where wespecify the boundary conditions (the wavefunction and its derivative) at x0 and the routine returnsthe values of the wavefunction and its derivative at xN with desired accuracy.

    The idea is to divide the total integration interval [xA, xB ] into two parts, [xA, xC ] and [xC , xB ]where xA < xC < xB . Then use the integration algorithm to integrate within the two sub-intervalsfrom the endpoints xA and xB towards the common matchpoint xC , using some guessed value forthe energy E. This way we immediately resolve the issue of how to apply boundary conditions atboth xA and xB .

    What is the condition that E in fact is an eigenvalue? As always, when solving the Schrodingerequation in two separate regions, we require that the wavefunction and its derivative are continuousat the common point. If we label the solutions in the two sub-intervals A and B , the matchingcondition becomes

    A(xC , E) = B(xC , E) and A(xC , E) = B(xC , E), (5.1)

    where we have indicated the parametrical dependence on the energy. These two conditions can becombined into one:

    A(xC , E)A(xC , E)

    =B(xC , E)B(xC , E)

    , (5.2)

    where the expression on each side is referred to as the logarithmic derivative. If the wavefunctionhappends to have a node at the matchpoint, we can invert both sides, since it is unlikely that thederivative is also zero. If they are, then we should shift the matchpoint2.

    This conditions holds exactly if E is an eigenvalue. But what happens if it is not? It seemsintuitively obvious that if a function is zero at some point, it should have different signs on oppositesides of this point. It is however trivial to find counter-examples, such as f(x) = x2 around x = 0.If we nevertheless take it as a postulate (and it is possible to prove [3]) that the function (the labelsxC and E are implied)

    f(E) =AA

    B

    B(5.3)

    does change sign at the eigenvalue, we have an easy way for finding the eigenvalues: integrate thedifferential equation for a number of different values of E (say an array covering the energy intervalof interest), and find the zeros of f(E) by for instance polynomial interpolation (if speed is desiredand precision not) or bracketing (for high precision eigenvalues).

    A practical and simple way to perform this task is to study not the function f(E) but onlyrecord whether it is positive or negative. To avoid the risk of dividing by zero, we instead study

    g(E) = AB BA, (5.4)

    2 Actually it is found from using the algorithms that the calculations take longer time if the matchpoint is at anode of either the wavefunction or its derivative, even if in the actual implementation we do not use (5.2) butinstead a multiplicative variant to avoid the risk of dividing by zero.

    6

  • which obviously also changes sign around the eigenvalue. This way we produce an array (withentries corresponding to the relevant energy) of zeroes and ones, where zero represents g(E) < 0and one the opposite. It is then easy to search this array and find where it changes from one tozero.

    Once the eigenvalues have been located in this way, we employ a standard routine for bracketingthe roots of the equation g(E) to desired accuracy. The method is the van WijngaardenDekkerBrent method, which uses a mix of quadratic interpolation (primary method) and simple bisection(when the primary method gives too slow convergence). For details, see [2] (Section 9.3).

    6 Calculating the eigenfunctions

    Although it may seem trivial to calculate the eigenfunction once we know the corresponding eigen-value, there is one complication. If we only use the logarithmic derivative as a matching condition,we do not actually ensure continuity of the wavefunction or its derivative at points where eitherof them is (close to) zero. Similarly, in cases where both the wavefunction and the derivative havedifferent signs on either side of the matchpoint, these signs will cancel. As a consequence, we mayend up with a discontinuity in either the eigenfunction or its derivative.

    A simple way to avoid this is to consider the boundary conditions at xA and xB . Here we mustspecify the wavefunction and its derivative to supply initial values for the integration routines. Inpractically all cases the wavefunction is chosen to vanish at the boundary, and in many cases alsothe derivative. But if one looks closely at both the Numerov algorithm and Stormers rule, we seethat if we let both and be zero at the boundary, we will never get anything but zero for allpoints.

    Hence we must specify a non-zero value for the derivative at the endpoint. But since we willalways get out unnormalized wavefunctions, this value can in fact be chosen arbitrarily. It maythen seem appealing to use some very small value, to be close to zero, but this may actually noteven work, since due to truncation errors we still only get zero for all points. Therefore it isrecommended to use some finite but not too large value, such as 1.

    Even if nothing is said about the magnitude of the derivative at the endpoint (because of thenormalization ambiguity), the relative signs of the derivative at the two endpoints does matter.Consider for example the simple case of the symmetric infinite well. The lowest eigenfunction isa simple cos-function, with different signs of the derivative at the two endpoints (and no nodes).But for the next lowest eigenfunction, a sin-function, we have the same signs (and a node in themiddle of the interval). If, as boundary conditions, we choose these signs in the wrong ways, wewill end up with either a discontinuous eigenfunction (in the cos case) or discontinuous derivative(in the sin case).

    It is therefore important to have the correct relative signs for at the endpoints. Fortunatelythere is a simple way to determine these, since to find the eigenvalues, the signs are not important.Hence we can check during the process of finding the eigenvalues if the signs are chosen correctly,and record whether they are or not, and use this information when finally calculating the eigen-functions. Once the signs are chosen properly, it is a simple matter to use some large numberof steps (larger than or at least equal to Nfinal) to get the eigenfunctions, using the integrationroutines already discussed.

    Naturally we also need to normalize the eigenfunctions, but this is very straightforward: first

    7

  • integrate the absolute square of the eigenfunction over all space, and then divide the entire eigen-function by the square-root of the result. There are very elaborate methods available for numericalintegration, which are able of producing practically any precision desired. However, these alwaysrequire the integrand to be calculated at many different points, and we only have the eigenfunc-tions specified in certain discrete points defined by the final number of integration steps, which ofcourse can be taken very large, but not too large, due to round-off errors. Alternatively one couldinvent interpolation schemes which, in principle, could supply the wavefunction at any desiredpoint using polynomial interpolation using a number of neighboring points. But all this this isreally not necessary; acceptable precision is achieved using the simple extended Simpsons rule [2].

    A final point worth mentioning regarding the wavefunctions is that by counting the numberof nodes of the found wavefunctions, we can check that we actually obtain all eigenvalues in theintervall we are considering. This is because the ground state always has zero nodes, the firstexcited state one node, and so on.

    7 Discontinuous effective mass

    Until now, we have assumed the effective mass in the Schrodinger equation to be a constantthroughout the system, but there are certainly cases of interest most notably semiconductorheterostructure systems where this is not the case. In this section we shall describe how thiseffect rather effortlessly can be incorporated in the Stormer method for integrating the differentialequation.

    Although one may in principle be interested in the case where the effective mass is an arbitraryfunction m(x) of the coordinate, certainly the most commonly encountered case in practice isthat m changes abruptly (discontinuously) at certain points, but remains constant between thesepoints. In this case, the Schrodinger equation can be written in the more usual form[

    12m

    2

    x2+ V (x)

    ](x) = E(x). (7.1)

    The only tricky point is that in order to preserve the probability current, and hence ensure theHermiticity of the Schrodinger equation, the so-called BenDanielDuke boundary condition [1]

    1m

    (xm)(xm)

    =1m+

    +(xm)(xm)

    (7.2)

    for the wavefunction (x) and its derivative (x) must be imposed at those points xm where theeffective mass changes discontinuously. Here m is the effective mass to the right (left) of thepoint xm, and (x) indicate left and right derivatives. In addition, the wavefunction itself mustbe continuous at xm, which is why there is no need to add any index to (xm).

    Now, to incorporate this in the Stormer rule, we merely break the integration into severalsub-intervals in which the effective mass stays constant and impose the boundary conditionbetween the intervals. This is simple to accomplish, since the Stormer rule takes the derivative atthe end-point of the interval (or in this case sub-interval) as an input parameter.

    8

  • 8 Testing the algorithms; conclusions

    To test the algorithms (and above all their implementations), it is always necessary to comparecomputed values with known, preferably analytical, results. For the case of the Schrodinger equa-tion, the simplest test case is the infinite square well, for which simple analytical results are wellknown. Other candidates are the harmonic oscillator, and at least numerical solutions to arbitraryprecision may be found for the square well (finite depth).

    We do not present quantitative results here, but there are important conclusions to be drawnfrom the tests. When comparing the Numerov and Stormer methods, the differences are rathersmall for the harmonic oscillator and square well, regarding both time and precision. But forthe infinite square well, the Numerov algorithm required over 3 minutes for the same task theStormer rule completed in 3 seconds! This is a remarkable difference, especially when consideringthe fact that the Stormer rule also gave greater precision. The conclusion must therefore be thatthe Stormer rule is highly superior for slowly varying potentials, and otherwise at least as good asthe Numerov algorithm. Therefore the Numerov method is not recommended for real use.

    As for actual numerical values, it is possible with the proper choices of program control parame-ters to get eigenvalues with relative precision of 1010 for the infinite well and close to 108 in mostother cases, all using Stormers rule. Eigenfunctions have not been investigated so thoroughly, butit seems they are at least reproduced with relative accuracy of the order 106. Naturally there isa trade-off between accuracy and speed.

    References

    [1] J. H. Davies, The physics of low-dimensional semiconductors, Cambridge University Press,Cambridge, 1998.

    [2] W. H. Press, S. A. Teukolsky, W. T. Wetterling, and B. P. Flannery, Numerical Recipes in C.Cambridge University Press, 2nd Ed., 1992.

    [3] G. Lindblad. Quantum Mechanics with MATLAB. Technical Report, Dept. of Physics, RoyalInstitute of Technology, SE100 44 Stockholm, Sweden, 1999.

    9

    JoyeeHighlight