<<

Introduction to the Diffusion Monte Carlo Method

Ioan Kosztin, Byron Faber and Klaus Schulten Department of Physics, University of Illinois at Urbana-Champaign, 1110 West Green Street, Urbana, Illinois 61801 (August 25, 1995) A self–contained and tutorial presentation of the diffusion Monte Carlo method for determining the and of quantum systems is provided. First, the theoretical basis of the method is derived and then a numerical algorithm is formulated. The algorithm is applied to determine the ground state + of the harmonic oscillator, the Morse oscillator, the hydrogen atom, and the electronic ground state of the H2 ion and of the H2 molecule. A computer program on which the sample calculations are based is available upon request.

I. INTRODUCTION by simulating random walks of particles which are subject to birth/death processes imposed by the source/sink term. The The Schrodinger¨ equation provides the accepted description probability distribution of the random walks is identical to the for microscopic phenomena at non-relativistic . Many wave function. This is possible only for wave functions which molecular and solid state systems are governed by this equa- are positive everywhere, a feature, which limits the range of applicability of the DMC method. Such a formulation of the tion. Unfortunately, the Schrodinger¨ equation can be solved 3 analytically only in a few highly idealized cases; for most re- DMC method was given for the first time by Anderson who used this method to calculate the ground state energy of small alistic systems one needs to resort to numerical descriptions. + In this paper we want to introduce the reader to a relatively molecules such as H3 . recent numerical method of solving the Schrodinger¨ equation, A second formulation of the DMC method arises from the Diffusion Monte Carlo (DMC) method. This method is the Feynman path integral solution of the time–dependent suitable to describe the ground state of many quantum sys- Schrodinger¨ equation. By means of path integrals the wave tems. function can be expressed as a multi-dimensional integral The solution of the time-dependent Schrodinger¨ equation which can be evaluated by employing the Monte Carlo method. can be written as a linear superposition of stationary states Algorithms to solve the diffusion–reaction equation obeyed by the wave function and algorithms to evaluate the path integral in which the time dependence is given by a phase factor representation of the wave function yield essentially one and exp −iEnt/h¯ , where En is the n-th energy level of the quantum system in question. The energy scale can be cho- the same formulation of the DMC method. Which one of sen such that all energies are positive. In the DMC method the two formulations of the DMC method one adopts depends one actually considers the solution of the Schrodinger¨ equa- on one’s expertise: a formulation of the DMC method based tion assuming imaginary time τ, i.e., after replacing the time on the diffusion–reaction equation requires basic knowledge of the theory of stochastic processes; a path integral formu- t by −iτ. The solution is then given by a sum of transients of lation obviously requires familiarity with the corresponding the form exp −Enτ/h¯ , n = 0, 1,.... The DMC method is based upon the observation that, as a quantum system evolves formulation of quantum mechanics. in imaginary time, the longest lasting transient corresponds to The purpose of this article is to provide a self-contained and tutorial presentation of the path-integral formulation of the ground state with energy E0

1 to provide the reader with an overview. above steps. First Step: Imaginary Time Schrodinger¨ Equation. In this step, the solution of the time–dependent Schrodinger¨ equation of a quantum system is expressed as a formal series expansion A. Imaginary Time Schrodinger¨ Equation in terms of the eigenfunctions of the Hamiltonian. One then performs a transformation from real time t to imaginary time For simplicity, let us consider a single particle of mass τ, replacing t →−iτ. The solution of the obtained imagi- m which moves along the x–axis in a potential V (x). Its nary time Schrodinger¨ equation becomes a series of transients wave function Ψ(x, t) is governed by the time-dependent which decay exponentially as τ →∞. The longest lasting Schrodinger¨ equation5 transient corresponds to the ground state (i.e., the state with the lowest possible energy) of the system. ∂Ψ ih¯ = Hˆ Ψ , (2.1) Second Step: Path Integral Formulation and Monte Car- ∂t lo Integration. In this step, the imaginary time Schrodinger¨ equation is investigated by means of the path integral method. where the Hamiltonian has the form By using path integrals the solution of this equation can be h¯2 ∂2 reduced to quadrature, provided that an initial state wave func- Hˆ = − + V (x) . (2.2) 2m ∂x2 tion is given. Standard Monte Carlo methods4 permit one to evaluate numerically the path integral to any desired accuracy, Assuming that the potential for x →±∞becomes infinite, assuming that the initial state wave function and, therefore, i.e., the particle motion is confined to a finite spatial domain, the ground state wave function as well, is positive definite. In the formal solution of (2.1) can be written as a series expansion this case the wave function itself can be interpreted as a prob- in terms of the eigenfunctions of Hˆ ability density and the “classical” Monte Carlo method can ∞ i be applied. According to the general principles of quantum − Ent Ψ(x, t)= c φ (x) e h¯ . mechanics, only the square of the absolute value of the wave n n (2.3) function has the meaning of a probability density; the fact that n=0 the ground state wave function has to be a positive definite The eigenfunctions φn(x), which are square–integrable in the real quantity imposes severe limitations on the applicabili- present case, and the eigenvalues En are obtained from the ty of the Monte Carlo technique for solving the Schrodinger¨ time-independent Schrodinger¨ equation equation. An efficient implementation of the standard Monte Carlo algorithm for calculating the wave function as a large Hφˆ n(x)=Enφn(x) , (2.4) multi-dimensional integral is realized through an alternation of diffusive displacements and of so-called birth–death processes subject to the boundary conditions limx→±∞ φn(x)=0. We applied to a set of imaginary particles, termed “replicas”, dis- label the energy eigenstates by n = 0, 1, 2,... and order the tributed in the configuration space of the system. The spatial energies distribution of these replicas converges to a probability density which represents the ground state wave function. The diffu- E0

