<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Dear Max,</p>
<p><br>
</p>
<p>Thanks for performing these tests!</p>
<p><br>
</p>
<p>I implemented Hubbard forces and stress with ortho-atomic orbitals, and I have thoroughly tested the implementation. I compared forces and stress computed using the exact analytical formulas versus finite differences, and the agreement was up to 10^{-6}
 Ry/Bohr which validates the implementation. I used the symmetric difference quotient (with the displacement parameter of 5 x 10^{-3} Bohr) to computed derivatives numerically:</p>
<p><a href="https://en.wikipedia.org/wiki/Numerical_differentiation" class="OWAAutoLink" id="LPlnk565393" previewremoved="true">https://en.wikipedia.org/wiki/Numerical_differentiation</a><br>
</p>
<p>For example, for NiO I obtained the following results:</p>
<p>Analytical:   F = -0.048891 Ry/Bohr</p>
<p>Numerical:  <span style="font-size: 12pt;">F = -0.048891 Ry/Bohr</span></p>
<p>As you can see forces agree up to <span style="font-size: 12pt;">10^{-6} Ry/Bohr. In a similar way I tested also stress.</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 15px;">> It seems that there is a bug in the implementation of the forces
 for U_projection_type = 'ortho-atomic’, or that some terms have been neglected when computing the derivatives.</span><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><font size="3">The analytical formulas are <b>exact</b>, we did not neglect anything. In fact, it took us a lot of time and effort to derive the exact formulas. Also I do not think that there is a bug, because my tests give excellent </font>agreement<font size="3"> between
 analytical and numerical derivatives for NiO and a couple of other systems.</font></p>
<p><font size="3"><br>
</font></p>
<p><font size="3">The path integral method looks to me a bit overkilling. Why not simply to compute the total energy for two atomic configurations and then simply divide the difference of energies by the difference in atomic positions (I mean only one atom
 must be slightly displaced at a time), i.e. [ E(x + delta) - E(x - delta) ] / (2*delta)? But in any case, since your method works well for standard DFT forces and DFT+U atomic forces, then we should try to understand why it gives weird results for the ortho-atomic
 case. </font></p>
<p><font size="3"><br>
</font></p>
<p><font size="3">Which version of Quantum ESPRESSO did you use? Was it 6.6 without any modifications, or did you apply the patch which I sent to you in the QE developers mailing list shortly after the release of QE 6.6? Are you running on your workstation
 or on Piz Daint (should not matter but good to know)? Which compilers and libraries do you use? </font></p>
<p><font size="3">Perhaps, you can try to increase the kinetic-energy cutoff and see if the agreement for the ortho-atomic case is better. Forces and stress converge slowly with respect to the cutoff (and maybe ortho-atomic case is even slower, but in my tests
 I did not observe this though). Also, maybe it would useful to try other compilers and libraries.</font></p>
<p><font size="3">If you want I can send you my input files for NiO which I used for the benchmarking and we can see what do you obtain using the path integral approach. Would you be so kind to perform these tests? On my side I can compute forces with finite
 differences for your system - could you send to me please the input and output files for reference?</font></p>
<p><font size="3"><br>
</font></p>
<p><span style="caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 15px;">> In the long run, it might be helpful to include such tests routinely
 as part of the QE development process.</span><font size="3"><br>
</font></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><font size="3">The QE </font>developers<font size="3"> team makes big effort to benchmark various functionalities of QE before the release and during the development process. In particular, we have a test suite with many examples which are used to benchmark
 various codes and various functionalities. For the DFT+Hubbard ortho-atomic forces, I tested everything using finite differences (as described above), I was convinced that all is good, and only then I added tests to the test suite. So we do care a lot about
 testing and benchmarking, but of course sometimes there maybe be some bugs which were overlooked or which comes for some other reason.</font></p>
