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