2 ∞ ∞ ∞ m N −i En−ER t 2 Ψ(x, t)= cn φn(x) e h¯ . (2.9) K x, τ|x0, 0 = lim dx1 ... dxN−1 × N→∞ −∞ −∞ 2πh¯∆τ n=0  (2.13) Wick Rotation of Time. Now let us perform a transformation  N  ∆τ m 2 from real time to imaginary time (also known as Wick rotation) exp − xj − xj− + V xj − ER .  h¯ 2∆τ 2 1  by introducing the new variable τ = it. The Schrodinger¨ j=1 equation (2.8) becomes Here ∆τ = τ/N is a small time step. One sets xN ≡ x. The ∂Ψ h¯2 ∂2Ψ wave function Ψ(x, τ) can be written in the form h¯ = − V (x) − ER Ψ , (2.10)   ∂τ 2m ∂x2 ∞ N−1 N   and the expansion (2.9) reads Ψ(x, τ)= lim dxj W (xn) × N→∞ −∞ j=0 n=1 ∞ − En−ER τ Ψ(x, τ)= cn φn(x) e h¯ . (2.11) ×P xn,xn− Ψ x , , n=0 1 ( 0 0) (2.14)

Noting the energy ordering (2.5), one can infer from (2.11) where we have defined the following asymptotic behavior for τ →∞ 1 2 m 2 m xn − xn−1 P xn,xn− ≡ exp − , 1 2πh¯∆τ 2¯h∆τ (i) if ER >E0, limτ→∞ Ψ(x, τ)=∞, the wave func- tion diverges exponentially fast; (2.15) E

3 P x ,...,x ≥ , x(i) = x(i) + σρ(i) , 0 N−1 0 and n n−1 n (2.25)

  (i) σ ρn ∞ N−1 where is given by (2.17) and is a Gaussian random num-  (i)   ρ n dxj P x0,...,xN−1 = 1 , (2.20) ber with zero mean and a variance equal to one. The ’s −∞ j=0 can be generated numerically by means of algorithms referred to as random number generators. One can check, using (2.25) (i) (i) can be approximated by the expression and (2.15), that the mean and the variance of x n x n−1 N x(i) x(i) σ 1 (i) (i) are equal to n−1 n and , respectively. Therefore, the I = f x ,...,xN− . (2.21) N 0 1 x(i) ,...,x(i) i=1 coordinate vectors N−1 0 , obtained through equa- x(i)∈P tion (2.25) for i = 1, 2,...,N , are distributed according to x(i) ∈P x(i) the probability density (2.22). We note in passing that the Here the notation means that the numbers j , x i = 1, 2,...,N ; j = 0,...,N − 1, are selected randomly sequence of positions n given by (2.25) defines a stochastic with the probability density P. The larger N , the better is the process, namely the well known Brownian diffusion process. N P approximation I ≈I. In fact, according to the central limit Repeating times the sampling of the wave function Ψ(x, τ) theorem4, the values of I obtained as a result of different sim- can be determined according to (2.21) and (2.14). ulations are distributed normally, i.e., according to a Gaussian Unfortunately, the algorithm outlined is impractical since it Ψ(x, τ) distribution, around the exact value I, the standard deviation provides only a route to calculate for a chosen time √ τ being proportional to 1/ N . , but no systematic method to obtain the ground state energy τ →∞ In order to evaluate Ψ(x, τ) in (2.14), for given x, τ and N, and wave function, which requires a description for . one defines Fortunately, the above so-called Monte Carlo algorithm can be improved and used to determine simultaneously both E 0 N and φ . The basic idea is to consider the wave function itself a P x ,...,x = P x ,x , 0 0 N−1 n n−1 (2.22) probability density. This implies that the wave function should n=1 be a positive definite function, a constraint which limits the and applicability of the suggested method. By sampling the initial wave function Ψ(x, 0) at N0 points one generates as many N Gaussian random walks which evolve in time according to f x ,...,x = Ψ x , W x , 0 N−1 ( 0 0) ( n) (2.23) (2.22) or, equivalently, according to (2.25); instead of tracing n=1 the motion of each random walk separately, one rather follows such that one can apply (2.19) and (2.21). For this purpose we the motion of a whole ensemble of random walks simultane- note that due to ously. The advantage of this procedure is that one can sample the wave function of the system, through the actual position ∞ of the random walks and the products of the weights W along dyP (x, y)P (y,z)=P (x, z) , (2.24) −∞ the corresponding trajectories, after each time step ∆τ. This procedure, as we explain below, also provides the possibility and (2.18) the probability distribution (2.22) does indeed obey to readjust the value of ER after each time step and to follow the property (2.20). The expression (2.21) can now be in- the time evolution of the system for as many time steps as voked to evaluate Ψ(x, τ) by means the path integral (2.14). are needed to converge to the ground state wave function and This requires the generation of sets of coordinate vectors energy . x(i) ∈P x(i) = x(i),x(i),...,x(i) i = , ,...,N , 0 1 N for 1 2 , The procedure, the so-called DMC method, interprets the (i) integrand in (2.14), i.e., where x = x. N In order to obtain vectors x(i) which sample the probabil- W (xN ) P xN ,xN−1 ··· W (x2) P (x2,x1) × ity density P one proceeds as follows: In a first step one (i) process 2N process 2N−1 process 4 process 3 generates, for a fixed x = xN , a Gaussian random number x(i) x(i) N−1 with mean value N (i.e., a Gaussian random number x(i) σ × W (x ) P (x ,x ) Ψ (x , 0) , (2.26) distributed about N ) and variance , according to the prob- 1 1 0 0 (i) (i) P x ,x process 2 process 1 process 0 ability density N N−1 given by (2.15). In a second x(i) x(i) step, a Gaussian random number N−2, with mean N−1 and as a product of probabilities and weights to be modeled by a se- σ P x(i) ,x(i) ries of sequential stochastic processes 0, 1, 2,...2N. We will variance , is generated according to N−1 N−2 . The (i) explain now how these processes are described numerically. steps are continued to produce random numbers x n until one Initial State. The 0-th process describes “particles” (ran- x(i) x(i) x(i) reaches 0 . Two consecutive random numbers n and n−1 dom walks) distributed according to the initial wave function are related through the equation Ψ (x0, 0), which is typically chosen as a Dirac δ–function

