Project 2, Variational Monte Carlo studies of electronic systems. Deadline June 1, Spring 2020

Computational Physics II FYS4411/FYS9411, Department of Physics, University of Oslo, Norway

Date: Mar 26, 2020

Copyright 1999-2020, Computational Physics II FYS4411/FYS9411. Released under CC Attribution-NonCommercial 4.0 license


The aim of this project is to use the Variational Monte Carlo (VMC) method to evaluate the ground state energy, onebody densities, expectation values of the kinetic and potential energies and single-particle denisties of quantum dots with $N=2$, $N=6$, $N=12$ and $N=20$ electrons. These are so-called closed shell systems.

Theoretical background and description of the physical system

We consider a system of electrons confined in a pure two-dimensional isotropic harmonic oscillator potential, with an idealized total Hamiltonian given by

$$ \begin{equation} \label{eq:finalH} \tag{1} \hat{H}=\sum_{i=1}^{N} \left( -\frac{1}{2} \nabla_i^2 + \frac{1}{2} \omega^2r_i^2 \right)+\sum_{i<j}\frac{1}{r_{ij}}, \end{equation} $$

where natural units ($\hbar=c=e=m_e=1$) are used and all energies are in so-called atomic units a.u. We will study systems of many electrons $N$ as functions of the oscillator frequency $\omega$ using the above Hamiltonian. The Hamiltonian includes a standard harmonic oscillator part

$$ \hat{H}_0=\sum_{i=1}^{N} \left( -\frac{1}{2} \nabla_i^2 + \frac{1}{2} \omega^2r_i^2 \right), $$

and the repulsive interaction between two electrons given by

$$ \hat{H}_1=\sum_{i<j}\frac{1}{r_{ij}}, $$

with the distance between electrons given by $r_{ij}=\vert \boldsymbol{r}_1-\boldsymbol{r}_2\vert$. We define the modulus of the positions of the electrons (for a given electron $i$) as $r_i = \sqrt{r_{i_x}^2+r_{i_y}^2}$.

Project 2 a):

In exercises a-f we will deal only with a system of two electrons in a quantum dot with a frequency of $\hbar\omega = 1$. The reason for this is that we have exact closed form expressions for the ground state energy from Taut's work for selected values of $\omega$, see M. Taut, Phys. Rev. A 48, 3561 (1993). The energy is given by $3$ a.u. (atomic units) when the interaction between the electrons is included. If only the harmonic oscillator part of the Hamiltonian is included, the so-called unperturbed part,

$$ \hat{H}_0=\sum_{i=1}^{N} \left( -\frac{1}{2} \nabla_i^2 + \frac{1}{2} \omega^2r_i^2 \right), $$

the energy is $2$ a.u. The wave function for one electron in an oscillator potential in two dimensions is

$$ \phi_{n_x,n_y}(x,y) = A H_{n_x}(\sqrt{\omega}x)H_{n_y}(\sqrt{\omega}y)\exp{(-\omega(x^2+y^2)/2}. $$

The functions $H_{n_x}(\sqrt{\omega}x)$ are so-called Hermite polynomials, discussed in connection with project 1 while $A$ is a normalization constant. For the lowest-lying state we have $n_x=n_y=0$ and an energy $\epsilon_{n_x,n_y}=\omega(n_x+n_y+1) = \omega$. Convince yourself that the lowest-lying energy for the two-electron system is simply $2\omega$.

The unperturbed wave function for the ground state of the two-electron system is given by

$$ \Phi(\boldsymbol{r}_1,\boldsymbol{r}_2) = C\exp{\left(-\omega(r_1^2+r_2^2)/2\right)}, $$

with $C$ being a normalization constant and $r_i = \sqrt{r_{i_x}^2+r_{i_y}^2}$. Note that the vector $\boldsymbol{r}_i$ refers to the $x$ and $y$ position for a given particle. What is the total spin of this wave function? Find arguments for why the ground state should have this specific total spin.

Project 2 b):

We want to perform a Variational Monte Carlo calculation of the ground state of two electrons in a quantum dot well with different oscillator energies, assuming total spin $S=0$ using the Hamiltonian of Eq. (1). Our trial wave function which has the following form

