2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017 by the GROMACS development team.
5 * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
6 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7 * and including many others, as listed in the AUTHORS file in the
8 * top-level source directory and at http://www.gromacs.org.
10 * GROMACS is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
15 * GROMACS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with GROMACS; if not, see
22 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * If you want to redistribute modifications to GROMACS, please
26 * consider that scientific software is very special. Version
27 * control is crucial - bugs must be traceable. We will be happy to
28 * consider code for inclusion in the official distribution, but
29 * derived work must not be called official GROMACS. Details are found
30 * in the README & COPYING files - if they are missing, get the
31 * official version at http://www.gromacs.org.
33 * To help us fund GROMACS development, we humbly ask that you cite
34 * the research papers on the package. Check out http://www.gromacs.org.
36 #ifndef GMX_MDTYPES_INTERACTION_CONST_H
37 #define GMX_MDTYPES_INTERACTION_CONST_H
42 #include "gromacs/mdtypes/md_enums.h"
43 #include "gromacs/utility/alignedallocator.h"
44 #include "gromacs/utility/real.h"
48 /* Used with force switching or a constant potential shift:
49 * rsw = max(r - r_switch, 0)
50 * force/p = r^-(p+1) + c2*rsw^2 + c3*rsw^3
51 * potential = r^-p + c2/3*rsw^3 + c3/4*rsw^4 + cpot
52 * With a constant potential shift c2 and c3 are both 0.
61 /* Used with potential switching:
62 * rsw = max(r - r_switch, 0)
63 * sw = 1 + c3*rsw^3 + c4*rsw^4 + c5*rsw^5
64 * dsw = 3*c3*rsw^2 + 4*c4*rsw^3 + 5*c5*rsw^4
65 * force = force*dsw - potential*sw
68 struct switch_consts_t
75 /* Convenience type for vector with aligned memory */
77 using AlignedVector = std::vector<T, gmx::AlignedAllocator<T>>;
79 /* Force/energy interpolation tables for Ewald long-range corrections
81 * Interpolation is linear for the force, quadratic for the potential.
83 struct EwaldCorrectionTables
85 // 1/table_spacing, units 1/nm
88 AlignedVector<real> tableF;
90 AlignedVector<real> tableV;
91 // Coulomb force+energy table, size of array is tabq_size*4,
92 // entry quadruplets are: F[i], F[i+1]-F[i], V[i], 0,
93 // this is used with 4-wide SIMD for aligned loads
94 AlignedVector<real> tableFDV0;
97 /* The physical interaction parameters for non-bonded interaction calculations
99 * This struct contains copies of the physical interaction parameters
100 * from the user input as well as processed values that are need in
101 * non-bonded interaction kernels.
103 * The default constructor gives plain Coulomb and LJ interactions cut off
104 * a 1 nm without potential shifting and a Coulomb pre-factor of 1.
106 struct interaction_const_t
108 /* This struct contains the soft-core parameters from t_lambda,
109 * but processed for direct use in the kernels.
111 struct SoftCoreParameters
114 SoftCoreParameters(const t_lambda& fepvals);
116 // Alpha parameter for Van der Waals interactions
118 // Alpha parameter for Coulomb interactions
120 // Exponent for the dependence of the soft-core on lambda
122 // Value for sigma^6 for LJ interaction with C6<=0 and/or C12<=0
123 real sigma6WithInvalidSigma;
124 // Minimum value for sigma^6, used when soft-core is applied to Coulomb interactions
129 VanDerWaalsType vdwtype = VanDerWaalsType::Cut;
130 InteractionModifiers vdw_modifier = InteractionModifiers::None;
133 real rvdw_switch = 0;
134 struct shift_consts_t dispersion_shift = { 0, 0, 0 };
135 struct shift_consts_t repulsion_shift = { 0, 0, 0 };
136 struct switch_consts_t vdw_switch = { 0, 0, 0 };
137 bool useBuckingham = false;
138 real buckinghamBMax = 0;
140 /* type of electrostatics */
141 CoulombInteractionType eeltype = CoulombInteractionType::Cut;
142 InteractionModifiers coulomb_modifier = InteractionModifiers::None;
146 real rcoulomb_switch = 0;
149 real ewaldcoeff_q = 0;
150 real ewaldcoeff_lj = 0;
151 LongRangeVdW ljpme_comb_rule = LongRangeVdW::Geom; /* LJ combination rule for the LJ PME mesh part */
152 real sh_ewald = 0; /* -sh_ewald is added to the direct space potential */
153 real sh_lj_ewald = 0; /* sh_lj_ewald is added to the correction potential */
155 /* Dielectric constant resp. multiplication factor for charges */
159 /* Constants for reaction-field or plain cut-off */
160 //! Dielectric constant for reaction field beyond the cutoff distance
161 real reactionFieldPermitivity = 1;
162 //! Coefficient for reaction field; scales relation between epsilon_r and reactionFieldPermitivity
163 real reactionFieldCoefficient = 0;
164 //! Constant shift to reaction field Coulomb interaction to make potential an integral of force
165 real reactionFieldShift = 0;
167 // Coulomb Ewald correction table
168 std::unique_ptr<EwaldCorrectionTables> coulombEwaldTables;
169 // Van der Waals Ewald correction table
170 std::unique_ptr<EwaldCorrectionTables> vdwEwaldTables;
172 // Free-energy parameters, only present when free-energy calculations are requested
173 std::unique_ptr<SoftCoreParameters> softCoreParameters;