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.
39 #include "gromacs/legacyheaders/inputrec.h"
41 #include "gromacs/legacyheaders/macros.h"
42 #include "gromacs/legacyheaders/typedefs.h"
43 #include "gromacs/utility/fatalerror.h"
46 /* The minimum number of integration steps required for reasonably accurate
47 * integration of first and second order coupling algorithms.
49 const int nstmin_berendsen_tcouple = 5;
50 const int nstmin_berendsen_pcouple = 10;
51 const int nstmin_harmonic = 20;
53 static int nst_wanted(const t_inputrec *ir)
65 int ir_optimal_nstcalcenergy(const t_inputrec *ir)
67 return nst_wanted(ir);
70 int tcouple_min_integration_steps(int etc)
81 n = nstmin_berendsen_tcouple;
84 /* V-rescale supports instantaneous rescaling */
91 case etcANDERSENMASSIVE:
95 gmx_incons("Unknown etc value");
102 int ir_optimal_nsttcouple(const t_inputrec *ir)
104 int nmin, nwanted, n;
108 nmin = tcouple_min_integration_steps(ir->etc);
110 nwanted = nst_wanted(ir);
113 if (ir->etc != etcNO)
115 for (g = 0; g < ir->opts.ngtc; g++)
117 if (ir->opts.tau_t[g] > 0)
119 tau_min = min(tau_min, ir->opts.tau_t[g]);
124 if (nmin == 0 || ir->delta_t*nwanted <= tau_min)
130 n = (int)(tau_min/(ir->delta_t*nmin) + 0.001);
135 while (nwanted % n != 0)
144 int pcouple_min_integration_steps(int epc)
155 n = nstmin_berendsen_pcouple;
157 case epcPARRINELLORAHMAN:
162 gmx_incons("Unknown epc value");
169 int ir_optimal_nstpcouple(const t_inputrec *ir)
171 int nmin, nwanted, n;
173 nmin = pcouple_min_integration_steps(ir->epc);
175 nwanted = nst_wanted(ir);
177 if (nmin == 0 || ir->delta_t*nwanted <= ir->tau_p)
183 n = (int)(ir->tau_p/(ir->delta_t*nmin) + 0.001);
188 while (nwanted % n != 0)
197 gmx_bool ir_coulomb_switched(const t_inputrec *ir)
199 return (ir->coulombtype == eelSWITCH ||
200 ir->coulombtype == eelSHIFT ||
201 ir->coulombtype == eelENCADSHIFT ||
202 ir->coulombtype == eelPMESWITCH ||
203 ir->coulombtype == eelPMEUSERSWITCH ||
204 ir->coulomb_modifier == eintmodPOTSWITCH ||
205 ir->coulomb_modifier == eintmodFORCESWITCH);
208 gmx_bool ir_coulomb_is_zero_at_cutoff(const t_inputrec *ir)
210 return (ir->cutoff_scheme == ecutsVERLET ||
211 ir_coulomb_switched(ir) || ir->coulomb_modifier != eintmodNONE ||
212 ir->coulombtype == eelRF_ZERO);
215 gmx_bool ir_coulomb_might_be_zero_at_cutoff(const t_inputrec *ir)
217 return (ir_coulomb_is_zero_at_cutoff(ir) || ir->coulombtype == eelUSER || ir->coulombtype == eelPMEUSER);
220 gmx_bool ir_vdw_switched(const t_inputrec *ir)
222 return (ir->vdwtype == evdwSWITCH ||
223 ir->vdwtype == evdwSHIFT ||
224 ir->vdwtype == evdwENCADSHIFT ||
225 ir->vdw_modifier == eintmodPOTSWITCH ||
226 ir->vdw_modifier == eintmodFORCESWITCH);
229 gmx_bool ir_vdw_is_zero_at_cutoff(const t_inputrec *ir)
231 return (ir->cutoff_scheme == ecutsVERLET ||
232 ir_vdw_switched(ir) || ir->vdw_modifier != eintmodNONE);
235 gmx_bool ir_vdw_might_be_zero_at_cutoff(const t_inputrec *ir)
237 return (ir_vdw_is_zero_at_cutoff(ir) || ir->vdwtype == evdwUSER);