Essential dynamics: move bNeedDoEdsam evaluation to separate function
authorCarsten Kutzner <ckutzne@gwdg.de>
Fri, 6 Dec 2013 12:03:55 +0000 (13:03 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Wed, 25 Dec 2013 06:17:29 +0000 (07:17 +0100)
The bool variable edi->bNeedDoEdsam is used to signal whether any essential
dynamics constraints have to be evaluated for the ED group. This variable
was evaluated at the beginning of an ED simulation in write_edo_legend().
The latter is however not called if continuing from checkpoint. To
get rid of having to remember whether edi->bNeedDoEdsam was already
initialized, there is now a function bNeedDoEdsam(edi) that is evaluated
every time when called.
Also corrected a few typos.

Change-Id: Iab899a677a85ee8270354859c98cc9e5a9db34b7

src/mdlib/edsam.c

index a64e2317712aaca3b2c55e26d99b2b2ba67eb9cb..316baac52da943a3c46d7371441e7c323cc5313d 100644 (file)
@@ -94,7 +94,7 @@ typedef struct
     real   *xproj;   /* instantaneous x projections    */
     real   *fproj;   /* instantaneous f projections    */
     real    radius;  /* instantaneous radius           */
-    real   *refproj; /* starting or target projecions  */
+    real   *refproj; /* starting or target projections */
     /* When using flooding as harmonic restraint: The current reference projection
      * is at each step calculated from the initial refproj0 and the slope. */
     real  *refproj0, *refprojslope;
@@ -180,8 +180,6 @@ typedef struct edpar
     t_edvecs            vecs;         /* eigenvectors                         */
     real                slope;        /* minimal slope in acceptance radexp   */
 
-    gmx_bool            bNeedDoEdsam; /* if any of the options mon, linfix, ...
-                                       * is used (i.e. apart from flooding)   */
     t_edflood           flood;        /* parameters especially for flooding   */
     struct t_ed_buffer *buf;          /* handle to local buffers              */
     struct edpar       *next_edi;     /* Pointer to another ED group          */
@@ -238,6 +236,19 @@ static void write_edo_legend(gmx_edsam_t ed, int nED, const output_env_t oenv);
 /* End function declarations */
 
 
+/* Do we have to perform essential dynamics constraints or possibly only flooding
+ * for any of the ED groups? */
+static gmx_bool bNeedDoEdsam(t_edpar *edi)
+{
+    return     edi->vecs.mon.neig
+            || edi->vecs.linfix.neig
+            || edi->vecs.linacc.neig
+            || edi->vecs.radfix.neig
+            || edi->vecs.radacc.neig
+            || edi->vecs.radcon.neig;
+}
+
+
 /* Multiple ED groups will be labeled with letters instead of numbers
  * to avoid confusion with eigenvector indices */
 static char get_EDgroupChar(int nr_edi, int nED)
@@ -341,7 +352,7 @@ static void project(rvec      *x,     /* positions to project */
                     t_edpar   *edi)   /* edi data set */
 {
     /* It is not more work to subtract the average position in every
-     * subroutine again, because these routines are rarely used simultanely */
+     * subroutine again, because these routines are rarely used simultaneously */
     project_to_eigvectors(x, &edi->vecs.mon, edi);
     project_to_eigvectors(x, &edi->vecs.linfix, edi);
     project_to_eigvectors(x, &edi->vecs.linacc, edi);
@@ -2492,15 +2503,6 @@ static void write_edo_legend(gmx_edsam_t ed, int nED, const output_env_t oenv)
 
     for (nr_edi = 1; nr_edi <= nED; nr_edi++)
     {
-        /* Remember for each ED group whether we have to do essential dynamics
-         * constraints or possibly only flooding */
-        edi->bNeedDoEdsam = edi->vecs.mon.neig
-            || edi->vecs.linfix.neig
-            || edi->vecs.linacc.neig
-            || edi->vecs.radfix.neig
-            || edi->vecs.radacc.neig
-            || edi->vecs.radcon.neig;
-
         fprintf(ed->edo, "#\n");
         fprintf(ed->edo, "# Summary of applied con/restraints for the ED group %c\n", get_EDgroupChar(nr_edi, nED));
         fprintf(ed->edo, "# Atoms in average structure: %d\n", edi->sav.nr);
@@ -2618,7 +2620,7 @@ static void write_edo_legend(gmx_edsam_t ed, int nED, const output_env_t oenv)
     edi         = ed->edpar;
     for (nr_edi = 1; nr_edi <= nED; nr_edi++)
     {
-        if (edi->bNeedDoEdsam) /* Only print ED legend if at least one ED option is on */
+        if ( bNeedDoEdsam(edi) ) /* Only print ED legend if at least one ED option is on */
         {
             nice_legend(&setname, &nsets, &LegendStr, "RMSD to ref", "nm", get_EDgroupChar(nr_edi, nED) );
 
@@ -3057,14 +3059,14 @@ void do_edsam(t_inputrec     *ir,
     while (edi != NULL)
     {
         edinr++;
-        if (edi->bNeedDoEdsam)
+        if ( bNeedDoEdsam(edi) )
         {
 
             buf = edi->buf->do_edsam;
 
             if (ed->bFirst)
             {
-                /* initialise radacc radius for slope criterion */
+                /* initialize radacc radius for slope criterion */
                 buf->oldrad = calc_radius(&edi->vecs.radacc);
             }
 
@@ -3196,7 +3198,7 @@ void do_edsam(t_inputrec     *ir,
                     copy_rvec(x_unsh, xs[edi->sav.anrs_loc[i]]);
                 }
             }
-        } /* END of if (edi->bNeedDoEdsam) */
+        } /* END of if ( bNeedDoEdsam(edi) ) */
 
         /* Prepare for the next ED group */
         edi = edi->next_edi;