1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2010, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * For more info, check our website at http://www.gromacs.org
34 * GROningen Mixture of Alchemy and Childrens' Stories
44 #include "gmx_fatal.h"
47 /* The minimum number of integration steps required for reasonably accurate
48 * integration of first and second order coupling algorithms.
50 const int nstmin_berendsen_tcouple = 5;
51 const int nstmin_berendsen_pcouple = 10;
52 const int nstmin_harmonic = 20;
54 static int nst_wanted(const t_inputrec *ir)
66 int ir_optimal_nstcalcenergy(const t_inputrec *ir)
68 return nst_wanted(ir);
71 int tcouple_min_integration_steps(int etc)
82 n = nstmin_berendsen_tcouple;
85 /* V-rescale supports instantaneous rescaling */
92 case etcANDERSENMASSIVE:
96 gmx_incons("Unknown etc value");
103 int ir_optimal_nsttcouple(const t_inputrec *ir)
109 nmin = tcouple_min_integration_steps(ir->etc);
111 nwanted = nst_wanted(ir);
114 if (ir->etc != etcNO)
116 for(g=0; g<ir->opts.ngtc; g++)
118 if (ir->opts.tau_t[g] > 0)
120 tau_min = min(tau_min,ir->opts.tau_t[g]);
125 if (nmin == 0 || ir->delta_t*nwanted <= tau_min)
131 n = (int)(tau_min/(ir->delta_t*nmin) + 0.001);
136 while (nwanted % n != 0)
145 int pcouple_min_integration_steps(int epc)
156 n = nstmin_berendsen_pcouple;
158 case epcPARRINELLORAHMAN:
163 gmx_incons("Unknown epc value");
170 int ir_optimal_nstpcouple(const t_inputrec *ir)
174 nmin = pcouple_min_integration_steps(ir->epc);
176 nwanted = nst_wanted(ir);
178 if (nmin == 0 || ir->delta_t*nwanted <= ir->tau_p)
184 n = (int)(ir->tau_p/(ir->delta_t*nmin) + 0.001);
189 while (nwanted % n != 0)