In this journal you will document your progress of the project, making use of the weekly milestones.
Every week you should
- write down on the day of the lecture a short plan (bullet list is sufficient) of how you want to reach the weekly milestones. Think about how to distribute work in the group, what pieces of code functionality need to be implemented.
- write about your progress until Monday, 23:59 before the next lecture with respect to the milestones. Substantiate your progress with links to code, pictures or test results. Reflect on the relation to your original plan.
We will give feedback on your progress on Tuesday before the following lecture. Consult the grading scheme for details how the journal enters your grade.
Note that the file format of the journal is markdown. This is a flexible and easy method of converting text to HTML. Documentation of the syntax of markdown can be found here. You will find how to include links and images particularly.
- Research on the process of VMC and the different algorithms (@mserraperalta, @abermejillo, @dbedialaunetar)
- Write a sketch for the structure of the library (@mserraperalta)
- Search for a trial wavefunction and compute the analytic
$E_{local}$ for the harmonic oscillator (@mserraperalta) - Implement the Metropolis algorithm (@abermejillo)
- Implement the Monte Carlo integration algorithm (@dbedialaunetar)
- Validate the results for E(parameter) for the harmonic oscillator (@mserraperalta, @abermejillo, @dbedialaunetar)
First, we will briefly comment how the tasks from the bulletlist have been performed and by whom.
- @dbedialaunetar, @abermejillo and @mserraperalta all did some research and discussed how to best implement the different algorithms.
- @mserraperalta prepared a skeleton for the project.
- @mserraperalta implemented symbolic calculation of the local E and the trial wavefunction. First he included the case of the Harmonic Oscillator.
- @abermejillo implemented the Metropolis algorithm and also a function find optimal trial move that finds a trial move with average acceptance ratio 0.5
$\pm$ tol. - @dbedialaunetar implemented the Monte Carlo integration algorithm.
- @abermejillo and @mserraperalta checked that the walkers sampled a gaussian correctly and @mserraperalta that the energy of the Harmonic Oscillator is computed correctly.
Results and comments
After implementing the Metropolis algorithm we have to check that functions are properly sampled. We perform this analysis for a very simple function, a gaussian. The parameter that needs to be fixed is the trial move. As we made a choice to perform trial moves according to a Gaussian distribution, the parameter of the trial move is the standard deviation of the Gaussian (
In these figures, we can see the histogram of 50000 steps for three different values of the trial move. According to the choice of units, a distance of the order of unity is the most appropriate from the three histograms, and this is confirmed by the sampling. When the trial move is 10, the sampling is a bit worse than when it is 1. When the sampling is 0.01, it is completely inservible. Finally, we compute an optimal trial move
After implementing the Montecarlo algorithm and the symbolic treatment, we test out our code for the quantum harmonic oscillator. We use the following hamiltonian
and the following trial wave function
where position is in units of
We now show the expectation values of the energy obtained for different values of
For each point, we averaged
Noteworthy, the trial wavefunction does not need to be normalized because the Metropolis algorithm works with the ratio
Finally, we plot the optimal trial move parameter (
It makes sense that the trial move parameter decreases as the width of the probability density function decreases, that is, as
(due 18 April 2022, 23:59)
- Try to implement computational parallelization for different walkers (@mserraperalta).
- Implement the steepest descent method (@dbedialaunetar).
- Implement the Helium hamiltonian and try to obtain a simplified symbolic representation of E_local (@abermejillo).
- Start obtaining numerical results for harmonic oscillator and hydrogen and helium atoms with steepest descent. (@abermejillo, @mserraperalta, @dbedialaunetar)
- Discuss extra things to implement (first excited state energy, different minimization algorithms...) (@abermejillo, @mserraperalta, @dbedialaunetar)
- @mserraperalta implemented the parallelization of walkers and did a timing analysis comparing computations with parallelization. @dbedialaunetar found a problem and a solution to the parallelization in a windows OS explaind in the README.
- @dbedialaunetar implementet the steepest descent method with an analytical approach and @mserraperalta implemented it numerically.
- @abermejillo tried to improve symbolic computation by using mathematica instead of simpy. In the end he implemented a numerical approach for the E_local of the Helium atom.
Results and comments
The Variational Quantum Monte Carlo is the perfect algorithm to implement parallelized processes in which different walkers are generated separately. This is done in python via a library called multiprocessing. An analysis of the benefit this approach brings was done and the results are shown in the following table for increasing amount of walkers for 25,000 steps
Number of walkers | time[s] (1 core) | time[s] (4 cores) |
---|---|---|
250 | 1.97 | 2.20 |
1000 | 4.64 | 3.91 |
4000 | 14.9 | 10.1 |
We can see that if the number of walkers is high, there is an increase of the performance using parallelization (although it is not by a factor of 4). And in the next table for increasing number of steps of each walker for 1,000 walkers
Number of steps | time[s] (1 core) | time[s] (4 cores) |
---|---|---|
2500 | 0.54 | 0.49 |
25000 | 4.87 | 4.16 |
50000 | 9.30 | 8.33 |
75000 | 14.7 | 12.5 |
Here we can see that the decrease in run time using more cores is not as good as when varying the number of walkers, but there is still an advantage. In order to have get the maximum advantage, all operations should be parallelized, which is not the case in our script. This will be discussed for next week.
In order to show that the steepest descent method works we show results for the Hydrogen atom.
Energy( |
Variance(E) |
---|---|
E(0.7500000) = -0.468773517423537 | var(E) = 0.000382813001703 |
E(0.8000000) = -0.480007940902344 | var(E) = 0.000309257553983 |
E(0.8561721) = -0.489718355285708 | var(E) = 0.000244191116223 |
E(0.8993894) = -0.494939687705365 | var(E) = 0.000176918907625 |
E(0.9295933) = -0.497542602378653 | var(E) = 0.000134685913367 |
E(0.9511378) = -0.498798018343832 | var(E) = 0.000091811032635 |
E(0.9657055) = -0.499423280203444 | var(E) = 0.000064533778343 |
E(0.9764358) = -0.499699941901200 | var(E) = 0.000044718674631 |
E(0.9828816) = -0.499847871572190 | var(E) = 0.000032776923049 |
E(0.9886190) = -0.499936068661564 | var(E) = 0.000021438067264 |
E(0.9924621) = -0.499974008600859 | var(E) = 0.000015704293168 |
E(0.9949302) = -0.499986968297463 | var(E) = 0.000010002118490 |
E(0.9962429) = -0.499995004621390 | var(E) = 0.000007280616394 |
E(0.9977734) = -0.499996372657338 | var(E) = 0.000004331229248 |
Where we can see how the method works correctly reaches a value of
In addition to these computations we also need to monitor the acceptance ratio, which is a powerful tool to know that we are sampling correctly. The following images show, with the example function
|
|
---|---|
|
|
---|---|
|
|
---|---|
The conclusions drawn from this demonstration are the expected. In the first row we see how the implemented code to find a balanced acceptance ratio (see find_optimal_trial_move in lib.py) works perfectly. The algorithm found a trial move standard deviation of
This previous choice of the optimal trial move is performed before any computation along the project, so it is ensured that the acceptance ratio is correctly balanced.
In addition we can check how this holds for a set of walkers. In particular we sample the density of probability of the hydrogen atom with 10,000 walkers, and 10,000 steps each and check the acceptance ratio for each of them. We can observe in the following figure how the acceptance ratio is indeed approximately 0.5.
(due 25 April 2022, 23:59)
- Make the parallelization of the processes as complete as posssible (@mserraperalta)
- Monitor the acceptance ratio (@abermejillo)
- Increase efficiency by calculating optimal trial move every X moves instead of every time (@abermejillo)
- Improve generalization of the code by using numpy in all arguments of the functions (@mserraperalta)
- Generalize code to multimple variational parameters (@dbedialaunetar)
- Obtain results for the Helium atom with 1 and 2 variational parameters (@abermejillo)
- Update documentation, README and start sketching the report (@abermejillo, @dbedialaunetar and @mserraperalta)
- Extras if possible: Implement calculations for H2 and the first excited of He (@abermejillo and @dbedialaunetar)
- @mserraperalta improved the parallelization process in MC_integration: commit
- @abermejillo monitored the acceptance ratio:commit
- @abermejillo increased efficiency by reducing the amount of times
$\sigma_{tm,opt}$ is computed commit - @mserraperalta generalized the arguments of some functions: commit
- @dbedialaunetar generalized the minimization problem to multiple variational parameters: commit
- @abermejillo obtained results for the Helium atom with a 2 parameter wavefunction
- @abermejillo included inputs for the 2 first excited levels of Helium: commit
Results and comments
First, the results for the monitoring of the acceptance ration were added at the end of Week 2.
In last week's journal progress, we reported a slight speed-up in computation time thanks to the parallelization of the sampling of different walkers. However, the parallelization was not complete. We first obtained the samples of the various walkers in parallel, but we then joined all the results using only one core (the leading one), in order to then separate the task of computing the energy of the samples into different cores again. This week, the whole process, from taking the samples to calculating the energy, is parallelized, without joining the results in the middle. The results for
BEFORE | Number of walkers | time[s] (1 core) | time[s] (4 cores) | NOW | time[s] (1 core) | time[s] (4 cores) | time[s] (8 cores) |
---|---|---|---|---|---|---|---|
_ | 250 | 1.75 | 2.07 | _ | 2.34 | 2.22 | 2.8. |
_ | 1000 | 3.76 | 3.02 | _ | 4.12 | 2.91 | 3.16 |
_ | 4000 | 9.75 | 6.38 | _ | 9.94 | 5.17 | 4.52 |
The results before and after completely parallelizing the process are quite similar, and for high number of walkers the code seems to be more efficient with 4 cores. The improvement gained has been of 19% in the best of cases (with the exception of the 30% increase with 8 cores and 4000 walkers) but we also lost efficiency in some others. The library that we use for parallelization is multiprocessing
, and although it can be benefitial in some cases, other libraries, such as ray
, work much better in other situations. This could be something to explore for the final report.
Comparing the timing results before completely parallelizing from last week and this week, we see that this week the times are lower. This results from a combination of two things: increasing efficiency by reducing the amount of times
Regarding minimization, since last week we have been using a numerical scheme for the gradient descent method, that is, we calculate the derivative
This week, we implemented the hamiltonian and trial wave functions, ground states and excited states, of the Helium atom with two parameters, and also the gradient descent method for any dimension of
is
The reason why the process is not done in one go is that due to the statistical nature of the calculation of
Finally, we support our claim that our gradient descent algorithm works for any dimensional
We know that the exact solution is given for
(due 2 May 2022, 23:59)