2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomP1P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: CubicSplineTable
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwCSTab_GeomP1P1_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
60 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
61 real velec,felec,velecsum,facel,crf,krf,krf2;
64 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
68 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
76 jindex = nlist->jindex;
78 shiftidx = nlist->shift;
80 shiftvec = fr->shift_vec[0];
81 fshift = fr->fshift[0];
83 charge = mdatoms->chargeA;
89 vdwtype = mdatoms->typeA;
91 vftab = kernel_data->table_vdw->data;
92 vftabscale = kernel_data->table_vdw->scale;
94 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
95 rcutoff = fr->rcoulomb;
96 rcutoff2 = rcutoff*rcutoff;
101 /* Start outer loop over neighborlists */
102 for(iidx=0; iidx<nri; iidx++)
104 /* Load shift vector for this list */
105 i_shift_offset = DIM*shiftidx[iidx];
106 shX = shiftvec[i_shift_offset+XX];
107 shY = shiftvec[i_shift_offset+YY];
108 shZ = shiftvec[i_shift_offset+ZZ];
110 /* Load limits for loop over neighbors */
111 j_index_start = jindex[iidx];
112 j_index_end = jindex[iidx+1];
114 /* Get outer coordinate index */
116 i_coord_offset = DIM*inr;
118 /* Load i particle coords and add shift vector */
119 ix0 = shX + x[i_coord_offset+DIM*0+XX];
120 iy0 = shY + x[i_coord_offset+DIM*0+YY];
121 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
127 /* Load parameters for i particles */
128 iq0 = facel*charge[inr+0];
129 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
131 /* Reset potential sums */
135 /* Start inner kernel loop */
136 for(jidx=j_index_start; jidx<j_index_end; jidx++)
138 /* Get j neighbor index, and coordinate index */
140 j_coord_offset = DIM*jnr;
142 /* load j atom coordinates */
143 jx0 = x[j_coord_offset+DIM*0+XX];
144 jy0 = x[j_coord_offset+DIM*0+YY];
145 jz0 = x[j_coord_offset+DIM*0+ZZ];
147 /* Calculate displacement vector */
152 /* Calculate squared distance and things based on it */
153 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
155 rinv00 = gmx_invsqrt(rsq00);
157 rinvsq00 = rinv00*rinv00;
159 /* Load parameters for j particles */
161 vdwjidx0 = 2*vdwtype[jnr+0];
163 /**************************
164 * CALCULATE INTERACTIONS *
165 **************************/
173 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
174 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
176 /* Calculate table index by multiplying r with table scale and truncate to integer */
182 /* REACTION-FIELD ELECTROSTATICS */
183 velec = qq00*(rinv00+krf*rsq00-crf);
184 felec = qq00*(rinv00*rinvsq00-krf2);
186 /* CUBIC SPLINE TABLE DISPERSION */
190 Geps = vfeps*vftab[vfitab+2];
191 Heps2 = vfeps*vfeps*vftab[vfitab+3];
195 FF = Fp+Geps+2.0*Heps2;
198 /* CUBIC SPLINE TABLE REPULSION */
201 Geps = vfeps*vftab[vfitab+6];
202 Heps2 = vfeps*vfeps*vftab[vfitab+7];
206 FF = Fp+Geps+2.0*Heps2;
209 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
211 /* Update potential sums from outer loop */
217 /* Calculate temporary vectorial force */
222 /* Update vectorial force */
226 f[j_coord_offset+DIM*0+XX] -= tx;
227 f[j_coord_offset+DIM*0+YY] -= ty;
228 f[j_coord_offset+DIM*0+ZZ] -= tz;
232 /* Inner loop uses 66 flops */
234 /* End of innermost loop */
237 f[i_coord_offset+DIM*0+XX] += fix0;
238 f[i_coord_offset+DIM*0+YY] += fiy0;
239 f[i_coord_offset+DIM*0+ZZ] += fiz0;
243 fshift[i_shift_offset+XX] += tx;
244 fshift[i_shift_offset+YY] += ty;
245 fshift[i_shift_offset+ZZ] += tz;
248 /* Update potential energies */
249 kernel_data->energygrp_elec[ggid] += velecsum;
250 kernel_data->energygrp_vdw[ggid] += vvdwsum;
252 /* Increment number of inner iterations */
253 inneriter += j_index_end - j_index_start;
255 /* Outer loop uses 15 flops */
258 /* Increment number of outer iterations */
261 /* Update outer/inner flops */
263 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*66);
266 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomP1P1_F_c
267 * Electrostatics interaction: ReactionField
268 * VdW interaction: CubicSplineTable
269 * Geometry: Particle-Particle
270 * Calculate force/pot: Force
273 nb_kernel_ElecRFCut_VdwCSTab_GeomP1P1_F_c
274 (t_nblist * gmx_restrict nlist,
275 rvec * gmx_restrict xx,
276 rvec * gmx_restrict ff,
277 t_forcerec * gmx_restrict fr,
278 t_mdatoms * gmx_restrict mdatoms,
279 nb_kernel_data_t * gmx_restrict kernel_data,
280 t_nrnb * gmx_restrict nrnb)
282 int i_shift_offset,i_coord_offset,j_coord_offset;
283 int j_index_start,j_index_end;
284 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
285 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
286 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
287 real *shiftvec,*fshift,*x,*f;
289 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
291 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
292 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
293 real velec,felec,velecsum,facel,crf,krf,krf2;
296 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
300 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
308 jindex = nlist->jindex;
310 shiftidx = nlist->shift;
312 shiftvec = fr->shift_vec[0];
313 fshift = fr->fshift[0];
315 charge = mdatoms->chargeA;
319 nvdwtype = fr->ntype;
321 vdwtype = mdatoms->typeA;
323 vftab = kernel_data->table_vdw->data;
324 vftabscale = kernel_data->table_vdw->scale;
326 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
327 rcutoff = fr->rcoulomb;
328 rcutoff2 = rcutoff*rcutoff;
333 /* Start outer loop over neighborlists */
334 for(iidx=0; iidx<nri; iidx++)
336 /* Load shift vector for this list */
337 i_shift_offset = DIM*shiftidx[iidx];
338 shX = shiftvec[i_shift_offset+XX];
339 shY = shiftvec[i_shift_offset+YY];
340 shZ = shiftvec[i_shift_offset+ZZ];
342 /* Load limits for loop over neighbors */
343 j_index_start = jindex[iidx];
344 j_index_end = jindex[iidx+1];
346 /* Get outer coordinate index */
348 i_coord_offset = DIM*inr;
350 /* Load i particle coords and add shift vector */
351 ix0 = shX + x[i_coord_offset+DIM*0+XX];
352 iy0 = shY + x[i_coord_offset+DIM*0+YY];
353 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
359 /* Load parameters for i particles */
360 iq0 = facel*charge[inr+0];
361 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
363 /* Start inner kernel loop */
364 for(jidx=j_index_start; jidx<j_index_end; jidx++)
366 /* Get j neighbor index, and coordinate index */
368 j_coord_offset = DIM*jnr;
370 /* load j atom coordinates */
371 jx0 = x[j_coord_offset+DIM*0+XX];
372 jy0 = x[j_coord_offset+DIM*0+YY];
373 jz0 = x[j_coord_offset+DIM*0+ZZ];
375 /* Calculate displacement vector */
380 /* Calculate squared distance and things based on it */
381 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
383 rinv00 = gmx_invsqrt(rsq00);
385 rinvsq00 = rinv00*rinv00;
387 /* Load parameters for j particles */
389 vdwjidx0 = 2*vdwtype[jnr+0];
391 /**************************
392 * CALCULATE INTERACTIONS *
393 **************************/
401 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
402 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
404 /* Calculate table index by multiplying r with table scale and truncate to integer */
410 /* REACTION-FIELD ELECTROSTATICS */
411 felec = qq00*(rinv00*rinvsq00-krf2);
413 /* CUBIC SPLINE TABLE DISPERSION */
416 Geps = vfeps*vftab[vfitab+2];
417 Heps2 = vfeps*vfeps*vftab[vfitab+3];
419 FF = Fp+Geps+2.0*Heps2;
422 /* CUBIC SPLINE TABLE REPULSION */
424 Geps = vfeps*vftab[vfitab+6];
425 Heps2 = vfeps*vfeps*vftab[vfitab+7];
427 FF = Fp+Geps+2.0*Heps2;
429 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
433 /* Calculate temporary vectorial force */
438 /* Update vectorial force */
442 f[j_coord_offset+DIM*0+XX] -= tx;
443 f[j_coord_offset+DIM*0+YY] -= ty;
444 f[j_coord_offset+DIM*0+ZZ] -= tz;
448 /* Inner loop uses 53 flops */
450 /* End of innermost loop */
453 f[i_coord_offset+DIM*0+XX] += fix0;
454 f[i_coord_offset+DIM*0+YY] += fiy0;
455 f[i_coord_offset+DIM*0+ZZ] += fiz0;
459 fshift[i_shift_offset+XX] += tx;
460 fshift[i_shift_offset+YY] += ty;
461 fshift[i_shift_offset+ZZ] += tz;
463 /* Increment number of inner iterations */
464 inneriter += j_index_end - j_index_start;
466 /* Outer loop uses 13 flops */
469 /* Increment number of outer iterations */
472 /* Update outer/inner flops */
474 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*53);