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-2010, The GROMACS development team.
6 * Copyright (c) 2012,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/legacyheaders/macros.h"
44 #include "gromacs/legacyheaders/inputrec.h"
45 #include "gromacs/utility/fatalerror.h"
48 /* The minimum number of integration steps required for reasonably accurate
49 * integration of first and second order coupling algorithms.
51 const int nstmin_berendsen_tcouple = 5;
52 const int nstmin_berendsen_pcouple = 10;
53 const int nstmin_harmonic = 20;
55 static int nst_wanted(const t_inputrec *ir)
67 int ir_optimal_nstcalcenergy(const t_inputrec *ir)
69 return nst_wanted(ir);
72 int tcouple_min_integration_steps(int etc)
83 n = nstmin_berendsen_tcouple;
86 /* V-rescale supports instantaneous rescaling */
93 case etcANDERSENMASSIVE:
97 gmx_incons("Unknown etc value");
104 int ir_optimal_nsttcouple(const t_inputrec *ir)
106 int nmin, nwanted, n;
110 nmin = tcouple_min_integration_steps(ir->etc);
112 nwanted = nst_wanted(ir);
115 if (ir->etc != etcNO)
117 for (g = 0; g < ir->opts.ngtc; g++)
119 if (ir->opts.tau_t[g] > 0)
121 tau_min = min(tau_min, ir->opts.tau_t[g]);
126 if (nmin == 0 || ir->delta_t*nwanted <= tau_min)
132 n = (int)(tau_min/(ir->delta_t*nmin) + 0.001);
137 while (nwanted % n != 0)
146 int pcouple_min_integration_steps(int epc)
157 n = nstmin_berendsen_pcouple;
159 case epcPARRINELLORAHMAN:
164 gmx_incons("Unknown epc value");
171 int ir_optimal_nstpcouple(const t_inputrec *ir)
173 int nmin, nwanted, n;
175 nmin = pcouple_min_integration_steps(ir->epc);
177 nwanted = nst_wanted(ir);
179 if (nmin == 0 || ir->delta_t*nwanted <= ir->tau_p)
185 n = (int)(ir->tau_p/(ir->delta_t*nmin) + 0.001);
190 while (nwanted % n != 0)
199 gmx_bool ir_coulomb_switched(const t_inputrec *ir)
201 return (ir->coulombtype == eelSWITCH ||
202 ir->coulombtype == eelSHIFT ||
203 ir->coulombtype == eelENCADSHIFT ||
204 ir->coulombtype == eelPMESWITCH ||
205 ir->coulombtype == eelPMEUSERSWITCH ||
206 ir->coulomb_modifier == eintmodPOTSWITCH ||
207 ir->coulomb_modifier == eintmodFORCESWITCH);
210 gmx_bool ir_coulomb_is_zero_at_cutoff(const t_inputrec *ir)
212 return (ir->cutoff_scheme == ecutsVERLET ||
213 ir_coulomb_switched(ir) || ir->coulomb_modifier != eintmodNONE ||
214 ir->coulombtype == eelRF_ZERO);
217 gmx_bool ir_coulomb_might_be_zero_at_cutoff(const t_inputrec *ir)
219 return (ir_coulomb_is_zero_at_cutoff(ir) || ir->coulombtype == eelUSER || ir->coulombtype == eelPMEUSER);
222 gmx_bool ir_vdw_switched(const t_inputrec *ir)
224 return (ir->vdwtype == evdwSWITCH ||
225 ir->vdwtype == evdwSHIFT ||
226 ir->vdwtype == evdwENCADSHIFT ||
227 ir->vdw_modifier == eintmodPOTSWITCH ||
228 ir->vdw_modifier == eintmodFORCESWITCH);
231 gmx_bool ir_vdw_is_zero_at_cutoff(const t_inputrec *ir)
233 return (ir->cutoff_scheme == ecutsVERLET ||
234 ir_vdw_switched(ir) || ir->vdw_modifier != eintmodNONE);
237 gmx_bool ir_vdw_might_be_zero_at_cutoff(const t_inputrec *ir)
239 return (ir_vdw_is_zero_at_cutoff(ir) || ir->vdwtype == evdwUSER);