mirror of
https://github.com/TREX-CoE/qmc-lttc.git
synced 2024-08-25 14:41:47 +02:00
deploy: 38197cb0dd
This commit is contained in:
parent
0fff333037
commit
7827f02cbe
536
index.html
536
index.html
@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2021-02-04 Thu 16:27 -->
|
||||
<!-- 2021-02-04 Thu 18:12 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Quantum Monte Carlo</title>
|
||||
@ -329,148 +329,152 @@ for the JavaScript code in this tag.
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#org484a53e">1. Introduction</a>
|
||||
<li><a href="#org8147bc4">1. Introduction</a>
|
||||
<ul>
|
||||
<li><a href="#org4798a98">1.1. Energy and local energy</a></li>
|
||||
<li><a href="#org0c90626">1.1. Energy and local energy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgfc53e9e">2. Numerical evaluation of the energy of the hydrogen atom</a>
|
||||
<li><a href="#org236e915">2. Numerical evaluation of the energy of the hydrogen atom</a>
|
||||
<ul>
|
||||
<li><a href="#org57b7ef5">2.1. Local energy</a>
|
||||
<li><a href="#org20fce44">2.1. Local energy</a>
|
||||
<ul>
|
||||
<li><a href="#org668920d">2.1.1. Exercise 1</a>
|
||||
<li><a href="#org6aa2eea">2.1.1. Exercise 1</a>
|
||||
<ul>
|
||||
<li><a href="#org46559e7">2.1.1.1. Solution</a></li>
|
||||
<li><a href="#orgea8540d">2.1.1.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org08f0363">2.1.2. Exercise 2</a>
|
||||
<li><a href="#orga99da73">2.1.2. Exercise 2</a>
|
||||
<ul>
|
||||
<li><a href="#org385509d">2.1.2.1. Solution</a></li>
|
||||
<li><a href="#orgf3fa97e">2.1.2.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgdbd4a06">2.1.3. Exercise 3</a>
|
||||
<li><a href="#orgb83dff4">2.1.3. Exercise 3</a>
|
||||
<ul>
|
||||
<li><a href="#orgdd8f833">2.1.3.1. Solution</a></li>
|
||||
<li><a href="#orge819a18">2.1.3.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgb04b7f7">2.1.4. Exercise 4</a>
|
||||
<li><a href="#orgd73f763">2.1.4. Exercise 4</a>
|
||||
<ul>
|
||||
<li><a href="#orgc1c0619">2.1.4.1. Solution</a></li>
|
||||
<li><a href="#org37ddd7b">2.1.4.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org3b484c9">2.1.5. Exercise 5</a>
|
||||
<li><a href="#org0448ef8">2.1.5. Exercise 5</a>
|
||||
<ul>
|
||||
<li><a href="#org4d9621e">2.1.5.1. Solution</a></li>
|
||||
<li><a href="#orgc6d6285">2.1.5.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org4ea3772">2.2. Plot of the local energy along the \(x\) axis</a>
|
||||
<li><a href="#orgacb0e57">2.2. Plot of the local energy along the \(x\) axis</a>
|
||||
<ul>
|
||||
<li><a href="#orgaa030b2">2.2.1. Exercise</a>
|
||||
<li><a href="#orgb0b40fb">2.2.1. Exercise</a>
|
||||
<ul>
|
||||
<li><a href="#org724a0e8">2.2.1.1. Solution</a></li>
|
||||
<li><a href="#orgd3b3255">2.2.1.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org72726f5">2.3. Numerical estimation of the energy</a>
|
||||
<li><a href="#orgf2d1b9f">2.3. Numerical estimation of the energy</a>
|
||||
<ul>
|
||||
<li><a href="#org6eb7d45">2.3.1. Exercise</a>
|
||||
<li><a href="#org37958cd">2.3.1. Exercise</a>
|
||||
<ul>
|
||||
<li><a href="#org59929b3">2.3.1.1. Solution</a></li>
|
||||
<li><a href="#org0a6757b">2.3.1.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org5a9cc67">2.4. Variance of the local energy</a>
|
||||
<li><a href="#org3a5c93e">2.4. Variance of the local energy</a>
|
||||
<ul>
|
||||
<li><a href="#orgdca84d5">2.4.1. Exercise (optional)</a>
|
||||
<li><a href="#orgf25a4df">2.4.1. Exercise (optional)</a>
|
||||
<ul>
|
||||
<li><a href="#org1c8885c">2.4.1.1. <span class="done DONE">DONE</span> Solution</a></li>
|
||||
<li><a href="#org7cfa378">2.4.1.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org6240c00">2.4.2. Exercise</a>
|
||||
<li><a href="#org82674e9">2.4.2. Exercise</a>
|
||||
<ul>
|
||||
<li><a href="#org7a641d8">2.4.2.1. Solution</a></li>
|
||||
<li><a href="#org984e04b">2.4.2.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgaf4dafc">3. Variational Monte Carlo</a>
|
||||
<li><a href="#orged64ccd">3. Variational Monte Carlo</a>
|
||||
<ul>
|
||||
<li><a href="#orgc635579">3.1. Computation of the statistical error</a>
|
||||
<li><a href="#org01e38cc">3.1. Computation of the statistical error</a>
|
||||
<ul>
|
||||
<li><a href="#org0dbd817">3.1.1. Exercise</a>
|
||||
<li><a href="#org0dbdc24">3.1.1. Exercise</a>
|
||||
<ul>
|
||||
<li><a href="#org9bf5d86">3.1.1.1. Solution</a></li>
|
||||
<li><a href="#orgdfc0533">3.1.1.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgc075f26">3.2. Uniform sampling in the box</a>
|
||||
<li><a href="#orgfd318d6">3.2. Uniform sampling in the box</a>
|
||||
<ul>
|
||||
<li><a href="#org2193660">3.2.1. Exercise</a>
|
||||
<li><a href="#org74432b8">3.2.1. Exercise</a>
|
||||
<ul>
|
||||
<li><a href="#orge564bf3">3.2.1.1. Solution</a></li>
|
||||
<li><a href="#org99a7b2f">3.2.1.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org49db507">3.3. Metropolis sampling with \(\Psi^2\)</a>
|
||||
<li><a href="#orgcddcdcf">3.3. Metropolis sampling with \(\Psi^2\)</a>
|
||||
<ul>
|
||||
<li><a href="#orgb9a128c">3.3.1. Optimal step size</a></li>
|
||||
<li><a href="#org6d05d27">3.3.2. Exercise</a>
|
||||
<li><a href="#org8b3f6fe">3.3.1. Optimal step size</a></li>
|
||||
<li><a href="#orgd7c523f">3.3.2. Exercise</a>
|
||||
<ul>
|
||||
<li><a href="#orgae06be2">3.3.2.1. Solution</a></li>
|
||||
<li><a href="#orgac64351">3.3.2.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgce90675">3.4. Generalized Metropolis algorithm</a>
|
||||
<li><a href="#org4f2ffad">3.4. Generalized Metropolis algorithm</a>
|
||||
<ul>
|
||||
<li><a href="#org6a93c6c">3.4.1. Gaussian random number generator</a></li>
|
||||
<li><a href="#org661046d">3.4.2. Exercise 1</a>
|
||||
<li><a href="#org6290597">3.4.1. Gaussian random number generator</a></li>
|
||||
<li><a href="#orgc3a15c4">3.4.2. Exercise 1</a>
|
||||
<ul>
|
||||
<li><a href="#orgfb6225c">3.4.2.1. Solution</a></li>
|
||||
<li><a href="#org1bb7357">3.4.2.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgfe231df">3.4.3. Exercise 2</a>
|
||||
<li><a href="#org3594157">3.4.3. Exercise 2</a>
|
||||
<ul>
|
||||
<li><a href="#orga73cfde">3.4.3.1. Solution</a></li>
|
||||
<li><a href="#orgfe0293b">3.4.3.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org0d4554c">4. Diffusion Monte Carlo</a>
|
||||
<li><a href="#org3154c2b">4. Diffusion Monte Carlo</a>
|
||||
<ul>
|
||||
<li><a href="#orgc93ceb9">4.1. Schrödinger equation in imaginary time</a></li>
|
||||
<li><a href="#org1224530">4.2. Relation to diffusion</a></li>
|
||||
<li><a href="#org393a5ec">4.3. Importance sampling</a>
|
||||
<li><a href="#org7b4dacf">4.1. Schrödinger equation in imaginary time</a></li>
|
||||
<li><a href="#orgd350691">4.2. Relation to diffusion</a></li>
|
||||
<li><a href="#org78b3d2b">4.3. Importance sampling</a>
|
||||
<ul>
|
||||
<li><a href="#orgecc90ea">4.3.1. Appendix : Details of the Derivation</a></li>
|
||||
<li><a href="#org7548f1f">4.3.1. Appendix : Details of the Derivation</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org292fbee">4.4. Pure Diffusion Monte Carlo</a></li>
|
||||
<li><a href="#orgce09db6">4.5. Hydrogen atom</a>
|
||||
<li><a href="#org4a7db09">4.4. Pure Diffusion Monte Carlo</a></li>
|
||||
<li><a href="#orgb1e1f31">4.5. Hydrogen atom</a>
|
||||
<ul>
|
||||
<li><a href="#orgeda527c">4.5.1. Exercise</a></li>
|
||||
<li><a href="#org10928e0">4.5.1. Exercise</a>
|
||||
<ul>
|
||||
<li><a href="#org834cb8c">4.5.1.1. Solution</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgf4f054d">5. Project</a></li>
|
||||
<li><a href="#org8424122">6. Acknowledgments</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org3be55e0">5. Project</a></li>
|
||||
<li><a href="#orgfa0dc42">6. Acknowledgments</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org484a53e" class="outline-2">
|
||||
<h2 id="org484a53e"><span class="section-number-2">1</span> Introduction</h2>
|
||||
<div id="outline-container-org8147bc4" class="outline-2">
|
||||
<h2 id="org8147bc4"><span class="section-number-2">1</span> Introduction</h2>
|
||||
<div class="outline-text-2" id="text-1">
|
||||
<p>
|
||||
This website contains the QMC tutorial of the 2021 LTTC winter school
|
||||
@ -510,8 +514,8 @@ coordinates, etc).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org4798a98" class="outline-3">
|
||||
<h3 id="org4798a98"><span class="section-number-3">1.1</span> Energy and local energy</h3>
|
||||
<div id="outline-container-org0c90626" class="outline-3">
|
||||
<h3 id="org0c90626"><span class="section-number-3">1.1</span> Energy and local energy</h3>
|
||||
<div class="outline-text-3" id="text-1-1">
|
||||
<p>
|
||||
For a given system with Hamiltonian \(\hat{H}\) and wave function \(\Psi\), we define the local energy as
|
||||
@ -594,8 +598,8 @@ energy computed over these configurations:
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgfc53e9e" class="outline-2">
|
||||
<h2 id="orgfc53e9e"><span class="section-number-2">2</span> Numerical evaluation of the energy of the hydrogen atom</h2>
|
||||
<div id="outline-container-org236e915" class="outline-2">
|
||||
<h2 id="org236e915"><span class="section-number-2">2</span> Numerical evaluation of the energy of the hydrogen atom</h2>
|
||||
<div class="outline-text-2" id="text-2">
|
||||
<p>
|
||||
In this section, we consider the hydrogen atom with the following
|
||||
@ -624,8 +628,8 @@ To do that, we will compute the local energy and check whether it is constant.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org57b7ef5" class="outline-3">
|
||||
<h3 id="org57b7ef5"><span class="section-number-3">2.1</span> Local energy</h3>
|
||||
<div id="outline-container-org20fce44" class="outline-3">
|
||||
<h3 id="org20fce44"><span class="section-number-3">2.1</span> Local energy</h3>
|
||||
<div class="outline-text-3" id="text-2-1">
|
||||
<p>
|
||||
You will now program all quantities needed to compute the local energy of the H atom for the given wave function.
|
||||
@ -652,8 +656,8 @@ to catch the error.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org668920d" class="outline-4">
|
||||
<h4 id="org668920d"><span class="section-number-4">2.1.1</span> Exercise 1</h4>
|
||||
<div id="outline-container-org6aa2eea" class="outline-4">
|
||||
<h4 id="org6aa2eea"><span class="section-number-4">2.1.1</span> Exercise 1</h4>
|
||||
<div class="outline-text-4" id="text-2-1-1">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -698,8 +702,8 @@ and returns the potential.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org46559e7" class="outline-5">
|
||||
<h5 id="org46559e7"><span class="section-number-5">2.1.1.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-orgea8540d" class="outline-5">
|
||||
<h5 id="orgea8540d"><span class="section-number-5">2.1.1.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-1-1-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -740,8 +744,8 @@ and returns the potential.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org08f0363" class="outline-4">
|
||||
<h4 id="org08f0363"><span class="section-number-4">2.1.2</span> Exercise 2</h4>
|
||||
<div id="outline-container-orga99da73" class="outline-4">
|
||||
<h4 id="orga99da73"><span class="section-number-4">2.1.2</span> Exercise 2</h4>
|
||||
<div class="outline-text-4" id="text-2-1-2">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -776,8 +780,8 @@ input arguments, and returns a scalar.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org385509d" class="outline-5">
|
||||
<h5 id="org385509d"><span class="section-number-5">2.1.2.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-orgf3fa97e" class="outline-5">
|
||||
<h5 id="orgf3fa97e"><span class="section-number-5">2.1.2.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-1-2-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -804,8 +808,8 @@ input arguments, and returns a scalar.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgdbd4a06" class="outline-4">
|
||||
<h4 id="orgdbd4a06"><span class="section-number-4">2.1.3</span> Exercise 3</h4>
|
||||
<div id="outline-container-orgb83dff4" class="outline-4">
|
||||
<h4 id="orgb83dff4"><span class="section-number-4">2.1.3</span> Exercise 3</h4>
|
||||
<div class="outline-text-4" id="text-2-1-3">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -886,8 +890,8 @@ Therefore, the local kinetic energy is
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgdd8f833" class="outline-5">
|
||||
<h5 id="orgdd8f833"><span class="section-number-5">2.1.3.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-orge819a18" class="outline-5">
|
||||
<h5 id="orge819a18"><span class="section-number-5">2.1.3.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-1-3-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -928,8 +932,8 @@ Therefore, the local kinetic energy is
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgb04b7f7" class="outline-4">
|
||||
<h4 id="orgb04b7f7"><span class="section-number-4">2.1.4</span> Exercise 4</h4>
|
||||
<div id="outline-container-orgd73f763" class="outline-4">
|
||||
<h4 id="orgd73f763"><span class="section-number-4">2.1.4</span> Exercise 4</h4>
|
||||
<div class="outline-text-4" id="text-2-1-4">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -988,8 +992,8 @@ are calling is yours.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgc1c0619" class="outline-5">
|
||||
<h5 id="orgc1c0619"><span class="section-number-5">2.1.4.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-org37ddd7b" class="outline-5">
|
||||
<h5 id="org37ddd7b"><span class="section-number-5">2.1.4.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-1-4-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -1020,8 +1024,8 @@ are calling is yours.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org3b484c9" class="outline-4">
|
||||
<h4 id="org3b484c9"><span class="section-number-4">2.1.5</span> Exercise 5</h4>
|
||||
<div id="outline-container-org0448ef8" class="outline-4">
|
||||
<h4 id="org0448ef8"><span class="section-number-4">2.1.5</span> Exercise 5</h4>
|
||||
<div class="outline-text-4" id="text-2-1-5">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -1031,8 +1035,8 @@ Find the theoretical value of \(a\) for which \(\Psi\) is an eigenfunction of \(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org4d9621e" class="outline-5">
|
||||
<h5 id="org4d9621e"><span class="section-number-5">2.1.5.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-orgc6d6285" class="outline-5">
|
||||
<h5 id="orgc6d6285"><span class="section-number-5">2.1.5.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-1-5-1">
|
||||
\begin{eqnarray*}
|
||||
E &=& \frac{\hat{H} \Psi}{\Psi} = - \frac{1}{2} \frac{\Delta \Psi}{\Psi} -
|
||||
@ -1052,8 +1056,8 @@ equal to -0.5 atomic units.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org4ea3772" class="outline-3">
|
||||
<h3 id="org4ea3772"><span class="section-number-3">2.2</span> Plot of the local energy along the \(x\) axis</h3>
|
||||
<div id="outline-container-orgacb0e57" class="outline-3">
|
||||
<h3 id="orgacb0e57"><span class="section-number-3">2.2</span> Plot of the local energy along the \(x\) axis</h3>
|
||||
<div class="outline-text-3" id="text-2-2">
|
||||
<p>
|
||||
The program you will write in this section will be written in
|
||||
@ -1084,8 +1088,8 @@ In Fortran, you will need to compile all the source files together:
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgaa030b2" class="outline-4">
|
||||
<h4 id="orgaa030b2"><span class="section-number-4">2.2.1</span> Exercise</h4>
|
||||
<div id="outline-container-orgb0b40fb" class="outline-4">
|
||||
<h4 id="orgb0b40fb"><span class="section-number-4">2.2.1</span> Exercise</h4>
|
||||
<div class="outline-text-4" id="text-2-2-1">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -1179,8 +1183,8 @@ plot './data' index 0 using 1:2 with lines title 'a=0.1', \
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org724a0e8" class="outline-5">
|
||||
<h5 id="org724a0e8"><span class="section-number-5">2.2.1.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-orgd3b3255" class="outline-5">
|
||||
<h5 id="orgd3b3255"><span class="section-number-5">2.2.1.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-2-1-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -1257,8 +1261,8 @@ plt.savefig(<span style="color: #8b2252;">"plot_py.png"</span>)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org72726f5" class="outline-3">
|
||||
<h3 id="org72726f5"><span class="section-number-3">2.3</span> Numerical estimation of the energy</h3>
|
||||
<div id="outline-container-orgf2d1b9f" class="outline-3">
|
||||
<h3 id="orgf2d1b9f"><span class="section-number-3">2.3</span> Numerical estimation of the energy</h3>
|
||||
<div class="outline-text-3" id="text-2-3">
|
||||
<p>
|
||||
If the space is discretized in small volume elements \(\mathbf{r}_i\)
|
||||
@ -1288,8 +1292,8 @@ The energy is biased because:
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-org6eb7d45" class="outline-4">
|
||||
<h4 id="org6eb7d45"><span class="section-number-4">2.3.1</span> Exercise</h4>
|
||||
<div id="outline-container-org37958cd" class="outline-4">
|
||||
<h4 id="org37958cd"><span class="section-number-4">2.3.1</span> Exercise</h4>
|
||||
<div class="outline-text-4" id="text-2-3-1">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -1360,8 +1364,8 @@ To compile the Fortran and run it:
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org59929b3" class="outline-5">
|
||||
<h5 id="org59929b3"><span class="section-number-5">2.3.1.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-org0a6757b" class="outline-5">
|
||||
<h5 id="org0a6757b"><span class="section-number-5">2.3.1.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-3-1-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -1478,8 +1482,8 @@ a = 2.0000000000000000 E = -8.0869806678448772E-002
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org5a9cc67" class="outline-3">
|
||||
<h3 id="org5a9cc67"><span class="section-number-3">2.4</span> Variance of the local energy</h3>
|
||||
<div id="outline-container-org3a5c93e" class="outline-3">
|
||||
<h3 id="org3a5c93e"><span class="section-number-3">2.4</span> Variance of the local energy</h3>
|
||||
<div class="outline-text-3" id="text-2-4">
|
||||
<p>
|
||||
The variance of the local energy is a functional of \(\Psi\)
|
||||
@ -1506,8 +1510,8 @@ energy can be used as a measure of the quality of a wave function.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgdca84d5" class="outline-4">
|
||||
<h4 id="orgdca84d5"><span class="section-number-4">2.4.1</span> Exercise (optional)</h4>
|
||||
<div id="outline-container-orgf25a4df" class="outline-4">
|
||||
<h4 id="orgf25a4df"><span class="section-number-4">2.4.1</span> Exercise (optional)</h4>
|
||||
<div class="outline-text-4" id="text-2-4-1">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -1518,8 +1522,8 @@ Prove that :
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org1c8885c" class="outline-5">
|
||||
<h5 id="org1c8885c"><span class="section-number-5">2.4.1.1</span> <span class="done DONE">DONE</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-org7cfa378" class="outline-5">
|
||||
<h5 id="org7cfa378"><span class="section-number-5">2.4.1.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-4-1-1">
|
||||
<p>
|
||||
\(\bar{E} = \langle E \rangle\) is a constant, so \(\langle \bar{E}
|
||||
@ -1538,8 +1542,8 @@ Prove that :
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org6240c00" class="outline-4">
|
||||
<h4 id="org6240c00"><span class="section-number-4">2.4.2</span> Exercise</h4>
|
||||
<div id="outline-container-org82674e9" class="outline-4">
|
||||
<h4 id="org82674e9"><span class="section-number-4">2.4.2</span> Exercise</h4>
|
||||
<div class="outline-text-4" id="text-2-4-2">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -1615,8 +1619,8 @@ To compile and run:
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org7a641d8" class="outline-5">
|
||||
<h5 id="org7a641d8"><span class="section-number-5">2.4.2.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-org984e04b" class="outline-5">
|
||||
<h5 id="org984e04b"><span class="section-number-5">2.4.2.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-2-4-2-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -1755,8 +1759,8 @@ a = 2.0000000000000000 E = -8.0869806678448772E-002 s2 = 1.8068814
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgaf4dafc" class="outline-2">
|
||||
<h2 id="orgaf4dafc"><span class="section-number-2">3</span> Variational Monte Carlo</h2>
|
||||
<div id="outline-container-orged64ccd" class="outline-2">
|
||||
<h2 id="orged64ccd"><span class="section-number-2">3</span> Variational Monte Carlo</h2>
|
||||
<div class="outline-text-2" id="text-3">
|
||||
<p>
|
||||
Numerical integration with deterministic methods is very efficient
|
||||
@ -1772,8 +1776,8 @@ interval.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgc635579" class="outline-3">
|
||||
<h3 id="orgc635579"><span class="section-number-3">3.1</span> Computation of the statistical error</h3>
|
||||
<div id="outline-container-org01e38cc" class="outline-3">
|
||||
<h3 id="org01e38cc"><span class="section-number-3">3.1</span> Computation of the statistical error</h3>
|
||||
<div class="outline-text-3" id="text-3-1">
|
||||
<p>
|
||||
To compute the statistical error, you need to perform \(M\)
|
||||
@ -1813,8 +1817,8 @@ And the confidence interval is given by
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org0dbd817" class="outline-4">
|
||||
<h4 id="org0dbd817"><span class="section-number-4">3.1.1</span> Exercise</h4>
|
||||
<div id="outline-container-org0dbdc24" class="outline-4">
|
||||
<h4 id="org0dbdc24"><span class="section-number-4">3.1.1</span> Exercise</h4>
|
||||
<div class="outline-text-4" id="text-3-1-1">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -1854,8 +1858,8 @@ input array.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org9bf5d86" class="outline-5">
|
||||
<h5 id="org9bf5d86"><span class="section-number-5">3.1.1.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-orgdfc0533" class="outline-5">
|
||||
<h5 id="orgdfc0533"><span class="section-number-5">3.1.1.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-3-1-1-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -1916,8 +1920,8 @@ input array.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgc075f26" class="outline-3">
|
||||
<h3 id="orgc075f26"><span class="section-number-3">3.2</span> Uniform sampling in the box</h3>
|
||||
<div id="outline-container-orgfd318d6" class="outline-3">
|
||||
<h3 id="orgfd318d6"><span class="section-number-3">3.2</span> Uniform sampling in the box</h3>
|
||||
<div class="outline-text-3" id="text-3-2">
|
||||
<p>
|
||||
We will now perform our first Monte Carlo calculation to compute the
|
||||
@ -1978,8 +1982,8 @@ compute the statistical error.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org2193660" class="outline-4">
|
||||
<h4 id="org2193660"><span class="section-number-4">3.2.1</span> Exercise</h4>
|
||||
<div id="outline-container-org74432b8" class="outline-4">
|
||||
<h4 id="org74432b8"><span class="section-number-4">3.2.1</span> Exercise</h4>
|
||||
<div class="outline-text-4" id="text-3-2-1">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -2081,8 +2085,8 @@ well as the index of the current step.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orge564bf3" class="outline-5">
|
||||
<h5 id="orge564bf3"><span class="section-number-5">3.2.1.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-org99a7b2f" class="outline-5">
|
||||
<h5 id="org99a7b2f"><span class="section-number-5">3.2.1.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-3-2-1-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -2188,8 +2192,8 @@ E = -0.48084122147238995 +/- 2.4983775878329355E-003
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org49db507" class="outline-3">
|
||||
<h3 id="org49db507"><span class="section-number-3">3.3</span> Metropolis sampling with \(\Psi^2\)</h3>
|
||||
<div id="outline-container-orgcddcdcf" class="outline-3">
|
||||
<h3 id="orgcddcdcf"><span class="section-number-3">3.3</span> Metropolis sampling with \(\Psi^2\)</h3>
|
||||
<div class="outline-text-3" id="text-3-3">
|
||||
<p>
|
||||
We will now use the square of the wave function to sample random
|
||||
@ -2308,8 +2312,8 @@ All samples should be kept, from both accepted <i>and</i> rejected moves.
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-orgb9a128c" class="outline-4">
|
||||
<h4 id="orgb9a128c"><span class="section-number-4">3.3.1</span> Optimal step size</h4>
|
||||
<div id="outline-container-org8b3f6fe" class="outline-4">
|
||||
<h4 id="org8b3f6fe"><span class="section-number-4">3.3.1</span> Optimal step size</h4>
|
||||
<div class="outline-text-4" id="text-3-3-1">
|
||||
<p>
|
||||
If the box is infinitely small, the ratio will be very close
|
||||
@ -2344,8 +2348,8 @@ the same variable later on to store a time step.
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-org6d05d27" class="outline-4">
|
||||
<h4 id="org6d05d27"><span class="section-number-4">3.3.2</span> Exercise</h4>
|
||||
<div id="outline-container-orgd7c523f" class="outline-4">
|
||||
<h4 id="orgd7c523f"><span class="section-number-4">3.3.2</span> Exercise</h4>
|
||||
<div class="outline-text-4" id="text-3-3-2">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -2454,8 +2458,8 @@ Can you observe a reduction in the statistical error?
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgae06be2" class="outline-5">
|
||||
<h5 id="orgae06be2"><span class="section-number-5">3.3.2.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-orgac64351" class="outline-5">
|
||||
<h5 id="orgac64351"><span class="section-number-5">3.3.2.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-3-3-2-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -2602,8 +2606,8 @@ A = 0.50762633333333318 +/- 3.4601756760043725E-004
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgce90675" class="outline-3">
|
||||
<h3 id="orgce90675"><span class="section-number-3">3.4</span> Generalized Metropolis algorithm</h3>
|
||||
<div id="outline-container-org4f2ffad" class="outline-3">
|
||||
<h3 id="org4f2ffad"><span class="section-number-3">3.4</span> Generalized Metropolis algorithm</h3>
|
||||
<div class="outline-text-3" id="text-3-4">
|
||||
<p>
|
||||
One can use more efficient numerical schemes to move the electrons by choosing a smarter expression for the transition probability.
|
||||
@ -2724,8 +2728,8 @@ The algorithm of the previous exercise is only slighlty modified as:
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org6a93c6c" class="outline-4">
|
||||
<h4 id="org6a93c6c"><span class="section-number-4">3.4.1</span> Gaussian random number generator</h4>
|
||||
<div id="outline-container-org6290597" class="outline-4">
|
||||
<h4 id="org6290597"><span class="section-number-4">3.4.1</span> Gaussian random number generator</h4>
|
||||
<div class="outline-text-4" id="text-3-4-1">
|
||||
<p>
|
||||
To obtain Gaussian-distributed random numbers, you can apply the
|
||||
@ -2789,8 +2793,8 @@ In Python, you can use the <a href="https://numpy.org/doc/stable/reference/rando
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-org661046d" class="outline-4">
|
||||
<h4 id="org661046d"><span class="section-number-4">3.4.2</span> Exercise 1</h4>
|
||||
<div id="outline-container-orgc3a15c4" class="outline-4">
|
||||
<h4 id="orgc3a15c4"><span class="section-number-4">3.4.2</span> Exercise 1</h4>
|
||||
<div class="outline-text-4" id="text-3-4-2">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -2832,8 +2836,8 @@ Write a function to compute the drift vector \(\frac{\nabla \Psi(\mathbf{r})}{\P
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgfb6225c" class="outline-5">
|
||||
<h5 id="orgfb6225c"><span class="section-number-5">3.4.2.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-org1bb7357" class="outline-5">
|
||||
<h5 id="org1bb7357"><span class="section-number-5">3.4.2.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-3-4-2-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -2866,8 +2870,8 @@ Write a function to compute the drift vector \(\frac{\nabla \Psi(\mathbf{r})}{\P
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgfe231df" class="outline-4">
|
||||
<h4 id="orgfe231df"><span class="section-number-4">3.4.3</span> Exercise 2</h4>
|
||||
<div id="outline-container-org3594157" class="outline-4">
|
||||
<h4 id="org3594157"><span class="section-number-4">3.4.3</span> Exercise 2</h4>
|
||||
<div class="outline-text-4" id="text-3-4-3">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -2963,8 +2967,8 @@ Modify the previous program to introduce the drift-diffusion scheme.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orga73cfde" class="outline-5">
|
||||
<h5 id="orga73cfde"><span class="section-number-5">3.4.3.1</span> Solution   <span class="tag"><span class="solution2">solution2</span></span></h5>
|
||||
<div id="outline-container-orgfe0293b" class="outline-5">
|
||||
<h5 id="orgfe0293b"><span class="section-number-5">3.4.3.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-3-4-3-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
@ -3152,8 +3156,8 @@ A = 0.62037333333333333 +/- 4.8970160591451110E-004
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org0d4554c" class="outline-2">
|
||||
<h2 id="org0d4554c"><span class="section-number-2">4</span> Diffusion Monte Carlo</h2>
|
||||
<div id="outline-container-org3154c2b" class="outline-2">
|
||||
<h2 id="org3154c2b"><span class="section-number-2">4</span> Diffusion Monte Carlo</h2>
|
||||
<div class="outline-text-2" id="text-4">
|
||||
<p>
|
||||
As we have seen, Variational Monte Carlo is a powerful method to
|
||||
@ -3170,8 +3174,8 @@ finding a near-exact numerical solution to the Schrödinger equation.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgc93ceb9" class="outline-3">
|
||||
<h3 id="orgc93ceb9"><span class="section-number-3">4.1</span> Schrödinger equation in imaginary time</h3>
|
||||
<div id="outline-container-org7b4dacf" class="outline-3">
|
||||
<h3 id="org7b4dacf"><span class="section-number-3">4.1</span> Schrödinger equation in imaginary time</h3>
|
||||
<div class="outline-text-3" id="text-4-1">
|
||||
<p>
|
||||
Consider the time-dependent Schrödinger equation:
|
||||
@ -3239,8 +3243,8 @@ system.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org1224530" class="outline-3">
|
||||
<h3 id="org1224530"><span class="section-number-3">4.2</span> Relation to diffusion</h3>
|
||||
<div id="outline-container-orgd350691" class="outline-3">
|
||||
<h3 id="orgd350691"><span class="section-number-3">4.2</span> Relation to diffusion</h3>
|
||||
<div class="outline-text-3" id="text-4-2">
|
||||
<p>
|
||||
The <a href="https://en.wikipedia.org/wiki/Diffusion_equation">diffusion equation</a> of particles is given by
|
||||
@ -3320,8 +3324,8 @@ Therefore, in both cases, you are dealing with a "Bosonic" ground state.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org393a5ec" class="outline-3">
|
||||
<h3 id="org393a5ec"><span class="section-number-3">4.3</span> Importance sampling</h3>
|
||||
<div id="outline-container-org78b3d2b" class="outline-3">
|
||||
<h3 id="org78b3d2b"><span class="section-number-3">4.3</span> Importance sampling</h3>
|
||||
<div class="outline-text-3" id="text-4-3">
|
||||
<p>
|
||||
In a molecular system, the potential is far from being constant
|
||||
@ -3419,8 +3423,8 @@ energies computed with the trial wave function.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgecc90ea" class="outline-4">
|
||||
<h4 id="orgecc90ea"><span class="section-number-4">4.3.1</span> Appendix : Details of the Derivation</h4>
|
||||
<div id="outline-container-org7548f1f" class="outline-4">
|
||||
<h4 id="org7548f1f"><span class="section-number-4">4.3.1</span> Appendix : Details of the Derivation</h4>
|
||||
<div class="outline-text-4" id="text-4-3-1">
|
||||
<p>
|
||||
\[
|
||||
@ -3481,8 +3485,8 @@ Defining \(\Pi(\mathbf{r},t) = \psi(\mathbf{r},\tau)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org292fbee" class="outline-3">
|
||||
<h3 id="org292fbee"><span class="section-number-3">4.4</span> Pure Diffusion Monte Carlo</h3>
|
||||
<div id="outline-container-org4a7db09" class="outline-3">
|
||||
<h3 id="org4a7db09"><span class="section-number-3">4.4</span> Pure Diffusion Monte Carlo</h3>
|
||||
<div class="outline-text-3" id="text-4-4">
|
||||
<p>
|
||||
Instead of having a variable number of particles to simulate the
|
||||
@ -3571,13 +3575,13 @@ the DMC algorithm. However, its use reduces significantly the time-step error.</
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-orgce09db6" class="outline-3">
|
||||
<h3 id="orgce09db6"><span class="section-number-3">4.5</span> Hydrogen atom</h3>
|
||||
<div id="outline-container-orgb1e1f31" class="outline-3">
|
||||
<h3 id="orgb1e1f31"><span class="section-number-3">4.5</span> Hydrogen atom</h3>
|
||||
<div class="outline-text-3" id="text-4-5">
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgeda527c" class="outline-4">
|
||||
<h4 id="orgeda527c"><span class="section-number-4">4.5.1</span> Exercise</h4>
|
||||
<div id="outline-container-org10928e0" class="outline-4">
|
||||
<h4 id="org10928e0"><span class="section-number-4">4.5.1</span> Exercise</h4>
|
||||
<div class="outline-text-4" id="text-4-5-1">
|
||||
<div class="exercise">
|
||||
<p>
|
||||
@ -3675,6 +3679,222 @@ time \(\tau_{\text{max}}\) =100 a.u.
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-sh">gfortran hydrogen.f90 qmc_stats.f90 pdmc.f90 -o pdmc
|
||||
./pdmc
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org834cb8c" class="outline-5">
|
||||
<h5 id="org834cb8c"><span class="section-number-5">4.5.1.1</span> Solution   <span class="tag"><span class="solution">solution</span></span></h5>
|
||||
<div class="outline-text-5" id="text-4-5-1-1">
|
||||
<p>
|
||||
<b>Python</b>
|
||||
</p>
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-python">#<span style="color: #b22222;">!/usr/bin/env python3</span>
|
||||
|
||||
<span style="color: #a020f0;">from</span> hydrogen <span style="color: #a020f0;">import</span> *
|
||||
<span style="color: #a020f0;">from</span> qmc_stats <span style="color: #a020f0;">import</span> *
|
||||
|
||||
<span style="color: #a020f0;">def</span> <span style="color: #0000ff;">MonteCarlo</span>(a, nmax, dt, tau, Eref):
|
||||
<span style="color: #a0522d;">sq_dt</span> = np.sqrt(dt)
|
||||
|
||||
<span style="color: #a0522d;">energy</span> = 0.
|
||||
<span style="color: #a0522d;">N_accep</span> = 0
|
||||
<span style="color: #a0522d;">normalization</span> = 0.
|
||||
|
||||
<span style="color: #a0522d;">w</span> = 1.
|
||||
<span style="color: #a0522d;">tau_current</span> = 0.
|
||||
|
||||
<span style="color: #a0522d;">r_old</span> = np.random.normal(loc=0., scale=1.0, size=(3))
|
||||
<span style="color: #a0522d;">d_old</span> = drift(a,r_old)
|
||||
<span style="color: #a0522d;">d2_old</span> = np.dot(d_old,d_old)
|
||||
<span style="color: #a0522d;">psi_old</span> = psi(a,r_old)
|
||||
|
||||
<span style="color: #a020f0;">for</span> istep <span style="color: #a020f0;">in</span> <span style="color: #483d8b;">range</span>(nmax):
|
||||
<span style="color: #a0522d;">el</span> = e_loc(a,r_old)
|
||||
<span style="color: #a0522d;">w</span> *= np.exp(-dt*(el - Eref))
|
||||
|
||||
<span style="color: #a0522d;">normalization</span> += w
|
||||
<span style="color: #a0522d;">energy</span> += w * el
|
||||
|
||||
<span style="color: #a0522d;">tau_current</span> += dt
|
||||
|
||||
# <span style="color: #b22222;">Reset when tau is reached</span>
|
||||
<span style="color: #a020f0;">if</span> tau_current > tau:
|
||||
<span style="color: #a0522d;">w</span> = 1.
|
||||
<span style="color: #a0522d;">tau_current</span> = 0.
|
||||
|
||||
<span style="color: #a0522d;">chi</span> = np.random.normal(loc=0., scale=1.0, size=(3))
|
||||
|
||||
<span style="color: #a0522d;">r_new</span> = r_old + dt * d_old + sq_dt * chi
|
||||
<span style="color: #a0522d;">d_new</span> = drift(a,r_new)
|
||||
<span style="color: #a0522d;">d2_new</span> = np.dot(d_new,d_new)
|
||||
<span style="color: #a0522d;">psi_new</span> = psi(a,r_new)
|
||||
|
||||
# <span style="color: #b22222;">Metropolis</span>
|
||||
<span style="color: #a0522d;">prod</span> = np.dot((d_new + d_old), (r_new - r_old))
|
||||
<span style="color: #a0522d;">argexpo</span> = 0.5 * (d2_new - d2_old)*dt + prod
|
||||
|
||||
<span style="color: #a0522d;">q</span> = psi_new / psi_old
|
||||
<span style="color: #a0522d;">q</span> = np.exp(-argexpo) * q*q
|
||||
|
||||
<span style="color: #a020f0;">if</span> np.random.uniform() <= q:
|
||||
<span style="color: #a0522d;">N_accep</span> += 1
|
||||
<span style="color: #a0522d;">r_old</span> = r_new
|
||||
<span style="color: #a0522d;">d_old</span> = d_new
|
||||
<span style="color: #a0522d;">d2_old</span> = d2_new
|
||||
<span style="color: #a0522d;">psi_old</span> = psi_new
|
||||
|
||||
<span style="color: #a020f0;">return</span> energy/normalization, N_accep/nmax
|
||||
|
||||
|
||||
# <span style="color: #b22222;">Run simulation</span>
|
||||
<span style="color: #a0522d;">a</span> = 1.2
|
||||
<span style="color: #a0522d;">nmax</span> = 100000
|
||||
<span style="color: #a0522d;">dt</span> = 0.05
|
||||
<span style="color: #a0522d;">tau</span> = 100.
|
||||
<span style="color: #a0522d;">E_ref</span> = -0.5
|
||||
|
||||
<span style="color: #a0522d;">X0</span> = [ MonteCarlo(a, nmax, dt, tau, E_ref) <span style="color: #a020f0;">for</span> i <span style="color: #a020f0;">in</span> <span style="color: #483d8b;">range</span>(30)]
|
||||
|
||||
# <span style="color: #b22222;">Energy</span>
|
||||
<span style="color: #a0522d;">X</span> = [ x <span style="color: #a020f0;">for</span> (x, _) <span style="color: #a020f0;">in</span> X0 ]
|
||||
<span style="color: #a0522d;">E</span>, <span style="color: #a0522d;">deltaE</span> = ave_error(X)
|
||||
<span style="color: #a020f0;">print</span>(f<span style="color: #8b2252;">"E = {E} +/- {deltaE}"</span>)
|
||||
|
||||
# <span style="color: #b22222;">Acceptance rate</span>
|
||||
<span style="color: #a0522d;">X</span> = [ x <span style="color: #a020f0;">for</span> (_, x) <span style="color: #a020f0;">in</span> X0 ]
|
||||
<span style="color: #a0522d;">A</span>, <span style="color: #a0522d;">deltaA</span> = ave_error(X)
|
||||
<span style="color: #a020f0;">print</span>(f<span style="color: #8b2252;">"A = {A} +/- {deltaA}"</span>)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<b>Fortran</b>
|
||||
</p>
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-f90"><span style="color: #a020f0;">subroutine</span> <span style="color: #0000ff;">pdmc</span>(a, dt, nmax, energy, accep, tau, E_ref)
|
||||
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
|
||||
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> a, dt, tau</span>
|
||||
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nmax </span>
|
||||
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> energy, accep</span>
|
||||
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> E_ref</span>
|
||||
|
||||
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> istep</span>
|
||||
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> n_accep</span>
|
||||
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> sq_dt, chi(3), d2_old, prod, u</span>
|
||||
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> psi_old, psi_new, d2_new, argexpo, q</span>
|
||||
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> r_old(3), r_new(3)</span>
|
||||
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> d_old(3), d_new(3)</span>
|
||||
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> e, w, norm, tau_current</span>
|
||||
|
||||
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">external</span> ::<span style="color: #a0522d;"> e_loc, psi</span>
|
||||
|
||||
sq_dt = dsqrt(dt)
|
||||
|
||||
! <span style="color: #b22222;">Initialization</span>
|
||||
energy = 0.d0
|
||||
n_accep = 0_8
|
||||
norm = 0.d0
|
||||
|
||||
w = 1.d0
|
||||
tau_current = 0.d0
|
||||
|
||||
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">random_gauss</span>(r_old,3)
|
||||
|
||||
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">drift</span>(a,r_old,d_old)
|
||||
d2_old = d_old(1)*d_old(1) + <span style="color: #a020f0;">&</span>
|
||||
d_old(2)*d_old(2) + <span style="color: #a020f0;">&</span>
|
||||
d_old(3)*d_old(3)
|
||||
|
||||
psi_old = psi(a,r_old)
|
||||
|
||||
<span style="color: #a020f0;">do</span> istep = 1,nmax
|
||||
e = e_loc(a,r_old)
|
||||
w = w * dexp(-dt*(e - E_ref))
|
||||
|
||||
norm = norm + w
|
||||
energy = energy + w*e
|
||||
|
||||
tau_current = tau_current + dt
|
||||
|
||||
! <span style="color: #b22222;">Reset when tau is reached</span>
|
||||
<span style="color: #a020f0;">if</span> (tau_current > tau) <span style="color: #a020f0;">then</span>
|
||||
w = 1.d0
|
||||
tau_current = 0.d0
|
||||
<span style="color: #a020f0;">endif</span>
|
||||
|
||||
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">random_gauss</span>(chi,3)
|
||||
r_new(:) = r_old(:) + dt*d_old(:) + chi(:)*sq_dt
|
||||
|
||||
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">drift</span>(a,r_new,d_new)
|
||||
d2_new = d_new(1)*d_new(1) + <span style="color: #a020f0;">&</span>
|
||||
d_new(2)*d_new(2) + <span style="color: #a020f0;">&</span>
|
||||
d_new(3)*d_new(3)
|
||||
|
||||
psi_new = psi(a,r_new)
|
||||
|
||||
! <span style="color: #b22222;">Metropolis</span>
|
||||
prod = (d_new(1) + d_old(1))*(r_new(1) - r_old(1)) + <span style="color: #a020f0;">&</span>
|
||||
(d_new(2) + d_old(2))*(r_new(2) - r_old(2)) + <span style="color: #a020f0;">&</span>
|
||||
(d_new(3) + d_old(3))*(r_new(3) - r_old(3))
|
||||
|
||||
argexpo = 0.5d0 * (d2_new - d2_old)*dt + prod
|
||||
|
||||
q = psi_new / psi_old
|
||||
q = dexp(-argexpo) * q*q
|
||||
|
||||
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">random_number</span>(u)
|
||||
|
||||
<span style="color: #a020f0;">if</span> (u <= q) <span style="color: #a020f0;">then</span>
|
||||
|
||||
n_accep = n_accep + 1_8
|
||||
|
||||
r_old(:) = r_new(:)
|
||||
d_old(:) = d_new(:)
|
||||
d2_old = d2_new
|
||||
psi_old = psi_new
|
||||
|
||||
<span style="color: #a020f0;">end if</span>
|
||||
|
||||
<span style="color: #a020f0;">end do</span>
|
||||
|
||||
energy = energy / norm
|
||||
accep = <span style="color: #a020f0;">dble</span>(n_accep) / <span style="color: #a020f0;">dble</span>(nmax)
|
||||
|
||||
<span style="color: #a020f0;">end subroutine</span> <span style="color: #0000ff;">pdmc</span>
|
||||
|
||||
<span style="color: #a020f0;">program</span> <span style="color: #0000ff;">qmc</span>
|
||||
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
|
||||
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">parameter</span> ::<span style="color: #a0522d;"> a = 1.2d0</span>
|
||||
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">parameter</span> ::<span style="color: #a0522d;"> dt = 0.05d0</span>
|
||||
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">parameter</span> ::<span style="color: #a0522d;"> E_ref = -0.5d0</span>
|
||||
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">parameter</span> ::<span style="color: #a0522d;"> tau = 100.d0</span>
|
||||
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">parameter</span> ::<span style="color: #a0522d;"> nmax = 100000</span>
|
||||
<span style="color: #228b22;">integer</span> , <span style="color: #a020f0;">parameter</span> ::<span style="color: #a0522d;"> nruns = 30</span>
|
||||
|
||||
<span style="color: #228b22;">integer</span> ::<span style="color: #a0522d;"> irun</span>
|
||||
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> X(nruns), accep(nruns)</span>
|
||||
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> ave, err</span>
|
||||
|
||||
<span style="color: #a020f0;">do</span> irun=1,nruns
|
||||
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">pdmc</span>(a, dt, nmax, X(irun), accep(irun), tau, E_ref)
|
||||
<span style="color: #a020f0;">enddo</span>
|
||||
|
||||
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">ave_error</span>(X,nruns,ave,err)
|
||||
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'E = '</span>, ave, <span style="color: #8b2252;">'+/-'</span>, err
|
||||
|
||||
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">ave_error</span>(accep,nruns,ave,err)
|
||||
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'A = '</span>, ave, <span style="color: #8b2252;">'+/-'</span>, err
|
||||
|
||||
<span style="color: #a020f0;">end program</span> <span style="color: #0000ff;">qmc</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<pre class="example">
|
||||
E = -0.49963953547336709 +/- 6.8755513992017491E-004
|
||||
A = 0.98963533333333342 +/- 6.3052128284666221E-005
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
@ -3684,8 +3904,8 @@ time \(\tau_{\text{max}}\) =100 a.u.
|
||||
|
||||
|
||||
|
||||
<div id="outline-container-orgf4f054d" class="outline-2">
|
||||
<h2 id="orgf4f054d"><span class="section-number-2">5</span> Project</h2>
|
||||
<div id="outline-container-org3be55e0" class="outline-2">
|
||||
<h2 id="org3be55e0"><span class="section-number-2">5</span> Project</h2>
|
||||
<div class="outline-text-2" id="text-5">
|
||||
<p>
|
||||
Change your PDMC code for one of the following:
|
||||
@ -3703,8 +3923,8 @@ And compute the ground state energy.
|
||||
|
||||
|
||||
|
||||
<div id="outline-container-org8424122" class="outline-2">
|
||||
<h2 id="org8424122"><span class="section-number-2">6</span> Acknowledgments</h2>
|
||||
<div id="outline-container-orgfa0dc42" class="outline-2">
|
||||
<h2 id="orgfa0dc42"><span class="section-number-2">6</span> Acknowledgments</h2>
|
||||
<div class="outline-text-2" id="text-6">
|
||||
|
||||
<div class="figure">
|
||||
@ -3724,7 +3944,7 @@ Union is not responsible for any use that might be made of such content.
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: Anthony Scemama, Claudia Filippi</p>
|
||||
<p class="date">Created: 2021-02-04 Thu 16:27</p>
|
||||
<p class="date">Created: 2021-02-04 Thu 18:12</p>
|
||||
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user