$$ \begin{equation} \psi_{T}(\boldsymbol{r}_1,\boldsymbol{r}_2) = C\exp{\left(-\alpha\omega(r_1^2+r_2^2)/2\right)} \exp{\left(\frac{ar_{12}}{(1+\beta r_{12})}\right)}, \label{eq:trial} \tag{2} \end{equation} $$

where $a$ is equal to one when the two electrons have anti-parallel spins and $1/3$ when the spins are parallel. Finally, $\alpha$ and $\beta$ are our variational parameters. Note well the dependence on $\alpha$ for the single-particle part of the trial function. It is important to remember this when you use higher-order Hermite polynomials. Find the analytical expressions for the local energy.

Project 2 c):

Your task is to perform a Variational Monte Carlo calculation using the Metropolis algorithm to compute the integral

$$ \begin{equation} \langle E \rangle = \frac{\int d\boldsymbol{r}_1d\boldsymbol{r}_2\psi^{\ast}_T(\boldsymbol{r}_1,\boldsymbol{r}_2)\hat{H}(\boldsymbol{r}_1,\boldsymbol{r}_2)\psi_T(\boldsymbol{r}_1,\boldsymbol{r}_2)} {\int d\boldsymbol{r}_1d\boldsymbol{r}_2\psi^{\ast}_T(\boldsymbol{r}_1,\boldsymbol{r}_2)\psi_T(\boldsymbol{r}_1,\boldsymbol{r}_2)}. \label{_auto1} \tag{3} \end{equation} $$

Compute the expectation value of the energy using both the analytical expression for the local energy and numerical derivation of the kinetic energy. Compare the time usage between the two approaches. Perform these calculations without importance sampling and also without the Jastrow factor. For the calculations without the Jastrow factor and repulsive Coulomb potential, your energy should equal 2.0 a.u. and your variance should be exactly equal to zero.

Project 2 d):

Add now importance sampling and repeat the calculations from the previous exercise but use only the analytical expression for the local energy. Perform also a blocking analysis in order to obtain the optimal standard deviation. Compare your results with the those without importance sampling and comment your results.

Project 2 e):

Using either the steepest descent method or the conjugate gradient method, find the optimal variational parameters and perform your Monte Carlo calculations using these.
In addition, you should parallelize your program using MPI and set it up to run on Smaug.

Project 2 f):

Finally, we wil now analyze and interpret our results for the two-electron systems. Find the energy minimum and discuss your results compared with the analytical solution from Taut's work, see reference [1] below. Compute also the mean distance $r_{12}=\vert \boldsymbol{r}_1-\boldsymbol{r}_2\vert$ (with $r_i = \sqrt{r_{i_x}^2+r_{i_y}^2}$) between the two electrons for the optimal set of the variational parameters. With the optimal parameters for the ground state wave function, compute the onebody density. Discuss your results and compare the results with those obtained with a pure harmonic oscillator wave functions. Run a Monte Carlo calculations without the Jastrow factor as well and compute the same quantities. How important are the correlations induced by the Jastrow factor? Compute also the expectation value of the kinetic energy and potential energy using $\omega=0.01$, $\omega=0.05$, $\omega=0.1$, $\omega=0.5$ and $\omega=1.0$. Comment your results. Hint, think of the virial theorem.

Project 2 g):

The previous exercises have prepared you for extending your calculational machinery to other systems. Here we will focus on quantum dots with $N=6$ and $N=12$ electrons.

The new item you need to pay attention to is the calculation of the Slater Determinant. This is an additional complication to your VMC calculations.
If we stick to harmonic oscillator like wave functions, the trial wave function for say an $N=6$ electron quantum dot can be written as

$$ \begin{equation} \psi_{T}(\boldsymbol{r}_1,\boldsymbol{r}_2,\dots, \boldsymbol{r}_6) = Det\left(\phi_{1}(\boldsymbol{r}_1),\phi_{2}(\boldsymbol{r}_2), \dots,\phi_{6}(\boldsymbol{r}_6)\right) \prod_{i<j}^{6}\exp{\left(\frac{a r_{ij}}{(1+\beta r_{ij})}\right)}, \label{_auto2} \tag{4} \end{equation} $$

where $Det$ is a Slater determinant and the single-particle wave functions are the harmonic oscillator wave functions for the $n_x=0,1$ and $n_y=0,1$ orbitals. Similarly, for the $N=12$ quantum dot, the trial wave function can take the form

