<div dir='auto'>Do you mean 1e-8 in single or double precision? I assume you mean single. Since angles are of order 1, a difference of 1e-8 is beyond the precision of the total force (unless you have a trivial system with only one angle as the potential).<div dir="auto"><br></div><div dir="auto">Cheers,</div><div dir="auto"><br></div><div dir="auto">Berk</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Oct 29, 2017 12:00 AM, Pavel Panchekha &lt;me@pavpanchekha.com&gt; wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small">Berk, thank you for the reply. The quality of the GROMACS source code is clear from reading it.</div><div style="font-size:small"><br /></div><div style="font-size:small">Thank you for explaining that the sign is not used except in computing the angle. Do you know how much error in the angle is acceptable? I am trying some variations on the dihedral angle computation and seeing answers that differ by 1e-8. Could that small a difference possibly matter?<br /></div><div style="font-size:small"><br /></div><div style="font-size:small">I&#39;ve noticed that earlier versions of GROMACS used a slightly different formula to compute <u>dih_angle</u> (using <u>acos</u> instead of <u>atan2</u>). Did the switch cause any known changes in behavior?<br /></div></div><div><br clear="all" /><div><div data-smartmail="gmail_signature"><div dir="ltr">—Pavel Panchekha</div></div></div>
<br /><div class="elided-text">On Sat, Oct 28, 2017 at 1:06 AM, Berk Hess <span dir="ltr">&lt;<a href="mailto:hess&#64;kth.se">hess&#64;kth.se</a>&gt;</span> wrote:<br /><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div>
    <div>Hi,<br />
      <br />
      In molecular dynamics it&#39;s rather likely that you hit corner
      cases, so we pay a lot of attention to numerical issues when
      writing and reviewing code. Therefore it is unlikely that there
      are cases that can be improved, but you are welcome to look.<br />
      <br />
      It is good that you mention the sign in dihedral angle. The return
      value is actually never used. The sign is only used to set the
      sign of the angle, which switches at angle&#61;0, so there is no
      stability issue.<br />
      <br />
      Cheers,<br />
      <br />
      Berk<div><div><br />
      <br />
      On 10/28/2017 07:16 AM, Pavel Panchekha wrote:<br />
    </div></div></div><div><div>
    <blockquote>
      
      <div dir="ltr">
        <div style="font-size:small">Hello,</div>
        <div style="font-size:small"><br />
        </div>
        <div style="font-size:small">I&#39;m a student
          at the University of Washington working on numerical accuracy,
          and I&#39;ve been looking into GROMACS as an example of a beloved
          and important large numerical program. Browsing through the
          code base, I was struck by the computation of the dihedral
          angle in <u>bonded.c</u>, at line 1569 (in GROMACS 5.1.4).</div>
        <div style="font-size:small"><br />
        </div>
        <div style="font-size:small">I wonder if
          it is possible for the <u>sign</u> variable to get the wrong
          value, if the input points are close to one another or have
          some other reason to experience cancellation when doing the
          cross product. I think this is fixable using an adaptive
          algorithm. Could changing the sign of the angle computed by <u>dih_angle</u>
          affect GROMACS&#39;s results?<br />
        </div>
        <div style="font-size:small"><br />
        </div>
        <div style="font-size:small">More broadly,
          has anyone ever had numerical accuracy issues with GROMACS?
          Would there be interest in reviewing a patch that improved the
          accuracy (for edge case inputs) for the dihedral angle
          computation?<br />
        </div>
        <div style="font-size:small"><br clear="all" />
        </div>
        <div>
          <div data-smartmail="gmail_signature">
            <div dir="ltr">—Pavel Panchekha</div>
          </div>
        </div>
      </div>
      <br />
      <fieldset></fieldset>
      <br />
    </blockquote>
    <br />
  </div></div></div>

<br />--<br />
Gromacs Developers mailing list<br />
<br />
* Please search the archive at <a href="http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List">http://www.gromacs.org/<wbr />Support/Mailing_Lists/GMX-<wbr />developers_List</a> before posting!<br />
<br />
* Can&#39;t post? Read <a href="http://www.gromacs.org/Support/Mailing_Lists">http://www.gromacs.org/<wbr />Support/Mailing_Lists</a><br />
<br />
* For (un)subscribe requests visit<br />
<a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers">https://maillist.sys.kth.se/<wbr />mailman/listinfo/gromacs.org_<wbr />gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request&#64;gromacs.org">gmx-developers-request&#64;<wbr />gromacs.org</a>.<br /></blockquote></div><br /></div>
</blockquote></div><br></div>