changed setup of trotter decomposition to make it easier to change the decomposition...
[gromacs/rigid-bodies.git] / include / update.h
blobfc522eb2df85db960eb2addf3ece3951a3e50db2
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.
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.
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.
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.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
36 #ifndef _update_h
37 #define _update_h
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
43 #include "typedefs.h"
44 #include "mshift.h"
45 #include "tgroup.h"
46 #include "network.h"
47 #include "force.h"
48 #include "pull.h"
49 #include "gmx_random.h"
51 /* Abstract type for stochastic dynamics */
52 typedef struct gmx_update *gmx_update_t;
54 /* Initialize the stochastic dynamics struct */
55 extern gmx_update_t init_update(FILE *fplog,t_inputrec *ir);
57 /* Store the random state from sd in state */
58 extern void get_stochd_state(gmx_update_t sd,t_state *state);
60 /* Set the random in sd from state */
61 extern void set_stochd_state(gmx_update_t sd,t_state *state);
63 /* Store the box at step step
64 * as a reference state for simulations with box deformation.
66 extern void set_deform_reference_box(gmx_update_t upd,
67 gmx_large_int_t step,matrix box);
69 extern void update_extended(FILE *fplog,
70 gmx_large_int_t step,
71 t_inputrec *inputrec,
72 t_mdatoms *md,
73 t_state *state,
74 gmx_ekindata_t *ekind,
75 matrix pcoupl_mu,
76 matrix M,
77 gmx_wallcycle_t wcycle,
78 gmx_update_t upd,
79 bool bInitStep,
80 bool bFirstHalf,
81 t_extmass *MassQ
83 /* Return TRUE if OK, FALSE in case of Shake Error */
85 extern void update_coords(FILE *fplog,
86 gmx_large_int_t step,
87 t_inputrec *inputrec, /* input record and box stuff */
88 t_mdatoms *md,
89 t_state *state,
90 rvec *f, /* forces on home particles */
91 bool bDoLR,
92 rvec *f_lr,
93 t_fcdata *fcd,
94 gmx_ekindata_t *ekind,
95 matrix M,
96 gmx_wallcycle_t wcycle,
97 gmx_update_t upd,
98 bool bInitStep,
99 bool bFirstHalf,
100 t_commrec *cr, /* these shouldn't be here -- need to think about it */
101 t_nrnb *nrnb,
102 gmx_constr_t constr,
103 t_idef *idef);
105 /* Return TRUE if OK, FALSE in case of Shake Error */
107 extern void update_constraints(FILE *fplog,
108 gmx_large_int_t step,
109 real *dvdlambda, /* FEP stuff */
110 t_inputrec *inputrec, /* input record and box stuff */
111 t_mdatoms *md,
112 t_state *state,
113 t_graph *graph,
114 rvec force[], /* forces on home particles */
115 t_idef *idef,
116 tensor vir_part,
117 tensor vir,
118 t_commrec *cr,
119 t_nrnb *nrnb,
120 gmx_wallcycle_t wcycle,
121 gmx_update_t upd,
122 gmx_constr_t constr,
123 bool bInitStep,
124 bool bFirstHalf,
125 bool bCalcVir,
126 real vetanew);
128 /* Return TRUE if OK, FALSE in case of Shake Error */
130 extern void update_box(FILE *fplog,
131 gmx_large_int_t step,
132 t_inputrec *inputrec, /* input record and box stuff */
133 t_mdatoms *md,
134 t_state *state,
135 t_graph *graph,
136 rvec force[], /* forces on home particles */
137 matrix *scale_tot,
138 matrix pcoupl_mu,
139 t_nrnb *nrnb,
140 gmx_wallcycle_t wcycle,
141 gmx_update_t upd,
142 bool bInitStep,
143 bool bFirstHalf);
144 /* Return TRUE if OK, FALSE in case of Shake Error */
146 extern void calc_ke_part(t_state *state,t_grpopts *opts,t_mdatoms *md,
147 gmx_ekindata_t *ekind,t_nrnb *nrnb,bool bFullStepV);
149 * Compute the partial kinetic energy for home particles;
150 * will be accumulated in the calling routine.
151 * The tensor is
153 * Ekin = SUM(i) 0.5 m[i] v[i] (x) v[i]
155 * use v[i] = v[i] - u[i] when calculating temperature
157 * u must be accumulated already.
159 * Now also computes the contribution of the kinetic energy to the
160 * free energy
164 extern void
165 init_ekinstate(ekinstate_t *ekinstate,t_inputrec *ir);
167 extern void
168 update_ekinstate(ekinstate_t *ekinstate,gmx_ekindata_t *ekind);
170 extern void
171 restore_ekinstate_from_state(t_commrec *cr,
172 gmx_ekindata_t *ekind,ekinstate_t *ekinstate);
174 extern void berendsen_tcoupl(t_grpopts *opts,gmx_ekindata_t *ekind,real dt);
176 extern void nosehoover_tcoupl(t_grpopts *opts,gmx_ekindata_t *ekind,real dt,
177 double xi[],double vxi[],t_extmass *MassQ);
179 extern t_state *init_bufstate(int size, int ntc);
183 extern trotter_update(t_inputrec *ir,gmx_ekindata_t *ekind, gmx_enerdata_t *enerd,
184 t_state *state, tensor vir, t_mdatoms *md,
185 t_extmass *MassQ, bool bFirstHalf, bool bThermo, bool bBaro, bool bInitStep);
189 extern void trotter_update(t_inputrec *ir,gmx_ekindata_t *ekind, gmx_enerdata_t *enerd,
190 t_state *state, tensor vir, t_mdatoms *md,
191 t_extmass *MassQ, int *trotter_seq);
193 extern int **init_trotter(t_inputrec *ir, t_state *state, t_extmass *Mass);
196 extern real NPT_energy(t_inputrec *ir, double *xi, double *vxi, real veta, tensor box, t_extmass *MassQ);
197 /* computes all the pressure/tempertature control energy terms to get a conserved energy */
199 extern void NBaroT_trotter(t_grpopts *opts, real dt,
200 double xi[],double vxi[],real *veta, t_extmass *MassQ);
202 extern void vrescale_tcoupl(t_grpopts *opts,gmx_ekindata_t *ekind,real dt,
203 double therm_integral[],
204 gmx_rng_t rng);
205 /* Compute temperature scaling. For V-rescale it is done in update. */
207 extern real vrescale_energy(t_grpopts *opts,double therm_integral[]);
208 /* Returns the V-rescale contribution to the conserved energy */
211 /* Set reference temp for simulated annealing at time t*/
212 extern void update_annealing_target_temp(t_grpopts *opts,real t);
214 extern real calc_temp(real ekin,real nrdf);
215 /* Calculate the temperature */
217 extern real calc_pres(int ePBC,int nwall,matrix box,
218 tensor ekin,tensor vir,tensor pres,real Elr);
219 /* Calculate the pressure tensor, returns the scalar pressure.
220 * The unit of pressure is bar, If Elr != 0
221 * a long range correction based on Ewald/PPPM is made (see c-code)
224 extern void parrinellorahman_pcoupl(FILE *fplog,gmx_large_int_t step,
225 t_inputrec *ir,real dt,tensor pres,
226 tensor box,tensor box_rel,tensor boxv,
227 tensor M,matrix mu,
228 bool bFirstStep);
230 extern void berendsen_pcoupl(FILE *fplog,gmx_large_int_t step,
231 t_inputrec *ir,real dt,tensor pres,matrix box,
232 matrix mu);
235 extern void berendsen_pscale(t_inputrec *ir,matrix mu,
236 matrix box,matrix box_rel,
237 int start,int nr_atoms,
238 rvec x[],unsigned short cFREEZE[],
239 t_nrnb *nrnb);
241 extern void correct_ekin(FILE *log,int start,int end,rvec v[],
242 rvec vcm,real mass[],real tmass,tensor ekin);
243 /* Correct ekin for vcm */
245 #endif /* _update_h */