<p><font size="3"><br>
</font></p>
<p><font size="3">Greetings,</font></p>
<p><font size="3">Iurii</font></p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<font size="3" face="'Times New Roman', Times, serif" color="808080">--<br>
Dr. Iurii TIMROV<br>
Postdoctoral Researcher<br>
<font color="808080"><font face="'Times New Roman', Times, serif"></font></font></font></div>
<font color="808080"></font>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<font size="3" face="'Times New Roman', Times, serif" color="808080">STI - IMX <font color="808080">
<font face="'Times New Roman', Times, serif">- THEOS</font></font></font><font size="3" face="'Times New Roman', Times, serif" color="808080"> and NCCR - MARVEL<br>
</font></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<font size="3" face="'Times New Roman', Times, serif" color="808080"><font size="3" face="'Times New Roman', Times, serif" color="808080">Swiss Federal Institute of Technology Lausanne (EPFL<font color="808080"><font face="'Times New Roman', Times, serif">)</font></font></font><br>
</font></div>
<font color="808080"></font>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<font size="3" face="'Times New Roman', Times, serif" color="808080">CH-1015 Lausanne, Switzerland<br>
+41 21 69 34 881</font></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<a href="http://people.epfl.ch/265334" tabindex="0" id="LPNoLP">http://people.epfl.ch/265334</a><br>
</div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> developers <developers-bounces@lists.quantum-espresso.org> on behalf of Max Amsler <amsler.max@gmail.com><br>
<b>Sent:</b> Saturday, September 12, 2020 12:44:33 PM<br>
<b>To:</b> General discussion list for Quantum ESPRESSO developers<br>
<b>Subject:</b> [QE-developers] Forces are not exact derivatives of the energy for U_projection_type = 'ortho-atomic'</font>
<div> </div>
</div>
<div>
<div class="" style="word-wrap:break-word; line-break:after-white-space">
<div class="">Dear all,</div>
After extensively testing the recently implemented forces for U_projection_type = 'ortho-atomic’, I have come across several cases where the geometry optimizations would fail: the energy would fluctuate without convergence using BFGS, and even damped dynamics
 would frequently not converge. Such a behavior usually points to a problem with the forces, which are either not exact or noisy.
<div class=""><br class="">
</div>
<div class="">Based on this observation, I decided to perform a routine test: I compute the integral of the forces times displacement along a path in configurational space, and compare it with the energy difference between the initial and final point. If the
 forces are exact derivatives of the energy, the path integral must be identical to the energy difference (up to machine precision if the step size of the path integral goes to zero). The method is described in sec 3.3, <a href="https://doi.org/10.1016/j.cpc.2020.107415" class="">https://doi.org/10.1016/j.cpc.2020.107415</a>,
 see also the attachment of the relevant section.  </div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""></div>
</div>
<div style="word-wrap:break-word; line-break:after-white-space">
<div class=""></div>
<div class=""><br class="">
</div>
<div class="">I performed this test for a TiO2 Rutile structure with 6 atoms per cellI, along a path in a random direction with 0.001 Ang step size and with a total of 501 steps. I used 3 different settings: DFT without U, DFT+U with U_projection_type = ‘atomic’
 (U=4.7147), and DFT+U with U_projection_type = 'ortho-atomic’ (U=4.7147). In the case of No-U and ‘atomic’, the relative error of the path integral and energy difference is less than1.d-4%, as expected when the forces are correct. But for 'ortho-atomic’ the
 relative error is a whopping 8%! This indicates that the forces are not the exact derivatives of the energy for U_projection_type = 'ortho-atomic’ (see also plot below, note that the y scale is logarithmic for the last two subplots).</div>
<div class=""><br class="">
</div>
<div class=""></div>
</div>
<div class="" style="word-wrap:break-word; line-break:after-white-space">
<div class=""></div>
<div class=""><br class="">
</div>
<div class="">It seems that there is a bug in the implementation of the forces for U_projection_type = 'ortho-atomic’, or that some terms have been neglected when computing the derivatives.</div>
<div class=""><br class="">
</div>
<div class="">In the long run, it might be helpful to include such tests routinely as part of the QE development process.</div>
<div class=""><br class="">
</div>
<div class="">Best</div>
<div class="">Max</div>
</div>
</div>
</body>
</html>