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.
36 * Note: this file was generated by the GROMACS c kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomP1P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: CubicSplineTable
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwCSTab_GeomP1P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
77 real velec,felec,velecsum,facel,crf,krf,krf2;
80 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
84 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
92 jindex = nlist->jindex;
94 shiftidx = nlist->shift;
96 shiftvec = fr->shift_vec[0];
97 fshift = fr->fshift[0];
99 charge = mdatoms->chargeA;
103 nvdwtype = fr->ntype;
105 vdwtype = mdatoms->typeA;
107 vftab = kernel_data->table_vdw->data;
108 vftabscale = kernel_data->table_vdw->scale;
110 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
111 rcutoff = fr->rcoulomb;
112 rcutoff2 = rcutoff*rcutoff;
117 /* Start outer loop over neighborlists */
118 for(iidx=0; iidx<nri; iidx++)
120 /* Load shift vector for this list */
121 i_shift_offset = DIM*shiftidx[iidx];
122 shX = shiftvec[i_shift_offset+XX];
123 shY = shiftvec[i_shift_offset+YY];
124 shZ = shiftvec[i_shift_offset+ZZ];
126 /* Load limits for loop over neighbors */
127 j_index_start = jindex[iidx];
128 j_index_end = jindex[iidx+1];
130 /* Get outer coordinate index */
132 i_coord_offset = DIM*inr;
134 /* Load i particle coords and add shift vector */
135 ix0 = shX + x[i_coord_offset+DIM*0+XX];
136 iy0 = shY + x[i_coord_offset+DIM*0+YY];
137 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
143 /* Load parameters for i particles */
144 iq0 = facel*charge[inr+0];
145 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
147 /* Reset potential sums */
151 /* Start inner kernel loop */
152 for(jidx=j_index_start; jidx<j_index_end; jidx++)
154 /* Get j neighbor index, and coordinate index */
156 j_coord_offset = DIM*jnr;
158 /* load j atom coordinates */
159 jx0 = x[j_coord_offset+DIM*0+XX];
160 jy0 = x[j_coord_offset+DIM*0+YY];
161 jz0 = x[j_coord_offset+DIM*0+ZZ];
163 /* Calculate displacement vector */
168 /* Calculate squared distance and things based on it */
169 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
171 rinv00 = gmx_invsqrt(rsq00);
173 rinvsq00 = rinv00*rinv00;
175 /* Load parameters for j particles */
177 vdwjidx0 = 2*vdwtype[jnr+0];
179 /**************************
180 * CALCULATE INTERACTIONS *
181 **************************/
189 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
190 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
192 /* Calculate table index by multiplying r with table scale and truncate to integer */
198 /* REACTION-FIELD ELECTROSTATICS */
199 velec = qq00*(rinv00+krf*rsq00-crf);
200 felec = qq00*(rinv00*rinvsq00-krf2);
202 /* CUBIC SPLINE TABLE DISPERSION */
206 Geps = vfeps*vftab[vfitab+2];
207 Heps2 = vfeps*vfeps*vftab[vfitab+3];
211 FF = Fp+Geps+2.0*Heps2;
214 /* CUBIC SPLINE TABLE REPULSION */
217 Geps = vfeps*vftab[vfitab+6];
218 Heps2 = vfeps*vfeps*vftab[vfitab+7];
222 FF = Fp+Geps+2.0*Heps2;
225 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
227 /* Update potential sums from outer loop */
233 /* Calculate temporary vectorial force */
238 /* Update vectorial force */
242 f[j_coord_offset+DIM*0+XX] -= tx;
243 f[j_coord_offset+DIM*0+YY] -= ty;
244 f[j_coord_offset+DIM*0+ZZ] -= tz;
248 /* Inner loop uses 66 flops */
250 /* End of innermost loop */
253 f[i_coord_offset+DIM*0+XX] += fix0;
254 f[i_coord_offset+DIM*0+YY] += fiy0;
255 f[i_coord_offset+DIM*0+ZZ] += fiz0;
259 fshift[i_shift_offset+XX] += tx;
260 fshift[i_shift_offset+YY] += ty;
261 fshift[i_shift_offset+ZZ] += tz;
264 /* Update potential energies */
265 kernel_data->energygrp_elec[ggid] += velecsum;
266 kernel_data->energygrp_vdw[ggid] += vvdwsum;
268 /* Increment number of inner iterations */
269 inneriter += j_index_end - j_index_start;
271 /* Outer loop uses 15 flops */
274 /* Increment number of outer iterations */
277 /* Update outer/inner flops */
279 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*66);
282 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomP1P1_F_c
283 * Electrostatics interaction: ReactionField
284 * VdW interaction: CubicSplineTable
285 * Geometry: Particle-Particle
286 * Calculate force/pot: Force
289 nb_kernel_ElecRFCut_VdwCSTab_GeomP1P1_F_c
290 (t_nblist * gmx_restrict nlist,
291 rvec * gmx_restrict xx,
292 rvec * gmx_restrict ff,
293 t_forcerec * gmx_restrict fr,
294 t_mdatoms * gmx_restrict mdatoms,
295 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
296 t_nrnb * gmx_restrict nrnb)
298 int i_shift_offset,i_coord_offset,j_coord_offset;
299 int j_index_start,j_index_end;
300 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
301 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
302 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
303 real *shiftvec,*fshift,*x,*f;
305 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
307 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
308 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
309 real velec,felec,velecsum,facel,crf,krf,krf2;
312 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
316 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
324 jindex = nlist->jindex;
326 shiftidx = nlist->shift;
328 shiftvec = fr->shift_vec[0];
329 fshift = fr->fshift[0];
331 charge = mdatoms->chargeA;
335 nvdwtype = fr->ntype;
337 vdwtype = mdatoms->typeA;
339 vftab = kernel_data->table_vdw->data;
340 vftabscale = kernel_data->table_vdw->scale;
342 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
343 rcutoff = fr->rcoulomb;
344 rcutoff2 = rcutoff*rcutoff;
349 /* Start outer loop over neighborlists */
350 for(iidx=0; iidx<nri; iidx++)
352 /* Load shift vector for this list */
353 i_shift_offset = DIM*shiftidx[iidx];
354 shX = shiftvec[i_shift_offset+XX];
355 shY = shiftvec[i_shift_offset+YY];
356 shZ = shiftvec[i_shift_offset+ZZ];
358 /* Load limits for loop over neighbors */
359 j_index_start = jindex[iidx];
360 j_index_end = jindex[iidx+1];
362 /* Get outer coordinate index */
364 i_coord_offset = DIM*inr;
366 /* Load i particle coords and add shift vector */
367 ix0 = shX + x[i_coord_offset+DIM*0+XX];
368 iy0 = shY + x[i_coord_offset+DIM*0+YY];
369 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
375 /* Load parameters for i particles */
376 iq0 = facel*charge[inr+0];
377 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
379 /* Start inner kernel loop */
380 for(jidx=j_index_start; jidx<j_index_end; jidx++)
382 /* Get j neighbor index, and coordinate index */
384 j_coord_offset = DIM*jnr;
386 /* load j atom coordinates */
387 jx0 = x[j_coord_offset+DIM*0+XX];
388 jy0 = x[j_coord_offset+DIM*0+YY];
389 jz0 = x[j_coord_offset+DIM*0+ZZ];
391 /* Calculate displacement vector */
396 /* Calculate squared distance and things based on it */
397 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
399 rinv00 = gmx_invsqrt(rsq00);
401 rinvsq00 = rinv00*rinv00;
403 /* Load parameters for j particles */
405 vdwjidx0 = 2*vdwtype[jnr+0];
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
417 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
418 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
420 /* Calculate table index by multiplying r with table scale and truncate to integer */
426 /* REACTION-FIELD ELECTROSTATICS */
427 felec = qq00*(rinv00*rinvsq00-krf2);
429 /* CUBIC SPLINE TABLE DISPERSION */
432 Geps = vfeps*vftab[vfitab+2];
433 Heps2 = vfeps*vfeps*vftab[vfitab+3];
435 FF = Fp+Geps+2.0*Heps2;
438 /* CUBIC SPLINE TABLE REPULSION */
440 Geps = vfeps*vftab[vfitab+6];
441 Heps2 = vfeps*vfeps*vftab[vfitab+7];
443 FF = Fp+Geps+2.0*Heps2;
445 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
449 /* Calculate temporary vectorial force */
454 /* Update vectorial force */
458 f[j_coord_offset+DIM*0+XX] -= tx;
459 f[j_coord_offset+DIM*0+YY] -= ty;
460 f[j_coord_offset+DIM*0+ZZ] -= tz;
464 /* Inner loop uses 53 flops */
466 /* End of innermost loop */
469 f[i_coord_offset+DIM*0+XX] += fix0;
470 f[i_coord_offset+DIM*0+YY] += fiy0;
471 f[i_coord_offset+DIM*0+ZZ] += fiz0;
475 fshift[i_shift_offset+XX] += tx;
476 fshift[i_shift_offset+YY] += ty;
477 fshift[i_shift_offset+ZZ] += tz;
479 /* Increment number of inner iterations */
480 inneriter += j_index_end - j_index_start;
482 /* Outer loop uses 13 flops */
485 /* Increment number of outer iterations */
488 /* Update outer/inner flops */
490 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*53);