e721f665e88831d18b5b5c9c41a3cc256ff5178d
[alexxy/gromacs.git] / include / md_support.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 _md_support_h
37 #define _md_support_h
38 #include "visibility.h"
39 #include "typedefs.h"
40 #include "types/globsig.h"
41 #include "sim_util.h"
42 #include "vcm.h"
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /* Define a number of flags to better control the information
49  * passed to compute_globals in md.c and global_stat.
50  */
51
52 /* We are rerunning the simulation */
53 #define CGLO_RERUNMD        (1<<1)
54 /* we are computing the kinetic energy from average velocities */
55 #define CGLO_EKINAVEVEL     (1<<2)
56 /* we are removing the center of mass momenta */
57 #define CGLO_STOPCM         (1<<3)
58 /* bGStat is defined in do_md */
59 #define CGLO_GSTAT          (1<<4)
60 /* Sum the energy terms in global computation */
61 #define CGLO_ENERGY         (1<<6)
62 /* Sum the kinetic energy terms in global computation */
63 #define CGLO_TEMPERATURE    (1<<7)
64 /* Sum the kinetic energy terms in global computation */
65 #define CGLO_PRESSURE       (1<<8)
66 /* Sum the constraint term in global computation */
67 #define CGLO_CONSTRAINT     (1<<9)
68 /* we are using an integrator that requires iteration over some steps - currently not used*/
69 #define CGLO_ITERATE        (1<<10)
70 /* it is the first time we are iterating (or, only once through is required */
71 #define CGLO_FIRSTITERATE   (1<<11)
72 /* Reading ekin from the trajectory */
73 #define CGLO_READEKIN       (1<<12)
74 /* we need to reset the ekin rescaling factor here */
75 #define CGLO_SCALEEKIN      (1<<13)
76
77
78 /* return the number of steps between global communcations */
79 GMX_LIBMD_EXPORT
80 int check_nstglobalcomm(FILE *fplog,t_commrec *cr,
81                         int nstglobalcomm,t_inputrec *ir);
82
83 /* check whether an 'nst'-style parameter p is a multiple of nst, and
84    set it to be one if not, with a warning. */
85 GMX_LIBMD_EXPORT
86 void check_nst_param(FILE *fplog,t_commrec *cr,
87                      const char *desc_nst,int nst,
88                      const char *desc_p,int *p);
89
90 /* check which of the multisim simulations has the shortest number of
91    steps and return that number of nsteps */
92 GMX_LIBMD_EXPORT
93 gmx_large_int_t get_multisim_nsteps(const t_commrec *cr,
94                                     gmx_large_int_t nsteps);
95
96 GMX_LIBMD_EXPORT
97 void rerun_parallel_comm(t_commrec *cr,t_trxframe *fr,
98                          gmx_bool *bNotLastFrame);
99
100 /* get the conserved energy associated with the ensemble type*/
101 GMX_LIBMD_EXPORT
102 real compute_conserved_from_auxiliary(t_inputrec *ir, t_state *state,           
103                                       t_extmass *MassQ);
104
105 /* set the lambda values at each step of mdrun when they change */
106 GMX_LIBMD_EXPORT
107 void set_current_lambdas(gmx_large_int_t step, t_lambda *fepvals, gmx_bool bRerunMD,
108                          t_trxframe *rerun_fr, t_state *state_global, t_state *state, double lam0[]);
109
110 int multisim_min(const gmx_multisim_t *ms,int nmin,int n);
111 /* Set an appropriate value for n across the whole multi-simulation */
112
113 int multisim_nstsimsync(const t_commrec *cr,
114                         const t_inputrec *ir,int repl_ex_nst);
115 /* Determine the interval for inter-simulation communication */
116                                    
117 GMX_LIBMD_EXPORT
118 void init_global_signals(globsig_t *gs,const t_commrec *cr,
119                          const t_inputrec *ir,int repl_ex_nst);
120 /* Constructor for globsig_t */
121
122 GMX_LIBMD_EXPORT
123 void copy_coupling_state(t_state *statea,t_state *stateb,
124                          gmx_ekindata_t *ekinda,gmx_ekindata_t *ekindb, t_grpopts* opts);
125 /* Copy stuff from state A to state B */
126
127 GMX_LIBMD_EXPORT
128 void compute_globals(FILE *fplog, gmx_global_stat_t gstat, t_commrec *cr, t_inputrec *ir,
129                      t_forcerec *fr, gmx_ekindata_t *ekind,
130                      t_state *state, t_state *state_global, t_mdatoms *mdatoms,
131                      t_nrnb *nrnb, t_vcm *vcm, gmx_wallcycle_t wcycle,
132                      gmx_enerdata_t *enerd,tensor force_vir, tensor shake_vir, tensor total_vir,
133                      tensor pres, rvec mu_tot, gmx_constr_t constr,
134                      globsig_t *gs,gmx_bool bInterSimGS,
135                      matrix box, gmx_mtop_t *top_global, real *pcurr,
136                      int natoms, gmx_bool *bSumEkinhOld, int flags);
137 /* Compute global variables during integration */
138
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif  /* _md_support_h */