4 (j) Ψ (x0, 0) = δ(x − x0) , (2.27) The replicas are characterized through a position x n where the suffix n counts the diffusive displacements and where (j) x where 0 is located in an area where the ground state of the counts the replicas. The number of replicas after n diffusive quantum system is expected to be large. The initial distribu- displacements will be denoted by Nn. In the initial step one tion (2.27) is obtained by simply placing all particles initially N x(i) i = ,...,N samples 0 replicas assigning positions 0 ,( 1 0) at position x0. according to the distribution Ψ (x0, 0). As mentioned, we Diffusive Displacement. As we explained earlier, the suc- actually choose all replicas to begin at the same point x . x ,x 0 cessive positions n−1 n in (2.26) can be generated through Rather than following the fate of each replica and of its de- (2.25). The Monte Carlo algorithm produces then the posi- x = x + σρ x = x + σρ scendants through many diffusive displacements, one follows tions 1 0 1, 2 1 2, etc by generating the all replicas simultaneously. Accordingly, one determines the series of random numbers ρn,n= 1, 2,.... (j) positions x following equation (2.25), i.e., one sets Birth–Death Process. Instead of accumulating the product of 1 the weight factors W for each particle, it is more efficient nu- x(j) = x(j) + h∆τ/m· ρ(j) merically to replicate (see below) the particles after each time 1 0 ¯ 1 (2.30) step with a probability proportional to W (xn). In this way, for replicas j = 1, 2,...N generating appropriate random after each time step ∆τ, the (unnormalized) wave function is 0 ρ(j) given by a histogram of the spatial distribution of the particles. numbers 1 . This can be regarded as a one–step diffu- The calculation of the wave function Ψ(x, τ) can be regarded sion process of the system of replicas. Once the new posi- as a simulated diffusion–reaction process of some imaginary tions (2.30) have been determined, one evaluates the weight W (x(i)) particles. 1 given by (2.16) and, according to (2.28), one deter- In the replication process each particle is replaced by a m(j) j = , ,...N j mines the set of integers 1 for 1 2 0. Replicas (j) (j) number of with m = 0 are terminated, replicas m = 1, 2, 3 are left 1 1 m(j) = , mn = min int[W (xn)+u , 3] (2.28) unaffected, except, that in case 1 2 3 one or two new replicas j are added to the system and their position is set to particles, where int[x] denotes the integer part of x and where x(j ) = x(j) N 1 1 . The number of replicas is counted and, thus, 1 u represents a random number uniformly distributed in the is determined. During the combined diffusion and birth–death interval [0, 1]. In case mn = 0 the particle is deleted and one process the distribution of replicas changes in such a way that stops the diffusion process; this is referred to as a “death” of x(j) the corresponding coordinates 1 will now be distributed ac- a particle. In case of mn = 1 the particle is unaffected and m = , cording to a probability density which will be identified with one continues with the next diffusion step. In case n 2 3 Ψ(x, ∆τ). one continues with the next diffusion step, but begins also a Adaptation of the Reference Energy ER. As a result of the new series (in case of mn = 3 two new series) of diffusive birth–death process the total number N1 of replicas changes displacements starting at the present location xn. This latter from its original N0 value. As discussed above, for ER val- case is referred to as the “birth” of a particle (of two particles Ψ(x, τ) m = ues less then the ground state energy the distribution for n 3). From (2.28) one can see that at most two new decays asymptotically to zero, i.e., the replicas eventually all particles can be generated whereas one would expect that for die; for ER values larger than the ground state energy, the int[W (xn)+u] ≥ 4 three or more new series would be start- distribution will increase indefinitely, i.e., the number N n will ed. This limitation on the birth rate of the particles is necessary exceed all bounds. Only for ER = E0 can one expect a stable in order to avoid numerical instabilities, especially at the be- asymptotic distribution such that the number of replicas fluc- ginning of the Monte Carlo simulation, when E R may differ N E tuates around an average value 0. The spatial distribution significantly from 0. The error resulting from the limitation and increases/decreases of the number of replicas allow one mn ≤ 3 is expected to be small since for sufficiently small ∆τ to adjust the value of ER as to keep the total number of repli- holds cas approximately constant. To this end, one proceeds from V (x) − ER (2.29). Averaged over all replicas this equation reads W (x) ≈ 1 − ∆τ (2.29) h¯ V  − ER W  ≈ 1 − 1 ∆τ (2.31) which, evidently, assumes values around unity. 1 h¯ where the average potential energy is

C. The Diffusion Monte Carlo Method N 1 V  = 1 V (x(j)) 1 1 (2.32) N1 We want to summarize now the algorithmic steps actually j=1 taken in a straightforward application of the DMC method. To realize the suggested algorithm one starts with N0 “particles”, The reader should note that this average varies with the num- referred to as “replicas”, which are placed according to a dis- ber of diffusion steps taken for all replicas; in the present case tribution Ψ (x0, 0). As pointed out above, the actual numbers we consider the average after the first diffusive displacement. of replicas will vary as replicas “die” and new ones are “born”. One would like the value of W  to be eventually always unity

5 such that the number of replicas remains constant. This leads D. Systems with Several Degrees of Freedom to the proper choice of ER

