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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomP1P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: CubicSplineTable
51 * Geometry: Particle-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRF_VdwCSTab_GeomP1P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
75 real velec,felec,velecsum,facel,crf,krf,krf2;
78 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
82 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
90 jindex = nlist->jindex;
92 shiftidx = nlist->shift;
94 shiftvec = fr->shift_vec[0];
95 fshift = fr->fshift[0];
97 charge = mdatoms->chargeA;
101 nvdwtype = fr->ntype;
103 vdwtype = mdatoms->typeA;
105 vftab = kernel_data->table_vdw->data;
106 vftabscale = kernel_data->table_vdw->scale;
111 /* Start outer loop over neighborlists */
112 for(iidx=0; iidx<nri; iidx++)
114 /* Load shift vector for this list */
115 i_shift_offset = DIM*shiftidx[iidx];
116 shX = shiftvec[i_shift_offset+XX];
117 shY = shiftvec[i_shift_offset+YY];
118 shZ = shiftvec[i_shift_offset+ZZ];
120 /* Load limits for loop over neighbors */
121 j_index_start = jindex[iidx];
122 j_index_end = jindex[iidx+1];
124 /* Get outer coordinate index */
126 i_coord_offset = DIM*inr;
128 /* Load i particle coords and add shift vector */
129 ix0 = shX + x[i_coord_offset+DIM*0+XX];
130 iy0 = shY + x[i_coord_offset+DIM*0+YY];
131 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
137 /* Load parameters for i particles */
138 iq0 = facel*charge[inr+0];
139 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
141 /* Reset potential sums */
145 /* Start inner kernel loop */
146 for(jidx=j_index_start; jidx<j_index_end; jidx++)
148 /* Get j neighbor index, and coordinate index */
150 j_coord_offset = DIM*jnr;
152 /* load j atom coordinates */
153 jx0 = x[j_coord_offset+DIM*0+XX];
154 jy0 = x[j_coord_offset+DIM*0+YY];
155 jz0 = x[j_coord_offset+DIM*0+ZZ];
157 /* Calculate displacement vector */
162 /* Calculate squared distance and things based on it */
163 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
165 rinv00 = gmx_invsqrt(rsq00);
167 rinvsq00 = rinv00*rinv00;
169 /* Load parameters for j particles */
171 vdwjidx0 = 2*vdwtype[jnr+0];
173 /**************************
174 * CALCULATE INTERACTIONS *
175 **************************/
180 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
181 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
183 /* Calculate table index by multiplying r with table scale and truncate to integer */
189 /* REACTION-FIELD ELECTROSTATICS */
190 velec = qq00*(rinv00+krf*rsq00-crf);
191 felec = qq00*(rinv00*rinvsq00-krf2);
193 /* CUBIC SPLINE TABLE DISPERSION */
197 Geps = vfeps*vftab[vfitab+2];
198 Heps2 = vfeps*vfeps*vftab[vfitab+3];
202 FF = Fp+Geps+2.0*Heps2;
205 /* CUBIC SPLINE TABLE REPULSION */
208 Geps = vfeps*vftab[vfitab+6];
209 Heps2 = vfeps*vfeps*vftab[vfitab+7];
213 FF = Fp+Geps+2.0*Heps2;
216 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
218 /* Update potential sums from outer loop */
224 /* Calculate temporary vectorial force */
229 /* Update vectorial force */
233 f[j_coord_offset+DIM*0+XX] -= tx;
234 f[j_coord_offset+DIM*0+YY] -= ty;
235 f[j_coord_offset+DIM*0+ZZ] -= tz;
237 /* Inner loop uses 66 flops */
239 /* End of innermost loop */
242 f[i_coord_offset+DIM*0+XX] += fix0;
243 f[i_coord_offset+DIM*0+YY] += fiy0;
244 f[i_coord_offset+DIM*0+ZZ] += fiz0;
248 fshift[i_shift_offset+XX] += tx;
249 fshift[i_shift_offset+YY] += ty;
250 fshift[i_shift_offset+ZZ] += tz;
253 /* Update potential energies */
254 kernel_data->energygrp_elec[ggid] += velecsum;
255 kernel_data->energygrp_vdw[ggid] += vvdwsum;
257 /* Increment number of inner iterations */
258 inneriter += j_index_end - j_index_start;
260 /* Outer loop uses 15 flops */
263 /* Increment number of outer iterations */
266 /* Update outer/inner flops */
268 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*66);
271 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomP1P1_F_c
272 * Electrostatics interaction: ReactionField
273 * VdW interaction: CubicSplineTable
274 * Geometry: Particle-Particle
275 * Calculate force/pot: Force
278 nb_kernel_ElecRF_VdwCSTab_GeomP1P1_F_c
279 (t_nblist * gmx_restrict nlist,
280 rvec * gmx_restrict xx,
281 rvec * gmx_restrict ff,
282 t_forcerec * gmx_restrict fr,
283 t_mdatoms * gmx_restrict mdatoms,
284 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
285 t_nrnb * gmx_restrict nrnb)
287 int i_shift_offset,i_coord_offset,j_coord_offset;
288 int j_index_start,j_index_end;
289 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
290 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
291 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
292 real *shiftvec,*fshift,*x,*f;
294 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
296 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
297 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
298 real velec,felec,velecsum,facel,crf,krf,krf2;
301 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
305 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
313 jindex = nlist->jindex;
315 shiftidx = nlist->shift;
317 shiftvec = fr->shift_vec[0];
318 fshift = fr->fshift[0];
320 charge = mdatoms->chargeA;
324 nvdwtype = fr->ntype;
326 vdwtype = mdatoms->typeA;
328 vftab = kernel_data->table_vdw->data;
329 vftabscale = kernel_data->table_vdw->scale;
334 /* Start outer loop over neighborlists */
335 for(iidx=0; iidx<nri; iidx++)
337 /* Load shift vector for this list */
338 i_shift_offset = DIM*shiftidx[iidx];
339 shX = shiftvec[i_shift_offset+XX];
340 shY = shiftvec[i_shift_offset+YY];
341 shZ = shiftvec[i_shift_offset+ZZ];
343 /* Load limits for loop over neighbors */
344 j_index_start = jindex[iidx];
345 j_index_end = jindex[iidx+1];
347 /* Get outer coordinate index */
349 i_coord_offset = DIM*inr;
351 /* Load i particle coords and add shift vector */
352 ix0 = shX + x[i_coord_offset+DIM*0+XX];
353 iy0 = shY + x[i_coord_offset+DIM*0+YY];
354 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
360 /* Load parameters for i particles */
361 iq0 = facel*charge[inr+0];
362 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
364 /* Start inner kernel loop */
365 for(jidx=j_index_start; jidx<j_index_end; jidx++)
367 /* Get j neighbor index, and coordinate index */
369 j_coord_offset = DIM*jnr;
371 /* load j atom coordinates */
372 jx0 = x[j_coord_offset+DIM*0+XX];
373 jy0 = x[j_coord_offset+DIM*0+YY];
374 jz0 = x[j_coord_offset+DIM*0+ZZ];
376 /* Calculate displacement vector */
381 /* Calculate squared distance and things based on it */
382 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
384 rinv00 = gmx_invsqrt(rsq00);
386 rinvsq00 = rinv00*rinv00;
388 /* Load parameters for j particles */
390 vdwjidx0 = 2*vdwtype[jnr+0];
392 /**************************
393 * CALCULATE INTERACTIONS *
394 **************************/
399 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
400 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
402 /* Calculate table index by multiplying r with table scale and truncate to integer */
408 /* REACTION-FIELD ELECTROSTATICS */
409 felec = qq00*(rinv00*rinvsq00-krf2);
411 /* CUBIC SPLINE TABLE DISPERSION */
414 Geps = vfeps*vftab[vfitab+2];
415 Heps2 = vfeps*vfeps*vftab[vfitab+3];
417 FF = Fp+Geps+2.0*Heps2;
420 /* CUBIC SPLINE TABLE REPULSION */
422 Geps = vfeps*vftab[vfitab+6];
423 Heps2 = vfeps*vfeps*vftab[vfitab+7];
425 FF = Fp+Geps+2.0*Heps2;
427 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
431 /* Calculate temporary vectorial force */
436 /* Update vectorial force */
440 f[j_coord_offset+DIM*0+XX] -= tx;
441 f[j_coord_offset+DIM*0+YY] -= ty;
442 f[j_coord_offset+DIM*0+ZZ] -= tz;
444 /* Inner loop uses 53 flops */
446 /* End of innermost loop */
449 f[i_coord_offset+DIM*0+XX] += fix0;
450 f[i_coord_offset+DIM*0+YY] += fiy0;
451 f[i_coord_offset+DIM*0+ZZ] += fiz0;
455 fshift[i_shift_offset+XX] += tx;
456 fshift[i_shift_offset+YY] += ty;
457 fshift[i_shift_offset+ZZ] += tz;
459 /* Increment number of inner iterations */
460 inneriter += j_index_end - j_index_start;
462 /* Outer loop uses 13 flops */
465 /* Increment number of outer iterations */
468 /* Update outer/inner flops */
470 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*53);