slides from fys4411 lectures - universitetet i oslo · slides from fys4411 lectures morten...

281
Slides from FYS4411 Lectures Morten Hjorth-Jensen 1 Department of Physics and Center of Mathematics for Applications University of Oslo, N-0316 Oslo, Norway Spring 2013 1 / 281

Upload: others

Post on 18-Jun-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

  • Slides from FYS4411 Lectures

    Morten Hjorth-Jensen

    1Department of Physics and Center of Mathematics for ApplicationsUniversity of Oslo, N-0316 Oslo, Norway

    Spring 2013

    1 / 281

  • Topics for Week 4, January 21-25

    Introduction, Parallelization, MPI and Variational MonteCarlo

    I Presentation of topics to be covered and introduction toVariational Monte Carlo (Lecture notes chapter 14, withchapter 11 and 12 as background material from FYS3150).

    I Variational Monte Carlo theory and presentation of project1. (lecture notes chapter 14, Thijssen chapter 12)

    I Next week: Introduction to Message Passing Interface(MPI), object orientation, version control etc at thecomputer lab.

    I Assignment for next week: study chapter 14 of Lecturenotes or Chapter 12 of Thijssen and start with exercises 1aand 1b of the project.

    2 / 281

  • 24 January - 31 May

    Course overview, Computational aspects

    I Parallelization (MPI), high-performance computing topicsand object orientation. Choose between Fortran2008and/or C++ as programming languages. Python alsopossible as programming language.

    I Algorithms for Monte Carlo Simulations (multidimensionalintegrals), Metropolis-Hastings and importance samplingalgorithms. Improved Monte Carlo methods (exercise 1 ofpart 1 of the project)

    I Statistical analysis of data from Monte Carlo calculations,blocking method. (exercise 1 of part 1)

    3 / 281

  • 24 January - 31 May

    Course overview, Computational aspects

    I Search for minima in multidimensional spaces (conjugategradient method, steepest descent method,quasi-Newton-Raphson, Broyden-Jacobian). Part 1 of theproject.

    I Iterative methods for solutions of non-linear equations, part1.

    I Object orientation, both partsI VMC for molecules and/or Diffusion Monte Carlo for

    fermionic systems. Part 2, after April 1.

    Part 1 is expected finished before Easter, March 22.

    4 / 281

  • 24 January -31 May

    Quantum Mechanical Methods and Systems

    1. Variational Monte Carlo for ’ab initio’ studies of quantummechanical many-body systems.

    2. Simulation of three-dimensional systems like atoms ormolecules, or other fermionic systems in one, two andthree dimensions.

    3. Aim of part 1 of the project: understand how to simulateqauntum mechanical systems with many interactingparticles using variational Monte Carlo methods.

    The methods are relevant for atomic, molecular,solid state,materials science, nanotechnology, quantum chemistry andnuclear physics.

    5 / 281

  • 24 January -31 May

    Quantum Mechanical Methods and Systems

    1. Part 2 of the project solves much of the same systems asin part 1 but now we will look at molecules as well, stillusing variational Monte Carlo.

    2. Alternatively, we may think of introducing diffusion MonteCarlo (DMC), which in principle allows for an exact solutionof Schrödinger’s equation.

    3. The VMC results will then be used as input to the DMCcalculations

    6 / 281

  • 24 January -31 May

    Projects, deadlines and oral exam

    1. Deadline part 1: March 222. Deadline full project: 31 May3. Oral exam: After June 15.

    The oral exam is based on your presentation of the project.

    7 / 281

  • 24 January -31 May

    More on projects

    1. Keep a logbook, important for keeping track of all yourchanges etc etc.

    2. The projects should be written as a regular scientificarticle, with introduction, formalism, codes which havebeen developed and discussion of results. Conclusionsand references should also be included. An example canbe found on the webpage of the course.

    3. The link with the article example contains also an article onhow to use latex and write good scientific articles!

    8 / 281

  • Lectures and ComputerLab

    I Lectures: Thursday (14.15-16, room FV329)I Detailed lecture notes, all programs presented and

    projects can be found at the homepage of the course.I Computerlab: 16-19 thursday, room FV329I Weekly plans and relevant information are on the official

    webpage.I Chapters 11-16 of the FYS3150 lecture notes give a good

    starting point. Chapter 16 will also be revised. Chapter 17on diffusion Monte carlo is also not yet ready. Werecommend also J. M. Thijssen text ComputationalPhysics. For MPI we recommend Gropp, Lusk andSjellum’s text.

    9 / 281

  • Thijssen’s text

    J. M. Thijssen’s text

    I ComputationalPhysics

    I Chapters 3-6 and 12,possibly also chapter8-9

    I see http://www.tn.tudelft.nl/tn/People/Staff/Thijssen/comphybook.html

    10 / 281

    http://www.tn.tudelft.nl/tn/People/Staff/Thijssen/comphybook.htmlhttp://www.tn.tudelft.nl/tn/People/Staff/Thijssen/comphybook.htmlhttp://www.tn.tudelft.nl/tn/People/Staff/Thijssen/comphybook.htmlhttp://www.tn.tudelft.nl/tn/People/Staff/Thijssen/comphybook.htmlhttp://www.tn.tudelft.nl/tn/People/Staff/Thijssen/comphybook.html

  • MPI text

    Gropp, Lusk andSjellum

    I Using MPII Chapters 1-5I seehttp://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10761

    11 / 281

    http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10761http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10761http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10761http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10761http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10761

  • Selected Texts and lectures on C/C++

    J. J. Barton and L. R. Nackman,Scientific and Engineering C++, Addison Wesley,3rd edition 2000.

    B. Stoustrup, The C++ programming language, Pearson, 1997.

    George Em Karniadakis and Robert M. Kirby II, Parallel Scientific Computing inC++ and MPI http://www.cambridge.org/catalogue/catalogue.asp?isbn=9780521520805

    D. Yang, C++ and Object-oriented Numeric Computing for Scientists andEngineers, Springer 2000.

    More books reviewed at http:://www.accu.org/ andhttp://www.comeaucomputing.com/booklist/

    12 / 281

    http://www.cambridge.org/catalogue/catalogue.asp?isbn=9780521520805http://www.cambridge.org/catalogue/catalogue.asp?isbn=9780521520805http:://www.accu.org/http://www.comeaucomputing.com/booklist/

  • Definitions and notations

    The Schrödinger equation reads

    Ĥ(r1, r2, . . . , rN )Ψλ(r1, r2, . . . , rN ) = EλΨλ(r1, r2, . . . , rN ), (1)

    where the vector ri represents the coordinates (spatial and spin) of particle i , λ stands

    for all the quantum numbers needed to classify a given N-particle state and Ψλ is the

    pertaining eigenfunction. Throughout this course, Ψ refers to the exact eigenfunction,

    unless otherwise stated.

    13 / 281

  • Definitions and notations

    We write the Hamilton operator, or Hamiltonian, in a generic way

    Ĥ = T̂ + V̂

    where T̂ represents the kinetic energy of the system

    T̂ =N∑

    i=1

    p2i2mi

    =N∑

    i=1

    (−

    ~2

    2mi∇i2)

    =N∑

    i=1

    t(ri )

    while the operator V̂ for the potential energy is given by

    V̂ =N∑

    i=1

    u(ri ) +N∑

    ji=1

    v(ri , rj ) +N∑

    ijk=1

    v(ri , rj , rk ) + . . . (2)

    Hereafter we use natural units, viz. ~ = c = e = 1, with e the elementary chargeand c

    the speed of light. This means that momenta and masses have dimension energy.

    14 / 281

  • Definitions and notations

    If one does quantum chemistry, after having introduced the Born-Oppenheimerapproximation which effectively freezes out the nucleonic degrees of freedom, theHamiltonian for N = Ne electrons takes the following form

    Ĥ =Ne∑i=1

    t(ri )−Ne∑i=1

    kZri

    +

    Ne∑i

  • Definitions and notations

    We can rewrite this as

    Ĥ = Ĥ0 + Ĥ1 =Ne∑i=1

    ĥi +Ne∑

    i

  • Definitions and notations

    The potential energy term due to the attraction of the nucleus defines the onebody fieldui = u(ri ) of Eq. (47). We have moved this term into the Ĥ0 part of the Hamiltonian,instead of keeping it in V̂ as in Eq. (47). The reason is that we will hereafter treat Ĥ0 asour non-interacting Hamiltonian. For a many-body wavefunction Φλ defined by anappropriate single-particle basis, we may solve exactly the non-interacting eigenvalueproblem

    Ĥ0Φλ = eλΦλ,

    with eλ being the non-interacting energy. This energy is defined by the sum over

    single-particle energies to be defined below. For atoms the single-particle energies

    could be the hydrogen-like single-particle energies corrected for the charge Z . For

    nuclei and quantum dots, these energies could be given by the harmonic oscillator in

    three and two dimensions, respectively.

    17 / 281

  • Definitions and notations

    We will assume that the interacting part of the Hamiltonian can be approximated by atwo-body interaction. This means that our Hamiltonian is written as

    Ĥ = Ĥ0 + Ĥ1 =N∑

    i=1

    hi +N∑

    i

  • Definitions and notations

    Our Hamiltonian is invariant under the permutation (interchange) of two particles.Since we deal with fermions however, the total wave function is antisymmetric. Let P̂be an operator which interchanges two particles. Due to the symmetries we haveascribed to our Hamiltonian, this operator commutes with the total Hamiltonian,

    [Ĥ, P̂] = 0,

    meaning that Ψλ(r1, r2, . . . , rN ) is an eigenfunction of P̂ as well, that is

    P̂ij Ψλ(r1, r2, . . . , ri , . . . , rj , . . . , rN ) = Ψλ(r1, r2, . . . , rj , . . . , ri , . . . , rN ).

    We have introduced the suffix ij in order to indicate that we permute particles i and j .

    The Pauli principle tells us that the total wave function for a system of fermions has to

    be antisymmetric. What does that mean for the above permutation?

    19 / 281

  • Definitions and notations

    In our case we assume that we can approximate the exact eigenfunction with a Slaterdeterminant

    Φ(r1, r2, . . . , rN , α, β, . . . , σ) =1√

    N!

    ∣∣∣∣∣∣∣∣∣ψα(r1) ψα(r2) . . . . . . ψα(rN )ψβ(r1) ψβ(r2) . . . . . . ψβ(rN ). . . . . . . . . . . . . . .. . . . . . . . . . . . . . .

    ψσ(r1) ψσ(r2) . . . . . . ψγ(rN )

    ∣∣∣∣∣∣∣∣∣ , (7)

    where ri stand for the coordinates and spin values of a particle i and α, β, . . . , γ are

    quantum numbers needed to describe remaining quantum numbers.

    20 / 281

  • Definitions and notations

    The single-particle function ψα(ri ) are eigenfunctions of the onebody Hamiltonian hi ,that is

    hi = h(ri ) = t(ri ) + u(ri ),

    with eigenvalueshiψα(ri ) = t(ri ) + u(ri )ψα(ri ) = εαψα(ri ).

    The energies εα are the so-called non-interacting single-particle energies, or

    unperturbed energies. The total energy is in this case the sum over all single-particle

    energies, if no two-body or more complicated many-body interactions are present.

    21 / 281

  • Definitions and notations

    Let us denote the ground state energy by E0. According to the variational principle wehave

    E0 ≤ E [Φ] =∫

    Φ∗ĤΦdτ

    where Φ is a trial function which we assume to be normalized∫Φ∗Φdτ = 1,

    where we have used the shorthand dτ = dr1dr2 . . . drN .

    22 / 281

  • Quantum Monte Carlo Motivation

    Most quantum mechanical problems of interest in e.g., atomic, molecular, nuclear andsolid state physics consist of a large number of interacting electrons and ions ornucleons. The total number of particles N is usually sufficiently large that an exactsolution cannot be found. Typically, the expectation value for a chosen hamiltonian for asystem of N particles is

    〈H〉 =∫dR1dR2 . . . dRN Ψ∗(R1,R2, . . . ,RN )H(R1,R2, . . . ,RN )Ψ(R1,R2, . . . ,RN )∫

    dR1dR2 . . . dRN Ψ∗(R1,R2, . . . ,RN )Ψ(R1,R2, . . . ,RN ),

    an in general intractable problem. an in general intractable problem.

    This integral is actually the starting point in a Variational Monte Carlo calculation.

    Gaussian quadrature: Forget it! given 10 particles and 10 mesh points for each

    degree of freedom and an ideal 1 Tflops machine (all operations take the same time),

    how long will it ta ke to compute the above integral? Lifetime of the universe

    T ≈ 4.7× 1017s.

    23 / 281

  • Quantum Monte Carlo

    As an example from the nuclear many-body problem, we have Schrödinger’s equationas a differential equation

    ĤΨ(r1, .., rA, α1, .., αA) = EΨ(r1, .., rA, α1, .., αA)

    wherer1, .., rA,

    are the coordinates andα1, .., αA,

    are sets of relevant quantum numbers such as spin and isospin for a system of A

    nucleons (A = N + Z , N being the number of neutrons and Z the number of protons).

    24 / 281

  • Quantum Monte Carlo

    There are

    2A ×(

    AZ

    )coupled second-order differential equations in 3A dimensions.For a nucleus like 10Be this number is 215040. This is a truely challenging many-bodyproblem.

    Methods like partial differential equations can at most be used for 2-3 particles.

    25 / 281

  • Quantum Many-particle (body) Methods

    1. Monte-Carlo methods

    2. Renormalization group (RG) methods, in particular density matrix RG

    3. Large-scale diagonalization (Iterative methods, Lanczo’s method,dimensionalities 1010 states)

    4. Coupled cluster theory, favoured method in quantum chemistry, molecular andatomic physics. Applications to ab initio calculations in nuclear physics as well forlarge nuclei.

    5. Perturbative many-body methods

    6. Green’s function methods

    7. Density functional theory/Mean-field theory and Hartree-Fock theory

    The physics of the system hints at which many-body methods to use. For systems with

    strong correlations among the constituents, item 5 and 7 are ruled out.

    26 / 281

  • Pros and Cons of Monte Carlo

    I Is physically intuitive.

    I Allows one to study systems with many degrees of freedom. Diffusion MonteCarlo (DMC) and Green’s function Monte Carlo (GFMC) yield in principle theexact solution to Schrödinger’s equation.

    I Variational Monte Carlo (VMC) is easy to implement but needs a reliable trialwave function, can be difficult to obtain. This is where we will use Hartree-Focktheory to construct an optimal basis.

    I DMC/GFMC for fermions (spin with half-integer values, electrons, baryons,neutrinos, quarks) has a sign problem. Nature prefers an anti-symmetric wavefunction. PDF in this case given distribution of random walkers (p ≥ 0).

    I The solution has a statistical error, which can be large.

    I There is a limit for how large systems one can study, DMC needs a huge numberof random walkers in order to achieve stable results.

    I Obtain only the lowest-lying states with a given symmetry. Can get excitedstates.

    27 / 281

  • Where and why do we use Monte Carlo Methods inQuantum Physics

    I Quantum systems with many particles at finite temperature: Path Integral MonteCarlo with applications to dense matter and quantum liquids (phase transitionsfrom normal fluid to superfluid). Strong correlations.

    I Bose-Einstein condensation of dilute gases, method transition from non-linearPDE to Diffusion Monte Carlo as density increases.

    I Light atoms, molecules, solids and nuclei.

    I Lattice Quantum-Chromo Dynamics. Impossible to solve without MCcalculations.

    I Simulations of systems in solid state physics, from semiconductors to spinsystems. Many electrons active and possibly strong correlations.

    28 / 281

  • Quantum Monte Carlo

    Given a hamiltonian H and a trial wave function ΨT , the variational principle states thatthe expectation value of 〈H〉, defined through

    E [H] = 〈H〉 =∫

    dRΨ∗T (R)H(R)ΨT (R)∫dRΨ∗T (R)ΨT (R)

    ,

    is an upper bound to the ground state energy E0 of the hamiltonian H, that is

    E0 ≤ 〈H〉.

    In general, the integrals involved in the calculation of various expectation values are

    multi-dimensional ones. Traditional integration methods such as the Gauss-Legendre

    will not be adequate for say the computation of the energy of a many-body system.

    29 / 281

  • Quantum Monte Carlo

    The trial wave function can be expanded in the eigenstates of the hamiltonian sincethey form a complete set, viz.,

    ΨT (R) =∑

    i

    ai Ψi (R),

    and assuming the set of eigenfunctions to be normalized one obtains∑nm a

    ∗man

    ∫dRΨ∗m(R)H(R)Ψn(R)∑

    nm a∗man

    ∫dRΨ∗m(R)Ψn(R)

    =

    ∑n a

    2nEn∑

    n a2n≥ E0,

    where we used that H(R)Ψn(R) = EnΨn(R). In general, the integrals involved in the

    calculation of various expectation values are multi-dimensional ones. The variational

    principle yields the lowest state of a given symmetry.

    30 / 281

  • Quantum Monte Carlo

    In most cases, a wave function has only small values in large parts of configurationspace, and a straightforward procedure which uses homogenously distributed randompoints in configuration space will most likely lead to poor results. This may suggest thatsome kind of importance sampling combined with e.g., the Metropolis algorithm maybe a more efficient way of obtaining the ground state energy. The hope is then thatthose regions of configurations space where the wave function assumes appreciablevalues are sampled more efficiently.

    The tedious part in a VMC calculation is the search for the variational minimum. A

    good knowledge of the system is required in order to carry out reasonable VMC

    calculations. This is not always the case, and often VMC calculations serve rather as

    the starting point for so-called diffusion Monte Carlo calculations (DMC). DMC is a way

    of solving exactly the many-body Schrödinger equation by means of a stochastic

    procedure. A good guess on the binding energy and its wave function is however

    necessary. A carefully performed VMC calculation can aid in this context.

    31 / 281

  • Quantum Monte Carlo

    I Construct first a trial wave function ψαT (R), for a many-body system consisting ofN particles located at positions R = (R1, . . . ,RN). The trial wave functiondepends on α variational parameters α = (α1, . . . , αN ).

    I Then we evaluate the expectation value of the hamiltonian H

    E [H] = 〈H〉 =∫

    dRΨ∗Tα (R)H(R)ΨTα (R)∫dRΨ∗Tα (R)ΨTα (R)

    .

    I Thereafter we vary α according to some minimization algorithm and return to thefirst step.

    32 / 281

  • Quantum Monte CarloChoose a trial wave function ψT (R).

    P(R) =|ψT (R)|2∫|ψT (R)|2 dR

    .

    This is our new probability distribution function (PDF). The approximation to theexpectation value of the Hamiltonian is now

    E [H] ≈∫

    dRΨ∗T (R)H(R)ΨT (R)∫dRΨ∗T (R)ΨT (R)

    .

    Define a new quantity

    EL(R) =1

    ψT (R)HψT (R),

    called the local energy, which, together with our trial PDF yields

    E [H] = 〈H〉 ≈∫

    P(R)EL(R)dR ≈1N

    N∑i=1

    P(Ri)EL(Ri)

    with N being the number of Monte Carlo samples.

    33 / 281

  • Quantum Monte Carlo

    Algo:

    I Initialisation: Fix the number of Monte Carlo steps. Choose an initial R andvariational parameters α and calculate

    ∣∣ψαT (R)∣∣2.I Initialise the energy and the variance and start the Monte Carlo calculation.

    1. Calculate a trial position Rp = R + r ∗ step where r is arandom variable r ∈ [0,1].

    2. Metropolis algorithm to accept or reject this move

    w = P(Rp)/P(R).

    3. If the step is accepted, then we set R = Rp. Updateaverages

    I Finish and compute final averages.

    Observe that the jumping in space is governed by the variable step. Called brute-force

    sampling. Need importance sampling to get more relevant sampling.

    34 / 281

  • Quantum Monte Carlo

    The radial Schrödinger equation for the hydrogen atom can be written as

    −~2

    2m∂2u(r)∂r2

    −(

    ke2

    r−

    ~2l(l + 1)2mr2

    )u(r) = Eu(r),

    or with dimensionless variables

    −12∂2u(ρ)∂ρ2

    −u(ρ)ρ

    +l(l + 1)

    2ρ2u(ρ)− λu(ρ) = 0,

    with the hamiltonian

    H = −12∂2

    ∂ρ2−

    +l(l + 1)

    2ρ2.

    Use variational parameter α in the trial wave function

    uαT (ρ) = αρe−αρ.

    35 / 281

  • Quantum Monte Carlo

    Inserting this wave function into the expression for the local energy EL gives

    EL(ρ) = −1ρ−α

    2

    (α−

    ).

    α 〈H〉 σ2 σ/√

    N7.00000E-01 -4.57759E-01 4.51201E-02 6.71715E-048.00000E-01 -4.81461E-01 3.05736E-02 5.52934E-049.00000E-01 -4.95899E-01 8.20497E-03 2.86443E-041.00000E-00 -5.00000E-01 0.00000E+00 0.00000E+001.10000E+00 -4.93738E-01 1.16989E-02 3.42036E-041.20000E+00 -4.75563E-01 8.85899E-02 9.41222E-041.30000E+00 -4.54341E-01 1.45171E-01 1.20487E-03

    36 / 281

  • Quantum Monte Carlo

    We note that at α = 1 we obtain the exact result, and the variance is zero, as it should.The reason is that we then have the exact wave function, and the action of thehamiltionan on the wave function

    Hψ = constant× ψ,

    yields just a constant. The integral which defines various expectation values involvingmoments of the hamiltonian becomes then

    〈Hn〉 =∫

    dRΨ∗T (R)Hn(R)ΨT (R)∫

    dRΨ∗T (R)ΨT (R)= constant×

    ∫dRΨ∗T (R)ΨT (R)∫dRΨ∗T (R)ΨT (R)

    = constant.

    This gives an important information: the exact wave function leads to zero

    variance! Variation is then performed by minimizing both the energy and the variance.

    37 / 281

  • Quantum Monte Carlo

    The helium atom consists of two electrons and a nucleus with charge Z = 2. Thecontribution to the potential energy due to the attraction from the nucleus is

    −2ke2

    r1−

    2ke2

    r2,

    and if we add the repulsion arising from the two interacting electrons, we obtain thepotential energy

    V (r1, r2) = −2ke2

    r1−

    2ke2

    r2+

    ke2

    r12,

    with the electrons separated at a distance r12 = |r1 − r2|.

    38 / 281

  • Quantum Monte Carlo

    The hamiltonian becomes then

    Ĥ = −~2∇212m

    −~2∇222m

    −2ke2

    r1−

    2ke2

    r2+

    ke2

    r12,

    and Schrödingers equation readsĤψ = Eψ.

    All observables are evaluated with respect to the probability distribution

    P(R) =|ψT (R)|2∫|ψT (R)|2 dR

    .

    generated by the trial wave function. The trial wave function must approximate an exact

    eigenstate in order that accurate results are to be obtained. Improved trial wave

    functions also improve the importance sampling, reducing the cost of obtaining a

    certain statistical accuracy.

    39 / 281

  • Quantum Monte Carlo

    Choice of trial wave function for Helium: Assume r1 → 0.

    EL(R) =1

    ψT (R)HψT (R) =

    1ψT (R)

    (−

    12∇21 −

    Zr1

    )ψT (R) + finite terms.

    EL(R) =1

    RT (r1)

    (−

    12

    d2

    dr21−

    1r1

    ddr1−

    Zr1

    )RT (r1) + finite terms

    For small values of r1, the terms which dominate are

    limr1→0

    EL(R) =1

    RT (r1)

    (−

    1r1

    ddr1−

    Zr1

    )RT (r1),

    since the second derivative does not diverge due to the finiteness of Ψ at the origin.

    40 / 281

  • Quantum Monte Carlo

    This results in1

    RT (r1)dRT (r1)

    dr1= −Z ,

    andRT (r1) ∝ e−Zr1 .

    A similar condition applies to electrons 2 as well. For orbital momenta l > 0 we have

    1RT (r)

    dRT (r)dr

    = −Z

    l + 1.

    Similarly, studying the case r12 → 0 we can write a possible trial wave function as

    ψT (R) = e−α(r1+r2)eβr12 .

    The last equation can be generalized to

    ψT (R) = φ(r1)φ(r2) . . . φ(rN )∏i

  • VMC code for helium, see under resources for allprograms

    42 / 281

  • VMC code for helium, main part

    #include "vmcsolver.h"#include

    using namespace s td ;

    i n t main ( ){

    VMCSolver ∗ so l ve r = new VMCSolver ( ) ;so lver−>runMonteCar lo In tegra t ion ( ) ;return 0;

    }

    43 / 281

  • VMC code for helium, VMC class

    # i fndef VMCSOLVER H#define VMCSOLVER H#include

    using namespace arma ;

    class VMCSolver{public :

    VMCSolver ( ) ;void runMonteCar lo In tegra t ion ( ) ;

    44 / 281

  • VMC code for helium, VMC class

    private :double waveFunction ( const mat &r ) ;double loca lEnergy ( const mat &r ) ;i n t nDimensions , charge , n p a r t i c l e s ;double stepLength , h , h2 , alpha ;long idum ;i n t nCycles ;mat rOld , rNew ;

    } ;#endif / / VMCSOLVER H

    45 / 281

  • VMC code for helium, VMC part itself, additionalfunctions needed

    #include "vmcsolver.h"#include "lib.h"#include #include using namespace arma ;using namespace

    46 / 281

  • VMC code for helium, VMC part itself, initial data, canbe read from command line or file

    VMCSolver : : VMCSolver ( ) :nDimensions ( 3 ) ,charge ( 2 ) ,stepLength ( 1 . 0 ) ,n p a r t i c l e s ( 2 ) ,h (0 .001) ,h2(1000000) ,idum(−1) ,alpha (0 .5∗ charge ) ,nCycles (1000000)

    {}

    47 / 281

  • VMC code for helium, VMC part itself

    void VMCSolver : : runMonteCar lo In tegra t ion ( ){

    rOld = zeros( n p a r t i c l e s , nDimensions ) ;rNew = zeros( n p a r t i c l e s , nDimensions ) ;double waveFunctionOld = 0;double waveFunctionNew = 0;double energySum = 0;double energySquaredSum = 0;double del taE ;

    48 / 281

  • VMC code for helium, VMC part itself

    / / i n i t i a l t r i a l p o s i t i o n sfor ( i n t i = 0 ; i < n p a r t i c l e s ; i ++) {

    for ( i n t j = 0 ; j < nDimensions ; j ++) {rOld ( i , j ) = stepLength ∗ ( ran2 (&idum ) −

    0 .5 ) ;}

    }rNew = rOld ;/ / loop over Monte Car lo cyc lesfor ( i n t cycle = 0; cycle < nCycles ; cycle ++) {

    49 / 281

  • VMC code for helium, VMC part itself

    / / Store the cu r ren t value o f the wavef u n c t i o n

    waveFunctionOld = waveFunction ( rOld ) ;/ / New p o s i t i o n to t e s tfor ( i n t i = 0 ; i < n p a r t i c l e s ; i ++) {

    for ( i n t j = 0 ; j < nDimensions ; j ++) {rNew ( i , j ) = rOld ( i , j ) + stepLength

    ∗ ( ran2 (&idum ) − 0 .5 ) ;}/ / Reca lcu la te the value o f the wave

    f u n c t i o nwaveFunctionNew = waveFunction ( rNew ) ;

    50 / 281

  • VMC code for helium, VMC part itself

    / / Check f o r step acceptance ( i f yes ,update pos i t i on , i f no , rese tp o s i t i o n )

    i f ( ran2 (&idum )

  • VMC code for helium, VMC part itself

    / / update energiesdel taE = loca lEnergy ( rNew ) ;energySum += del taE ;energySquaredSum += del taE ∗del taE ;

    }}double energy = energySum / ( nCycles ∗ n p a r t i c l e s

    ) ;double energySquared = energySquaredSum / (

    nCycles ∗ n p a r t i c l e s ) ;cout

  • VMC code for helium, VMC part, the local energy

    double VMCSolver : : loca lEnergy ( const mat &r ){

    mat rP lus = zeros( n p a r t i c l e s , nDimensions );

    mat rMinus = zeros( n p a r t i c l e s , nDimensions) ;

    rP lus = rMinus = r ;double waveFunctionMinus = 0;double waveFunctionPlus = 0;double waveFunct ionCurrent = waveFunction ( r ) ;

    53 / 281

  • VMC code for helium, VMC part, the local energy

    / / K i n e t i c energydouble k ine t i cEnergy = 0;for ( i n t i = 0 ; i < n p a r t i c l e s ; i ++) {

    for ( i n t j = 0 ; j < nDimensions ; j ++) {rP lus ( i , j ) += h ;rMinus ( i , j ) −= h ;waveFunctionMinus = waveFunction ( rMinus

    ) ;waveFunctionPlus = waveFunction ( rP lus ) ;k ine t i cEnergy −= ( waveFunctionMinus +

    waveFunctionPlus − 2 ∗waveFunct ionCurrent ) ;

    rP lus ( i , j ) = r ( i , j ) ;rMinus ( i , j ) = r ( i , j ) ;

    }}k ine t i cEnergy = 0.5 ∗ h2 ∗ k ine t i cEnergy /

    waveFunct ionCurrent ;

    54 / 281

  • VMC code for helium, VMC part, the local energy

    / / P o t e n t i a l energydouble po ten t ia lEnergy = 0;double r S i n g l e P a r t i c l e = 0 ;for ( i n t i = 0 ; i < n p a r t i c l e s ; i ++) {

    r S i n g l e P a r t i c l e = 0 ;for ( i n t j = 0 ; j < nDimensions ; j ++) {

    r S i n g l e P a r t i c l e += r ( i , j ) ∗ r ( i , j ) ;}po ten t ia lEnergy −= charge / s q r t (

    r S i n g l e P a r t i c l e ) ;}

    55 / 281

  • VMC code for helium, VMC part, the local energy

    / / C on t r i b u t i on from e lec t ron−e lec t r onp o t e n t i a l

    double r12 = 0;for ( i n t i = 0 ; i < n p a r t i c l e s ; i ++) {

    for ( i n t j = i + 1 ; j < n p a r t i c l e s ; j ++) {r12 = 0;for ( i n t k = 0; k < nDimensions ; k++) {

    r12 += ( r ( i , k ) − r ( j , k ) ) ∗ ( r ( i , k )− r ( j , k ) ) ;

    }po ten t ia lEnergy += 1 / s q r t ( r12 ) ;

    }}return k ine t i cEnergy + po ten t ia lEnergy ;

    }

    56 / 281

  • VMC code for helium, VMC part, the wave function

    double VMCSolver : : waveFunction ( const mat &r ){

    double argument = 0 ;for ( i n t i = 0 ; i < n p a r t i c l e s ; i ++) {

    double r S i n g l e P a r t i c l e = 0 ;for ( i n t j = 0 ; j < nDimensions ; j ++) {

    r S i n g l e P a r t i c l e += r ( i , j ) ∗ r ( i , j ) ;}argument += s q r t ( r S i n g l e P a r t i c l e ) ;

    }return exp(−argument ∗ alpha ) ;

    }

    57 / 281

  • Structuring the codeDuring the development of our code we need to make several checks. It is also veryinstructive to compute a closed form expression for the local energy. Since our wavefunction is rather simple it is straightforward to find an analytic expressions. Considerfirst the case of the simple helium function

    ΨT (r1, r2) = e−α(r1+r2)

    The local energy is for this case

    EL1 = (α− Z )(

    1r1

    +1r2

    )+

    1r12− α2

    which gives an expectation value for the local energy given by

    〈EL1〉 = α2 − 2α(

    Z −516

    )In our project, the simple form is

    ΨT (r1, r2) = e−αω(r21 +r

    22 )/2

    Find the contribution to the local energy!

    58 / 281

  • Structuring the code

    With closed form formulae we can speed up the computation of the correlation. In ourcase we write it as

    ΨC = exp

    ∑i

  • Structuring the code

    We can test this by computing the local energy for our helium wave function

    ψT (r1, r2) = exp (−α(r1 + r2)) exp(

    r122(1 + βr12)

    ),

    with α and β as variational parameters.The local energy is for this case

    EL2 = EL1 +1

    2(1 + βr12)2

    {α(r1 + r2)

    r12(1−

    r1r2r1r2

    )−1

    2(1 + βr12)2−

    2r12

    +2β

    1 + βr12

    }It is very useful to test your code against these expressions. It means also that you

    don’t need to compute a derivative numerically as discussed in the above code

    example.

    60 / 281

  • Your tasks for today and till next week

    I Implement the closed form expression for the local energy

    I Convince yourself that the closed form expressions are correct.

    I Implement the above expressions for the helium atom with two electrons.

    I Start working on exercises 1a and 1b.

    61 / 281

  • Topics for Week 6, February 4-8

    Importance sampling, Fokker-Planck and Langevinequations

    I Repetition from last weekI Importance sampling, discussion of codes, crash

    introduction to get you started

    Project work this week: try to finalize 1a and 1b. Startimplementing importance sampling.

    62 / 281

  • Importance sampling, what we want to doWe need to replace the brute force Metropolis algorithm with a walk in coordinatespace biased by the trial wave function. This approach is based on the Fokker-Planckequation and the Langevin equation for generating a trajectory in coordinate space.This is explained later.For a diffusion process characterized by a time-dependent probability density P(x , t) inone dimension the Fokker-Planck equation reads (for one particle /walker)

    ∂P∂t

    = D∂

    ∂x

    (∂

    ∂x− F

    )P(x , t),

    where F is a drift term and D is the diffusion coefficient.The new positions in coordinate space are given as the solutions of the Langevinequation using Euler’s method, namely, we go from the Langevin equation

    ∂x(t)∂t

    = DF (x(t)) + η,

    with η a random variable, yielding a new position

    y = x + DF (x)∆t + ξ,

    where ξ is gaussian random variable and ∆t is a chosen time step.

    63 / 281

  • Importance sampling, what we want to do

    The process of isotropic diffusion characterized by a time-dependent probabilitydensity P(x , t) obeys (as an approximation) the so-called Fokker-Planck equation

    ∂P∂t

    =∑

    i

    D∂

    ∂xi

    (∂

    ∂xi− Fi

    )P(x , t),

    where Fi is the i th component of the drift term (drift velocity) caused by an externalpotential, and D is the diffusion coefficient. The convergence to a stationary probabilitydensity can be obtained by setting the left hand side to zero. The resulting equation willbe satisfied if and only if all the terms of the sum are equal zero,

    ∂2P∂xi 2

    = P∂

    ∂xiFi + Fi

    ∂xiP.

    64 / 281

  • Importance sampling, what we want to do

    The drift vector should be of the form F = g(x) ∂P∂x . Then,

    ∂2P∂xi 2

    = P∂g∂P

    (∂P∂xi

    )2+ Pg

    ∂2P∂xi 2

    + g(∂P∂xi

    )2.

    The condition of stationary density means that the left hand side equals zero. In otherwords, the terms containing first and second derivatives have to cancel each other. It ispossible only if g = 1P , which yields

    F = 21

    ΨT∇ΨT , (8)

    which is known as the so-called quantum force. This term is responsible for pushing

    the walker towards regions of configuration space where the trial wave function is large,

    increasing the efficiency of the simulation in contrast to the Metropolis algorithm where

    the walker has the same probability of moving in every direction.

    65 / 281

  • Importance Sampling

    The Fokker-Planck equation yields a (the solution to the equation) transition probabilitygiven by the Green’s function

    G(y , x ,∆t) =1

    (4πD∆t)3N/2exp

    (−(y − x − D∆tF (x))2/4D∆t

    )which in turn means that our brute force Metropolis algorithm

    A(y , x) = min(1, q(y , x))),

    with q(y , x) = |ΨT (y)|2/|ΨT (x)|2 is now replaced by

    q(y , x) =G(x , y ,∆t)|ΨT (y)|2

    G(y , x ,∆t)|ΨT (x)|2

    Read more in Thijssen’s text chapters 8.8 and 12.2.

    66 / 281

  • Importance sampling, new positions

    for ( v a r i a t e =1; v a r i a t e

  • Importance sampling, new positions

    / / loop over monte ca r l o cyc lesfor ( cyc les = 1; cyc les

  • Importance sampling, new positions

    / / we move only one p a r t i c l e a t the t imefor ( k = 0 ; k < number par t i c les ; k++) {

    i f ( k != i ) {for ( j =0; j < dimension ; j ++) {

    r new [ k ] [ j ] = r o l d [ k ] [ j ] ;}

    }}/ / wave function onemove ( r new ,

    qforce new , &wfnew , beta ) ;wfnew = wave funct ion ( r new , beta ) ;quantum force ( r new , qforce new , beta ,

    wfnew ) ;

    69 / 281

  • Importance sampling, new positions

    / / we compute the log o f the r a t i o o f thegreens f u n c t i o n s to be used i n the

    / / Met ropo l is−Hast ings a lgo r i thmgreens func t ion = 0 . 0 ;for ( j =0; j < dimension ; j ++) {

    greens func t ion += 0 .5∗ ( q f o r ce o ld [ i ] [ j ]+qforce new [ i ] [ j ] ) ∗

    (D∗ t imestep ∗0.5∗ ( q f o r ce o ld [ i ] [ j ]−qforce new [ i ] [ j ] )−r new [ i ] [ j ]+ r o l d[ i ] [ j ] ) ;

    }greens func t ion = exp ( greens func t ion ) ;

    70 / 281

  • Importance sampling, new positions

    / / The Met ropo l i s t e s t i s performed bymoving one p a r t i c l e a t the t ime

    i f ( ran2 (&idum )

  • Importance sampling, Quantum force

    void quantum force ( double ∗∗ r , double ∗∗ qforce ,double beta , double wf )

    {i n t i , j ;double wfminus , wfp lus ;double ∗∗ r p l us , ∗∗ r minus ;

    r p l u s = ( double ∗∗ ) mat r i x ( number par t ic les ,dimension , sizeof ( double ) ) ;

    r minus = ( double ∗∗ ) mat r i x ( number par t ic les ,dimension , sizeof ( double ) ) ;

    for ( i = 0 ; i < number par t i c les ; i ++) {for ( j =0; j < dimension ; j ++) {

    r p l u s [ i ] [ j ] = r minus [ i ] [ j ] = r [ i ] [ j ] ;}

    }. . .

    72 / 281

  • Importance sampling, Quantum force in functionvmc importance.cpp, brute force derivative

    / / compute the f i r s t d e r i v a t i v efor ( i = 0 ; i < number par t i c les ; i ++) {

    for ( j = 0 ; j < dimension ; j ++) {r p l u s [ i ] [ j ] = r [ i ] [ j ]+h ;r minus [ i ] [ j ] = r [ i ] [ j ]−h ;wfminus = wave funct ion ( r minus , beta ) ;wfp lus = wave funct ion ( r p lus , beta ) ;q force [ i ] [ j ] = ( wfplus−wfminus ) ∗2 .0 / wf / ( 2∗ h ) ;r p l u s [ i ] [ j ] = r [ i ] [ j ] ;r minus [ i ] [ j ] = r [ i ] [ j ] ;

    }}

    } / / end of quantum force f u n c t i o n

    73 / 281

  • Closed form expressions for quantum force

    The general derivative formula of the Jastrow factor is

    1ΨC

    ∂ΨC∂xk

    =

    k−1∑i=1

    ∂gik∂xk

    +N∑

    i=k+1

    ∂gki∂xk

    However, with our

    ΨC =∏i

  • Your tasks from the previous weeks plus new tasks

    I Implement the closed form expression for the local energy and the so-calledquantum force

    I Convince yourself that the closed form expressions are correct.

    I Implement the closed form expressions for systems with more than twoelectrons.

    I Start implementing importance sampling, part 1c

    I Finish part 1a and begin part 1b.

    I You need to produce random numbers with a Gaussian distribution.

    I Reading task: Thijssen’s text chapters 8.8 and 12.2.

    75 / 281

  • Structuring the code, simple task

    I Make another copy of your code.

    I Implement the closed form expression for the local energy

    I Compile the new and old codes with the -pg option for profiling.

    I Run both codes and profile them afterwards usinggprof{nameexecutable} > outprofile

    I Study the time usage in the file outprofile

    76 / 281

  • Efficient calculations of wave function ratios

    In the Metropolis/Hasting algorithm, the acceptance ratio determines the probability fora particle to be accepted at a new position. The ratio of the trial wave functionsevaluated at the new and current positions is given by

    R ≡ΨnewTΨcurT

    =ΨnewDΨcurD︸ ︷︷ ︸RSD

    ΨnewCΨcurC︸ ︷︷ ︸

    RC

    . (9)

    Here ΨD is our Slater determinant while ΨC is our correlation function. We need tooptimize ∇ΨT /ΨT ratio and the second derivative as well, that is the ∇2ΨT /ΨT ratio.The first is needed when we compute the so-called quantum force in importancesampling. The second is needed when we compute the kinetic energy term of the localenergy.

    ∇ΨΨ

    =∇(ΨD ΨC)

    ΨD ΨC=

    ΨC∇ΨD + ΨD∇ΨCΨDΨC

    =∇ΨD

    ΨD+

    ∇ΨCΨC

    77 / 281

  • Efficient calculations of wave function ratios

    The expectation value of the kinetic energy expressed in atomic units for electron i is

    〈K̂i 〉 = −12〈Ψ|∇2i |Ψ〉〈Ψ|Ψ〉

    , (10)

    Ki = −12∇2i Ψ

    Ψ. (11)

    ∇2ΨΨ

    =∇2(ΨD ΨC)

    ΨD ΨC=

    ∇·[∇(ΨD ΨC)]ΨD ΨC

    =∇·[ΨC∇ΨD + ΨD∇ΨC ]

    ΨD ΨC

    =∇ΨC ·∇ΨD + ΨC∇2ΨD + ∇ΨD ·∇ΨC + ΨD∇2ΨC

    ΨD ΨC(12)

    ∇2ΨΨ

    =∇2ΨD

    ΨD+∇2ΨC

    ΨC+ 2

    ∇ΨDΨD

    ·∇ΨC

    ΨC(13)

    78 / 281

  • Definitions

    We define the correlated function as

    ΨC =∏i

  • Efficient calculations of wave function ratios

    The total number of different relative distances rij is N(N − 1)/2. In a matrix storageformat, the set forms a strictly upper triangular matrix

    r ≡

    0 r1,2 r1,3 · · · r1,N... 0 r2,3 · · · r2,N...

    ... 0. . .

    ......

    ......

    . . . rN−1,N0 0 0 · · · 0

    . (14)

    This applies to g = g(rij ) as well.

    In our algorithm we will move one particle at the time, say the kth-particle . Keep this in

    mind in the discussion to come.

    80 / 281

  • Efficient calculations of wave function ratios

    RC =ΨnewCΨcurC

    =

    k−1∏i=1

    gnewikgcurik

    N∏i=k+1

    gnewkigcurki

    . (15)

    For the Padé-Jastrow form

    RC =ΨnewCΨcurC

    =eUnew

    eUcur= e∆U , (16)

    where

    ∆U =k−1∑i=1

    (f newik − f

    curik)

    +N∑

    i=k+1

    (f newki − f

    curki)

    (17)

    One needs to develop a special algorithm that runs only through the elements of theupper triangular matrix g and have k as an index.

    81 / 281

  • Efficient calculations of wave function ratios

    The expression to be derived in the following is of interest when computing thequantum force and the kinetic energy. It has the form

    ∇i ΨCΨC

    =1

    ΨC

    ∂ΨC∂xi

    ,

    for all dimensions and with i running over all particles. For the first derivative onlyN − 1 terms survive the ratio because the g-terms that are not differentiated cancelwith their corresponding ones in the denominator. Then,

    1ΨC

    ∂ΨC∂xk

    =

    k−1∑i=1

    1gik

    ∂gik∂xk

    +N∑

    i=k+1

    1gki

    ∂gki∂xk

    . (18)

    An equivalent equation is obtained for the exponential form after replacing gij byexp(fij ), yielding:

    1ΨC

    ∂ΨC∂xk

    =

    k−1∑i=1

    ∂gik∂xk

    +N∑

    i=k+1

    ∂gki∂xk

    , (19)

    with both expressions scaling as O(N).

    82 / 281

  • Efficient calculations of wave function ratios

    Using the identity∂

    ∂xigij = −

    ∂xjgij (20)

    on the right hand side terms of Eq. (18) and Eq. (19), we get expressions where all thederivatives acting on the particle are represented by the second index of g:

    1ΨC

    ∂ΨC∂xk

    =

    k−1∑i=1

    1gik

    ∂gik∂xk

    −N∑

    i=k+1

    1gki

    ∂gki∂xi

    , (21)

    and for the exponential case:

    1ΨC

    ∂ΨC∂xk

    =

    k−1∑i=1

    ∂gik∂xk

    −N∑

    i=k+1

    ∂gki∂xi

    . (22)

    83 / 281

  • Efficient calculations of wave function ratios

    For correlation forms depending only on the scalar distances rij we can use the chainrule. Noting that

    ∂gij∂xj

    =∂gij∂rij

    ∂rij∂xj

    =xj − xi

    rij

    ∂gij∂rij

    , (23)

    after substitution in Eq. (21) and Eq. (22) we arrive at

    1ΨC

    ∂ΨC∂xk

    =

    k−1∑i=1

    1gik

    rikrik

    ∂gik∂rik

    −N∑

    i=k+1

    1gki

    rkirki

    ∂gki∂rki

    . (24)

    84 / 281

  • Efficient calculations of wave function ratiosNote that for the Padé-Jastrow form we can set gij ≡ g(rij ) = ef (rij ) = efij and

    ∂gij∂rij

    = gij∂fij∂rij

    . (25)

    Therefore,

    1ΨC

    ∂ΨC∂xk

    =

    k−1∑i=1

    rikrik

    ∂fik∂rik−

    N∑i=k+1

    rkirki

    ∂fki∂rki

    , (26)

    wherer ij = |r j − r i | = (xj − xi )e1 + (yj − yi )e2 + (zj − zi )e3 (27)

    is the vectorial distance. When the correlation function is the linear Padé-Jastrow weset

    fij =arij

    (1 + βrij ), (28)

    which yields the closed form expression

    ∂fij∂rij

    =a

    (1 + βrij )2. (29)

    85 / 281

  • Efficient calculations of wave function ratios

    Computing the ∇2ΨC/ΨC ratio

    ∇k ΨC =k−1∑i=1

    1gik

    ∇k gik +N∑

    i=k+1

    1gki

    ∇k gki .

    After multiplying by ΨC and taking the gradient on both sides we get,

    ∇2k ΨC = ∇k ΨC ·

    k−1∑i=1

    1gik

    ∇k gik +N∑

    i=k+1

    1gki

    ∇k gki

    + ΨC∇k ·

    N∑i=k+1

    1gki

    ∇k gki +N∑

    i=k+1

    1gki

    ∇k gki

    = ΨC

    (∇k ΨC

    ΨC

    )2+ ΨC∇k ·

    N∑i=k+1

    1gki

    ∇k gki +N∑

    i=k+1

    1gki

    ∇k gki

    . (30)

    86 / 281

  • Efficient calculations of wave function ratiosNow,

    ∇k ·(

    1gik

    ∇k gik)

    = ∇k(

    1gik

    )·∇k gik +

    1gik

    ∇k ·∇k gik

    = −1

    g2ik∇k gik ·∇k gik +

    1gik

    ∇k ·(

    r ikrik

    ∂gik∂rik

    )= −

    1g2ik

    (∇k gik )2

    +1

    gik

    [∇k

    (1rik

    ∂gik∂rik

    )· r ik +

    (1rik

    ∂gik∂rik

    )∇k · r ik

    ]= −

    1g2ik

    (r ikrik

    ∂gik∂rik

    )2+

    1gik

    [∇k

    (1rik

    ∂gik∂rik

    )· r ik +

    (1rik

    ∂gik∂rik

    )d]

    = −1

    g2ik

    (∂gik∂rik

    )2+

    1gik

    [∇k

    (1rik

    ∂gik∂rik

    )· r ik +

    (1rik

    ∂gik∂rik

    )d], (31)

    with d being the number of spatial dimensions.

    87 / 281

  • Efficient calculations of wave function ratios

    Moreover,

    ∇k(

    1rik

    ∂gik∂rik

    )=

    r ikrik

    ∂rik

    (1rik

    ∂gik∂rik

    )=

    r ikrik

    (−

    1r2ik

    ∂gik∂rik

    +1rik

    ∂2gik∂r2ik

    ).

    We finally get

    ∇k ·(

    1gik

    ∇k gik)

    = −1

    g2ik

    (∂gik∂rik

    )2+

    1gik

    [(d − 1

    rik

    )∂gik∂rik

    +∂2gik∂r2ik

    ].

    88 / 281

  • Efficient calculations of wave function ratios

    Inserting the last expression in Eq. (30) and after division by ΨC we get,

    ∇2k ΨCΨC

    =

    (∇k ΨC

    ΨC

    )2+

    k−1∑i=1

    −1

    g2ik

    (∂gik∂rik

    )2+

    1gik

    [(d − 1

    rik

    )∂gik∂rik

    +∂2gik∂r2ik

    ]

    +N∑

    i=k+1

    −1

    g2ki

    (∂gki∂rki

    )2+

    1gki

    [(d − 1

    rki

    )∂gki∂rki

    +∂2gki∂r2ki

    ]. (32)

    89 / 281

  • Efficient calculations of wave function ratios

    For the exponential case we have

    ∇2k ΨCΨC

    =

    (∇k ΨC

    ΨC

    )2+

    k−1∑i=1

    −1

    g2ik

    (gik

    ∂fik∂rik

    )2+

    1gik

    [(d − 1

    rik

    )gik

    ∂fik∂rik

    +∂

    ∂rik

    (gik

    ∂fik∂rik

    )]

    +N∑

    i=k+1

    −1

    g2ki

    (gik

    ∂fki∂rki

    )2+

    1gki

    [(d − 1

    rki

    )gki

    ∂fki∂rki

    +∂

    ∂rki

    (gki

    ∂fki∂rki

    )].

    90 / 281

  • Efficient calculations of wave function ratios

    Using

    ∂rik

    (gik

    ∂fik∂rik

    )=∂gik∂rik

    ∂fik∂rik

    + gik∂2fik∂r2ik

    = gik∂fik∂rik

    ∂fik∂rik

    + gik∂2fik∂r2ik

    = gik

    (∂fik∂rik

    )2+ gik

    ∂2fik∂r2ik

    and substituting this result into the equation above gives rise to the final expression,

    ∇2k ΨPJΨPJ

    =

    (∇k ΨPJ

    ΨPJ

    )2+

    k−1∑i=1

    [(d − 1

    rik

    )∂fik∂rik

    +∂2fik∂r2ik

    ]+

    N∑i=k+1

    [(d − 1

    rki

    )∂fki∂rki

    +∂2fki∂r2ki

    ]. (33)

    91 / 281

  • Summing up: Bringing it all together, Local energy

    The second derivative of the Jastrow factor divided by the Jastrow factor (the way itenters the kinetic energy) is

    [∇2ΨC

    ΨC

    ]x

    = 2N∑

    k=1

    k−1∑i=1

    ∂2gik∂x2k

    +N∑

    k=1

    k−1∑i=1

    ∂gik∂xk

    −N∑

    i=k+1

    ∂gki∂xi

    2

    But we have a simple form for the function, namely

    ΨC =∏i

  • Bringing it all together, Local energy

    Using

    f (rij ) =arij

    1 + βrij,

    and g′(rkj ) = dg(rkj )/drkj and g′′(rkj ) = d2g(rkj )/dr2kj we find that for particle k wehave

    ∇2k ΨCΨC

    =∑ij 6=k

    (rk − ri )(rk − rj )rki rkj

    a(1 + βrki )2

    a(1 + βrkj )2

    +∑j 6=k

    (2a

    rkj (1 + βrkj )2−

    2aβ(1 + βrkj )3

    )

    93 / 281

  • Important feature

    For the correlation part

    ΨC =∏i

  • Importance sampling, Fokker-Planck and Langevinequations

    A stochastic process is simply a function of two variables, one is the time, the other is astochastic variable X , defined by specifying

    I the set {x} of possible values for X ;

    I the probability distribution, wX (x), over this set, or briefly w(x)

    The set of values {x} for X may be discrete, or continuous. If the set of values iscontinuous, then wX (x) is a probability density so that wX (x)dx is the probability that

    one finds the stochastic variable X to have values in the range [x , x + dx ] .

    95 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    An arbitrary number of other stochastic variables may be derived from X . For example,any Y given by a mapping of X , is also a stochastic variable. The mapping may also betime-dependent, that is, the mapping depends on an additional variable t

    YX (t) = f (X , t).

    The quantity YX (t) is called a random function, or, since t often is time, a stochasticprocess. A stochastic process is a function of two variables, one is the time, the otheris a stochastic variable X . Let x be one of the possible values of X then

    y(t) = f (x , t),

    is a function of t , called a sample function or realization of the process. In physics one

    considers the stochastic process to be an ensemble of such sample functions.

    96 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    For many physical systems initial distributions of a stochastic variable y tend toequilibrium distributions: w(y , t)→ w0(y) as t →∞. In equilibrium detailed balanceconstrains the transition rates

    W (y → y ′)w(y) = W (y ′ → y)w0(y),

    where W (y ′ → y) is the probability, per unit time, that the system changes from a state|y〉 , characterized by the value y for the stochastic variable Y , to a state |y ′〉.Note that for a system in equilibrium the transition rate W (y ′ → y) and the reverseW (y → y ′) may be very different.

    97 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    Consider, for instance, a simple system that has only two energy levels �0 = 0 and�1 = ∆E .For a system governed by the Boltzmann distribution we find (the partition function hasbeen taken out)

    W (0→ 1) exp−�0/kT = W (1→ 0) exp−�1/kT

    We get thenW (1→ 0)W (0→ 1)

    = exp−∆E/kT ,

    which goes to zero when T tends to zero.

    98 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    If we assume a discrete set events, our initial probability distribution function can begiven by

    wi (0) = δi,0,

    and its time-development after a given time step ∆t = � is

    wi (t) =∑

    j

    W (j → i)wj (t = 0).

    The continuous analog to wi (0) is

    w(x)→ δ(x), (34)

    where we now have generalized the one-dimensional position x to a

    generic-dimensional vector x. The Kroenecker δ function is replaced by the δ

    distribution function δ(x) at t = 0.

    99 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    The transition from a state j to a state i is now replaced by a transition to a state withposition y from a state with position x. The discrete sum of transition probabilities canthen be replaced by an integral and we obtain the new distribution at a time t + ∆t as

    w(y, t + ∆t) =∫

    W (y, t + ∆t |x, t)w(x, t)dx, (35)

    and after m time steps we have

    w(y, t + m∆t) =∫

    W (y, t + m∆t |x, t)w(x, t)dx. (36)

    When equilibrium is reached we have

    w(y) =∫

    W (y|x, t)w(x)dx, (37)

    that is no time-dependence. Note our change of notation for W

    100 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    We can solve the equation for w(y, t) by making a Fourier transform to momentumspace. The PDF w(x, t) is related to its Fourier transform w̃(k, t) through

    w(x, t) =∫ ∞−∞

    dk exp (ikx)w̃(k, t), (38)

    and using the definition of the δ-function

    δ(x) =1

    ∫ ∞−∞

    dk exp (ikx), (39)

    we see thatw̃(k, 0) = 1/2π. (40)

    101 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    We can then use the Fourier-transformed diffusion equation

    ∂w̃(k, t)∂t

    = −Dk2w̃(k, t), (41)

    with the obvious solution

    w̃(k, t) = w̃(k, 0) exp[−(Dk2t)

    )=

    12π

    exp[−(Dk2t)

    ]. (42)

    102 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    Using Eq. (38) we obtain

    w(x, t) =∫ ∞−∞

    dk exp [ikx]1

    2πexp

    [−(Dk2t)

    ]=

    1√

    4πDtexp

    [−(x2/4Dt)

    ], (43)

    with the normalization condition ∫ ∞−∞

    w(x, t)dx = 1. (44)

    103 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    It is rather easy to verify by insertion that Eq. (43) is a solution of the diffusion equation.The solution represents the probability of finding our random walker at position x attime t if the initial distribution was placed at x = 0 at t = 0.There is another interesting feature worth observing. The discrete transition probabilityW itself is given by a binomial distribution. The results from the central limit theoremstate that transition probability in the limit n→∞ converges to the normal distribution.It is then possible to show that

    W (il − jl, n�)→ W (y, t + ∆t |x, t) =1

    √4πD∆t

    exp[−((y− x)2/4D∆t)

    ], (45)

    and that it satisfies the normalization condition and is itself a solution to the diffusion

    equation.

    104 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    Let us now assume that we have three PDFs for times t0 < t ′ < t , that is w(x0, t0),w(x′, t ′) and w(x, t). We have then

    w(x, t) =∫ ∞−∞

    W (x.t |x′.t ′)w(x′, t ′)dx′,

    andw(x, t) =

    ∫ ∞−∞

    W (x.t |x0.t0)w(x0, t0)dx0,

    andw(x′, t ′) =

    ∫ ∞−∞

    W (x′.t ′|x0, t0)w(x0, t0)dx0.

    105 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    We can combine these equations and arrive at the famousEinstein-Smoluchenski-Kolmogorov-Chapman (ESKC) relation

    W (xt |x0t0) =∫ ∞−∞

    W (x, t |x′, t ′)W (x′, t ′|x0, t0)dx′.

    We can replace the spatial dependence with a dependence upon say the velocity (ormomentum), that is we have

    W (v, t |v0, t0) =∫ ∞−∞

    W (v, t |v′, t ′)W (v′, t ′|v0, t0)dx′.

    106 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    We will now derive the Fokker-Planck equation. We start from the ESKC equation

    W (x, t |x0, t0) =∫ ∞−∞

    W (x, t |x′, t ′)W (x′, t ′|x0, t0)dx′.

    Define s = t ′ − t0, τ = t − t ′ and t − t0 = s + τ . We have then

    W (x, s + τ |x0) =∫ ∞−∞

    W (x, τ |x′)W (x′, s|x0)dx′.

    107 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    Assume now that τ is very small so that we can make an expansion in terms of a smallstep xi , with x′ = x− ξ, that is

    W (x, s|x0) +∂W∂s

    τ + O(τ2) =∫ ∞−∞

    W (x, τ |x− ξ)W (x− ξ, s|x0)dx′.

    We assume that W (x, τ |x− ξ) takes non-negligible values only when ξ is small. This isjust another way of stating the Master equation!!

    108 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    We say thus that x changes only by a small amount in the time interval τ . This meansthat we can make a Taylor expansion in terms of ξ, that is we expand

    W (x, τ |x− ξ)W (x− ξ, s|x0) =∞∑

    n=0

    (−ξ)n

    n!∂n

    ∂xn[W (x + ξ, τ |x)W (x, s|x0)] .

    We can then rewrite the ESKC equation as

    ∂W∂s

    τ = −W (x, s|x0) +∞∑

    n=0

    (−ξ)n

    n!∂n

    ∂xn

    [W (x, s|x0)

    ∫ ∞−∞

    ξnW (x + ξ, τ |x)dξ].

    We have neglected higher powers of τ and have used that for n = 0 we get simply

    W (x, s|x0) due to normalization.

    109 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    We say thus that x changes only by a small amount in the time interval τ . This meansthat we can make a Taylor expansion in terms of ξ, that is we expand

    W (x, τ |x− ξ)W (x− ξ, s|x0) =∞∑

    n=0

    (−ξ)n

    n!∂n

    ∂xn[W (x + ξ, τ |x)W (x, s|x0)] .

    We can then rewrite the ESKC equation as

    ∂W (x, s|x0)∂s

    τ = −W (x, s|x0)+∞∑

    n=0

    (−ξ)n

    n!∂n

    ∂xn

    [W (x, s|x0)

    ∫ ∞−∞

    ξnW (x + ξ, τ |x)dξ].

    We have neglected higher powers of τ and have used that for n = 0 we get simply

    W (x, s|x0) due to normalization.

    110 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    We simplify the above by introducing the moments

    Mn =1τ

    ∫ ∞−∞

    ξnW (x + ξ, τ |x)dξ =〈[∆x(τ)]n〉

    τ,

    resulting in∂W (x, s|x0)

    ∂s=∞∑

    n=1

    (−ξ)n

    n!∂n

    ∂xn[W (x, s|x0)Mn] .

    111 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    When τ → 0 we assume that 〈[∆x(τ)]n〉 → 0 more rapidly than τ itself if n > 2. Whenτ is much larger than the standard correlation time of system then Mn for n > 2 cannormally be neglected. This means that fluctuations become negligible at large timescales.If we neglect such terms we can rewrite the ESKC equation as

    ∂W (x, s|x0)∂s

    = −∂M1W (x, s|x0)

    ∂x+

    12∂2M2W (x, s|x0)

    ∂x2.

    112 / 281

  • Importance sampling, Fokker-Planck and Langevinequations

    In a more compact form we have

    ∂W∂s

    = −∂M1W∂x

    +12∂2M2W∂x2

    ,

    which is the Fokker-Planck equation! It is trivial to replace position with velocity

    (momentum).

    113 / 281

  • Langevin equation

    Consider a particle suspended in a liquid. On its path through the liquid it willcontinuously collide with the liquid molecules. Because on average the particle willcollide more often on the front side than on the back side, it will experience asystematic force proportional with its velocity, and directed opposite to its velocity.Besides this systematic force the particle will experience a stochastic force F (t). Theequations of motion then read

    drdt

    = v ,

    dvdt

    = −ξv + F .

    114 / 281

  • Langevin equation

    From hydrodynamics we know that the friction constant ξ is given by

    ξ = 6πηa/m

    where η is the viscosity of the solvent and a is the radius of the particle .Solving the second equation in the previous slide we get

    v(t) = v0e−ξt +∫ t

    0dτe−ξ(t−τ)F (τ).

    115 / 281

  • Langevin equation

    If we want to get some useful information out of this, we have to average over allpossible realizations of F (t), with the initial velocity as a condition. A useful quantity forexample is

    〈v(t) · v(t)〉v0 = v−ξ2t0 + 2

    ∫ t0

    dτe−ξ(2t−τ)v0 · 〈F (τ)〉v0

    +

    ∫ t0

    dτ ′∫ t

    0dτe−ξ(2t−τ−τ

    ′)〈F (τ) · F (τ ′)〉v0 .

    116 / 281

  • Langevin equation

    In order to continue we have to make some assumptions about the conditionalaverages of the stochastic forces. In view of the chaotic character of the stochasticforces the following assumptions seem to be appropriate

    〈F (t)〉 = 0,

    〈F (t) · F (t ′)〉v0 = Cv0δ(t − t′).

    117 / 281

  • Langevin equation

    We omit the subscript v0, when the quantity of interest turns out to be independent ofv0. Using the last three equations we get

    〈v(t) · v(t)〉v0 = v20 e−2ξt +

    Cv02ξ

    (1− e−2ξt ).

    For large t this should be equal to 3kT/m, from which it follows that

    〈F (t) · F (t ′)〉 = 6kTmξδ(t − t ′).

    This result is called the fluctuation-dissipation theorem .

    118 / 281

  • Langevin equation

    Integrating

    v(t) = v0e−ξt +∫ t

    0dτe−ξ(t−τ)F (τ),

    we get

    r(t) = r0 + v01ξ

    (1− e−ξt ) +∫ t

    0dτ∫ τ

    0τ ′e−ξ(τ−τ

    ′)F (τ ′),

    from which we calculate the mean square displacement

    〈(r(t)− r0)2〉v0 =v20ξ

    (1− e−ξt )2 +3kTmξ2

    (2ξt − 3 + 4e−ξt − e−2ξt ).

    119 / 281

  • Langevin equation

    For very large t this becomes

    〈(r(t)− r0)2〉 =6kTmξ

    t

    from which we get the Einstein relation

    D =kTmξ

    where we have used 〈(r(t)− r0)2〉 = 6Dt .

    120 / 281

  • Topics for Week 8, February 18-22

    Slater determinants for systems with more than twoparticles

    I Repetition from last timeI Construction of the Slater determinant.

    Project work this week: try to finalize 1c with importancesampling. Start implementing functions for Slater determinants.

    121 / 281

  • Slater determinants

    The potentially most time-consuming part is the evaluation of the gradient and theLaplacian of an N-particle Slater determinant. We have to differentiate the determinantwith respect to all spatial coordinates of all particles. A brute force differentiation wouldinvolve N · d evaluations of the entire determinant which would even worsen thealready undesirable time scaling, making it Nd · O(N3) ∼ O(d · N4). This posesserious hindrances to the overall efficiency of our code.

    Before we proceed we need however to define the determinant and other quantities.

    This involves the computation of the expectation value of the energy. The latter will also

    serve as a useful test for our algorithms.

    122 / 281

  • Definitions

    The quantum mechanical wave function of a given state withquantum numbers λ (encompassing all quantum numbersneeded to specify the system), ignoring time, is with N particles(electrons in our case)

    Ψλ = Ψλ(x1, x2, . . . , xN),

    with xi = (ri , σi) and the projection of σi takes the values{−1/2,+1/2} for fermions with spin 1/2. We will hereafteralways refer to Ψλ as the exact wave function, and if the groundstate is not degenerate we label it as

    Ψ0 = Ψ0(x1, x2, . . . , xN).

    123 / 281

  • Definitions

    Since the solution Ψλ seldomly can be found in closed form,approximations are sought. In this text we define anapproximative wave function or an ansatz to the exact wavefunction as

    Φλ = Φλ(x1, x2, . . . , xN),

    withΦ0 = Φ0(x1, x2, . . . , xN),

    being the ansatz to the ground state.

    124 / 281

  • Definitions

    The wave function Ψλ is sought in the Hilbert space of eithersymmetric or anti-symmetric N-body functions, namely

    Ψλ ∈ HN := H1 ⊕H1 ⊕ · · · ⊕ H1,

    where the single-particle Hilbert space H1 is the space ofsquare integrable functions over ∈ Rd ⊕ (σ) resulting in

    H1 := L2(Rd ⊕ (σ)).

    125 / 281

  • DefinitionsOur Hamiltonian is invariant under the permutation(interchange) of two fermions. Since we deal with fermionshowever, the total wave function is antisymmetric. Let P̂ be anoperator which interchanges two fermions. Due to thesymmetries we have ascribed to our Hamiltonian, this operatorcommutes with the total Hamiltonian,

    [Ĥ, P̂] = 0,

    meaning that Ψλ(x1, x2, . . . , xN) is an eigenfunction of P̂ as well,that is

    P̂ijΨλ(x1, x2, . . . , xi , . . . , xj , . . . , xN) = βΨλ(x1, x2, . . . , xj , . . . , xi , . . . , xN),

    where β is the eigenvalue of P̂. We have introduced the suffix ijin order to indicate that we permute fermions i and j . The Pauliprinciple tells us that the total wave function for a system offermions has to be antisymmetric, resulting in the eigenvalueβ = −1.

    126 / 281

  • Definitions and notations

    The Schrödinger equation reads

    Ĥ(x1, x2, . . . , xN )Ψλ(x1, x2, . . . , xN ) = EλΨλ(x1, x2, . . . , xN ), (46)

    where the vector xi represents the coordinates (spatial and spin) of particle i , λ stands

    for all the quantum numbers needed to classify a given N-particle state and Ψλ is the

    pertaining eigenfunction. Throughout this course, Ψ refers to the exact eigenfunction,

    unless otherwise stated.

    127 / 281

  • Definitions and notations

    We write the Hamilton operator, or Hamiltonian, in a generic way

    Ĥ = T̂ + V̂

    where T̂ represents the kinetic energy of the system

    T̂ =N∑

    i=1

    p2i2mi

    =N∑

    i=1

    (−

    ~2

    2mi∇i2)

    =N∑

    i=1

    t(xi )

    while the operator V̂ for the potential energy is given by

    V̂ =N∑

    i=1

    ûext(xi ) +N∑

    ji=1

    v(xi , xj ) +N∑

    ijk=1

    v(xi , xj , xk ) + . . . (47)

    Hereafter we use natural units, viz. ~ = c = e = 1, with e the elementary charge and c

    the speed of light. This means that momenta and masses have dimension energy.

    128 / 281

  • Definitions and notations

    If one does quantum chemistry or atomic physics as we do here, after havingintroduced the Born-Oppenheimer approximation which effectively freezes out thenucleonic degrees of freedom, the Hamiltonian for N = ne electrons takes the followingform

    Ĥ =ne∑

    i=1

    t(xi )−ne∑

    i=1

    kZri

    +

    ne∑i

  • Definitions and notations

    We can rewrite this as

    Ĥ = Ĥ0 + ĤI =ne∑

    i=1

    ĥ0(xi ) +ne∑

    i

  • Definitions and notations

    The potential energy term due to the attraction of the nucleus defines the one-bodyfield ui = uext(xi ) of Eq. (47). We have moved this term into the Ĥ0 part of theHamiltonian, instead of keeping it in V̂ as in Eq. (47). The reason is that we willhereafter treat Ĥ0 as our non-interacting Hamiltonian. For a many-body wavefunctionΦλ defined by an appropriate single-particle basis, we may solve exactly thenon-interacting eigenvalue problem

    Ĥ0Φλ = wλΦλ,

    with wλ being the non-interacting energy. This energy is defined by the sum over

    single-particle energies to be defined below. For atoms the single-particle energies

    could be the hydrogen-like single-particle energies corrected for the charge Z . For

    nuclei and quantum dots, these energies could be given by the harmonic oscillator in

    three and two dimensions, respectively.

    131 / 281

  • Definitions and notations

    We will assume that the interacting part of the Hamiltonian can be approximated by atwo-body interaction. This means that our Hamiltonian is written as

    Ĥ = Ĥ0 + ĤI =N∑

    i=1

    ĥ0(xi ) +N∑

    i

  • Definitions and notations

    Our Hamiltonian is invariant under the permutation (interchange) of two fermions.Since we deal with fermions, the total wave function is antisymmetric. Let P̂ be anoperator which interchanges two fermions. Due to the symmetries we have ascribed toour Hamiltonian, this operator commutes with the total Hamiltonian,

    [Ĥ, P̂] = 0,

    meaning that Ψλ(x1, x2, . . . , xN ) is an eigenfunction of P̂ as well, that is

    P̂ij Ψλ(x1, x2, . . . , xi , . . . , xj , . . . , xN ) = βΨλ(x1, x2, . . . , xi , . . . , xj , . . . , xN ),

    where β is the eigenvalue of P̂. We have introduced the suffix ij in order to indicate that

    we permute fermions i and j . The Pauli principle tells us that the total wave function for

    a system of fermions has to be antisymmetric, resulting in the eigenvalue β = −1.

    133 / 281

  • Definitions and notations

    In our case we assume that we can approximate the exact eigenfunction with a Slaterdeterminant

    Φ(x1, x2, . . . , xN , α, β, . . . , σ) =1√

    N!

    ∣∣∣∣∣∣∣∣∣ψα(x1) ψα(x2) . . . . . . ψα(xN )ψβ(x1) ψβ(x2) . . . . . . ψβ(xN ). . . . . . . . . . . . . . .. . . . . . . . . . . . . . .

    ψσ(x1) ψσ(x2) . . . . . . ψσ(xN )

    ∣∣∣∣∣∣∣∣∣ ,(52)

    where xi stand for the coordinates and spin values of a particle i and α, β, . . . , γ are

    quantum numbers needed to describe remaining quantum numbers.

    134 / 281

  • Definitions and notations

    Let us denote the ground state energy by E0. According to the variational principle wehave

    E0 ≤ E [Φ] =∫

    Φ∗ĤΦdτ

    where Φ is a trial function which we assume to be normalized∫Φ∗Φdτ = 1,

    where we have used the shorthand dτ = dx1dx2 . . . dxN .

    135 / 281

  • Definitions and notations

    In the Hartree-Fock method the trial function is the Slater determinant of Eq. (52) whichcan be rewritten as

    Φ(x1, x2, . . . , xN , α, β, . . . , ν) =1√

    N!

    ∑P

    (−)P P̂ψα(x1)ψβ(x2) . . . ψν(xN ) =√

    N!AΦH ,

    (53)

    where we have introduced the antisymmetrization operator A defined by thesummation over all possible permutations of two fermions.

    136 / 281

  • Definitions and notations

    It is defined asA =

    1N!

    ∑p

    (−)pP̂, (54)

    with p standing for the number of permutations. We have introduced for later use theso-called Hartree-function, defined by the simple product of all possible single-particlefunctions

    ΦH (x1, x2, . . . , xN , α, β, . . . , ν) = ψα(x1)ψβ(x2) . . . ψν(xN ).

    137 / 281

  • Definitions and notations

    Both Ĥ0 andˆ̂

    IH are invariant under all possible permutations of any two fermions andhence commute with A

    [H0,A] = [HI ,A] = 0. (55)

    Furthermore, A satisfiesA2 = A, (56)

    since every permutation of the Slater determinant reproduces it.

    138 / 281

  • Definitions and notations

    The expectation value of Ĥ0∫Φ∗Ĥ0Φdτ = N!

    ∫Φ∗HAĤ0AΦHdτ

    is readily reduced to ∫Φ∗Ĥ0Φdτ = N!

    ∫Φ∗H Ĥ0AΦHdτ,

    where we have used eqs. (55) and (56). The next step is to replace theantisymmetrization operator by its definition Eq. (53) and to replace Ĥ0 with the sum ofone-body operators

    ∫Φ∗Ĥ0Φdτ =

    N∑i=1

    ∑p

    (−)p∫

    Φ∗H ĥ0P̂ΦHdτ.

    139 / 281

  • Definitions and notations

    The integral vanishes if two or more fermions are permuted in only one of theHartree-functions ΦH because the individual single-particle wave functions areorthogonal. We obtain then

    ∫Φ∗Ĥ0Φdτ =

    N∑i=1

    ∫Φ∗H ĥ0ΦHdτ.

    Orthogonality of the single-particle functions allows us to further simplify the integral,and we arrive at the following expression for the expectation values of the sum ofone-body Hamiltonians

    ∫Φ∗Ĥ0Φdτ =

    N∑µ=1

    ∫ψ∗µ(x)ĥ0ψµ(x)dx. (57)

    140 / 281

  • Definitions and notations

    We introduce the following shorthand for the above integral

    〈µ|ĥ0|µ〉 =∫ψ∗µ(x)ĥ0ψµ(x)dx.,

    and rewrite Eq. (57) as ∫Φ∗Ĥ0Φdτ =

    N∑µ=1

    〈µ|ĥ0|µ〉. (58)

    141 / 281

  • Definitions and notations

    The expectation value of the two-body part of the Hamiltonian (assuming a two-bodyHamiltonian at most) is obtained in a similar manner. We have∫

    Φ∗ĤIΦdτ = N!∫

    Φ∗HAĤIAΦHdτ,

    which reduces to

    ∫Φ∗ĤIΦdτ =

    N∑i≤j=1

    ∑p

    (−)p∫

    Φ∗H v̂(xij )P̂ΦHdτ,

    by following the same arguments as for the one-body Hamiltonian.

    142 / 281

  • Definitions and notations

    Because of the dependence on the inter-particle distance rij , permutations of any twofermions no longer vanish, and we get

    ∫Φ∗ĤIΦdτ =

    N∑i

  • Definitions and notations

    We obtain

    ∫Φ∗ĤIΦdτ =

    12

    N∑µ=1

    N∑ν=1

    [∫ψ∗µ(xi )ψ

    ∗ν(xj )v̂(xij )ψµ(xi )ψν(xj )dxi dxj

    −∫ψ∗µ(xi )ψ

    ∗ν(xj )v̂(xij )ψν(xi )ψµ(xj )dxi dxj

    ].

    (59)

    The first term is the so-called direct term. In Hartree-Fock theory it leads to the

    so-called Hartree term, while the second is due to the Pauli principle and is called the

    exchange term and in Hartree-Fock theory it defines the so-called Fock term. The

    factor 1/2 is introduced because we now run over all pairs twice.

    144 / 281

  • Definitions and notations

    The last equation allows us to introduce some further definitions. The single-particlewave functions ψµ(x), defined by the quantum numbers µ and x (recall that x alsoincludes spin degree, later we will also add isospin) are defined as the overlap

    ψα(x) = 〈x |α〉.

    145 / 281

  • Definitions and notations

    We introduce the following shorthands for the above two integrals

    〈µν|V |µν〉 =∫ψ∗µ(xi )ψ

    ∗ν(xj )v̂(xij )ψµ(xi )ψν(xj )dxi dxj ,

    and〈µν|V |νµ〉 =

    ∫ψ∗µ(xi )ψ

    ∗ν(xj )v̂(xij )ψν(xi )ψµ(xj )dxi dxj .

    146 / 281

  • Definitions and notations

    The direct and exchange matrix elements can be brought together if we define theantisymmetrized matrix element

    〈µν|V |µν〉AS = 〈µν|V |µν〉 − 〈µν|V |νµ〉,

    or for a general matrix element

    〈µν|V |στ〉AS = 〈µν|V |στ〉 − 〈µν|V |τσ〉.

    It has the symmetry property

    〈µν|V |στ〉AS = −〈µν|V |τσ〉AS = −〈νµ|V |στ〉AS.

    147 / 281

  • Definitions and notations

    The antisymmetric matrix element is also hermitian, implying

    〈µν|V |στ〉AS = 〈στ |V |µν〉AS.

    With these notations we rewrite Eq. (59) as

    ∫Φ∗ĤIΦdτ =

    12

    N∑µ=1

    N∑ν=1

    〈µν|V |µν〉AS. (60)

    148 / 281

  • Definitions and notations

    Combining Eqs. (58) and (60) we obtain the energy functional

    E [Φ] =N∑µ=1

    〈µ|ĥ0|µ〉+12

    N∑µ=1

    N∑ν=1

    〈µν|V |µν〉AS. (61)

    This equation is very useful, in particular if we only look at the unperturbed part H0.

    This part can be represented by closed form expressions that can be used to check our

    algorithms.

    149 / 281

  • Slater determinants

    We are now ready to start implementing the coding of the Slater determinant. Thepotentially most time-consuming part is the evaluation of the gradient and theLaplacian of an N-particle Slater determinant. We have to differentiate the determinantwith respect to all spatial coordinates of all particles. A brute force differentiation wouldinvolve N · d evaluations of the entire determinant which would even worsen thealready undesirable time scaling, making it Nd · O(N3) ∼ O(d · N4). This posesserious hindrances to the overall efficiency of our code.The efficiency can be improved however if we move only one electron at the time. TheSlater determinant matrix D is defined by the matrix elements

    dij ≡ φj (xi ) (62)

    where φj (ri ) is a single particle wave function. The columns correspond to the position

    of a given particle while the rows stand for the various quantum numbers.

    150 / 281

  • Slater determinants

    What we need to realize is that when differentiating a Slater determinant with respectto some given coordinate, only one row of the corresponding Slater matrix is changed.Therefore, by recalculating the whole determinant we risk producing redundantinformation. The solution turns out to be an algorithm that requires to keep track of theinverse of the Slater matrix.Let the current position in phase space be represented by the (N · d)-element vectorrold and the new suggested position by the vector rnew.The inverse of D can be expressed in terms of its cofactors Cij and its determinant |D|:

    d−1ij =Cji|D|

    (63)

    Notice that the interchanged indices indicate that the matrix of cofactors is to be

    transposed.

    151 / 281

  • Slater determinants

    If D is invertible, then we must obviously have D−1D = 1, or explicitly in terms of theindividual elements of D and D−1:

    N∑k=1

    dik d−1kj = δij (64)

    Consider the ratio, which we shall call R, between |D(rnew)| and |D(rold)|. By definition,each of these determinants can individually be expressed in terms of the i th row of itscofactor matrix

    R ≡|D(rnew)||D(rold)|

    =

    ∑Nj=1 dij (r

    new) Cij (rnew)∑Nj=1 dij (rold) Cij (rold)

    (65)

    152 / 281

  • Slater determinants

    Suppose now that we move only one particle at a time, meaning that rnew differs fromrold by the position of only one, say the i th, particle . This means that D(rnew) andD(rold) differ only by the entries of the i th row. Recall also that the i th row of a cofactormatrix C is independent of the entries of the i th row of its corresponding matrix D. Inthis particular case we therefore get that the i th row of C(rnew) and C(rold) must beequal. Explicitly, we have:

    Cij (rnew) = Cij (rold) ∀ j ∈ {1, . . . ,N} (66)

    153 / 281

  • Slater determinants

    Inserting this into the numerator of eq. (65) and using eq. (63) to substitute thecofactors with the elements of the inverse matrix, we get:

    R =

    ∑Nj=1 dij (r

    new) Cij (rold)∑Nj=1 dij (rold) Cij (rold)

    =

    ∑Nj=1 dij (r

    new) d−1ji (rold)∑N

    j=1 dij (rold) d−1ji (r

    old)(67)

    154 / 281

  • Slater determinants

    Now by eq. (64) the denominator of the rightmost expression must be unity, so that wefinally arrive at:

    R =N∑

    j=1

    dij (rnew) d−1ji (r

    old) =N∑

    j=1

    φj (rnewi ) d−1ji (r

    old) (68)

    What this means is that in order to get the ratio when only the i th particle has been

    moved, we only need to calculate the dot product of the vector(φ1(rnewi ), . . . , φN (r

    newi )

    )of single particle wave functions evaluated at this new

    position with the i th column of the inverse matrix D−1 evaluated at the original position.Such an operation has a time scaling of O(N). The only extra thing we need to do is tomaintain the inverse matrix D−1(xold).

    155 / 281

  • Slater determinants

    If the new position rnew is accepted, then the inverse matrix can by suitably updated byan algorithm having a time scaling of O(N2). This algorithm goes as follows. First weupdate all but the i th column of D−1. For each column j 6= i , we first calculate thequantity:

    Sj = (D(rnew)×D−1(rold))ij =N∑

    l=1

    dil (rnew) d−1lj (r

    old) (69)

    The new elements of the j th column of D−1 are then given by:

    d−1kj (rnew) = d−1kj (r

    old)−SjR

    d−1ki (rold)

    ∀ k ∈ {1, . . . ,N}j 6= i (70)

    156 / 281

  • Slater determinants

    Finally the elements of the i th column of D−1 are updated simply as follows:

    d−1ki (rnew) =

    1R

    d−1ki (rold) ∀ k ∈ {1, . . . ,N} (71)

    We see from these formulas that the time scaling of an update of D−1 after changingone row of D is O(N2).

    157 / 281

  • Slater determinants

    The scheme is also applicable for the calculation of the ratios involving derivatives. It

    turns out that differentiating the Slater determinant with respect to the coordinates of a

    single particle ri changes only the i th row of the corresponding Slater matrix.

    158 / 281

  • Slater determinants

    The gradient and Laplacian can therefore be calculated as follows:

    ∇i |D(r)||D(r)|

    =N∑

    j=1

    ∇i dij (r) d−1ji (r) =N∑

    j=1

    ∇iφj (ri ) d−1ji (r) (72)

    and∇2i |D(r)||D(r)|

    =N∑

    j=1

    ∇2i dij (r) d−1ji (r) =

    N∑j=1

    ∇2i φj (ri ) d−1ji (r) (73)

    159 / 281

  • Slater determinants

    Thus, to calculate all the derivatives of the Slater determinant, we only need thederivatives of the single particle wave functions (∇iφj (ri ) and ∇2i φj (ri )) and theelements of the corresponding inverse Slater matrix (D−1(ri )). A calculation of a singlederivative is by the above result an O(N) operation. Since there are d · N derivatives,the time scaling of the total evaluation becomes O(d · N2). With an O(N2) updatingalgorithm for the inverse matrix, the total scaling is no worse, which is far better thanthe brute force approach yielding O(d · N4).Important note: In most cases you end with closed form expressions for thesingle-particle wave functions. It is then useful to calculate the various derivatives andmake separate functions for them.

    160 / 281

  • Slater determinant: Explicit expressions for variousAtoms, beryllium

    The Slater determinant takes the form

    Φ(r1, r2, , r3, r4, α, β, γ, δ) =1√

    4!

    ∣∣∣∣∣∣∣∣ψ100↑(r1) ψ100↑(r2) ψ100↑(r3) ψ100↑(r4)ψ100↓(r1) ψ100↓(r2) ψ100↓(r3) ψ100↓(r4)ψ200↑(r1) ψ200↑(r2) ψ200↑(r3) ψ200↑(r4)ψ200↓(r1) ψ200↓(r2) ψ200↓(r3) ψ200↓(r4)

    ∣∣∣∣∣∣∣∣ .The Slater determinant as written is zero since the spatial wave functions for the spin

    up and spin down states are equal. But we can rewrite it as the product of two Slater

    determinants, one for spin up and one for spin down.

    161 / 281

  • Slater determinant: Explicit expressions for variousAtoms, beryllium

    We can rewrite it as

    Φ(r1, r2, , r3, r4, α, β, γ, δ) = Det ↑ (1, 2)Det ↓ (3, 4)− Det ↑ (1, 3)Det ↓ (2, 4)

    −Det ↑ (1, 4)Det ↓ (3, 2) + Det ↑ (2, 3)Det ↓ (1, 4)− Det ↑ (2, 4)Det ↓ (1, 3)

    +Det ↑ (3, 4)Det ↓ (1, 2),

    where we have defined

    Det ↑ (1, 2) =1√

    2

    ∣∣∣∣ ψ100↑(r1) ψ100↑(r2)ψ200↑(r1) ψ200↑(r2)∣∣∣∣ ,

    and

    Det ↓ (3, 4) =1√

    2

    ∣∣∣∣ ψ100↓(r3) ψ100↓(r4)ψ200↓(r3) ψ200↓(r4)∣∣∣∣ .

    The total determinant is still zero!

    162 / 281

  • Slater determinant: Explicit expressions for variousAtoms, beryllium

    We want to avoid to sum over spin variables, in particular when the interaction does notdepend on spin.It can be shown, see for example Moskowitz and Kalos, Int. J. Quantum Chem. 20(1981) 1107, that for the variational energy we can approximate the Slater determinantas

    Φ(r1, r2, , r3, r4, α, β, γ, δ) ∝ Det ↑ (1, 2)Det ↓ (3, 4),

    or more generally asΦ(r1, r2, . . . rN ) ∝ Det ↑ Det ↓,

    where we have the Slater determinant as the product of a spin up part involving thenumber of electrons with spin up only (2 for beryllium and 5 for neon) and a spin downpart involving the electrons with spin down.This ansatz is not antisymmetric under the exchange of electrons with opposite spinsbut it can be shown that it gives the same expectation value for the energy as the fullSlater determinant.

    As long as the Hamiltonian is spin independent, the above is correct. It is rather

    straightforward to see this if you go back to the equations for the energy discussed

    earlier today.

    163 / 281

  • Slater determinants

    We will thus factorize the full determinant |D| into two smaller ones, where each can beidentified with ↑ and ↓ respectively:

    |D| = |D|↑ · |D|↓ (74)

    The combined dimensionality of the two smaller determinants equals thedimensionality of the full determinant. Such a factorization is advantageous in that itmakes it possible to perform the calculation of the ratio R and the updating of theinverse matrix separately for |D|↑ and |D|↓:

    |D|new

    |D|old=|D|new↑|D|old↑

    ·|D|new↓|D|old↓

    (75)

    164 / 281

  • Slater determinants

    This reduces the calculation time by a constant factor. The maximal time reductionhappens in a system of equal numbers of ↑ and ↓ particles, so that the two factorizeddeterminants are half the size of the original one.Consider the case of moving only one particle at a time which originally had thefollowing time scaling for one transition:

    OR(N) +Oinverse(N2) (76)

    For the factorized determinants one of the two determinants is obviously unaffected by

    the change so that it cancels from the ratio R.

    165 / 281

  • Slater determinants

    Therefore, only one determinant of size N/2 is involved in each calculation of R andupdate of the inverse matrix. The scaling of each transition then becomes:

    OR(N/2) +Oinverse(N2/4) (77)

    and the time scaling when the transitions for all N particles are put together:

    OR(N2/2) +Oinverse(N3/4) (78)

    which gives the same reduction as in the case of moving all particles at once.

    166 / 281

  • Updating the Slater matrix

    Computing the ratios discussed above requires that we maintain the inverse of theSlater matrix evaluated at the current position. Each time a trial position is accepted,the row number i of the Slater matrix changes and updating its inverse has to becarried out. Getting the inverse of an N × N matrix by Gaussian elimination has acomplexity of order of O(N3) operations, a luxury that we cannot afford for each time aparticle move is accepted. We will use the expression