(1) The DMC method described above is valid for a quantum E = V  (2.33) R 1 system with one degree of freedom x. However, the method However, if the distribution of replicas deviates too strong- can be easily extended to quantum systems with several de- ly from φ0(x) the number of replicas can experience strong grees of freedom. Such systems arise, for example, in case of changes which need to be repaired by ‘overcompensating’ a particle moving in two or three spatial dimensions or in case through a suitable choice of ER. In fact, in case N1/N0 < 1 of several interacting particles. For these two cases the DMC one would like to increase subsequently the number of replicas method can be readily generalized. in order to restore the initial number of replicas and, hence, Particle in d Dimensions. The Hamiltonian of a particle of m V x ,...x choose an ER value larger than (2.33); in case N1/N0 > 1 mass moving in a potential ( 1 d) can be written one would like to decrease subsequently the number of repli- 2 d cas and, hence, choose an ER value smaller than (2.33). A h¯ ∂2 Hˆ = − + V (x ,...,xd) , suitable choice is 2 1 (2.38) 2m ∂xα α=1 ( ) h¯ N E 2 = V  + 1 − 1 . (2.34) R 1 xα α = , ..., d ∆τ N0 where , 1 , denotes the Cartesian coordinates of the particle and d (= 2, 3) represents the spatial dimension. In order to justify that (2.34) serves our purpose one notes For the Hamiltonian (2.38), the DMC algorithm can be de- that exp[−∆τ(V −ER)/h¯], for sufficiently small ∆τ,is vised in a similar way as for (2.2). The only difference to the 1 − ∆τ(V −ER)/h¯. In the subsequent birth–death process one degree of freedom case is that during each time step ∆τ N this would lead to an 1 value (recall that during the diffusion one needs to execute d random walks for each replica. Indeed, process the number of replicas does not change) related to E R the kinetic energy term in (2.38) can be formally regarded as by the sum of kinetic energies of d “particles” having the same mass m and moving along the xα, α = 1, ..., d, directions. h¯ N E = V  − − 1 . Consequently, the diffusive displacements are governed by R 1 ∆τ 1 N (2.35) 0 the distribution However, one would like the total number of replicas during P xn,1,xn−1,1; ... xn,d,xn−1,d = (2.39) the next birth–death process to return to the initial value N 0 E 1 2 and R to be given by an expression similar to (2.33). This d m m(xn,α−xn−1,α) 2 exp − . can be achieved by adding to both sides of equation (2.35) α=1 2πh¯∆τ 2¯h∆τ the same quantityh ¯ 1 −N1/N0 /∆τ. Hence, the redefined value for the reference energy is The product of probabilities can be described through indepen- dent random processes, i.e., one can reproduce the probability h N E(2) = E(1) + ¯ − 1 , (2.39) through d independent diffusive displacements applied R R ∆τ 1 N (2.36) 0 for each replica to the d spatial directions. S Particles. In the case of S interacting particles, which move which, by taking (2.33) into account, is identical to (2.34). d Equation (2.34) should be regarded as an empirical result in spatial dimensions, the most general form of the Hamilto- nian is given by (assuming that no internal, e.g., spin, degrees rather than an exact one. In fact, any expression of the form of freedom are involved) ER = V +α 1 −N/N0 , with arbitrary positive α, can be 9 used equally well in place of (2.34) . Usually, the actual value S 2 d α h¯ ∂2 of the “feedback” parameter is chosen empirically for each Hˆ = − + V {xjα} , 2 (2.40) 2mj ∂xjα individual problem so as to reduce as much as possible the j=1 α=1 statistical fluctuations in N and, at the same time, to diminish 0 unwanted correlations between the successive generation of where V {xjα} accounts for both an interaction between replicas. Equation (2.34) suggests that a good starting value particles and for an interaction due to an external field; {x jα} α h/∆τ for is ¯ , a value used in our DMC program. denotes the dependence on the coordinates of all particles. By ... 2nd, 3rd, Displacements. The diffusive displacements, rescaling the coordinates in (2.40) birth–death processes and estimates for new ER values are repeated until, after a sufficiently large number of steps, the m x = x ,j= ,...,S , α= ,...,d energy ER and the distribution of replicas becomes stationary. jα jα 1 1 mj The ground state energy is then (2.41) E = lim V n (2.37) 0 n−>∞ where m is an arbitrary mass, one can make the Hamiltonian since Nn/Nn−1 → 1. The distribution of replicas provides (2.40) look formally the same as the Hamiltonian (2.38) de- the ground state function φ0(x). scribing a single particle of mass m which moves in d = S×d

6 spatial dimensions. Hence, the generalization of the DMC al- respectively. By denoting the value of a given physical quan- gorithm for this case is again apparent. tity with the same symbol as the quantity itself (e.g., xL → x Sign Problem. The case in which (2.40) actually describes in the case of coordinate x), the Schrodinger¨ equation (2.10) a system of identical particles cannot be treated like that of can be recast a single particle moving in d = S × d spatial dimensions. ∂Ψ hT¯ ∂2Ψ T E For such systems a prescribed boson or fermion symmetry of = − V (x) − ER Ψ . (3.1) ∂τ mL2 ∂x2 h the wave function with respect to an interchange of particles 2 ¯ must be obeyed. For bosons (particles with integer spin) the It is convenient to choose L, T , and E such that total wave function (i.e., the product of the orbital and the spin hT¯ 1 T E wave functions) is symmetric with respect to any permutation = , and = 1 (3.2) of the particles while for fermions (particles with half–integer 2mL2 2 h¯ spin) the total wave function is antisymmetric with respect to holds. Since there are three unknown units and only two re- such permutation. This constraint determines the symmetry of lationships between them, one has the freedom to specify the the orbital part of the ground state wave function for fermionic actual value of either L, T , E while the value of the other two systems (but not for bosonic ones): in many cases of interest, units follows from (3.2). the (orbital) ground state wave function of fermionic systems In dimensionless units obeying (3.2) the original imaginary– will have nodes, i.e., regions with different signs, which make time Schrodinger¨ equation reads the DMC method, as presented here, inapplicable. We shall not address this issue in further detail and shall consider only ∂Ψ 1 ∂2Ψ = − V (x) − ER Ψ . (3.3) cases where the so-called “sign problem” of the ground state ∂τ 2 ∂x2 wave function does not arise. It is not difficult to transcribe also the other relevant equa- To summarize, a DMC algorithm for a system with one tions above in dimensionless units; for example, the functions degree of freedom can be adopted to a system of S interact- (2.15, 2.16) become ing particles moving in d spatial dimensions with an effective dimension of d = S × d. Exactly this feature of the DMC 2 1 xn − xn− method makes it so attractive for the evaluation of the ground P x ,x = − 1 , n n−1 π∆τ exp ∆τ state of a quantum system. However, in the case of identical 2 2 fermions, one needs to obey the actual symmetry of the ground state wave function and the method often is not applicable. and

W (xn) = exp {− [V (xn) − ER]} ,

