<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi,<br><br>I don't know what is going wrong in your calculations.<br><br>I repeated your calculations with a script for many distances<br>and the forces perfectly match the numerical derivative of the potential.<br><br>Example: distance, pot, force:<br>3.998 -40.569943757001 -5.14772e+00<br>4.000 -40.559660943670 -5.13585e+00<br>4.002 -40.549401856871 -5.12399e+00<br><br>The numerical derivative of pot at d=4 (a=2) gives 5.135475,<br>which gives a difference of 0.0004 kJ/mol.<br>I expect this difference to go down if I take the points closer together.<br><br>Berk<br><br>&gt; Date: Sun, 14 Jun 2009 19:11:08 +0200<br>&gt; From: dommert@icp.uni-stuttgart.de<br>&gt; To: gmx-users@gromacs.org<br>&gt; Subject: [gmx-users] Electrostatic forces<br>&gt; <br>&gt; Hello Gromacs users and developers,<br>&gt; <br>&gt;    I have a few questions concerning the calculation of the electrostatic<br>&gt;    forces in Gromacs.<br>&gt; <br>&gt;    Unfortunately I am not able to reproduce the electrostatic forces<br>&gt;    computed by the gromacs code ( VERSION 4.0.99_DEAD_CVS_BRANCH_20090604<br>&gt;    (double precision), compiled on MacOS X 10.5 using its native gcc and<br>&gt;    no fortran compiler ) by a self written code , that also uses double<br>&gt;    precision, though the energies derived with the different codes match<br>&gt;    perfectly. To get an idea where the deviation stems from Berk already<br>&gt;    gave me the hint to setup following configuration:<br>&gt; <br>&gt;    A positive charge is located at (5.0+a,5.0,5.0) and a negative charge<br>&gt;    at (5.0-a,5.0,5.0) in a cubic box of size 10x10x10 and this setup for<br>&gt;    the electrostatic forces with an arbitrary parameter a, that allows me<br>&gt;    to control the strength of the interaction. Furthermore following<br>&gt;    mdp-parameter were applied to achieve a very high accuracy of the Ewald<br>&gt;    sum (  delta &lt; 10^-18 kJ / (mol nm) compared to an infinite large cutoff ):<br>&gt; <br>&gt;     rlist=4.5<br>&gt;     rcoulomb=4.5<br>&gt;     rvdw=4.5<br>&gt; <br>&gt;     coulomb-type=ewald<br>&gt;     knx=kny=knz=70<br>&gt;     ewald_rtol=1.348768e-21 ( -&gt; 1/beta=0.6666667 )<br>&gt; <br>&gt;    Now I checked different cases:<br>&gt; <br>&gt;     1. a = 2.5 -&gt; only the reciprocal part of the Ewald sum is taken into<br>&gt;     account and we have small terms in the sums:<br>&gt; <br>&gt;       In this case everything is perfect, apart from the forces in y and z<br>&gt;       direction. The forces as well as the energies match up the last<br>&gt;       digit.<br>&gt; <br>&gt;     2. a=2.0 -&gt; both contribtions from direct and recipr. space and the<br>&gt;     amount of the terms is much larger.<br>&gt; <br>&gt;       The energies also match perfectly, however the forces differ<br>&gt;       already by an amount of 10^-2 kJ / (mol nm).<br>&gt; <br>&gt;     3. a=0.2 -&gt; very large terms<br>&gt; <br>&gt;       Furthermore the energies fit perfectly, but the forces differ<br>&gt;       significantly.<br>&gt; <br>&gt;    As a first resumee I have assumed the implementation of the calculation<br>&gt;    of the direct forces is wrong. Than I checked the code and compared the<br>&gt;    analog part in gromacs. To stay as compatible as much is also use<br>&gt;    gmx_erfc() in my code.<br>&gt; <br>&gt;    The energies are derived by summing over all pairs within the cutoff.<br>&gt;    In this routine also the forces are calculated and added to the involved <br>&gt;    particles.<br>&gt; <br>&gt;    Unfortunately there are so many sources where an an error can easily be<br>&gt;    introduce. So at first I checked terms get lost during the summation of the<br>&gt;    forces. But then I would not obtain exactly the same energies like<br>&gt;    gromacs. To exclude the possibility of a wrong calculation of the<br>&gt;    direct forces I already compared the code lines for the force<br>&gt;    calculation in gromacs (src/mdlib/tables.c line 655) and the other<br>&gt;    code, but they also match. <br>&gt; <br>&gt; <br>&gt;    Can somebody give me an idea, where this deviations can arise from ?<br>&gt;    Obviously an increase of the forces yields significant differences.<br>&gt;    This can also be observed, when I decrease the box size and test case<br>&gt;    1.). For a 4x4x4 box the deviation is as large as the actual force.<br>&gt; <br>&gt; Cheers,<br>&gt; <br>&gt; Flo<br>&gt; <br>&gt; Florian Dommert<br>&gt; Dipl.-Phys.<br>&gt; <br>&gt; Institute for Computational Physics<br>&gt; University Stuttgart<br>&gt; <br>&gt; Pfaffenwaldring 27<br>&gt; 70569 Stuttgart<br>&gt; <br>&gt; Tel: +49 - 711 / 6856-3613<br>&gt; Fax: +49 - 711 / 6856-3658<br>&gt; <br>&gt; EMail: dommert@icp.uni-stuttgart.de<br>&gt; Home: http://www.icp.uni-stuttgart.de/~icp/Florian_Dommert<br>&gt; <br>&gt; !! PGP-ENCODED emails preferred !!<br><br /><hr />What can you do with the new Windows Live? <a href='http://www.microsoft.com/windows/windowslive/default.aspx' target='_new'>Find out</a></body>
</html>