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 * Copyright (c) 2013,2014, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
42 #include "gromacs/legacyheaders/typedefs.h"
43 #include "gromacs/fileio/tpxio.h"
44 #include "gromacs/utility/smalloc.h"
45 #include "gromacs/math/vec.h"
46 #include "gromacs/legacyheaders/mvdata.h"
47 #include "gromacs/utility/fatalerror.h"
48 #include "gromacs/legacyheaders/txtdump.h"
49 #include "gromacs/legacyheaders/mdatoms.h"
50 #include "gromacs/legacyheaders/mdrun.h"
51 #include "gromacs/legacyheaders/names.h"
52 #include "gromacs/legacyheaders/update.h"
53 #include "gromacs/legacyheaders/mdebin.h"
57 #define NOT_FINISHED(l1, l2) \
58 printf("not finished yet: lines %d .. %d in %s\n", l1, l2, __FILE__)
60 void set_state_entries(t_state *state, const t_inputrec *ir)
64 /* The entries in the state in the tpx file might not correspond
65 * with what is needed, so we correct this here.
68 if (ir->efep != efepNO || ir->bExpanded)
70 state->flags |= (1<<estLAMBDA);
71 state->flags |= (1<<estFEPSTATE);
73 state->flags |= (1<<estX);
74 if (state->lambda == NULL)
76 snew(state->lambda, efptNR);
80 snew(state->x, state->nalloc);
82 if (EI_DYNAMICS(ir->eI))
84 state->flags |= (1<<estV);
87 snew(state->v, state->nalloc);
92 state->flags |= (1<<estSDX);
93 if (state->sd_X == NULL)
95 /* sd_X is not stored in the tpx file, so we need to allocate it */
96 snew(state->sd_X, state->nalloc);
101 state->flags |= (1<<estCGP);
102 if (state->cg_p == NULL)
104 /* cg_p is not stored in the tpx file, so we need to allocate it */
105 snew(state->cg_p, state->nalloc);
110 if (ir->ePBC != epbcNONE)
112 state->flags |= (1<<estBOX);
113 if (PRESERVE_SHAPE(*ir))
115 state->flags |= (1<<estBOX_REL);
117 if ((ir->epc == epcPARRINELLORAHMAN) || (ir->epc == epcMTTK))
119 state->flags |= (1<<estBOXV);
121 if (ir->epc != epcNO)
123 if (IR_NPT_TROTTER(ir) || (IR_NPH_TROTTER(ir)))
126 state->flags |= (1<<estNHPRES_XI);
127 state->flags |= (1<<estNHPRES_VXI);
128 state->flags |= (1<<estSVIR_PREV);
129 state->flags |= (1<<estFVIR_PREV);
130 state->flags |= (1<<estVETA);
131 state->flags |= (1<<estVOL0);
135 state->flags |= (1<<estPRES_PREV);
140 if (ir->etc == etcNOSEHOOVER)
142 state->flags |= (1<<estNH_XI);
143 state->flags |= (1<<estNH_VXI);
146 if (ir->etc == etcVRESCALE)
148 state->flags |= (1<<estTC_INT);
151 init_gtc_state(state, state->ngtc, state->nnhpres, ir->opts.nhchainlength); /* allocate the space for nose-hoover chains */
152 init_ekinstate(&state->ekinstate, ir);
154 init_energyhistory(&state->enerhist);
155 init_df_history(&state->dfhist, ir->fepvals->n_lambda);
156 state->swapstate.eSwapCoords = ir->eSwapCoords;
160 void init_parallel(t_commrec *cr, t_inputrec *inputrec,
163 bcast_ir_mtop(cr, inputrec, mtop);