Fix malformed CUDA version macro check
[alexxy/gromacs.git] / include / update.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team,
6  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012,2013, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38
39 #ifndef _update_h
40 #define _update_h
41 #include "visibility.h"
42 #include "typedefs.h"
43 #include "mshift.h"
44 #include "tgroup.h"
45 #include "network.h"
46 #include "force.h"
47 #include "pull.h"
48 #include "gmx_random.h"
49 #include "maths.h"
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 /* Abstract type for stochastic dynamics */
56 typedef struct gmx_update *gmx_update_t;
57
58 /* Initialize the stochastic dynamics struct */
59 gmx_update_t init_update(FILE *fplog, t_inputrec *ir);
60
61 /* Store the random state from sd in state */
62 GMX_LIBMD_EXPORT
63 void get_stochd_state(gmx_update_t sd, t_state *state);
64
65 /* Set the random in sd from state */
66 GMX_LIBMD_EXPORT
67 void set_stochd_state(gmx_update_t sd, t_state *state);
68
69 /* Store the box at step step
70  * as a reference state for simulations with box deformation.
71  */
72 GMX_LIBMD_EXPORT
73 void set_deform_reference_box(gmx_update_t upd,
74                               gmx_large_int_t step, matrix box);
75
76 GMX_LIBMD_EXPORT
77 void update_tcouple(FILE             *fplog,
78                     gmx_large_int_t   step,
79                     t_inputrec       *inputrec,
80                     t_state          *state,
81                     gmx_ekindata_t   *ekind,
82                     gmx_wallcycle_t   wcycle,
83                     gmx_update_t      upd,
84                     t_extmass        *MassQ,
85                     t_mdatoms        *md
86                     );
87
88 GMX_LIBMD_EXPORT
89 void update_pcouple(FILE             *fplog,
90                     gmx_large_int_t   step,
91                     t_inputrec       *inputrec,
92                     t_state          *state,
93                     matrix            pcoupl_mu,
94                     matrix            M,
95                     gmx_wallcycle_t   wcycle,
96                     gmx_update_t      upd,
97                     gmx_bool          bInitStep);
98
99 GMX_LIBMD_EXPORT
100 void update_coords(FILE             *fplog,
101                    gmx_large_int_t   step,
102                    t_inputrec       *inputrec, /* input record and box stuff    */
103                    t_mdatoms        *md,
104                    t_state          *state,
105                    gmx_bool          bMolPBC,
106                    rvec             *f, /* forces on home particles */
107                    gmx_bool          bDoLR,
108                    rvec             *f_lr,
109                    tensor           *vir_lr_constr,
110                    t_fcdata         *fcd,
111                    gmx_ekindata_t   *ekind,
112                    matrix            M,
113                    gmx_wallcycle_t   wcycle,
114                    gmx_update_t      upd,
115                    gmx_bool          bInitStep,
116                    int               bUpdatePart,
117                    t_commrec        *cr, /* these shouldn't be here -- need to think about it */
118                    t_nrnb           *nrnb,
119                    gmx_constr_t      constr,
120                    t_idef           *idef);
121
122 /* Return TRUE if OK, FALSE in case of Shake Error */
123
124 GMX_LIBMD_EXPORT
125 extern gmx_bool update_randomize_velocities(t_inputrec *ir, gmx_large_int_t step, t_mdatoms *md, t_state *state, gmx_update_t upd, t_idef *idef, gmx_constr_t constr, gmx_bool bIsDomainDecomposition);
126
127 GMX_LIBMD_EXPORT
128 void update_constraints(FILE             *fplog,
129                         gmx_large_int_t   step,
130                         real             *dvdlambda, /* FEP stuff */
131                         t_inputrec       *inputrec,  /* input record and box stuff      */
132                         gmx_ekindata_t   *ekind,
133                         t_mdatoms        *md,
134                         t_state          *state,
135                         gmx_bool          bMolPBC,
136                         t_graph          *graph,
137                         rvec              force[], /* forces on home particles */
138                         t_idef           *idef,
139                         tensor            vir_part,
140                         tensor            vir,
141                         t_commrec        *cr,
142                         t_nrnb           *nrnb,
143                         gmx_wallcycle_t   wcycle,
144                         gmx_update_t      upd,
145                         gmx_constr_t      constr,
146                         gmx_bool          bInitStep,
147                         gmx_bool          bFirstHalf,
148                         gmx_bool          bCalcVir,
149                         real              vetanew);
150
151 /* Return TRUE if OK, FALSE in case of Shake Error */
152
153 GMX_LIBMD_EXPORT
154 void update_box(FILE             *fplog,
155                 gmx_large_int_t   step,
156                 t_inputrec       *inputrec, /* input record and box stuff       */
157                 t_mdatoms        *md,
158                 t_state          *state,
159                 t_graph          *graph,
160                 rvec              force[], /* forces on home particles */
161                 matrix           *scale_tot,
162                 matrix            pcoupl_mu,
163                 t_nrnb           *nrnb,
164                 gmx_wallcycle_t   wcycle,
165                 gmx_update_t      upd,
166                 gmx_bool          bInitStep,
167                 gmx_bool          bFirstHalf);
168 /* Return TRUE if OK, FALSE in case of Shake Error */
169
170 void calc_ke_part(t_state *state, t_grpopts *opts, t_mdatoms *md,
171                   gmx_ekindata_t *ekind, t_nrnb *nrnb, gmx_bool bEkinAveVel, gmx_bool bSaveOld);
172 /*
173  * Compute the partial kinetic energy for home particles;
174  * will be accumulated in the calling routine.
175  * The tensor is
176  *
177  * Ekin = SUM(i) 0.5 m[i] v[i] (x) v[i]
178  *
179  *     use v[i] = v[i] - u[i] when calculating temperature
180  *
181  * u must be accumulated already.
182  *
183  * Now also computes the contribution of the kinetic energy to the
184  * free energy
185  *
186  */
187
188
189 void
190 init_ekinstate(ekinstate_t *ekinstate, const t_inputrec *ir);
191
192 GMX_LIBMD_EXPORT
193 void
194 update_ekinstate(ekinstate_t *ekinstate, gmx_ekindata_t *ekind);
195
196 void
197 restore_ekinstate_from_state(t_commrec *cr,
198                              gmx_ekindata_t *ekind, ekinstate_t *ekinstate);
199
200 void berendsen_tcoupl(t_inputrec *ir, gmx_ekindata_t *ekind, real dt);
201
202 void andersen_tcoupl(t_inputrec *ir, t_mdatoms *md, t_state *state, gmx_rng_t rng, real rate, t_idef *idef, int nblocks, int *sblock, gmx_bool *randatom, int *randatom_list, gmx_bool *randomize, real *boltzfac);
203
204 void nosehoover_tcoupl(t_grpopts *opts, gmx_ekindata_t *ekind, real dt,
205                        double xi[], double vxi[], t_extmass *MassQ);
206
207 GMX_LIBMD_EXPORT
208 t_state *init_bufstate(const t_state *template_state);
209
210 void destroy_bufstate(t_state *state);
211
212 GMX_LIBMD_EXPORT
213 void trotter_update(t_inputrec *ir, gmx_large_int_t step, gmx_ekindata_t *ekind,
214                     gmx_enerdata_t *enerd, t_state *state, tensor vir, t_mdatoms *md,
215                     t_extmass *MassQ, int **trotter_seqlist, int trotter_seqno);
216
217 GMX_LIBMD_EXPORT
218 int **init_npt_vars(t_inputrec *ir, t_state *state, t_extmass *Mass, gmx_bool bTrotter);
219
220 real NPT_energy(t_inputrec *ir, t_state *state, t_extmass *MassQ);
221 /* computes all the pressure/tempertature control energy terms to get a conserved energy */
222
223 void NBaroT_trotter(t_grpopts *opts, real dt,
224                     double xi[], double vxi[], real *veta, t_extmass *MassQ);
225
226 void vrescale_tcoupl(t_inputrec *ir, gmx_ekindata_t *ekind, real dt,
227                      double therm_integral[],
228                      gmx_rng_t rng);
229 /* Compute temperature scaling. For V-rescale it is done in update. */
230
231 real vrescale_energy(t_grpopts *opts, double therm_integral[]);
232 /* Returns the V-rescale contribution to the conserved energy */
233
234 void rescale_velocities(gmx_ekindata_t *ekind, t_mdatoms *mdatoms,
235                         int start, int end, rvec v[]);
236 /* Rescale the velocities with the scaling factor in ekind */
237
238 GMX_LIBMD_EXPORT
239 void update_annealing_target_temp(t_grpopts *opts, real t);
240 /* Set reference temp for simulated annealing at time t*/
241
242 real calc_temp(real ekin, real nrdf);
243 /* Calculate the temperature */
244
245 real calc_pres(int ePBC, int nwall, matrix box, tensor ekin, tensor vir,
246                tensor pres);
247 /* Calculate the pressure tensor, returns the scalar pressure.
248  * The unit of pressure is bar.
249  */
250
251 void parrinellorahman_pcoupl(FILE *fplog, gmx_large_int_t step,
252                              t_inputrec *ir, real dt, tensor pres,
253                              tensor box, tensor box_rel, tensor boxv,
254                              tensor M, matrix mu,
255                              gmx_bool bFirstStep);
256
257 void berendsen_pcoupl(FILE *fplog, gmx_large_int_t step,
258                       t_inputrec *ir, real dt, tensor pres, matrix box,
259                       matrix mu);
260
261
262 void berendsen_pscale(t_inputrec *ir, matrix mu,
263                       matrix box, matrix box_rel,
264                       int start, int nr_atoms,
265                       rvec x[], unsigned short cFREEZE[],
266                       t_nrnb *nrnb);
267
268 void correct_ekin(FILE *log, int start, int end, rvec v[],
269                   rvec vcm, real mass[], real tmass, tensor ekin);
270 /* Correct ekin for vcm */
271
272
273 #ifdef __cplusplus
274 }
275 #endif
276
277 #endif  /* _update_h */