Update copyright statements and change license to LGPL
[alexxy/gromacs.git] / include / sim_util.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, 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 _sim_util_h
40 #define _sim_util_h
41
42 #include <time.h>
43 #include "visibility.h"
44 #include "typedefs.h"
45 #include "enxio.h"
46 #include "mdebin.h"
47 #include "update.h"
48 #include "vcm.h"
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 typedef struct {
55   t_fileio *fp_trn;
56   t_fileio *fp_xtc;
57   int  xtc_prec;
58   ener_file_t fp_ene;
59   const char *fn_cpt;
60   gmx_bool bKeepAndNumCPT;
61   int  eIntegrator;
62   gmx_bool  bExpanded;
63   int elamstats;
64   int  simulation_part;
65   FILE *fp_dhdl;
66   FILE *fp_field;
67 } gmx_mdoutf_t;
68
69 typedef struct gmx_global_stat *gmx_global_stat_t;
70
71 typedef struct {
72   double real;
73 #ifdef GMX_CRAY_XT3
74   double proc;
75 #else
76   clock_t proc;
77 #endif
78   double realtime;
79   double proctime;
80   double time_per_step;
81   double last;
82   gmx_large_int_t nsteps_done;
83 } gmx_runtime_t;
84
85
86 GMX_LIBMD_EXPORT
87 void do_pbc_first(FILE *log,matrix box,t_forcerec *fr,
88                          t_graph *graph,rvec x[]);
89
90 GMX_LIBMD_EXPORT
91 void do_pbc_first_mtop(FILE *fplog,int ePBC,matrix box,
92                               gmx_mtop_t *mtop,rvec x[]);
93
94 GMX_LIBMD_EXPORT
95 void do_pbc_mtop(FILE *fplog,int ePBC,matrix box,
96                         gmx_mtop_t *mtop,rvec x[]);
97
98
99                      
100 /* ROUTINES from stat.c */
101 GMX_LIBMD_EXPORT
102 gmx_global_stat_t global_stat_init(t_inputrec *ir);
103
104 void global_stat_destroy(gmx_global_stat_t gs);
105
106 void global_stat(FILE *log,gmx_global_stat_t gs,
107                         t_commrec *cr,gmx_enerdata_t *enerd,
108                         tensor fvir,tensor svir,rvec mu_tot,
109                         t_inputrec *inputrec,
110                         gmx_ekindata_t *ekind,
111                         gmx_constr_t constr,t_vcm *vcm,
112                         int nsig,real *sig,
113                         gmx_mtop_t *top_global, t_state *state_local, 
114                         gmx_bool bSumEkinhOld, int flags);
115 /* Communicate statistics over cr->mpi_comm_mysim */
116
117 gmx_mdoutf_t *init_mdoutf(int nfile,const t_filenm fnm[],
118                                  int mdrun_flags,
119                                  const t_commrec *cr,const t_inputrec *ir,
120                                  const output_env_t oenv);
121 /* Returns a pointer to a data structure with all output file pointers
122  * and names required by mdrun.
123  */
124
125 GMX_LIBMD_EXPORT
126 void done_mdoutf(gmx_mdoutf_t *of);
127 /* Close all open output files and free the of pointer */
128
129 #define MDOF_X   (1<<0)
130 #define MDOF_V   (1<<1)
131 #define MDOF_F   (1<<2)
132 #define MDOF_XTC (1<<3)
133 #define MDOF_CPT (1<<4)
134
135 GMX_LIBMD_EXPORT
136 void write_traj(FILE *fplog,t_commrec *cr,
137                        gmx_mdoutf_t *of,
138                        int mdof_flags,
139                        gmx_mtop_t *top_global,
140                        gmx_large_int_t step,double t,
141                        t_state *state_local,t_state *state_global,
142                        rvec *f_local,rvec *f_global,
143                        int *n_xtc,rvec **x_xtc);
144 /* Routine that writes frames to trn, xtc and/or checkpoint.
145  * What is written is determined by the mdof_flags defined above.
146  * Data is collected to the master node only when necessary.
147  */
148
149 GMX_LIBMD_EXPORT
150 int do_per_step(gmx_large_int_t step,gmx_large_int_t nstep);
151 /* Return TRUE if io should be done */
152
153 /* ROUTINES from sim_util.c */
154
155 GMX_LIBMD_EXPORT
156 double gmx_gettime();
157
158 GMX_LIBMD_EXPORT
159 void print_time(FILE *out, gmx_runtime_t *runtime,
160                        gmx_large_int_t step,t_inputrec *ir, t_commrec *cr);
161
162 GMX_LIBMD_EXPORT
163 void runtime_start(gmx_runtime_t *runtime);
164
165 GMX_LIBMD_EXPORT
166 void runtime_end(gmx_runtime_t *runtime);
167
168 GMX_LIBMD_EXPORT
169 void runtime_upd_proc(gmx_runtime_t *runtime);
170 /* The processor time should be updated every once in a while,
171  * since on 32-bit manchines it loops after 72 minutes.
172  */
173   
174 GMX_LIBMD_EXPORT
175 void print_date_and_time(FILE *log,int pid,const char *title,
176                                 const gmx_runtime_t *runtime);
177   
178 GMX_LIBMD_EXPORT
179 void finish_run(FILE *log,t_commrec *cr,const char *confout,
180                        t_inputrec *inputrec,
181                        t_nrnb nrnb[],gmx_wallcycle_t wcycle,
182                        gmx_runtime_t *runtime,
183                        wallclock_gpu_t *gputimes,
184                        int omp_nth_pp,
185                        gmx_bool bWriteStat);
186
187 void calc_enervirdiff(FILE *fplog,int eDispCorr,t_forcerec *fr);
188
189 void calc_dispcorr(FILE *fplog,t_inputrec *ir,t_forcerec *fr,
190                    gmx_large_int_t step, int natoms,
191                    matrix box,real lambda,tensor pres,tensor virial,
192                    real *prescorr, real *enercorr, real *dvdlcorr);
193
194 void initialize_lambdas(FILE *fplog,t_inputrec *ir,int *fep_state,real *lambda,double *lam0);
195
196 GMX_LIBMD_EXPORT
197 void do_constrain_first(FILE *log,gmx_constr_t constr,
198                                t_inputrec *inputrec,t_mdatoms *md,
199                                t_state *state,rvec *f,
200                                t_graph *graph,t_commrec *cr,t_nrnb *nrnb,
201                                t_forcerec *fr, gmx_localtop_t *top, tensor shake_vir); 
202                           
203 GMX_LIBMD_EXPORT
204 void init_md(FILE *fplog,
205                     t_commrec *cr,t_inputrec *ir, const output_env_t oenv, 
206                     double *t,double *t0,
207                     real *lambda,int *fep_state, double *lam0,
208                     t_nrnb *nrnb,gmx_mtop_t *mtop,
209                     gmx_update_t *upd,
210                     int nfile,const t_filenm fnm[],
211                     gmx_mdoutf_t **outf,t_mdebin **mdebin,
212                     tensor force_vir,tensor shake_vir,
213                     rvec mu_tot,
214                     gmx_bool *bSimAnn,t_vcm **vcm, 
215                     t_state *state, unsigned long Flags);
216   /* Routine in sim_util.c */
217
218 #ifdef __cplusplus
219 }
220 #endif
221
222 #endif  /* _sim_util_h */