III. ALGORITHM respectively. As a consequence, the diffusive displacements (2.25) are described by √ Our goal is to provide an algorithm for the DMC method xn = xn−1 + ∆τρn (3.4) presented in the previous section and to apply this algorithm to obtain the ground state energy and wave function for sam- ple quantum systems. Some of the examples chosen below, e.g., the harmonic oscillator, have an analytical solution and, B. Computer Program therefore, allow one to test the diffusion Monte Carlo method. Other examples, e.g., the hydrogen molecule,can not be solved The flow diagram of the computer program 11 implement- analytically and, hence, the DMC method provides a conve- ing the DMC method is shown in Fig. 1. Each block in the nient way of solving the problem. The obtained results turn diagram performs specific tasks which are explained now. out to be in good agreement with results obtained by means of All external data required for the calculation are collected other numerical methods10. through a menu driven, interactive interface in the Input block. First, one has to select the quantum system on which the calculation is performed. At the program level this means d A. Dimensionless Units to define the right spatial dimensionality and the potential energy V (see Sec. IV) which corresponds to the selected sys- tem. The quantum systems covered by our program are the In order to implement the DMC method into a numerical ground state of the harmonic oscillator, of the Morse oscil- + algorithm, one needs to rewrite all the relevant equations in lator, of the hydrogen atom, of the H 2 ion (electronic state) dimensionless units. One can go from conventional (e.g., SI) and of the hydrogen molecule (electronic state). The results units to dimensionless units by explicitly writing each physi- of the simulation for all these cases are presented in Sec. IV cal quantity as its magnitude times the corresponding unit. In below. The other input parameters are: the initial number of mechanics the unit of any physical quantity can be expressed replicas (N0), the maximum number of replicas (N max), the as a proper combination of three independent units, such as, seed value for the random number generators, the number of L, T and E, which denote the unit of length, time and energy, time steps to run the simulation (τ0), the value of the time step

7 (∆τ), the limits of the coordinates for the spatial sampling of initial position of the replicas [c.f. (2.33)]. the replicas (xmin,xmax) and, finally, the number of spatial After initializing the replicas the program enters into a loop “boxes” (nb) for sorting the replicas during their sampling. which essentially consists of three routines: walk, branch Suggested values for these parameters are (in dimensionless and count. One loop corresponds to taking one time step units): N0 = 500, Nmax = 2000, τ0 = 1000, ∆τ = 0.1, ∆τ. xmin = −20, xmax = 20 and nb = 200. walk: This routine performs the diffusion process of the repli- cas by adding√ to the coordinates of the active (alive) replicas the value ∆τρ, where ρ is a random number drawn from Input a Gaussian distribution with mean zero and standard devia- tion one [c.f. (3.4)]. The program uses for this purpose the Gaussian random number generator gasdev 4 . 1 branch: The birth–death (branching) processes, which fol- low the diffusion steps of the replicas, are performed by the Initialize replicas routine branch. For each alive replica the number m n, given by (2.28), is calculated. For the generation of u in (2.28), a [ , ] 2 uniformly distributed random number in the interval 0 1 , the 4 program employs the function ran3 . If a value mn = 0 results, the replica is killed by setting the corresponding ex- walk istence flag to zero. If a value mn = 1 results, the replica is 6 left as it is. If a value n = 2 results, the replica is duplicated 3 (the first inactive replica in psips is set active with the same coordinates as the original replica). If a value n = 3 results, branch test two identical copies of the replica are generated in psips. The reader may note that never more than two copies are born; this limitation is necessary to prevent the uncontrolled growth 4 5 of the number of replicas which psips, due to its finite size, 7 might not be able to accommodate. Such growth might occur count when all the replicas are located in (almost) the same place and when one can expect that large values mn can arise. Since (by choice) the replicas initially are located in one and the Output same point of the configuration space the first diffusion pro- cess does not spread the replicas far enough and, for certain initial positions, mn could then become large for all replicas. Fig. 1. Flow diagram of the DMC algorithm. The algorithm also terminates if all the mn’s assume values zero. To avoid this possibility one needs to choose the initial In the next block, Initialize replicas, a two di- location of the replicas with care. In general, any point where mensional matrix, called psips,isdefined with the following the ground state wave function is large is a good choice. structure: The first (row) index identifies the replicas and takes count: The role of this routine is to return the ground state integer values between one and Nmax. The second (column) wave function of the system (i.e., the spatial distribution of the index points to information regarding the replica identified by replicas) at the end of the simulation. To this end, the spatial the first index, and is a positive integer less or equal to the num- xmin,xmax nb interval ( ) is divided equally into “boxes” (sub- ber of degrees of freedom of the system (i.e., d , see Sec.II D) intervals) for each degree of freedom and then, by employing plus one. For a given replica, say i, psips[i][1] is used as standard numerical methods8, one counts the distribution of an existence flag: it is zero (one) if the replica is dead (alive). replicas among these “boxes”. The counting process starts af- psips[i][j] (j = ,...,d + ) The other elements , 2 1 are ter τ0 (in units of ∆τ) time steps when the system has already used to store the coordinates of the replica (i.e., x j,α according reached its (identified through a converged to the notations of Sec.II D) during the simulation. V τ ) and is performed in a cumulative way for another τ 0 To initialize the matrix psips one sets equal to one the time steps. This strategy can be justified as follows: once value of the existence flag psips[j][1] for j = 1,...N0 stationarity is reached, the wave function Ψ(x, τ) ∝ φ0(x) ( replicas j ≥No are not born yet and, accordingly, their will practically not change in time; hence, the replicas will existence flag is set to zero), and then one assigns the same essentially sample one and the same wave function at any sub- coordinates for all these replicas (for the actual values of these sequent time and the cumulative counting of the replicas in coordinates, see Sec.IV). Such a choice for the initial distri- the “boxes” can be used; this procedure yields better statistics bution of the replicas corresponds to a δ–function for Ψ(x, 0). for φ0(x) than sampling of replicas at only one instant in time; For a suitable choice of x0 one can be certain that there is by cumulative counting, the effective number of replicas used always a significant overlap of Ψ(x, 0) and the ground state to sample the wave function is enhanced by a factor of τ 0 wave function φ0(x). The initial value of the reference energy (number of time steps the counting is done). ER is simply given by the value of the potential energy at the Once the spatial distribution of replicas is known, one can

