diff --git a/index.html b/index.html index 70dcd21..5012b44 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- +[0/3]
Last things to do[0/3]
Last things to doThis website contains the QMC tutorial of the 2021 LTTC winter school @@ -496,7 +496,7 @@ starting from an approximate wave function.
-Code examples will be given in Python and Fortran. You can use +Code examples will be given in Python3 and Fortran. You can use whatever language you prefer to write the programs.
@@ -514,8 +514,8 @@ coordinates, etc).For a given system with Hamiltonian \(\hat{H}\) and wave function \(\Psi\), we define the local energy as @@ -598,8 +598,8 @@ energy computed over these configurations:
In this section, we consider the hydrogen atom with the following @@ -628,8 +628,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. @@ -656,8 +656,8 @@ to catch the error.
@@ -679,7 +679,8 @@ and returns the potential. Python
import numpy as np +#!/usr/bin/env python3 +import numpy as np def potential(r): # TODO @@ -701,14 +702,15 @@ and returns the potential.
Python
import numpy as np +#!/usr/bin/env python3 +import numpy as np def potential(r): distance = np.sqrt(np.dot(r,r)) @@ -742,8 +744,8 @@ and returns the potential.
@@ -778,8 +780,8 @@ input arguments, and returns a scalar.
Python @@ -806,8 +808,8 @@ input arguments, and returns a scalar.
@@ -827,7 +829,7 @@ We differentiate \(\Psi\) with respect to \(x\):
-\[\Psi(\mathbf{r}) = \exp(-a\,|\mathbf{r}|) \] +\[ \Psi(\mathbf{r}) = \exp(-a\,|\mathbf{r}|) \] \[\frac{\partial \Psi}{\partial x} = \frac{\partial \Psi}{\partial |\mathbf{r}|} \frac{\partial |\mathbf{r}|}{\partial x} = - \frac{a\,x}{|\mathbf{r}|} \Psi(\mathbf{r}) \] @@ -888,8 +890,8 @@ Therefore, the local kinetic energy is
Python @@ -930,8 +932,8 @@ Therefore, the local kinetic energy is
@@ -990,8 +992,8 @@ are calling is yours.
Python @@ -1022,8 +1024,8 @@ are calling is yours.
@@ -1033,8 +1035,8 @@ Find the theoretical value of \(a\) for which \(\Psi\) is an eigenfunction of \(
The program you will write in this section will be written in @@ -1068,7 +1070,9 @@ It will use the functions previously defined. In Python, you should put at the beginning of the file
from hydrogen import e_loc +#!/usr/bin/env python3 + +from hydrogen import e_loc
@@ -1084,8 +1088,8 @@ In Fortran, you will need to compile all the source files together:
@@ -1111,7 +1115,9 @@ choose a grid which does not contain the origin to avoid numerical issues. Python
import numpy as np +#!/usr/bin/env python3 + +import numpy as np import matplotlib.pyplot as plt from hydrogen import e_loc @@ -1177,14 +1183,16 @@ plot './data' index 0 using 1:2 with lines title 'a=0.1', \
Python
import numpy as np +#!/usr/bin/env python3 + +import numpy as np import matplotlib.pyplot as plt from hydrogen import e_loc @@ -1253,8 +1261,8 @@ plt.savefig("plot_py.png")
If the space is discretized in small volume elements \(\mathbf{r}_i\) @@ -1267,7 +1275,7 @@ multiplied by the volume element:
\[ \langle E \rangle_{\Psi^2} \approx \frac{\sum_i w_i E_L(\mathbf{r}_i)}{\sum_i w_i}, \;\; - w_i = \left[\Psi(\mathbf{r}_i)\right]^2 \delta \mathbf{r} + w_i = \left|\Psi(\mathbf{r}_i)\right|^2 \delta \mathbf{r} \]
@@ -1284,8 +1292,8 @@ The energy is biased because:@@ -1300,7 +1308,9 @@ Compute a numerical estimate of the energy using a grid of Python
import numpy as np +#!/usr/bin/env python3 + +import numpy as np from hydrogen import e_loc, psi interval = np.linspace(-5,5,num=50) @@ -1354,14 +1364,16 @@ To compile the Fortran and run it:
Python
import numpy as np +#!/usr/bin/env python3 + +import numpy as np from hydrogen import e_loc, psi interval = np.linspace(-5,5,num=50) @@ -1470,8 +1482,8 @@ a = 2.0000000000000000 E = -8.0869806678448772E-002
The variance of the local energy is a functional of \(\Psi\) @@ -1498,8 +1510,8 @@ energy can be used as a measure of the quality of a wave function.
@@ -1510,8 +1522,8 @@ Prove that :
\(\bar{E} = \langle E \rangle\) is a constant, so \(\langle \bar{E} @@ -1530,8 +1542,8 @@ Prove that :
@@ -1547,7 +1559,9 @@ a grid of \(50\times50\times50\) points in the range \((-5,-5,-5) \le Python
import numpy as np from hydrogen import e_loc, psi +#!/usr/bin/env python3 + +import numpy as np from hydrogen import e_loc, psi interval = np.linspace(-5,5,num=50) @@ -1605,14 +1619,16 @@ To compile and run:
Python
import numpy as np +#!/usr/bin/env python3 + +import numpy as np from hydrogen import e_loc, psi interval = np.linspace(-5,5,num=50) @@ -1743,8 +1759,8 @@ a = 2.0000000000000000 E = -8.0869806678448772E-002 s2 = 1.8068814
Numerical integration with deterministic methods is very efficient @@ -1754,14 +1770,14 @@ on a grid, it is usually more efficient to use Monte Carlo sampling.
-Moreover, Monte Carlo sampling will alow us to remove the bias due +Moreover, Monte Carlo sampling will allow us to remove the bias due to the discretization of space, and compute a statistical confidence interval.
To compute the statistical error, you need to perform \(M\) @@ -1801,8 +1817,8 @@ And the confidence interval is given by
@@ -1816,7 +1832,9 @@ input array. Python
from math import sqrt +#!/usr/bin/env python3 + +from math import sqrt def ave_error(arr): #TODO return (average, error) @@ -1840,14 +1858,16 @@ input array.
Python
from math import sqrt +#!/usr/bin/env python3 + +from math import sqrt def ave_error(arr): M = len(arr) assert(M>0) @@ -1900,8 +1920,8 @@ input array.
We will now perform our first Monte Carlo calculation to compute the @@ -1943,9 +1963,9 @@ One Monte Carlo run will consist of \(N_{\rm MC}\) Monte Carlo iterations. At ev
normalization
energy
Python
from hydrogen import * +#!/usr/bin/env python3 + +from hydrogen import * from qmc_stats import * def MonteCarlo(a, nmax): @@ -2178,8 +2202,8 @@ E = -0.49518773675598715 +/- 5.2391494923686175E-004
We will now use the square of the wave function to sample random @@ -2270,7 +2294,7 @@ The algorithm is summarized as follows:
@@ -2342,7 +2366,9 @@ Can you observe a reduction in the statistical error? Python
from hydrogen import * +#!/usr/bin/env python3 + +from hydrogen import * from qmc_stats import * def MonteCarlo(a,nmax,dt): @@ -2426,14 +2452,16 @@ Can you observe a reduction in the statistical error?
Python
from hydrogen import * +#!/usr/bin/env python3 + +from hydrogen import * from qmc_stats import * def MonteCarlo(a,nmax,dt): @@ -2572,8 +2600,8 @@ A = 0.51695266666666673 +/- 4.0445505648997396E-004