2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
45 #include "gmx_omp_nthreads.h"
46 #include "nbnxn_kernel_ref.h"
47 #include "../nbnxn_consts.h"
48 #include "nbnxn_kernel_common.h"
50 /*! \brief Typedefs for declaring lookup tables of kernel functions.
53 typedef void (*p_nbk_func_noener)(const nbnxn_pairlist_t *nbl,
54 const nbnxn_atomdata_t *nbat,
55 const interaction_const_t *ic,
60 typedef void (*p_nbk_func_ener)(const nbnxn_pairlist_t *nbl,
61 const nbnxn_atomdata_t *nbat,
62 const interaction_const_t *ic,
69 /* Analytical reaction-field kernels */
71 #include "nbnxn_kernel_ref_includes.h"
72 #define VDW_FORCE_SWITCH
73 #include "nbnxn_kernel_ref_includes.h"
74 #undef VDW_FORCE_SWITCH
75 #define VDW_POT_SWITCH
76 #include "nbnxn_kernel_ref_includes.h"
81 /* Tabulated exclusion interaction electrostatics kernels */
83 #include "nbnxn_kernel_ref_includes.h"
84 #define VDW_FORCE_SWITCH
85 #include "nbnxn_kernel_ref_includes.h"
86 #undef VDW_FORCE_SWITCH
87 #define VDW_POT_SWITCH
88 #include "nbnxn_kernel_ref_includes.h"
90 /* Twin-range cut-off kernels */
91 #define VDW_CUTOFF_CHECK
92 #include "nbnxn_kernel_ref_includes.h"
93 #define VDW_FORCE_SWITCH
94 #include "nbnxn_kernel_ref_includes.h"
95 #undef VDW_FORCE_SWITCH
96 #define VDW_POT_SWITCH
97 #include "nbnxn_kernel_ref_includes.h"
99 #undef VDW_CUTOFF_CHECK
104 coultRF, coultTAB, coultTAB_TWIN, coultNR
108 vdwtCUT, vdwtFSWITCH, vdwtPSWITCH, vdwtNR
111 p_nbk_func_noener p_nbk_c_noener[coultNR][vdwtNR] =
113 { nbnxn_kernel_ElecRF_VdwLJ_F_ref, nbnxn_kernel_ElecRF_VdwLJFsw_F_ref, nbnxn_kernel_ElecRF_VdwLJPsw_F_ref },
114 { nbnxn_kernel_ElecQSTab_VdwLJ_F_ref, nbnxn_kernel_ElecQSTab_VdwLJFsw_F_ref, nbnxn_kernel_ElecQSTab_VdwLJPsw_F_ref },
115 { nbnxn_kernel_ElecQSTabTwinCut_VdwLJ_F_ref, nbnxn_kernel_ElecQSTabTwinCut_VdwLJFsw_F_ref, nbnxn_kernel_ElecQSTabTwinCut_VdwLJPsw_F_ref }
118 p_nbk_func_ener p_nbk_c_ener[coultNR][vdwtNR] =
120 { nbnxn_kernel_ElecRF_VdwLJ_VF_ref, nbnxn_kernel_ElecRF_VdwLJFsw_VF_ref, nbnxn_kernel_ElecRF_VdwLJPsw_VF_ref },
121 { nbnxn_kernel_ElecQSTab_VdwLJ_VF_ref, nbnxn_kernel_ElecQSTab_VdwLJFsw_VF_ref, nbnxn_kernel_ElecQSTab_VdwLJPsw_VF_ref },
122 { nbnxn_kernel_ElecQSTabTwinCut_VdwLJ_VF_ref, nbnxn_kernel_ElecQSTabTwinCut_VdwLJFsw_VF_ref, nbnxn_kernel_ElecQSTabTwinCut_VdwLJPsw_VF_ref }
125 p_nbk_func_ener p_nbk_c_energrp[coultNR][vdwtNR] =
127 { nbnxn_kernel_ElecRF_VdwLJ_VgrpF_ref, nbnxn_kernel_ElecRF_VdwLJFsw_VgrpF_ref, nbnxn_kernel_ElecRF_VdwLJPsw_VgrpF_ref },
128 { nbnxn_kernel_ElecQSTab_VdwLJ_VgrpF_ref, nbnxn_kernel_ElecQSTab_VdwLJFsw_VgrpF_ref, nbnxn_kernel_ElecQSTab_VdwLJPsw_VgrpF_ref },
129 { nbnxn_kernel_ElecQSTabTwinCut_VdwLJ_VgrpF_ref, nbnxn_kernel_ElecQSTabTwinCut_VdwLJFsw_VgrpF_ref, nbnxn_kernel_ElecQSTabTwinCut_VdwLJPsw_VgrpF_ref }
133 nbnxn_kernel_ref(const nbnxn_pairlist_set_t *nbl_list,
134 const nbnxn_atomdata_t *nbat,
135 const interaction_const_t *ic,
144 nbnxn_pairlist_t **nbl;
149 nnbl = nbl_list->nnbl;
152 if (EEL_RF(ic->eeltype) || ic->eeltype == eelCUT)
158 if (ic->rcoulomb == ic->rvdw)
164 coult = coultTAB_TWIN;
168 switch (ic->vdw_modifier)
170 case eintmodPOTSHIFT:
174 case eintmodFORCESWITCH:
177 case eintmodPOTSWITCH:
181 gmx_incons("Unsupported VdW modifier");
185 #pragma omp parallel for schedule(static) num_threads(gmx_omp_nthreads_get(emntNonbonded))
186 for (nb = 0; nb < nnbl; nb++)
188 nbnxn_atomdata_output_t *out;
191 out = &nbat->out[nb];
193 if (clearF == enbvClearFYes)
195 clear_f(nbat, nb, out->f);
198 if ((force_flags & GMX_FORCE_VIRIAL) && nnbl == 1)
204 fshift_p = out->fshift;
206 if (clearF == enbvClearFYes)
208 clear_fshift(fshift_p);
212 if (!(force_flags & GMX_FORCE_ENERGY))
214 /* Don't calculate energies */
215 p_nbk_c_noener[coult][vdwt](nbl[nb], nbat,
221 else if (out->nV == 1)
223 /* No energy groups */
227 p_nbk_c_ener[coult][vdwt](nbl[nb], nbat,
237 /* Calculate energy group contributions */
240 for (i = 0; i < out->nV; i++)
244 for (i = 0; i < out->nV; i++)
249 p_nbk_c_energrp[coult][vdwt](nbl[nb], nbat,
259 if (force_flags & GMX_FORCE_ENERGY)
261 reduce_energies_over_lists(nbat, nnbl, Vvdw, Vc);