diff --git a/index.html b/index.html index 236ee75..0928000 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Quantum Monte Carlo @@ -329,79 +329,79 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 Introduction

+
+

1 Introduction

We propose different exercises to understand quantum Monte Carlo (QMC) @@ -436,8 +436,8 @@ coordinates, etc).

-
-

2 Numerical evaluation of the energy

+
+

2 Numerical evaluation of the energy

In this section we consider the Hydrogen atom with the following @@ -510,8 +510,8 @@ E & = & \frac{\langle \Psi| \hat{H} | \Psi\rangle}{\langle \Psi |\Psi \rangle} \end{eqnarray*}

-
-

2.1 Local energy

+
+

2.1 Local energy

Write all the functions of this section in a single file : @@ -534,8 +534,8 @@ to catch the error.

-
-

2.1.1 Exercise 1

+
+

2.1.1 Exercise 1

@@ -546,8 +546,8 @@ Find the theoretical value of \(a\) for which \(\Psi\) is an eigenfunction of \(

-
-

2.1.2 Exercise 2

+
+

2.1.2 Exercise 2

@@ -567,7 +567,7 @@ and returns the potential.

    -
  1. Python
    +
  2. Python
    import numpy as np
    @@ -579,7 +579,7 @@ and returns the potential.
     
  3. -
  4. Python   solution
    +
  5. Python   solution
    import numpy as np
    @@ -593,7 +593,7 @@ and returns the potential.
     
  6. -
  7. Fortran
    +
  8. Fortran
    double precision function potential(r)
    @@ -606,7 +606,7 @@ and returns the potential.
     
  9. -
  10. Fortran   solution
    +
  11. Fortran   solution
    double precision function potential(r)
    @@ -627,8 +627,8 @@ and returns the potential.
     
-
-

2.1.3 Exercise 3

+
+

2.1.3 Exercise 3

@@ -641,7 +641,7 @@ input arguments, and returns a scalar.

    -
  1. Python
    +
  2. Python
    def psi(a, r):
    @@ -651,7 +651,7 @@ input arguments, and returns a scalar.
     
  3. -
  4. Python   solution
    +
  5. Python   solution
    def psi(a, r):
    @@ -661,7 +661,7 @@ input arguments, and returns a scalar.
     
  6. -
  7. Fortran
    +
  8. Fortran
    double precision function psi(a, r)
    @@ -674,7 +674,7 @@ input arguments, and returns a scalar.
     
  9. -
  10. Fortran   solution
    +
  11. Fortran   solution
    double precision function psi(a, r)
    @@ -689,8 +689,8 @@ input arguments, and returns a scalar.
     
-
-

2.1.4 Exercise 4

+
+

2.1.4 Exercise 4

@@ -749,7 +749,7 @@ So the local kinetic energy is

    -
  1. Python
    +
  2. Python
    def kinetic(a,r):
    @@ -759,7 +759,7 @@ So the local kinetic energy is
     
  3. -
  4. Python   solution
    +
  5. Python   solution
    def kinetic(a,r):
    @@ -771,7 +771,7 @@ So the local kinetic energy is
     
  6. -
  7. Fortran
    +
  8. Fortran
    double precision function kinetic(a,r)
    @@ -784,7 +784,7 @@ So the local kinetic energy is
     
  9. -
  10. Fortran   solution
    +
  11. Fortran   solution
    double precision function kinetic(a,r)
    @@ -805,8 +805,8 @@ So the local kinetic energy is
     
-
-

2.1.5 Exercise 5

+
+

2.1.5 Exercise 5

@@ -827,7 +827,7 @@ local kinetic energy.

    -
  1. Python
    +
  2. Python
    def e_loc(a,r):
    @@ -837,7 +837,7 @@ local kinetic energy.
     
  3. -
  4. Python   solution
    +
  5. Python   solution
    def e_loc(a,r):
    @@ -847,7 +847,7 @@ local kinetic energy.
     
  6. -
  7. Fortran
    +
  8. Fortran
    double precision function e_loc(a,r)
    @@ -860,7 +860,7 @@ local kinetic energy.
     
  9. -
  10. Fortran   solution
    +
  11. Fortran   solution
    double precision function e_loc(a,r)
    @@ -877,8 +877,8 @@ local kinetic energy.
     
    -
    -

    2.2 Plot of the local energy along the \(x\) axis

    +
    +

    2.2 Plot of the local energy along the \(x\) axis

    @@ -889,8 +889,8 @@ choose a grid which does not contain the origin.

    -
    -

    2.2.1 Exercise

    +
    +

    2.2.1 Exercise

    @@ -905,7 +905,7 @@ Gnuplot to plot the files.

      -
    1. Python
      +
    2. Python
      import numpy as np
      @@ -926,7 +926,7 @@ plt.savefig("plot_py.png")
       
    3. -
    4. Python   solution
      +
    5. Python   solution
      import numpy as np
      @@ -955,7 +955,7 @@ plt.savefig("plot_py.png")
       
    6. -
    7. Fortran
      +
    8. Fortran
      program plot
      @@ -1005,7 +1005,7 @@ plot './data' index 0 using 1:2 with lines title 'a=0.1', \
       
    9. -
    10. Fortran   solution
      +
    11. Fortran   solution
      program plot
      @@ -1077,8 +1077,8 @@ plot './data' index 0 using 1:2 with lines title 'a=0.1', \
       
      -
      -

      2.3 Numerical estimation of the energy

      +
      +

      2.3 Numerical estimation of the energy

      If the space is discretized in small volume elements \(\mathbf{r}_i\) @@ -1108,8 +1108,8 @@ The energy is biased because:

      -
      -

      2.3.1 Exercise

      +
      +

      2.3.1 Exercise

      @@ -1122,7 +1122,7 @@ Compute a numerical estimate of the energy in a grid of

        -
      1. Python
        +
      2. Python
        import numpy as np
        @@ -1142,7 +1142,7 @@ Compute a numerical estimate of the energy in a grid of
         
      3. -
      4. Python   solution
        +
      5. Python   solution
        import numpy as np
        @@ -1174,7 +1174,7 @@ Compute a numerical estimate of the energy in a grid of
         
      6. -
      7. Fortran
        +
      8. Fortran
        program energy_hydrogen
        @@ -1211,7 +1211,7 @@ To compile the Fortran and run it:
         
      9. -
      10. Fortran   solution
        +
      11. Fortran   solution
        program energy_hydrogen
        @@ -1280,8 +1280,8 @@ a =    2.0000000000000000          E =   -8.0869806678448772E-002
         
        -
        -

        2.4 Variance of the local energy

        +
        +

        2.4 Variance of the local energy

        The variance of the local energy is a functional of \(\Psi\) @@ -1308,8 +1308,8 @@ energy can be used as a measure of the quality of a wave function.

        -
        -

        2.4.1 Exercise (optional)

        +
        +

        2.4.1 Exercise (optional)

        @@ -1321,8 +1321,8 @@ Prove that :

        -
        -

        2.4.2 Exercise

        +
        +

        2.4.2 Exercise

        @@ -1337,7 +1337,7 @@ in a grid of \(50\times50\times50\) points in the range

          -
        1. Python
          +
        2. Python
          import numpy as np
          @@ -1356,7 +1356,7 @@ in a grid of \(50\times50\times50\) points in the range
           
        3. -
        4. Python   solution
          +
        5. Python   solution
          import numpy as np
          @@ -1392,7 +1392,7 @@ in a grid of \(50\times50\times50\) points in the range
           
        6. -
        7. Fortran
          +
        8. Fortran
          program variance_hydrogen
          @@ -1434,7 +1434,7 @@ To compile and run:
           
        9. -
        10. Fortran   solution
          +
        11. Fortran   solution
          program variance_hydrogen
          @@ -1511,8 +1511,8 @@ a =    2.0000000000000000       E =   -8.0869806678448772E-002  s2 =    1.806881
           
          -
          -

          3 Variational Monte Carlo

          +
          +

          3 Variational Monte Carlo

          Numerical integration with deterministic methods is very efficient @@ -1528,8 +1528,8 @@ interval.

          -
          -

          3.1 Computation of the statistical error

          +
          +

          3.1 Computation of the statistical error

          To compute the statistical error, you need to perform \(M\) @@ -1569,8 +1569,8 @@ And the confidence interval is given by

          -
          -

          3.1.1 Exercise

          +
          +

          3.1.1 Exercise

          @@ -1582,7 +1582,7 @@ input array.

            -
          1. Python
            +
          2. Python
            from math import sqrt
            @@ -1594,7 +1594,7 @@ input array.
             
          3. -
          4. Python   solution
            +
          5. Python   solution
            from math import sqrt
            @@ -1613,7 +1613,7 @@ input array.
             
          6. -
          7. Fortran
            +
          8. Fortran
            subroutine ave_error(x,n,ave,err)
            @@ -1628,7 +1628,7 @@ input array.
             
          9. -
          10. Fortran   solution
            +
          11. Fortran   solution
            subroutine ave_error(x,n,ave,err)
            @@ -1656,8 +1656,8 @@ input array.
             
            -
            -

            3.2 Uniform sampling in the box

            +
            +

            3.2 Uniform sampling in the box

            We will now do our first Monte Carlo calculation to compute the @@ -1691,8 +1691,8 @@ compute the statistical error.

            -
            -

            3.2.1 Exercise

            +
            +

            3.2.1 Exercise

            @@ -1706,7 +1706,7 @@ compute the average energy and the associated error bar.

              -
            1. Python
              +
            2. Python

              @@ -1732,7 +1732,7 @@ the Python   solution
              +

            3. Python   solution
              from hydrogen  import *
              @@ -1759,7 +1759,7 @@ the Fortran
              +
            4. Fortran

              @@ -1819,7 +1819,7 @@ well as the index of the current step.

            5. -
            6. Fortran   solution
              +
            7. Fortran   solution

              @@ -1892,8 +1892,8 @@ E = -0.49588321986667677 +/- 7.1758863546737969E-004

              -
              -

              3.3 Metropolis sampling with \(\Psi^2\)

              +
              +

              3.3 Metropolis sampling with \(\Psi^2\)

              We will now use the square of the wave function to sample random @@ -1981,8 +1981,8 @@ step such that the acceptance rate is close to 0.5 is a good compromise.

              -
              -

              3.3.1 Exercise

              +
              +

              3.3.1 Exercise

              @@ -2003,7 +2003,7 @@ Can you observe a reduction in the statistical error?

                -
              1. Python
                +
              2. Python
                from hydrogen  import *
                @@ -2033,7 +2033,7 @@ Can you observe a reduction in the statistical error?
                 
              3. -
              4. Python   solution
                +
              5. Python   solution
                from hydrogen  import *
                @@ -2076,7 +2076,7 @@ Can you observe a reduction in the statistical error?
                 
              6. -
              7. Fortran
                +
              8. Fortran
                subroutine metropolis_montecarlo(a,nmax,tau,energy,accep)
                @@ -2129,7 +2129,7 @@ Can you observe a reduction in the statistical error?
                 
              9. -
              10. Fortran   solution
                +
              11. Fortran   solution
                subroutine metropolis_montecarlo(a,nmax,tau,energy,accep)
                @@ -2209,8 +2209,8 @@ A =   0.51713866666666664      +/-   3.7072551835783688E-004
                 
                -
                -

                3.4 Gaussian random number generator

                +
                +

                3.4 Gaussian random number generator

                To obtain Gaussian-distributed random numbers, you can apply the @@ -2267,8 +2267,8 @@ In Python, you can use the -

                3.5 Generalized Metropolis algorithm

                +
                +

                3.5 Generalized Metropolis algorithm

                One can use more efficient numerical schemes to move the electrons, @@ -2367,8 +2367,8 @@ The transition probability becomes:

                -
                -

                3.5.1 Exercise 1

                +
                +

                3.5.1 Exercise 1

                @@ -2379,7 +2379,7 @@ Write a function to compute the drift vector \(\frac{\nabla \Psi(\mathbf{r})}{\P

                  -
                1. Python
                  +
                2. Python
                  def drift(a,r):
                  @@ -2389,7 +2389,7 @@ Write a function to compute the drift vector \(\frac{\nabla \Psi(\mathbf{r})}{\P
                   
                3. -
                4. Python   solution
                  +
                5. Python   solution
                  def drift(a,r):
                  @@ -2400,7 +2400,7 @@ Write a function to compute the drift vector \(\frac{\nabla \Psi(\mathbf{r})}{\P
                   
                6. -
                7. Fortran
                  +
                8. Fortran
                  subroutine drift(a,r,b)
                  @@ -2414,7 +2414,7 @@ Write a function to compute the drift vector \(\frac{\nabla \Psi(\mathbf{r})}{\P
                   
                9. -
                10. Fortran   solution
                  +
                11. Fortran   solution
                  subroutine drift(a,r,b)
                  @@ -2432,8 +2432,8 @@ Write a function to compute the drift vector \(\frac{\nabla \Psi(\mathbf{r})}{\P
                   
                -
                -

                3.5.2 Exercise 2

                +
                +

                3.5.2 Exercise 2

                @@ -2445,7 +2445,7 @@ Modify the previous program to introduce the drifted diffusion scheme.

                  -
                1. Python
                  +
                2. Python
                  from hydrogen  import *
                  @@ -2474,7 +2474,7 @@ Modify the previous program to introduce the drifted diffusion scheme.
                   
                3. -
                4. Python   solution
                  +
                5. Python   solution
                  from hydrogen  import *
                  @@ -2529,7 +2529,7 @@ Modify the previous program to introduce the drifted diffusion scheme.
                   
                6. -
                7. Fortran
                  +
                8. Fortran
                  subroutine variational_montecarlo(a,tau,nmax,energy,accep_rate)
                  @@ -2579,7 +2579,7 @@ Modify the previous program to introduce the drifted diffusion scheme.
                   
                9. -
                10. Fortran   solution
                  +
                11. Fortran   solution
                  subroutine variational_montecarlo(a,tau,nmax,energy,accep_rate)
                  @@ -2672,17 +2672,68 @@ A =   0.78861366666666666      +/-   3.7855335138754813E-004
                   
                  -
                  -

                  4 TODO Diffusion Monte Carlo

                  +
                  +

                  4 TODO Diffusion Monte Carlo

                  +

                  +Consider the time-dependent Schrödinger equation: +

                  + +

                  +\[ + i\frac{\partial \Psi(\mathbf{r},t)}{\partial t} = \hat{H} \Psi(\mathbf{r},t) + \] +

                  + +

                  +We can expand \(\Psi(\mathbf{r},0)\), in the basis of the eigenstates +of the time-independent Hamiltonian: +

                  + +

                  +\[ + \Psi(\mathbf{r},0) = \sum_k a_k\, \Phi_k(\mathbf{r}). + \] +

                  + +

                  +The solution of the Schrödinger equation at time \(t\) is +

                  + +

                  +\[ + \Psi(\mathbf{r},t) = \sum_k a_k \exp \left( -i\, E_k\, t \right) \Phi_k(\mathbf{r}). + \] +

                  + +

                  +Now, let's replace the time variable \(t\) by an imaginary time variable +\(\tau=i\,t\), we obtain +

                  + +

                  +\[ + -\frac{\partial \psi(\mathbf{r}, t)}{\partial \tau} = \hat{H} \psi(\mathbf{r}, t) + \] +

                  + +

                  +where \(\psi(\mathbf{r},\tau) = \Psi(\mathbf{r},-i\tau) = \Psi(\mathbf{r},t)\) +and +\[ + \psi(\mathbf{r},\tau) = \sum_k a_k \exp( -E_k\, \tau) \phi_k(\mathbf{r}). + \] +For large positive values of \(\tau\), \(\psi\) is dominated by the +\(k=0\) term, namely the ground state. +

                  -
                  -

                  4.1 TODO Hydrogen atom

                  +
                  +

                  4.1 TODO Hydrogen atom

                  -
                  -

                  4.1.1 Exercise

                  +
                  +

                  4.1.1 Exercise

                  @@ -2749,7 +2800,7 @@ energy of H for any value of \(a\).

                    -
                  1. Fortran
                    +
                  2. Fortran
                    subroutine variational_montecarlo(a,tau,nmax,energy,accep_rate)
                    @@ -2844,8 +2895,8 @@ A =   0.78861366666666655      +/-   3.5096729498002445E-004
                     
                    -
                    -

                    4.2 TODO Dihydrogen

                    +
                    +

                    4.2 TODO Dihydrogen

                    We will now consider the H2 molecule in a minimal basis composed of the @@ -2866,8 +2917,8 @@ the nuclei.

                    -
                    -

                    5 TODO [0/1] Last things to do

                    +
                    +

                    5 TODO [0/1] Last things to do

                    • [ ] Prepare 4 questions for the exam: multiple-choice questions @@ -2882,7 +2933,7 @@ the H\(_2\) molecule at $R$=1.4010 bohr. Answer: 0.17406 a.u.

                    Author: Anthony Scemama, Claudia Filippi

                    -

                    Created: 2021-01-26 Tue 12:13

                    +

                    Created: 2021-01-26 Tue 16:09

                    Validate