8 normalize the distribution to obtain the ground state wave shows the rapid convergence of the reference energy E R(τ) function using towards the exact ground state energy E0. The inset contains the plot of the ground state wave function: the results of the N i simulation are represented by triangles, while the continuous φ0(xi) ≈ ,i= 1,...,nb . (3.5) nb 2 line corresponds to the analytical result (4.2). The agreement i= Ni 1 between the diffusion Monte Carlo result and the analytical As should be apparent by now, until the completion of the al- expressions is very good. gorithm the routines walk and branch are called 2τ0 times while the count routine is called only τ0 times, namely, dur- ing the second half of the calculation. This is controlled by 0.5 the block test shown in Fig. 1. 0.8 Output DMC simulation Finally, the block returns the results of the simu- 0.4 analytical result lation. These results are: (i) the average value of the reference 0.6 energy ER≈E , which is calculated during the second > 0 R 0.3

τ τ (x) 0.4 part of the simulation (i.e., from 0 to 2 0) when the system o φ < E is already stabilized; (ii) the corresponding standard deviation 0.2 δER; (iii) the (imaginary) time evolution of ER for the first 0.2 τ time steps (used basically to check how fast stationarity is 0 0.1 reached by the system during the simulation); (iv) the normal- 0 -4 -2 0 2 4 ized spatial distribution of the replicas, i.e., the ground state x 0 wave function. Note that the average reference energy after n 0 20 40 60 80 100 time steps is defined through τ n Fig. 2. Reference energy ER (in dimensionless units) as a func- 1 tion of the imaginary time τ (in units of time steps ∆τ) obtained by ER(τ = n∆τ) = ER(i∆τ) . (3.6) n the DMC method for the harmonic oscillator. ER converges rapidly i=1 towards the exact ground state energy E0 = 0.5. The inset shows the corresponding ground state wave function φ0(x). The result of the simulation is represented by dots while the continuous line IV. EXAMPLES corresponds to the analytical solution (4.2)

In this section we report on the results obtained, by means of the DMC program, for the ground state energy and wave function of some quantum mechanical systems. The program B. Morse Oscillator was executed on an HP-9000 (series 700) workstation. In each case we specify the units used and present numerical results of the simulation. For all simulations the values of the input parameters suggested in Sec. III B, have been employed. The Morse potential is defined through V (x)=D e−2ax − 2e−ax . (4.3) A. Harmonic Oscillator In this case one has a natural length scale through L = 1/a For a one–dimensional harmonic oscillator, characterized ω which can be used as the unit of length. As a result, from by the proper angular frequency , one has (in SI units) (3.2), one has T = m/ha¯ 2 and E = h¯2a2/m. For simplicity we shall consider only the case when (in dimensionless units) V (x)=1mω2x2 . (4.1) D = 1/2; the exact ground state energy is E0 = −1/8, and 2 12 the corresponding wave function is Choosing T = 1/ω, one obtains from (3.2) L = h/mω¯ √ and E = hω¯ . In corresponding dimensionless units, the exact −x x φ0(x)= 2 exp −e − . (4.4) ground state energy is E0 = 1/2 and the ground state wave 2 function is5 2 − 1 x The results of the DMC description are presented in Fig. 3. φ (x)=π 4 exp − . (4.2) 0 2 Initially, all replicas were positioned in our simulation at the origin. The figure represents the time evolution of E R to- The results of the Monte Carlo simulation for the harmonic wards the exact ground state energy E0 = −0.125. The figure oscillator are given in Fig. 2. At the beginning of the simu- demonstrates also that the the resulting ground state wave lation all replicas are located at the origin. The main graph function is in excellent agreement with (4.4).

9 -0.1 -0.5 0.6 3 DMC simulation -0.6 -0.2 analytical result φ0(r): DMC simulation 0.4 φ > > (r): analytical result -0.7 2 0

R χ φ R (r)=r 0(r): DMC simulation (x)

o χ(r)=rφ0(r): analytical result (x) φ -0.3 o φ < E < E 0.2 -0.8 1

-0.9 -0.4 0 0 -5 0 x 5 10 15 0 2 x 4 6 -1 0 20 40 60 80 100 0 20 40 60 80 100 τ τ Fig. 3. DMC description of the Morse oscillator. The time evo- Fig. 4. DMC description of the hydrogen atom. The time evolu- lution of ER is shown. The inset presents the ground state wave tion of ER is shown. The inset presents both the radial wave function function; the numerical result is represented through dots, the wave φ0(r) and the function χ(r)=rφ0(r). function in the analytical form (4.4) is represented by a continuous line. + D. H2 Ion

+ C. Hydrogen Atom The H2 ion is held stabilized through a single electron moving in the electric field of two protons separated, at equi- librium, by a distance R = 1.06A˚ 10. The ground state of this quantum system can not be determined analytically. + In case of the hydrogen atom it is customary to choose the The numerically determined ground state energy of H 2 is a =h 2/me2(≈ . A) 10 unit of length equal to the Bohr radius ¯ 0 53 ˚ . E0 = −16.252 ± 0.002 eV . The DMC method can be ap- Thus, by setting L = a, one finds T = h¯ 3/me4 and plied in this case as for the hydrogen atom. The Hamiltonian E = me4/h¯2(≈ 27.21eV ). The well–known ground state is energy (in dimensionless units) is E0 = −1/2 and the corre- 5 h¯2 e2 e2 sponding radial wave function is Hˆ = − ∇2 − − (4.6) m |r + 1 R| |r − 1 R| 2 2 2 −r φ0(r)=2e . (4.5) where R denotes the separation between the two protons. The results of the DMC description are presented in Fig. 5. The We have carried out a DMC simulation for the hydrogen same dimensionless units as in the case of the hydrogen atom atom, generalizing the previous description to three spatial di- were employed and replicas were located initially at the origin, mensions. At τ = 0 all the replicas were located at (0, 0, 1), the nuclei being located at (0, 0, ±R/2), for R = 2. Figure 5 i.e., at a distance of one Bohr radius from the origin, along the shows that the ground state energy obtained asymptotically is − . positive z axis. Figure 4 shows the convergence of E R to the 16 75 eV (see Table I) which differs from the more exact 10 exact ground state energy. This convergence, however, is not numerical value by 0.5 eV, i.e., by about 3%. The inset in as rapid as in the case of the harmonic oscillator and the Morse Fig. 5 shows a plot of the spatial distribution of the replicas, oscillator. This is not surprising since the hydrogen atom has demonstrating that the electronic ground state wave function three degrees of freedom which require more sampling. The is nearly spherically symmetric. running time of the simulation has also increased (see Table I). The inset shows both the radial wave function φ0(r) (triangles) χ(r)=rφ (r) and the function 0 (squares). For comparison, E. H2 Molecule the corresponding analytical solutions are also plotted with continuous lines. Again the agreement between the analytical results and those obtained by our algorithm are good. The The H2 molecule is formed by two protons, at equilibrium error of the radial wave function in the vicinity of the origin separated by R = 0.74A˚ 10, and by two electrons. In the Born is due to insufficient sampling of the number of replicas in approximation one considers the proton positions fixed and this region of the configuration space. To improve the wave solves the corresponding stationary Schrodinger¨ equation for function for r ∼ 0 one may decrease the size of the counting the electrons. The wave function of the two electrons must be “boxes” in the vicinity of the origin, increase the number of antisymmetric with respect to exchange of the electrons. In replicas, or increase τ. the ground state the electrons are in a singlet spin state

