2 * This file is part of the GROMACS molecular simulation package.
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.
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.
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.
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.
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.
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.
49 #include "gmx_fatal.h"
57 #include "gmx_random.h"
63 #define NOT_FINISHED(l1,l2) \
64 printf("not finished yet: lines %d .. %d in %s\n",l1,l2,__FILE__)
66 static char *int_title(const char *title,int nodeid,char buf[], int size)
68 sprintf(buf,"%s (%d)",title,nodeid);
73 void set_state_entries(t_state *state,const t_inputrec *ir,int nnodes)
77 /* The entries in the state in the tpx file might not correspond
78 * with what is needed, so we correct this here.
81 if (ir->efep != efepNO || ir->bExpanded)
83 state->flags |= (1<<estLAMBDA);
84 state->flags |= (1<<estFEPSTATE);
86 state->flags |= (1<<estX);
87 if (state->lambda==NULL)
89 snew(state->lambda,efptNR);
92 snew(state->x,state->nalloc);
93 if (EI_DYNAMICS(ir->eI)) {
94 state->flags |= (1<<estV);
96 snew(state->v,state->nalloc);
98 if (ir->eI == eiSD2) {
99 state->flags |= (1<<estSDX);
100 if (state->sd_X == NULL) {
101 /* sd_X is not stored in the tpx file, so we need to allocate it */
102 snew(state->sd_X,state->nalloc);
107 state->flags |= (1<<estCGP);
108 if (state->cg_p == NULL)
110 /* cg_p is not stored in the tpx file, so we need to allocate it */
111 snew(state->cg_p,state->nalloc);
114 if (EI_SD(ir->eI) || ir->eI == eiBD || ir->etc == etcVRESCALE || ETC_ANDERSEN(ir->etc)) {
115 state->nrng = gmx_rng_n();
117 if (EI_SD(ir->eI) || ir->eI == eiBD || ETC_ANDERSEN(ir->etc)) {
118 /* This will be correct later with DD */
119 state->nrng *= nnodes;
120 state->nrngi *= nnodes;
122 state->flags |= ((1<<estLD_RNG) | (1<<estLD_RNGI));
123 snew(state->ld_rng, state->nrng);
124 snew(state->ld_rngi,state->nrngi);
131 state->nmcrng = gmx_rng_n();
132 snew(state->mc_rng,state->nmcrng);
133 snew(state->mc_rngi,1);
137 if (ir->ePBC != epbcNONE) {
138 state->flags |= (1<<estBOX);
139 if (PRESERVE_SHAPE(*ir)) {
140 state->flags |= (1<<estBOX_REL);
142 if ((ir->epc == epcPARRINELLORAHMAN) || (ir->epc == epcMTTK))
144 state->flags |= (1<<estBOXV);
146 if (ir->epc != epcNO)
148 if (IR_NPT_TROTTER(ir) || (IR_NPH_TROTTER(ir)))
151 state->flags |= (1<<estNHPRES_XI);
152 state->flags |= (1<<estNHPRES_VXI);
153 state->flags |= (1<<estSVIR_PREV);
154 state->flags |= (1<<estFVIR_PREV);
155 state->flags |= (1<<estVETA);
156 state->flags |= (1<<estVOL0);
160 state->flags |= (1<<estPRES_PREV);
165 if (ir->etc == etcNOSEHOOVER) {
166 state->flags |= (1<<estNH_XI);
167 state->flags |= (1<<estNH_VXI);
170 if (ir->etc == etcVRESCALE) {
171 state->flags |= (1<<estTC_INT);
174 init_gtc_state(state,state->ngtc,state->nnhpres,ir->opts.nhchainlength); /* allocate the space for nose-hoover chains */
175 init_ekinstate(&state->ekinstate,ir);
177 init_energyhistory(&state->enerhist);
178 init_df_history(&state->dfhist,ir->fepvals->n_lambda,ir->expandedvals->init_wl_delta);
182 void init_parallel(FILE *log, t_commrec *cr, t_inputrec *inputrec,
185 bcast_ir_mtop(cr,inputrec,mtop);
187 if (inputrec->eI == eiBD || EI_SD(inputrec->eI) || ETC_ANDERSEN(inputrec->etc)) {
188 /* Make sure the random seeds are different on each node */
189 inputrec->ld_seed += cr->nodeid;