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_ElecCSTab_VdwCSTab_GeomP1P1_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: CubicSplineTable
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_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;
86 vdwtype = mdatoms->typeA;
88 vftab = kernel_data->table_elec_vdw->data;
89 vftabscale = kernel_data->table_elec_vdw->scale;
94 /* Start outer loop over neighborlists */
95 for(iidx=0; iidx<nri; iidx++)
97 /* Load shift vector for this list */
98 i_shift_offset = DIM*shiftidx[iidx];
99 shX = shiftvec[i_shift_offset+XX];
100 shY = shiftvec[i_shift_offset+YY];
101 shZ = shiftvec[i_shift_offset+ZZ];
103 /* Load limits for loop over neighbors */
104 j_index_start = jindex[iidx];
105 j_index_end = jindex[iidx+1];
107 /* Get outer coordinate index */
109 i_coord_offset = DIM*inr;
111 /* Load i particle coords and add shift vector */
112 ix0 = shX + x[i_coord_offset+DIM*0+XX];
113 iy0 = shY + x[i_coord_offset+DIM*0+YY];
114 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
120 /* Load parameters for i particles */
121 iq0 = facel*charge[inr+0];
122 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
124 /* Reset potential sums */
128 /* Start inner kernel loop */
129 for(jidx=j_index_start; jidx<j_index_end; jidx++)
131 /* Get j neighbor index, and coordinate index */
133 j_coord_offset = DIM*jnr;
135 /* load j atom coordinates */
136 jx0 = x[j_coord_offset+DIM*0+XX];
137 jy0 = x[j_coord_offset+DIM*0+YY];
138 jz0 = x[j_coord_offset+DIM*0+ZZ];
140 /* Calculate displacement vector */
145 /* Calculate squared distance and things based on it */
146 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
148 rinv00 = gmx_invsqrt(rsq00);
150 /* Load parameters for j particles */
152 vdwjidx0 = 2*vdwtype[jnr+0];
154 /**************************
155 * CALCULATE INTERACTIONS *
156 **************************/
161 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
162 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
164 /* Calculate table index by multiplying r with table scale and truncate to integer */
170 /* CUBIC SPLINE TABLE ELECTROSTATICS */
173 Geps = vfeps*vftab[vfitab+2];
174 Heps2 = vfeps*vfeps*vftab[vfitab+3];
178 FF = Fp+Geps+2.0*Heps2;
179 felec = -qq00*FF*vftabscale*rinv00;
181 /* CUBIC SPLINE TABLE DISPERSION */
185 Geps = vfeps*vftab[vfitab+2];
186 Heps2 = vfeps*vfeps*vftab[vfitab+3];
190 FF = Fp+Geps+2.0*Heps2;
193 /* CUBIC SPLINE TABLE REPULSION */
196 Geps = vfeps*vftab[vfitab+6];
197 Heps2 = vfeps*vfeps*vftab[vfitab+7];
201 FF = Fp+Geps+2.0*Heps2;
204 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
206 /* Update potential sums from outer loop */
212 /* Calculate temporary vectorial force */
217 /* Update vectorial force */
221 f[j_coord_offset+DIM*0+XX] -= tx;
222 f[j_coord_offset+DIM*0+YY] -= ty;
223 f[j_coord_offset+DIM*0+ZZ] -= tz;
225 /* Inner loop uses 73 flops */
227 /* End of innermost loop */
230 f[i_coord_offset+DIM*0+XX] += fix0;
231 f[i_coord_offset+DIM*0+YY] += fiy0;
232 f[i_coord_offset+DIM*0+ZZ] += fiz0;
236 fshift[i_shift_offset+XX] += tx;
237 fshift[i_shift_offset+YY] += ty;
238 fshift[i_shift_offset+ZZ] += tz;
241 /* Update potential energies */
242 kernel_data->energygrp_elec[ggid] += velecsum;
243 kernel_data->energygrp_vdw[ggid] += vvdwsum;
245 /* Increment number of inner iterations */
246 inneriter += j_index_end - j_index_start;
248 /* Outer loop uses 15 flops */
251 /* Increment number of outer iterations */
254 /* Update outer/inner flops */
256 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*73);
259 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomP1P1_F_c
260 * Electrostatics interaction: CubicSplineTable
261 * VdW interaction: CubicSplineTable
262 * Geometry: Particle-Particle
263 * Calculate force/pot: Force
266 nb_kernel_ElecCSTab_VdwCSTab_GeomP1P1_F_c
267 (t_nblist * gmx_restrict nlist,
268 rvec * gmx_restrict xx,
269 rvec * gmx_restrict ff,
270 t_forcerec * gmx_restrict fr,
271 t_mdatoms * gmx_restrict mdatoms,
272 nb_kernel_data_t * gmx_restrict kernel_data,
273 t_nrnb * gmx_restrict nrnb)
275 int i_shift_offset,i_coord_offset,j_coord_offset;
276 int j_index_start,j_index_end;
277 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
278 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
279 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
280 real *shiftvec,*fshift,*x,*f;
282 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
284 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
285 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
286 real velec,felec,velecsum,facel,crf,krf,krf2;
289 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
293 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
301 jindex = nlist->jindex;
303 shiftidx = nlist->shift;
305 shiftvec = fr->shift_vec[0];
306 fshift = fr->fshift[0];
308 charge = mdatoms->chargeA;
309 nvdwtype = fr->ntype;
311 vdwtype = mdatoms->typeA;
313 vftab = kernel_data->table_elec_vdw->data;
314 vftabscale = kernel_data->table_elec_vdw->scale;
319 /* Start outer loop over neighborlists */
320 for(iidx=0; iidx<nri; iidx++)
322 /* Load shift vector for this list */
323 i_shift_offset = DIM*shiftidx[iidx];
324 shX = shiftvec[i_shift_offset+XX];
325 shY = shiftvec[i_shift_offset+YY];
326 shZ = shiftvec[i_shift_offset+ZZ];
328 /* Load limits for loop over neighbors */
329 j_index_start = jindex[iidx];
330 j_index_end = jindex[iidx+1];
332 /* Get outer coordinate index */
334 i_coord_offset = DIM*inr;
336 /* Load i particle coords and add shift vector */
337 ix0 = shX + x[i_coord_offset+DIM*0+XX];
338 iy0 = shY + x[i_coord_offset+DIM*0+YY];
339 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
345 /* Load parameters for i particles */
346 iq0 = facel*charge[inr+0];
347 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
349 /* Start inner kernel loop */
350 for(jidx=j_index_start; jidx<j_index_end; jidx++)
352 /* Get j neighbor index, and coordinate index */
354 j_coord_offset = DIM*jnr;
356 /* load j atom coordinates */
357 jx0 = x[j_coord_offset+DIM*0+XX];
358 jy0 = x[j_coord_offset+DIM*0+YY];
359 jz0 = x[j_coord_offset+DIM*0+ZZ];
361 /* Calculate displacement vector */
366 /* Calculate squared distance and things based on it */
367 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
369 rinv00 = gmx_invsqrt(rsq00);
371 /* Load parameters for j particles */
373 vdwjidx0 = 2*vdwtype[jnr+0];
375 /**************************
376 * CALCULATE INTERACTIONS *
377 **************************/
382 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
383 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
385 /* Calculate table index by multiplying r with table scale and truncate to integer */
391 /* CUBIC SPLINE TABLE ELECTROSTATICS */
394 Geps = vfeps*vftab[vfitab+2];
395 Heps2 = vfeps*vfeps*vftab[vfitab+3];
397 FF = Fp+Geps+2.0*Heps2;
398 felec = -qq00*FF*vftabscale*rinv00;
400 /* CUBIC SPLINE TABLE DISPERSION */
404 Geps = vfeps*vftab[vfitab+2];
405 Heps2 = vfeps*vfeps*vftab[vfitab+3];
407 FF = Fp+Geps+2.0*Heps2;
410 /* CUBIC SPLINE TABLE REPULSION */
413 Geps = vfeps*vftab[vfitab+6];
414 Heps2 = vfeps*vfeps*vftab[vfitab+7];
416 FF = Fp+Geps+2.0*Heps2;
418 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
422 /* Calculate temporary vectorial force */
427 /* Update vectorial force */
431 f[j_coord_offset+DIM*0+XX] -= tx;
432 f[j_coord_offset+DIM*0+YY] -= ty;
433 f[j_coord_offset+DIM*0+ZZ] -= tz;
435 /* Inner loop uses 61 flops */
437 /* End of innermost loop */
440 f[i_coord_offset+DIM*0+XX] += fix0;
441 f[i_coord_offset+DIM*0+YY] += fiy0;
442 f[i_coord_offset+DIM*0+ZZ] += fiz0;
446 fshift[i_shift_offset+XX] += tx;
447 fshift[i_shift_offset+YY] += ty;
448 fshift[i_shift_offset+ZZ] += tz;
450 /* Increment number of inner iterations */
451 inneriter += j_index_end - j_index_start;
453 /* Outer loop uses 13 flops */
456 /* Increment number of outer iterations */
459 /* Update outer/inner flops */
461 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*61);