10 -10 Fig. 6. The same dimensionless units as in the case of the hydrogen atom were employed and the replicas at τ = 0 were -20 6 located initially at {(0, 0, 1)(0, 0, −1)}; the position of the y 3 0 ( , , ±R/ ) R = . -3 protons were 0 0 2 , with 1 398. The simulation -30 -6 took about 55 seconds to complete and the obtained ground 6 > state energy was E0 = −30.973 eV (see Table I). This result R 3 -40 . . z 0 differs from the exact energy by 0 715 eV, i.e., by 2 3%. The

< E -3 inset of Fig. 6 shows the spatial distribution of the replicas -50 -6 which is nearly spherically symmetric. In Fig. 7 we present -6 -3 R 0 the results of a calculation in which an unphysically large 3 -60 x 6 value of 8.398 was assumed. In this case the distribution of the electronic cloud around the protons is clearly anisotropic, 0 20 40 60 80 100 the energy of the electrons is still negative. τ + E Fig. 5. DMC description of the H2 ion. The time evolution of R is shown. The inset presents the spatial distribution of the replicas, -30 i.e., the electron cloud. 8 y 4 0 -40 -4 1 -8

χ(1, 2)= χ 1 ,+ 1 (1)χ 1 ,− 1 (2) − χ 1 ,− 1 (1)χ 1 ,+ 1 (2) > 8 2 2 2 2 2 2 2 2 2 R -50 4 (4.7) z 0 < E -4 -8 χ ( , ) -60 which is antisymmetric. Here 1 ,± 1 1 2 denotes the wave -8 2 2 -4 1 0 , 4 function of electron 1 2 in the spin 2 state with magnetic quan- x 8 ± 1 -70 tum numbers 2 . Accordingly, in the wave function of the electronic ground state 0 20 40 60 80 100 τ Ψ0 = Φ(r1, r2) χ(1, 2) (4.8) Fig. 6. DMC description of the electronic ground state of the H2 molecule. The time evolution of ER is shown. The inset presents the factor Φ(r1, r2), describing the spatial distribution of the electrons, must be symmetric. This factor can be determined the spatial distribution of the replicas, i.e., the electron cloud. through -10 1 8 Φ(r1, r2)= φ(r1, r2)+φ(r2, r1) (4.9) y 4 0 2 -4 -8 -15 where φ(r1, r2) is a solution of 8 4 z h2 e2 e2 > 0

¯ R − ∇2 + ∇2 − − -20 -4 2m 1 2 |r − 1 R| |r + 1 R| -8 1 2 1 2 < E -8 -4 0 e2 e2 e2 4 − − + φ(r , r ) -25 x 8 |r − 1 R| |r + 1 R| |r − r | 1 2 2 2 2 2 1 2

= E0 φ(r1, r2) (4.10) -30 0 20 40 60 80 100 120 140 The Schrodinger¨ equation (4.10) cannot be solved analyt- τ ically. The available numerical result for the ground state Fig. 7. ER vs. τ and the spatial distribution of the replicas (inset) 10 energy of H2 is E0 = −31.688 ± 0.013 eV . The results at the end of the simulation for the H2 molecule for an unphysically of the diffusion Monte Carlo simulation for H 2 are shown in large separation between the two protons of 8.398 Bohr radius.

11 TABLE I. Results obtained during two different simulations performed on four quantum systems listed in the first column. During Simulation I (II) the initial number of replicas was 500 (4000), the time step ∆τ = 0.1 (0.05), the length of simulation τ = 1000∆τ (2000∆τ), the random number generator seed 1 and the number of boxes used to calculate the spatial distribution of the replicas 200 (400). ER and δER are defined in the text. ∆t represents the actual running time of the simulation on a HP-9000 (series 700) workstation. For the hydrogen atom the energies are given both in dimensionless units and in eV (in parenthesis), respectively. For comparison, E0 in the last column represents the exact value (analytical or obtained through an alternative numerical method) of the corresponding ground state energy. Simulation I Simulation II Quantum system ER δER ∆t ER δER ∆tE0 Harmonic oscillator 0.505 0.094 8 sec 0.500 0.048 4 min 0.5 Morse oscillator -0.1236 0.0749 10 sec -0.1245 0.0330 4 min -0.125 Hydrogen atom -0.495 0.080 18 sec -0.505 0.040 5 min 0.5 (-13.477 eV) (2.186 eV) (-13.752 eV) (1.093 eV) (13.6 eV) + a H2 ion -16.753 eV 2.869 eV 40 sec -16.476 eV 1.389 eV 11 min -16.25(2) eV a H2 molecule -30.973 eV 3.638 eV 55 sec -31.968 eV 1.754 eV 16 min -31.6(87) eV a Numerical values calculated based upon the heat of dissociation given by Hertzberg 10.

