Clean up cshake() and resolve old issues
[alexxy/gromacs.git] / src / gromacs / legacyheaders / constr.h
index 7c456db6928df35553d5f27790c49ef50182056c..79ac3a7bf028af4cf6c26ab75ba33d217be3dbcf 100644 (file)
@@ -1,48 +1,51 @@
-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
- *
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
+/*
+ * This file is part of the GROMACS molecular simulation package.
  *
- *                        VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
  * of the License, or (at your option) any later version.
  *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
  *
- * For more info, check our website at http://www.gromacs.org
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
  *
- * And Hey:
- * Gromacs Runs On Most of All Computer Systems
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
  */
 
 #ifndef _constr_h
 #define _constr_h
-#include "typedefs.h"
-#include "types/commrec.h"
+
+#include "gromacs/legacyheaders/typedefs.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+struct t_pbc;
+
 enum
 {
     econqCoord,         /* Constrain coordinates (mass weighted)           */
@@ -97,23 +100,23 @@ gmx_settledata_t settle_init(real mO, real mH, real invmO, real invmH,
                              real dOH, real dHH);
 /* Initializes and returns a structure with SETTLE parameters */
 
-void csettle(gmx_settledata_t settled,
-             int              nsettle,          /* Number of settles            */
-             t_iatom          iatoms[],         /* The settle iatom list        */
-             const t_pbc     *pbc,              /* PBC data pointer, can be NULL  */
-             real             b4[],             /* Old coordinates             */
-             real             after[],          /* New coords, to be settled   */
-             real             invdt,            /* 1/delta_t                    */
-             real            *v,                /* Also constrain v if v!=NULL  */
-             int              calcvir_atom_end, /* Calculate r x m delta_r up to this atom */
-             tensor           vir_r_m_dr,       /* sum r x m delta_r            */
-             int             *xerror,
-             t_vetavars      *vetavar           /* variables for pressure control */
+void csettle(gmx_settledata_t    settled,
+             int                 nsettle,          /* Number of settles            */
+             t_iatom             iatoms[],         /* The settle iatom list        */
+             const struct t_pbc *pbc,              /* PBC data pointer, can be NULL */
+             real                b4[],             /* Old coordinates              */
+             real                after[],          /* New coords, to be settled    */
+             real                invdt,            /* 1/delta_t                    */
+             real               *v,                /* Also constrain v if v!=NULL  */
+             int                 calcvir_atom_end, /* Calculate r x m delta_r up to this atom */
+             tensor              vir_r_m_dr,       /* sum r x m delta_r            */
+             int                *xerror,
+             t_vetavars         *vetavar           /* variables for pressure control */
              );
 
 void settle_proj(gmx_settledata_t settled, int econq,
                  int nsettle, t_iatom iatoms[],
-                 const t_pbc *pbc,   /* PBC data pointer, can be NULL  */
+                 const struct t_pbc *pbc,   /* PBC data pointer, can be NULL  */
                  rvec x[],
                  rvec *der, rvec *derp,
                  int CalcVirAtomEnd, tensor vir_r_m_dder,
@@ -122,9 +125,9 @@ void settle_proj(gmx_settledata_t settled, int econq,
  * of coordinates working on settle type constraint.
  */
 
-void cshake(atom_id iatom[], int ncon, int *nnit, int maxnit,
-            real dist2[], real xp[], real rij[], real m2[], real omega,
-            real invmass[], real tt[], real lagr[], int *nerror);
+void cshake(const atom_id iatom[], int ncon, int *nnit, int maxnit,
+            const real dist2[], real xp[], const real rij[], const real m2[], real omega,
+            const real invmass[], const real tt[], real lagr[], int *nerror);
 /* Regular iterative shake */
 
 void crattle(atom_id iatom[], int ncon, int *nnit, int maxnit,
@@ -138,6 +141,7 @@ gmx_bool constrain(FILE *log, gmx_bool bLog, gmx_bool bEner,
                    gmx_ekindata_t *ekind,
                    t_commrec *cr,
                    gmx_int64_t step, int delta_step,
+                   real step_scaling,
                    t_mdatoms *md,
                    rvec *x, rvec *xprime, rvec *min_proj,
                    gmx_bool bMolPBC, matrix box,
@@ -162,6 +166,11 @@ gmx_bool constrain(FILE *log, gmx_bool bLog, gmx_bool bEner,
  * step + delta_step is the step at which the final configuration
  * is meant to be; for update delta_step = 1.
  *
+ * step_scaling can be used to update coordinates based on the time
+ * step multiplied by this factor. Thus, normally 1.0 is passed. The
+ * SD1 integrator uses 0.5 in one of its calls, to correct positions
+ * for half a step of changed velocities.
+ *
  * If v!=NULL also constrain v by adding the constraint corrections / dt.
  *
  * If vir!=NULL calculate the constraint virial.
@@ -256,7 +265,7 @@ constrain_lincs(FILE *log, gmx_bool bLog, gmx_bool bEner,
                 gmx_lincsdata_t lincsd, t_mdatoms *md,
                 t_commrec *cr,
                 rvec *x, rvec *xprime, rvec *min_proj,
-                matrix box, t_pbc *pbc,
+                matrix box, struct t_pbc *pbc,
                 real lambda, real *dvdlambda,
                 real invdt, rvec *v,
                 gmx_bool bCalcVir, tensor vir_r_m_dr,