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,2015,2016,2017, 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.
37 #ifndef GMX_MDTYPES_INPUTREC_H
38 #define GMX_MDTYPES_INPUTREC_H
42 #include "gromacs/math/vectypes.h"
43 #include "gromacs/mdtypes/md_enums.h"
44 #include "gromacs/utility/basedefinitions.h"
45 #include "gromacs/utility/real.h"
47 #define EGP_EXCL (1<<0)
48 #define EGP_TABLE (1<<1)
54 class KeyValueTreeObject;
57 typedef struct t_grpopts {
58 int ngtc; /* # T-Coupl groups */
59 int nhchainlength; /* # of nose-hoover chains per group */
60 int ngacc; /* # Accelerate groups */
61 int ngfrz; /* # Freeze groups */
62 int ngener; /* # Ener groups */
63 real *nrdf; /* Nr of degrees of freedom in a group */
64 real *ref_t; /* Coupling temperature per group */
65 int *annealing; /* No/simple/periodic SA for each group */
66 int *anneal_npoints; /* Number of annealing time points per grp */
67 real **anneal_time; /* For ea. group: Time points */
68 real **anneal_temp; /* For ea. grp: Temperature at these times */
69 /* Final temp after all intervals is ref_t */
70 real *tau_t; /* Tau coupling time */
71 rvec *acc; /* Acceleration per group */
72 ivec *nFreeze; /* Freeze the group in each direction ? */
73 int *egp_flags; /* Exclusions/tables of energy group pairs */
76 int ngQM; /* nr of QM groups */
77 int *QMmethod; /* Level of theory in the QM calculation */
78 int *QMbasis; /* Basisset in the QM calculation */
79 int *QMcharge; /* Total charge in the QM region */
80 int *QMmult; /* Spin multiplicicty in the QM region */
81 gmx_bool *bSH; /* surface hopping (diabatic hop only) */
82 int *CASorbitals; /* number of orbiatls in the active space */
83 int *CASelectrons; /* number of electrons in the active space */
84 real *SAon; /* at which gap (A.U.) the SA is switched on */
86 int *SAsteps; /* in how many steps SA goes from 1-1 to 0.5-0.5*/
89 typedef struct t_simtemp {
90 int eSimTempScale; /* simulated temperature scaling; linear or exponential */
91 real simtemp_low; /* the low temperature for simulated tempering */
92 real simtemp_high; /* the high temperature for simulated tempering */
93 real *temperatures; /* the range of temperatures used for simulated tempering */
96 typedef struct t_lambda {
97 int nstdhdl; /* The frequency for calculating dhdl */
98 double init_lambda; /* fractional value of lambda (usually will use
99 init_fep_state, this will only be for slow growth,
100 and for legacy free energy code. Only has a
101 valid value if positive) */
102 int init_fep_state; /* the initial number of the state */
103 double delta_lambda; /* change of lambda per time step (fraction of (0.1) */
104 int edHdLPrintEnergy; /* print no, total or potential energies in dhdl */
105 int n_lambda; /* The number of foreign lambda points */
106 double **all_lambda; /* The array of all lambda values */
107 int lambda_neighbors; /* The number of neighboring lambda states to
108 calculate the energy for in up and down directions
110 int lambda_start_n; /* The first lambda to calculate energies for */
111 int lambda_stop_n; /* The last lambda +1 to calculate energies for */
112 real sc_alpha; /* free energy soft-core parameter */
113 int sc_power; /* lambda power for soft-core interactions */
114 real sc_r_power; /* r power for soft-core interactions */
115 real sc_sigma; /* free energy soft-core sigma when c6 or c12=0 */
116 real sc_sigma_min; /* free energy soft-core sigma for ????? */
117 gmx_bool bScCoul; /* use softcore for the coulomb portion as well (default FALSE) */
118 gmx_bool separate_dvdl[efptNR]; /* whether to print the dvdl term associated with
119 this term; if it is not specified as separate,
120 it is lumped with the FEP term */
121 int separate_dhdl_file; /* whether to write a separate dhdl.xvg file
122 note: NOT a gmx_bool, but an enum */
123 int dhdl_derivatives; /* whether to calculate+write dhdl derivatives
124 note: NOT a gmx_bool, but an enum */
125 int dh_hist_size; /* The maximum table size for the dH histogram */
126 double dh_hist_spacing; /* The spacing for the dH histogram */
129 typedef struct t_expanded {
130 int nstexpanded; /* The frequency of expanded ensemble state changes */
131 int elamstats; /* which type of move updating do we use for lambda monte carlo (or no for none) */
132 int elmcmove; /* what move set will be we using for state space moves */
133 int elmceq; /* the method we use to decide of we have equilibrated the weights */
134 int equil_n_at_lam; /* the minumum number of samples at each lambda for deciding whether we have reached a minimum */
135 real equil_wl_delta; /* WL delta at which we stop equilibrating weights */
136 real equil_ratio; /* use the ratio of weights (ratio of minimum to maximum) to decide when to stop equilibrating */
137 int equil_steps; /* after equil_steps steps we stop equilibrating the weights */
138 int equil_samples; /* after equil_samples total samples (steps/nstfep), we stop equilibrating the weights */
139 int lmc_seed; /* random number seed for lambda mc switches */
140 gmx_bool minvar; /* whether to use minumum variance weighting */
141 int minvarmin; /* the number of samples needed before kicking into minvar routine */
142 real minvar_const; /* the offset for the variance in MinVar */
143 int c_range; /* range of cvalues used for BAR */
144 gmx_bool bSymmetrizedTMatrix; /* whether to print symmetrized matrices */
145 int nstTij; /* How frequently to print the transition matrices */
146 int lmc_repeats; /* number of repetitions in the MC lambda jumps */ /*MRS -- VERIFY THIS */
147 int lmc_forced_nstart; /* minimum number of samples for each state before free sampling */ /* MRS -- VERIFY THIS! */
148 int gibbsdeltalam; /* distance in lambda space for the gibbs interval */
149 real wl_scale; /* scaling factor for wang-landau */
150 real wl_ratio; /* ratio between largest and smallest number for freezing the weights */
151 real init_wl_delta; /* starting delta for wang-landau */
152 gmx_bool bWLoneovert; /* use one over t convergece for wang-landau when the delta get sufficiently small */
153 gmx_bool bInit_weights; /* did we initialize the weights? TODO: REMOVE FOR 5.0, no longer needed with new logic */
154 real mc_temp; /* To override the main temperature, or define it if it's not defined */
155 real *init_lambda_weights; /* user-specified initial weights to start with */
159 /* Abstract types for enforced rotation only defined in pull_rotation.c */
160 typedef struct gmx_enfrot *gmx_enfrot_t;
161 typedef struct gmx_enfrotgrp *gmx_enfrotgrp_t;
164 int eType; /* Rotation type for this group */
165 int bMassW; /* Use mass-weighed positions? */
166 int nat; /* Number of atoms in the group */
167 int *ind; /* The global atoms numbers */
168 rvec *x_ref; /* The reference positions */
169 rvec vec; /* The normalized rotation vector */
170 real rate; /* Rate of rotation (degree/ps) */
171 real k; /* Force constant (kJ/(mol nm^2) */
172 rvec pivot; /* Pivot point of rotation axis (nm) */
173 int eFittype; /* Type of fit to determine actual group angle */
174 int PotAngle_nstep; /* Number of angles around the reference angle
175 for which the rotation potential is also
176 evaluated (for fit type 'potential' only) */
177 real PotAngle_step; /* Distance between two angles in degrees (for
178 fit type 'potential' only) */
179 real slab_dist; /* Slab distance (nm) */
180 real min_gaussian; /* Minimum value the gaussian must have so that
181 the force is actually evaluated */
182 real eps; /* Additive constant for radial motion2 and
183 flexible2 potentials (nm^2) */
184 gmx_enfrotgrp_t enfrotgrp; /* Stores non-inputrec rotation data per group */
187 typedef struct t_rot {
188 int ngrp; /* Number of rotation groups */
189 int nstrout; /* Output frequency for main rotation outfile */
190 int nstsout; /* Output frequency for per-slab data */
191 t_rotgrp *grp; /* Groups to rotate */
192 gmx_enfrot_t enfrot; /* Stores non-inputrec enforced rotation data */
195 /* Abstract type for IMD only defined in IMD.c */
198 typedef struct t_IMD {
199 int nat; /* Number of interactive atoms */
200 int *ind; /* The global indices of the interactive atoms */
201 struct t_gmx_IMD *setup; /* Stores non-inputrec IMD data */
204 /* Abstract types for position swapping only defined in swapcoords.cpp */
205 typedef struct t_swap *gmx_swapcoords_t;
207 typedef struct t_swapGroup {
208 char *molname; /* Name of the swap group, e.g. NA, CL, SOL */
209 int nat; /* Number of atoms in this group */
210 int *ind; /* The global ion group atoms numbers */
211 int nmolReq[eCompNR]; /* Requested number of molecules of this type
215 typedef struct t_swapcoords {
216 int nstswap; /* Every how many steps a swap is attempted? */
217 gmx_bool massw_split[2]; /* Use mass-weighted positions in split group? */
218 real cyl0r, cyl1r; /* Split cylinders defined by radius, upper and */
219 real cyl0u, cyl1u; /* ... lower extension. The split cylinders de- */
220 real cyl0l, cyl1l; /* ... fine the channels and are each anchored */
221 /* ... in the center of the split group */
222 int nAverage; /* Coupling constant (nr of swap attempt steps) */
223 real threshold; /* Ion counts may deviate from the requested
224 values by +-threshold before a swap is done */
225 real bulkOffset[eCompNR]; /* Offset of the swap layer (='bulk') w.r.t.
226 the compartment-defining layers */
227 int ngrp; /* Number of groups to be controlled */
228 t_swapGroup *grp; /* All swap groups, including split and solvent */
229 gmx_swapcoords_t si_priv; /* swap private data accessible in
236 explicit t_inputrec(const t_inputrec &) = delete;
237 t_inputrec &operator=(const t_inputrec &) = delete;
240 int eI; /* Integration method */
241 gmx_int64_t nsteps; /* number of steps to be taken */
242 int simulation_part; /* Used in checkpointing to separate chunks */
243 gmx_int64_t init_step; /* start at a stepcount >0 (used w. convert-tpr) */
244 int nstcalcenergy; /* frequency of energy calc. and T/P coupl. upd. */
245 int cutoff_scheme; /* group or verlet cutoffs */
246 int ns_type; /* which ns method should we use? */
247 int nstlist; /* number of steps before pairlist is generated */
248 int ndelta; /* number of cells per rlong */
249 int nstcomm; /* number of steps after which center of mass */
250 /* motion is removed */
251 int comm_mode; /* Center of mass motion removal algorithm */
252 int nstlog; /* number of steps after which print to logfile */
253 int nstxout; /* number of steps after which X is output */
254 int nstvout; /* id. for V */
255 int nstfout; /* id. for F */
256 int nstenergy; /* number of steps after which energies printed */
257 int nstxout_compressed; /* id. for compressed trj (.xtc,.tng) */
258 double init_t; /* initial time (ps) */
259 double delta_t; /* time step (ps) */
260 real x_compression_precision; /* precision of x in compressed trajectory file */
261 real fourier_spacing; /* requested fourier_spacing, when nk? not set */
262 int nkx, nky, nkz; /* number of k vectors in each spatial dimension*/
263 /* for fourier methods for long range electrost.*/
264 int pme_order; /* interpolation order for PME */
265 real ewald_rtol; /* Real space tolerance for Ewald, determines */
266 /* the real/reciprocal space relative weight */
267 real ewald_rtol_lj; /* Real space tolerance for LJ-Ewald */
268 int ewald_geometry; /* normal/3d ewald, or pseudo-2d LR corrections */
269 real epsilon_surface; /* Epsilon for PME dipole correction */
270 int ljpme_combination_rule; /* Type of combination rule in LJ-PME */
271 int ePBC; /* Type of periodic boundary conditions */
272 int bPeriodicMols; /* Periodic molecules */
273 gmx_bool bContinuation; /* Continuation run: starting state is correct */
274 int etc; /* temperature coupling */
275 int nsttcouple; /* interval in steps for temperature coupling */
276 gmx_bool bPrintNHChains; /* whether to print nose-hoover chains */
277 int epc; /* pressure coupling */
278 int epct; /* pressure coupling type */
279 int nstpcouple; /* interval in steps for pressure coupling */
280 real tau_p; /* pressure coupling time (ps) */
281 tensor ref_p; /* reference pressure (kJ/(mol nm^3)) */
282 tensor compress; /* compressability ((mol nm^3)/kJ) */
283 int refcoord_scaling; /* How to scale absolute reference coordinates */
284 rvec posres_com; /* The COM of the posres atoms */
285 rvec posres_comB; /* The B-state COM of the posres atoms */
286 int andersen_seed; /* Random seed for Andersen thermostat (obsolete) */
287 real verletbuf_tol; /* Per atom pair energy drift tolerance (kJ/mol/ps/atom) for list buffer */
288 real rlist; /* short range pairlist cut-off (nm) */
289 real rtpi; /* Radius for test particle insertion */
290 int coulombtype; /* Type of electrostatics treatment */
291 int coulomb_modifier; /* Modify the Coulomb interaction */
292 real rcoulomb_switch; /* Coulomb switch range start (nm) */
293 real rcoulomb; /* Coulomb cutoff (nm) */
294 real epsilon_r; /* relative dielectric constant */
295 real epsilon_rf; /* relative dielectric constant of the RF */
296 int implicit_solvent; /* No (=explicit water), or GBSA solvent models */
297 int gb_algorithm; /* Algorithm to use for calculation Born radii */
298 int nstgbradii; /* Frequency of updating Generalized Born radii */
299 real rgbradii; /* Cutoff for GB radii calculation */
300 real gb_saltconc; /* Salt concentration (M) for GBSA models */
301 real gb_epsilon_solvent; /* dielectric coeff. of implicit solvent */
302 real gb_obc_alpha; /* 1st scaling factor for Bashford-Case GB */
303 real gb_obc_beta; /* 2nd scaling factor for Bashford-Case GB */
304 real gb_obc_gamma; /* 3rd scaling factor for Bashford-Case GB */
305 real gb_dielectric_offset; /* Dielectric offset for Still/HCT/OBC */
306 int sa_algorithm; /* Algorithm for SA part of GBSA */
307 real sa_surface_tension; /* Energy factor for SA part of GBSA */
308 int vdwtype; /* Type of Van der Waals treatment */
309 int vdw_modifier; /* Modify the VdW interaction */
310 real rvdw_switch; /* Van der Waals switch range start (nm) */
311 real rvdw; /* Van der Waals cutoff (nm) */
312 int eDispCorr; /* Perform Long range dispersion corrections */
313 real tabext; /* Extension of the table beyond the cut-off, *
314 * as well as the table length for 1-4 interac. */
315 real shake_tol; /* tolerance for shake */
316 int efep; /* free energy calculations */
317 t_lambda *fepvals; /* Data for the FEP state */
318 gmx_bool bSimTemp; /* Whether to do simulated tempering */
319 t_simtemp *simtempvals; /* Variables for simulated tempering */
320 gmx_bool bExpanded; /* Whether expanded ensembles are used */
321 t_expanded *expandedvals; /* Expanded ensemble parameters */
322 int eDisre; /* Type of distance restraining */
323 real dr_fc; /* force constant for ta_disre */
324 int eDisreWeighting; /* type of weighting of pairs in one restraints */
325 gmx_bool bDisreMixed; /* Use comb of time averaged and instan. viol's */
326 int nstdisreout; /* frequency of writing pair distances to enx */
327 real dr_tau; /* time constant for memory function in disres */
328 real orires_fc; /* force constant for orientational restraints */
329 real orires_tau; /* time constant for memory function in orires */
330 int nstorireout; /* frequency of writing tr(SD) to enx */
331 real em_stepsize; /* The stepsize for updating */
332 real em_tol; /* The tolerance */
333 int niter; /* Number of iterations for convergence of */
334 /* steepest descent in relax_shells */
335 real fc_stepsize; /* Stepsize for directional minimization */
336 /* in relax_shells */
337 int nstcgsteep; /* number of steps after which a steepest */
338 /* descents step is done while doing cg */
339 int nbfgscorr; /* Number of corrections to the hessian to keep */
340 int eConstrAlg; /* Type of constraint algorithm */
341 int nProjOrder; /* Order of the LINCS Projection Algorithm */
342 real LincsWarnAngle; /* If bond rotates more than %g degrees, warn */
343 int nLincsIter; /* Number of iterations in the final Lincs step */
344 gmx_bool bShakeSOR; /* Use successive overrelaxation for shake */
345 real bd_fric; /* Friction coefficient for BD (amu/ps) */
346 gmx_int64_t ld_seed; /* Random seed for SD and BD */
347 int nwall; /* The number of walls */
348 int wall_type; /* The type of walls */
349 real wall_r_linpot; /* The potentail is linear for r<=wall_r_linpot */
350 int wall_atomtype[2]; /* The atom type for walls */
351 real wall_density[2]; /* Number density for walls */
352 real wall_ewald_zfac; /* Scaling factor for the box for Ewald */
354 /* COM pulling data */
355 gmx_bool bPull; /* Do we do COM pulling? */
356 struct pull_params_t *pull; /* The data for center of mass pulling */
357 struct pull_t *pull_work; /* The COM pull force calculation data structure; TODO this pointer should live somewhere else */
359 /* Enforced rotation data */
360 gmx_bool bRot; /* Calculate enforced rotation potential(s)? */
361 t_rot *rot; /* The data for enforced rotation potentials */
363 int eSwapCoords; /* Do ion/water position exchanges (CompEL)? */
366 gmx_bool bIMD; /* Allow interactive MD sessions for this .tpr? */
367 t_IMD *imd; /* Interactive molecular dynamics */
369 real cos_accel; /* Acceleration for viscosity calculation */
370 tensor deform; /* Triclinic deformation velocities (nm/ps) */
371 int userint1; /* User determined parameters */
379 t_grpopts opts; /* Group options */
380 gmx_bool bQMMM; /* QM/MM calculation */
381 int QMconstraints; /* constraints on QM bonds */
382 int QMMMscheme; /* Scheme: ONIOM or normal */
383 real scalefactor; /* factor for scaling the MM charges in QM calc.*/
385 /* Fields for removed features go here (better caching) */
386 gmx_bool bAdress; // Whether AdResS is enabled - always false if a valid .tpr was read
387 gmx_bool useTwinRange; // Whether twin-range scheme is active - always false if a valid .tpr was read
389 gmx::KeyValueTreeObject *params;
392 int ir_optimal_nstcalcenergy(const t_inputrec *ir);
394 int tcouple_min_integration_steps(int etc);
396 int ir_optimal_nsttcouple(const t_inputrec *ir);
398 int pcouple_min_integration_steps(int epc);
400 int ir_optimal_nstpcouple(const t_inputrec *ir);
402 /* Returns if the Coulomb force or potential is switched to zero */
403 gmx_bool ir_coulomb_switched(const t_inputrec *ir);
405 /* Returns if the Coulomb interactions are zero beyond the rcoulomb.
406 * Note: always returns TRUE for the Verlet cut-off scheme.
408 gmx_bool ir_coulomb_is_zero_at_cutoff(const t_inputrec *ir);
410 /* As ir_coulomb_is_zero_at_cutoff, but also returns TRUE for user tabulated
411 * interactions, since these might be zero beyond rcoulomb.
413 gmx_bool ir_coulomb_might_be_zero_at_cutoff(const t_inputrec *ir);
415 /* Returns if the Van der Waals force or potential is switched to zero */
416 gmx_bool ir_vdw_switched(const t_inputrec *ir);
418 /* Returns if the Van der Waals interactions are zero beyond the rvdw.
419 * Note: always returns TRUE for the Verlet cut-off scheme.
421 gmx_bool ir_vdw_is_zero_at_cutoff(const t_inputrec *ir);
423 /* As ir_vdw_is_zero_at_cutoff, but also returns TRUE for user tabulated
424 * interactions, since these might be zero beyond rvdw.
426 gmx_bool ir_vdw_might_be_zero_at_cutoff(const t_inputrec *ir);
428 /*! \brief Free memory from input record.
430 * All arrays and pointers will be freed.
432 * \param[in] ir The data structure
434 void done_inputrec(t_inputrec *ir);
436 void pr_inputrec(FILE *fp, int indent, const char *title, const t_inputrec *ir,
437 gmx_bool bMDPformat);
439 void cmp_inputrec(FILE *fp, const t_inputrec *ir1, const t_inputrec *ir2, real ftol, real abstol);
441 void comp_pull_AB(FILE *fp, pull_params_t *pull, real ftol, real abstol);
444 gmx_bool inputrecDeform(const t_inputrec *ir);
446 gmx_bool inputrecDynamicBox(const t_inputrec *ir);
448 gmx_bool inputrecPreserveShape(const t_inputrec *ir);
450 gmx_bool inputrecNeedMutot(const t_inputrec *ir);
452 gmx_bool inputrecTwinRange(const t_inputrec *ir);
454 gmx_bool inputrecExclForces(const t_inputrec *ir);
456 gmx_bool inputrecNptTrotter(const t_inputrec *ir);
458 gmx_bool inputrecNvtTrotter(const t_inputrec *ir);
460 gmx_bool inputrecNphTrotter(const t_inputrec *ir);
462 /*! \brief Return true if the simulation is 2D periodic with two walls. */
463 bool inputrecPbcXY2Walls(const t_inputrec *ir);
465 /* Returns true for MD integator with T and/or P-coupling that supports
466 * calculating the conserved energy quantity.
468 bool integratorHasConservedEnergyQuantity(const t_inputrec *ir);
470 /*! \brief Return the number of bounded dimensions
472 * \param[in] ir The input record with MD parameters
473 * \return the number of dimensions in which
474 * the coordinates of the particles are bounded, starting at X.
476 int inputrec2nboundeddim(const t_inputrec *ir);
478 /*! \brief Returns the number of degrees of freedom in center of mass motion
480 * \param[in] ir the inputrec structure
481 * \return the number of degrees of freedom of the center of mass
483 int ndof_com(const t_inputrec *ir);
485 #endif /* GMX_MDTYPES_INPUTREC_H */