, , V. DISCUSSION literature cited1 2 9. Any implementation of the DMC method leads to system- atic errors due to the use of a finite time step ∆τ. Apparently In this article, we have presented a detailed account of the these errors can be reduced to zero by choosing ∆τ → 0. path integral formulation of the DMC method devised for Unfortunately, this is not the case. Even worse: making the calculating simultaneously the ground state energy and wave time step shorter and shorter does not only increase the needed function of an arbitrary quantum system. A simple numerical computer time, but also renders the successive generations of algorithm based on the DMC method has been formulated and replicas more and more correlated such that their distribution a computer program, based on this algorithm, has been applied actually departs more and more from the ground state wave to determine numerically the ground state of a few quantum function. For each quantum system investigated it is necessary systems of pedagogical interest. to find the most convenient value of ∆τ which is short enough The DMC algorithm, as presented in this article, is quite to produce small systematic errors and at the same time is unstable numerically. We want to demonstrate here the need long enough to keep the successive distributions of replicas for an improvement of the method. This need arises due to the sufficiently uncorrelated. strong fluctuations stemming from the birth-death processes employed in this method. These fluctuations affect the ref- erence energy ER(τ) which is expected to converge to the ground state energy. This convergence is observed only for 0.8 the value of ER defined through equation (3.6). The ac- tual time dependence of ER is presented in Fig. 8 for the case of the harmonic oscillator. The fluctuations in E R are 0.6 E  large, but symmetrically distributed around R which ex- R plains the good agreement between the result of the simulation E with the exact result. Attempts to use our DMC program to 0.4 + calculate the electronic ground state energy of the H 2 ion and H2 molecule as a function of the separation between the two protons, which would allow one to determine the equilibrium 0.2 separation from the minimum of this dependence, have failed due to large fluctuations in ER. 100 120 140 160 180 200 The DMC algorithm can be significantly improved resort- τ 1,9 ing to a method called “importance sampling” . The basic Fig. 8. Fluctuations of ER about its average value ER≈0.5 idea of this method is to change the probability distribution well after the distribution of replicas reached its stationary form. of the replicas in a controlled way. This can be achieved by The relatively large fluctuations are due to the birth–death processes reformulating (2.10) such that the resulting equation has a so- which persist even if the replicas are distributed according to the ex- φ (x) E lution Ψ(x, τ) multiplied by an approximation of the ground act ground state wave function 0 and the reference energy R state wave function, the latter being obtained, for example, has been adapted to the exact ground state energy. from a variational method. Application of the DMC method to this new equation yields then replicas which spend more In order to apply the DMC method to calculate the ground time in “important” regions of the configuration space where state properties of a system with interacting fermions one has the wave function Ψ(x, τ) is expected to be large. For details to treat, as mentioned above, the “sign problem” due to the regarding importance sampling the reader is referred to the antisymmetry property of the many-fermion wave function.

12 , Two principle methods, the fixedÐnode method 13 1 and the 2 M. H. Kalos and P. A. Whitlock, Monte Carlo methods (J. Wiley releaseÐnode method14,1, have been proposed to deal with & Sons, New York, 1986). this problem. 3 J. B. Anderson, “A random–walk simulation of the Schrodinger¨ + Once some kind of importance sampling is implemented equation: H3 ”, J. Chem. Phys. 63, 1499–1503 (1975). 4 and the sign–problem, in the case of many–fermion systems, W. H. Press, S. A. Teukolsky, W. T. Vetterling and B. P. Flannery, is resolved, the DMC method can be used to compute ground Numerical recipes in C : the art of scientific computing (Cambridge 9 University Press, Cambridge, 1992), 2nd edn. state properties for molecules or molecular clusters and for 5 quantum spin, boson and fermion systems 15. The method is L. D. Landau and E. M. Lifshitz, Quantum Mechanics, vol. 3 of Course of Theoretical Physics (Pergamon Press, Oxford, 1977). also applicable to the study of ground–state phase transitions 6 due to quantum fluctuations, a topic of modern condensed R. P. Feynman and A. R. Hibbs, Quantum mechanics and path integrals (McGraw-Hill, New York, 1965). matter physics15. 7 D. Khandekar, S. Lawande and K. B. Hagwat, Path Integral Meth- Finally we would like to mention that the DMC method ods and Their Applications (World Scientific, London, 1993). has been extended and successfully applied to the study of 8 9 S. E. Koonin, Computational Physics (Benjamin, Reading, MA, the excited states of molecules and clusters and also to the 1986). study of finite temperature properties of different condensed 9 M. A. Suhm and R. O. Watts, “ studies matter systems. Also, the DMC method has been successfully of vibrational states in molecules and clusters”, Phys. Rep. 204, 16 applied in quantum field theories . 293–329 (1991). 10 G. Herzberg, Molecular Spectra and Molecular Structure (Van Nostrand, New York 1950). VI. ACKNOWLEDGMENTS 11 The program was written is the C programming language. A copy of the source code is freely available from one of the authors (K.S.). This work has been supported by a National Science Foun- 12 L. Infeld and T. E. Hull, “The factorization method”, Rev. Mod. dation REU fellowship to B.F., by funds of the University of Phys. 23,21–68 (1951). Illinois at Urbana-Champaign, and by a grant from the Na- 13 P. J. Reynolds, D. M. Ceperley, B. J. Adler and J. W. A. Lester, tional Science Foundation (BIR-9318159). “Fixed–node quantum Monte Carlo for molecules”, J. Chem. Phys. 77, 5593–5603 (1982). 14 D. M. Ceperley and B. J. Adler, “Quantum Monte Carlo for molecules: Green’s function and nodal release”, J. Chem. Phys. 81, 5833–5844 (1984). 15 M. Suzuki, Quantum Monte Carlo methods in condensed matter physics (World Scientific, Singapore, 1993). 1 D. Ceperley and B. Alder, “Quantum Monte Carlo”, Science 231, 16 T. Barnes and G. J. Daniell, “Numerical Solution of Field Theories 555–560 (1986). Using Random Walks”, Nucl. Phys. B257, 173–198 (1985).

13