$$ \begin{equation} \psi_{T}(\boldsymbol{r}_1,\boldsymbol{r}_2, \dots,\boldsymbol{r}_{12}) = Det\left(\phi_{1}(\boldsymbol{r}_1),\phi_{2}(\boldsymbol{r}_2), \dots,\phi_{12}(\boldsymbol{r}_{12})\right) \prod_{i<j}^{12}\exp{\left(\frac{ar_{ij}}{(1+\beta r_{ij})}\right)}, \label{_auto3} \tag{5} \end{equation} $$

In this case you need to include the $n_x=2$ and $n_y=2$ wave functions as well. Observe that $r_i = \sqrt{r_{i_x}^2+r_{i_y}^2}$. Use the Hermite polynomials defined in project 1. Reference [5] gives benchmark results for closed-shell systems up to $N=20$.

Write a function which sets up the Slater determinant. Find the Hermite polynomials which are needed for $n_x=0,1,2$ and obviously $n_y$ as well. Compare the results you obtain with those from project 1. Compute the ground state energies of quantum dots for $N=6$ and $N=12$ electrons, following the same set up as in the previous exercises for $\omega=0.01$, $\omega=0.05$, $\omega=0.1$, $\omega=0.5$, and $\omega=1.0$. The calculations should include parallelization, blocking, importance sampling and energy minimization using the conjugate gradient approach or similar approaches. To test your Slater determinant code, you should reproduce the unperturbed single-particle energies when the electron-electron repulsion is switched off. Convince yourself that the unperturbed ground state energies for $N=6$ is $10\omega$ and for $N=12$ we obtain $28\omega$. What is the expected total spin of the ground states?

Project 2 h):

With the optimal parameters for the ground state wave function, compute again the onebody density. Discuss your results and compare the results with those obtained with a pure harmonic oscillator wave functions. Run a Monte Carlo calculations without the Jastrow factor as well and compute the same quantities. How important are the correlations induced by the Jastrow factor? Compute also the expectation value of the kinetic energy and potential energy using $\omega=0.01$, $\omega=0.05$, $\omega=0.1$, $\omega=0.5$, and $\omega=1.0$. Comment your results.

Project 2 i):

The last exercise is a performance analysis of your code(s) for the case of $N=6$ electrons. Make a performance analysis by timing your serial code with and without vectorization. Perform several runs with the same number of Monte carlo cycles and compute an average timing analysis with and without vectorization. Comment your results. Use at least $10^6$ Monte Carlo samples.

Compare thereafter your serial code(s) with the speedup you get by parallelizing your code, running either OpenMP or MPI or both. Do you get a near $100\%$ speedup with the parallel version? Comment again your results and perform timing benchmarks several times in order to extract an average performance time.


  1. M. Taut, Phys. Rev. A 48, 3561 - 3566 (1993).

  2. B. L. Hammond, W. A. Lester and P. J. Reynolds, Monte Carlo methods in Ab Initio Quantum Chemistry, World Scientific, Singapore, 1994, chapters 2-5 and appendix B.

  3. B. H. Bransden and C. J. Joachain, Physics of Atoms and molecules, Longman, 1986. Chapters 6, 7 and 9.

  4. A. K. Rajagopal and J. C. Kimball, see Phys. Rev. B 15, 2819 (1977).

  5. M. L. Pedersen, G. Hagen, M. Hjorth-Jensen, S. Kvaal, and F. Pederiva, Phys. Rev. B 84, 115302 (2011)

Introduction to numerical projects

Here follows a brief recipe and recommendation on how to write a report for each project.

  • Give a short description of the nature of the problem and the eventual numerical methods you have used.

  • Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.

  • Include the source code of your program. Comment your program properly.

  • If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.

  • Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.

  • Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.

  • Try to give an interpretation of you results in your answers to the problems.

  • Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.

  • Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.

Format for electronic delivery of report and programs

The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. Place your report in your github repository and send us the link by the deadline. The following prescription should be followed when preparing the report:

  • In your github repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters. Include another folder with your final report.

  • Still in your github make a folder where you place your codes.

  • In this and all later projects, you should include tests (for example unit tests) of your code(s).

  • Comments from us on your projects, approval or not, corrections to be made etc can be found under your Devilry domain and are only visible to you and the teachers of the course.

Finally, we encourage you to work two and two together. Optimal working groups consist of 2-3 students. You can then hand in a common report.