diff --git a/index.html b/index.html index 040badc..196cd95 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- +This website contains the QMC tutorial of the 2021 LTTC winter school @@ -454,8 +478,8 @@ coordinates, etc).
For a given system with Hamiltonian \(\hat{H}\) and wave function \(\Psi\), we define the local energy as @@ -538,8 +562,8 @@ energy computed over these configurations:
In this section, we consider the hydrogen atom with the following @@ -568,8 +592,8 @@ To do that, we will compute the local energy and check whether it is constant.
You will now program all quantities needed to compute the local energy of the H atom for the given wave function. @@ -596,8 +620,8 @@ to catch the error.
@@ -641,10 +665,51 @@ and returns the potential.
+Python +
+#!/usr/bin/env python3 +import numpy as np + +def potential(r): + distance = np.sqrt(np.dot(r,r)) + assert (distance > 0) + return -1. / distance +
+Fortran +
+double precision function potential(r) + implicit none + double precision, intent(in) :: r(3) + + double precision :: distance + + distance = dsqrt( r(1)*r(1) + r(2)*r(2) + r(3)*r(3) ) + + if (distance > 0.d0) then + potential = -1.d0 / distance + else + stop 'potential at r=0.d0 diverges' + end if + +end function potential ++
@@ -678,10 +743,37 @@ input arguments, and returns a scalar.
+Python +
+def psi(a, r): + return np.exp(-a*np.sqrt(np.dot(r,r))) +
+Fortran +
+double precision function psi(a, r) + implicit none + double precision, intent(in) :: a, r(3) + + psi = dexp(-a * dsqrt( r(1)*r(1) + r(2)*r(2) + r(3)*r(3) )) +end function psi ++
@@ -761,10 +853,51 @@ Therefore, the local kinetic energy is
+Python +
+def kinetic(a,r): + distance = np.sqrt(np.dot(r,r)) + assert (distance > 0.) + + return a * (1./distance - 0.5 * a) +
+Fortran +
+double precision function kinetic(a,r) + implicit none + double precision, intent(in) :: a, r(3) + + double precision :: distance + + distance = dsqrt( r(1)*r(1) + r(2)*r(2) + r(3)*r(3) ) + + if (distance > 0.d0) then + + kinetic = a * (1.d0 / distance - 0.5d0 * a) + + else + stop 'kinetic energy diverges at r=0' + end if + +end function kinetic ++
@@ -822,23 +955,73 @@ are calling is yours.
+Python +
+def e_loc(a,r): + return kinetic(a,r) + potential(r) +
+Fortran +
+double precision function e_loc(a,r) + implicit none + double precision, intent(in) :: a, r(3) + + double precision, external :: kinetic + double precision, external :: potential + + e_loc = kinetic(a,r) + potential(r) + +end function e_loc ++
Find the theoretical value of \(a\) for which \(\Psi\) is an eigenfunction of \(\hat{H}\).
++\(a=1\) cancels the \(1/|r|\) term, and makes the energy constant and +equal to -0.5 atomic units. +
The program you will write in this section will be written in @@ -869,8 +1052,8 @@ In Fortran, you will need to compile all the source files together:
@@ -963,11 +1146,87 @@ plot './data' index 0 using 1:2 with lines title 'a=0.1', \
+Python +
+#!/usr/bin/env python3 + +import numpy as np +import matplotlib.pyplot as plt + +from hydrogen import e_loc + +x=np.linspace(-5,5) +plt.figure(figsize=(10,5)) + +for a in [0.1, 0.2, 0.5, 1., 1.5, 2.]: + y=np.array([ e_loc(a, np.array([t,0.,0.]) ) for t in x]) + plt.plot(x,y,label=f"a={a}") + +plt.tight_layout() +plt.legend() +plt.savefig("plot_py.png") ++
+
+Fortran +
+program plot + implicit none + double precision, external :: e_loc + + double precision :: x(50), energy, dx, r(3), a(6) + integer :: i, j + + a = (/ 0.1d0, 0.2d0, 0.5d0, 1.d0, 1.5d0, 2.d0 /) + + dx = 10.d0/(size(x)-1) + do i=1,size(x) + x(i) = -5.d0 + (i-1)*dx + end do + + r(:) = 0.d0 + + do j=1,size(a) + print *, '# a=', a(j) + do i=1,size(x) + r(1) = x(i) + energy = e_loc( a(j), r ) + print *, x(i), energy + end do + print *, '' + print *, '' + end do + +end program plot ++
+
If the space is discretized in small volume elements \(\mathbf{r}_i\) @@ -997,8 +1256,8 @@ The energy is biased because:
@@ -1071,8 +1330,8 @@ To compile the Fortran and run it:
The variance of the local energy is a functional of \(\Psi\) @@ -1099,8 +1358,8 @@ energy can be used as a measure of the quality of a wave function.
@@ -1111,8 +1370,8 @@ Prove that :
@@ -1191,8 +1450,8 @@ To compile and run:
Numerical integration with deterministic methods is very efficient @@ -1208,8 +1467,8 @@ interval.
To compute the statistical error, you need to perform \(M\) @@ -1249,8 +1508,8 @@ And the confidence interval is given by
@@ -1292,8 +1551,8 @@ input array.
We will now perform our first Monte Carlo calculation to compute the @@ -1354,8 +1613,8 @@ compute the statistical error.
@@ -1459,8 +1718,8 @@ well as the index of the current step.
We will now use the square of the wave function to sample random @@ -1579,8 +1838,8 @@ All samples should be kept, from both accepted and rejected moves.
If the box is infinitely small, the ratio will be very close @@ -1615,8 +1874,8 @@ the same variable later on to store a time step.
@@ -1727,8 +1986,8 @@ Can you observe a reduction in the statistical error?
One can use more efficient numerical schemes to move the electrons by choosing a smarter expression for the transition probability. @@ -1849,8 +2108,8 @@ The algorithm of the previous exercise is only slighlty modified as:
To obtain Gaussian-distributed random numbers, you can apply the
@@ -1914,8 +2173,8 @@ In Python, you can use the
-
@@ -1958,8 +2217,8 @@ Write a function to compute the drift vector \(\frac{\nabla \Psi(\mathbf{r})}{\P
@@ -2058,8 +2317,8 @@ Modify the previous program to introduce the drift-diffusion scheme.
As we have seen, Variational Monte Carlo is a powerful method to
@@ -2076,8 +2335,8 @@ finding a near-exact numerical solution to the Schrödinger equation.
Consider the time-dependent Schrödinger equation:
@@ -2145,8 +2404,8 @@ system.
The diffusion equation of particles is given by
@@ -2226,8 +2485,8 @@ Therefore, in both cases, you are dealing with a "Bosonic" ground state.
In a molecular system, the potential is far from being constant
@@ -2325,8 +2584,8 @@ energies computed with the trial wave function.
\[
@@ -2387,8 +2646,8 @@ Defining \(\Pi(\mathbf{r},t) = \psi(\mathbf{r},\tau)
Instead of having a variable number of particles to simulate the
@@ -2477,13 +2736,13 @@ the DMC algorithm. However, its use reduces significantly the time-step error.
@@ -2590,8 +2849,8 @@ time \(\tau\) =100 a.u.
-
Change your PDMC code for one of the following:
@@ -2608,8 +2867,8 @@ And compute the ground state energy.
3.4.2 Exercise 1
+3.4.2 Exercise 1
3.4.3 Exercise 2
+3.4.3 Exercise 2
4 Diffusion Monte Carlo
+4 Diffusion Monte Carlo
4.1 Schrödinger equation in imaginary time
+4.1 Schrödinger equation in imaginary time
4.2 Relation to diffusion
+4.2 Relation to diffusion
4.3 Importance sampling
+4.3 Importance sampling
4.3.1 Appendix : Details of the Derivation
+4.3.1 Appendix : Details of the Derivation
4.4 Pure Diffusion Monte Carlo
+4.4 Pure Diffusion Monte Carlo
4.5 Hydrogen atom
+4.5 Hydrogen atom
4.5.1 Exercise
+4.5.1 Exercise
5 Project
+5 Project
6 Acknowledgments
+6 Acknowledgments