michellab / plumed2

Development version of plumed 2
GNU Lesser General Public License v3.0
1 stars 0 forks source link

Neighbours are not computed correctly due to c++ roundoff errors #7

Closed carajillu closed 5 years ago

carajillu commented 5 years ago

Comment by JM on Sep2015 says that it gets at most 38 neighbours but paper says 44 with the same parameter set. I have counted them in pymol and 38 is correct, BUT the code is using a direct comparison test if (dij2 > dmin and dij2 < dmax), which fails sometimes due to c++ roundoff errors. I tried it in a small grid like the one in the picture and modifying the settings a bit:

a) replacing > and< by >= and <=, respectively. b) setting GPmin=0 and GPmax=0.15

which should give max 6 neighbours and it gives max 4. I replaced this if condition by a slightly more complex one:

if ( (dij2-dmin)>0.00001 and (dij2-dmax)<0.00001)

and that gives the correct number of neighbours

carajillu commented 5 years ago

Never mind, doesn't make a difference in real calculations