Merge release-4-5-patches into release-4-6
[alexxy/gromacs.git] / src / tools / gmx_dist.c
index ee8c4ded9ef19ccb12892192537ab01a64d91d00..aff4eca2d882ef9b5eba5e32d85d2d3c4b4fed55 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "smalloc.h"
 #include "macros.h"
-#include "math.h"
+#include <math.h>
 #include "xvgr.h"
 #include "copyrite.h"
 #include "statutil.h"
@@ -77,7 +77,12 @@ int gmx_dist(int argc,char *argv[])
     "With options [TT]-lt[tt] and [TT]-dist[tt] the number of contacts",
     "of all atoms in group 2 that are closer than a certain distance",
     "to the center of mass of group 1 are plotted as a function of the time",
-    "that the contact was continuously present.[PAR]",
+    "that the contact was continuously present. The [TT]-intra[tt] switch enables",
+    "calculations of intramolecular distances avoiding distance calculation to its",
+    "periodic images. For a proper function, the molecule in the input trajectory",
+    "should be whole (e.g. by preprocessing with [TT]trjconv -pbc[tt]) or a matching",
+    "topology should be provided. The [TT]-intra[tt] switch will only give",
+    "meaningful results for intramolecular and not intermolecular distances.[PAR]",
     "Other programs that calculate distances are [TT]g_mindist[tt]",
     "and [TT]g_bond[tt]."
   };
@@ -100,7 +105,7 @@ int gmx_dist(int argc,char *argv[])
   rvec    *com;
   real    *mass;
   FILE    *fp=NULL,*fplt=NULL;
-  gmx_bool    bCutoff,bPrintDist,bLifeTime;
+  gmx_bool    bCutoff,bPrintDist,bLifeTime,bIntra=FALSE;
   t_pbc   *pbc;
   int     *contact_time=NULL,*ccount=NULL,ccount_nalloc=0,sum;
   char    buf[STRLEN];
@@ -111,7 +116,9 @@ int gmx_dist(int argc,char *argv[])
 
   static real cut=0;
   
-  static t_pargs pa[] = {
+  t_pargs pa[] = {
+    { "-intra",      FALSE, etBOOL, {&bIntra},
+      "Calculate distances without considering periodic boundaries, e.g. intramolecular." },
     { "-dist",      FALSE, etREAL, {&cut},
       "Print all atoms in group 2 closer than dist to the center of mass of group 1" }
   };
@@ -211,7 +218,7 @@ int gmx_dist(int argc,char *argv[])
       /* write to output */
       fprintf(fp,"%12.7f ",t);
       for(g=0;(g<ngrps/2);g++) {
-       if (pbc)
+       if (pbc && (!bIntra))
          pbc_dx(pbc,com[2*g],com[2*g+1],dx);
        else
          rvec_sub(com[2*g],com[2*g+1],dx);
@@ -223,7 +230,7 @@ int gmx_dist(int argc,char *argv[])
     } else {
       for(i=0;(i<isize[1]);i++) { 
        j=index[1][i];
-       if (pbc)
+       if (pbc && (!bIntra))
          pbc_dx(pbc,x[j],com[0],dx);
        else
          rvec_sub(x[j],com[0],dx);