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_ElecEw_VdwCSTab_GeomP1P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: CubicSplineTable
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_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;
71 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
79 jindex = nlist->jindex;
81 shiftidx = nlist->shift;
83 shiftvec = fr->shift_vec[0];
84 fshift = fr->fshift[0];
86 charge = mdatoms->chargeA;
89 vdwtype = mdatoms->typeA;
91 vftab = kernel_data->table_vdw->data;
92 vftabscale = kernel_data->table_vdw->scale;
94 sh_ewald = fr->ic->sh_ewald;
95 ewtab = fr->ic->tabq_coul_FDV0;
96 ewtabscale = fr->ic->tabq_scale;
97 ewtabhalfspace = 0.5/ewtabscale;
102 /* Start outer loop over neighborlists */
103 for(iidx=0; iidx<nri; iidx++)
105 /* Load shift vector for this list */
106 i_shift_offset = DIM*shiftidx[iidx];
107 shX = shiftvec[i_shift_offset+XX];
108 shY = shiftvec[i_shift_offset+YY];
109 shZ = shiftvec[i_shift_offset+ZZ];
111 /* Load limits for loop over neighbors */
112 j_index_start = jindex[iidx];
113 j_index_end = jindex[iidx+1];
115 /* Get outer coordinate index */
117 i_coord_offset = DIM*inr;
119 /* Load i particle coords and add shift vector */
120 ix0 = shX + x[i_coord_offset+DIM*0+XX];
121 iy0 = shY + x[i_coord_offset+DIM*0+YY];
122 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
128 /* Load parameters for i particles */
129 iq0 = facel*charge[inr+0];
130 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
132 /* Reset potential sums */
136 /* Start inner kernel loop */
137 for(jidx=j_index_start; jidx<j_index_end; jidx++)
139 /* Get j neighbor index, and coordinate index */
141 j_coord_offset = DIM*jnr;
143 /* load j atom coordinates */
144 jx0 = x[j_coord_offset+DIM*0+XX];
145 jy0 = x[j_coord_offset+DIM*0+YY];
146 jz0 = x[j_coord_offset+DIM*0+ZZ];
148 /* Calculate displacement vector */
153 /* Calculate squared distance and things based on it */
154 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
156 rinv00 = gmx_invsqrt(rsq00);
158 rinvsq00 = rinv00*rinv00;
160 /* Load parameters for j particles */
162 vdwjidx0 = 2*vdwtype[jnr+0];
164 /**************************
165 * CALCULATE INTERACTIONS *
166 **************************/
171 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
172 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
174 /* Calculate table index by multiplying r with table scale and truncate to integer */
180 /* EWALD ELECTROSTATICS */
182 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
183 ewrt = r00*ewtabscale;
187 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
188 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
189 felec = qq00*rinv00*(rinvsq00-felec);
191 /* CUBIC SPLINE TABLE DISPERSION */
195 Geps = vfeps*vftab[vfitab+2];
196 Heps2 = vfeps*vfeps*vftab[vfitab+3];
200 FF = Fp+Geps+2.0*Heps2;
203 /* CUBIC SPLINE TABLE REPULSION */
206 Geps = vfeps*vftab[vfitab+6];
207 Heps2 = vfeps*vfeps*vftab[vfitab+7];
211 FF = Fp+Geps+2.0*Heps2;
214 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
216 /* Update potential sums from outer loop */
222 /* Calculate temporary vectorial force */
227 /* Update vectorial force */
231 f[j_coord_offset+DIM*0+XX] -= tx;
232 f[j_coord_offset+DIM*0+YY] -= ty;
233 f[j_coord_offset+DIM*0+ZZ] -= tz;
235 /* Inner loop uses 74 flops */
237 /* End of innermost loop */
240 f[i_coord_offset+DIM*0+XX] += fix0;
241 f[i_coord_offset+DIM*0+YY] += fiy0;
242 f[i_coord_offset+DIM*0+ZZ] += fiz0;
246 fshift[i_shift_offset+XX] += tx;
247 fshift[i_shift_offset+YY] += ty;
248 fshift[i_shift_offset+ZZ] += tz;
251 /* Update potential energies */
252 kernel_data->energygrp_elec[ggid] += velecsum;
253 kernel_data->energygrp_vdw[ggid] += vvdwsum;
255 /* Increment number of inner iterations */
256 inneriter += j_index_end - j_index_start;
258 /* Outer loop uses 15 flops */
261 /* Increment number of outer iterations */
264 /* Update outer/inner flops */
266 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*74);
269 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomP1P1_F_c
270 * Electrostatics interaction: Ewald
271 * VdW interaction: CubicSplineTable
272 * Geometry: Particle-Particle
273 * Calculate force/pot: Force
276 nb_kernel_ElecEw_VdwCSTab_GeomP1P1_F_c
277 (t_nblist * gmx_restrict nlist,
278 rvec * gmx_restrict xx,
279 rvec * gmx_restrict ff,
280 t_forcerec * gmx_restrict fr,
281 t_mdatoms * gmx_restrict mdatoms,
282 nb_kernel_data_t * gmx_restrict kernel_data,
283 t_nrnb * gmx_restrict nrnb)
285 int i_shift_offset,i_coord_offset,j_coord_offset;
286 int j_index_start,j_index_end;
287 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
288 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
289 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
290 real *shiftvec,*fshift,*x,*f;
292 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
294 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
295 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
296 real velec,felec,velecsum,facel,crf,krf,krf2;
299 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
303 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
306 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
314 jindex = nlist->jindex;
316 shiftidx = nlist->shift;
318 shiftvec = fr->shift_vec[0];
319 fshift = fr->fshift[0];
321 charge = mdatoms->chargeA;
322 nvdwtype = fr->ntype;
324 vdwtype = mdatoms->typeA;
326 vftab = kernel_data->table_vdw->data;
327 vftabscale = kernel_data->table_vdw->scale;
329 sh_ewald = fr->ic->sh_ewald;
330 ewtab = fr->ic->tabq_coul_F;
331 ewtabscale = fr->ic->tabq_scale;
332 ewtabhalfspace = 0.5/ewtabscale;
337 /* Start outer loop over neighborlists */
338 for(iidx=0; iidx<nri; iidx++)
340 /* Load shift vector for this list */
341 i_shift_offset = DIM*shiftidx[iidx];
342 shX = shiftvec[i_shift_offset+XX];
343 shY = shiftvec[i_shift_offset+YY];
344 shZ = shiftvec[i_shift_offset+ZZ];
346 /* Load limits for loop over neighbors */
347 j_index_start = jindex[iidx];
348 j_index_end = jindex[iidx+1];
350 /* Get outer coordinate index */
352 i_coord_offset = DIM*inr;
354 /* Load i particle coords and add shift vector */
355 ix0 = shX + x[i_coord_offset+DIM*0+XX];
356 iy0 = shY + x[i_coord_offset+DIM*0+YY];
357 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
363 /* Load parameters for i particles */
364 iq0 = facel*charge[inr+0];
365 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
367 /* Start inner kernel loop */
368 for(jidx=j_index_start; jidx<j_index_end; jidx++)
370 /* Get j neighbor index, and coordinate index */
372 j_coord_offset = DIM*jnr;
374 /* load j atom coordinates */
375 jx0 = x[j_coord_offset+DIM*0+XX];
376 jy0 = x[j_coord_offset+DIM*0+YY];
377 jz0 = x[j_coord_offset+DIM*0+ZZ];
379 /* Calculate displacement vector */
384 /* Calculate squared distance and things based on it */
385 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
387 rinv00 = gmx_invsqrt(rsq00);
389 rinvsq00 = rinv00*rinv00;
391 /* Load parameters for j particles */
393 vdwjidx0 = 2*vdwtype[jnr+0];
395 /**************************
396 * CALCULATE INTERACTIONS *
397 **************************/
402 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
403 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
405 /* Calculate table index by multiplying r with table scale and truncate to integer */
411 /* EWALD ELECTROSTATICS */
413 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
414 ewrt = r00*ewtabscale;
417 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
418 felec = qq00*rinv00*(rinvsq00-felec);
420 /* CUBIC SPLINE TABLE DISPERSION */
424 Geps = vfeps*vftab[vfitab+2];
425 Heps2 = vfeps*vfeps*vftab[vfitab+3];
427 FF = Fp+Geps+2.0*Heps2;
430 /* CUBIC SPLINE TABLE REPULSION */
433 Geps = vfeps*vftab[vfitab+6];
434 Heps2 = vfeps*vfeps*vftab[vfitab+7];
436 FF = Fp+Geps+2.0*Heps2;
438 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
442 /* Calculate temporary vectorial force */
447 /* Update vectorial force */
451 f[j_coord_offset+DIM*0+XX] -= tx;
452 f[j_coord_offset+DIM*0+YY] -= ty;
453 f[j_coord_offset+DIM*0+ZZ] -= tz;
455 /* Inner loop uses 59 flops */
457 /* End of innermost loop */
460 f[i_coord_offset+DIM*0+XX] += fix0;
461 f[i_coord_offset+DIM*0+YY] += fiy0;
462 f[i_coord_offset+DIM*0+ZZ] += fiz0;
466 fshift[i_shift_offset+XX] += tx;
467 fshift[i_shift_offset+YY] += ty;
468 fshift[i_shift_offset+ZZ] += tz;
470 /* Increment number of inner iterations */
471 inneriter += j_index_end - j_index_start;
473 /* Outer loop uses 13 flops */
476 /* Increment number of outer iterations */
479 /* Update outer/inner flops */
481 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*59);