<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Dear QE community,<br><br>I am new to ab initio program implementation. Recently I am studying the cg solver in KS_Solvers/CG/ccgdiagg.f90. And I found the algorithm in the paper <a href="https://arxiv.org/pdf/0906.2569">https://arxiv.org/pdf/0906.2569</a> (QUANTUM ESPRESSO: a modular and open-source software project for quantum simulations of materials), which published in 2009. I carefully read the Appendix A.2. Iterative diagonalization and formula <b>(A.8)</b> to <b>(A.22) </b>which corresponds to conjugate gradient method. However, I am struggling in understanding some pieces of code in the <i><b>ccgdiagg.f90</b></i>.<br><br>For the code in the No.164 to No.188 as listed here:<div><br></div><div>‘’’</div><div><pre class="code highlight" lang="fortran"><span> </span><span class="hljs-comment">!</span><span></span>
<span> </span><span class="hljs-comment"><span class="hljs-comment">! ...</span><span class="hljs-comment"> start iteration for </span><span class="hljs-comment">this band</span></span><span></span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> iterate: </span><span class="hljs-keyword">DO</span><span> iter = </span><span class="hljs-number">1</span><span>, maxter</span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> </span><span class="hljs-comment">! ... calculate P (PHP)|y></span><span></span>
<span> </span><span class="hljs-comment">! ... ( P = preconditioning matrix, assumed diagonal )</span><span></span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> g(:) = hpsi(:) / precondition(:)</span>
<span> ppsi(:) = spsi(:) / precondition(:)</span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> </span><span class="hljs-comment"><span class="hljs-comment">! ...</span><span class="hljs-comment"> ppsi is now </span><span class="hljs-comment">S P(P^2)|y> = S P^2|psi>)</span></span><span></span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> es(</span><span class="hljs-number">1</span><span>) = ddot( kdim2, spsi(</span><span class="hljs-number">1</span><span>), </span><span class="hljs-number">1</span><span>, g(</span><span class="hljs-number">1</span><span>), </span><span class="hljs-number">1</span><span> )</span>
<span> es(</span><span class="hljs-number">2</span><span>) = ddot( kdim2, spsi(</span><span class="hljs-number">1</span><span>), </span><span class="hljs-number">1</span><span>, ppsi(</span><span class="hljs-number">1</span><span>), </span><span class="hljs-number">1</span><span> )</span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> </span><span class="hljs-keyword">CALL</span><span> mp_sum( es , intra_bgrp_comm )</span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> es(</span><span class="hljs-number">1</span><span>) = es(</span><span class="hljs-number">1</span><span>) / es(</span><span class="hljs-number">2</span><span>)</span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> g(:) = g(:) - es(</span><span class="hljs-number">1</span><span>) * ppsi(:)</span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> </span><span class="hljs-comment">! ... e1 = <y| S P^2 PHP|y> / <y| S S P^2|y> ensures that </span><span></span>
<span> </span><span class="hljs-comment">! ... <g| S P^2|y> = 0</span><span></span>
<span> </span><span class="hljs-comment"><span class="hljs-comment">! ...</span><span class="hljs-comment"> orthogonalize to lowest </span><span class="hljs-comment">eigenfunctions (already calculated)</span></span><span></span>
<span> </span><span class="hljs-comment">!</span><span></span>
<span> </span><span class="hljs-comment"><span class="hljs-comment">! ...</span><span class="hljs-comment"> scg is used </span><span class="hljs-comment">as workspace</span></span><span></span>
<span> </span><span class="hljs-comment">!</span></pre></div><div>‘’’<br>As we know that <b>hpsi = H |psi> = H P |y></b>, since <b>|y> = P^(-1) |psi> </b>and <b>P</b> is precondition matrix. Then <b>g(:) = hpsi(:) / precondition(:)</b> , seems imply <b>g(:) ==> P^(-1) H P |y></b>, and similarly that <b>ppsi(:) ==> P^(-1) S P |y></b>. Now the question arrives, why the comment inside the code says that “<i><span class="hljs-comment">! ...</span><span class="hljs-comment"> ppsi is now </span><span class="hljs-comment">S P(P^2)|y> = S P^2|psi>)</span></i>” ?</div><div><br></div><div>And as for <b>es(1)</b> and<b> es(2)</b>, it seems <b>es(1) ==> <y| P S P^(-1) H P |y></b>, <b>es(2) ==> <y| P S P^(-1) S P |y ></b>. That are quiet different from that in the comment “ <u>e1 = <y| S P^2 PHP|y> / <y| S S P^2|y></u>”.</div><div><br></div><div>Is there any clue or reference materials to help understand that? </div><div><br>Sincerely,<br>HF Wang<br><br><div></div></div><div></div></body></html>