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_ElecRF_VdwCSTab_GeomP1P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: CubicSplineTable
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_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;
97 /* Start outer loop over neighborlists */
98 for(iidx=0; iidx<nri; iidx++)
100 /* Load shift vector for this list */
101 i_shift_offset = DIM*shiftidx[iidx];
102 shX = shiftvec[i_shift_offset+XX];
103 shY = shiftvec[i_shift_offset+YY];
104 shZ = shiftvec[i_shift_offset+ZZ];
106 /* Load limits for loop over neighbors */
107 j_index_start = jindex[iidx];
108 j_index_end = jindex[iidx+1];
110 /* Get outer coordinate index */
112 i_coord_offset = DIM*inr;
114 /* Load i particle coords and add shift vector */
115 ix0 = shX + x[i_coord_offset+DIM*0+XX];
116 iy0 = shY + x[i_coord_offset+DIM*0+YY];
117 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
123 /* Load parameters for i particles */
124 iq0 = facel*charge[inr+0];
125 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
127 /* Reset potential sums */
131 /* Start inner kernel loop */
132 for(jidx=j_index_start; jidx<j_index_end; jidx++)
134 /* Get j neighbor index, and coordinate index */
136 j_coord_offset = DIM*jnr;
138 /* load j atom coordinates */
139 jx0 = x[j_coord_offset+DIM*0+XX];
140 jy0 = x[j_coord_offset+DIM*0+YY];
141 jz0 = x[j_coord_offset+DIM*0+ZZ];
143 /* Calculate displacement vector */
148 /* Calculate squared distance and things based on it */
149 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
151 rinv00 = gmx_invsqrt(rsq00);
153 rinvsq00 = rinv00*rinv00;
155 /* Load parameters for j particles */
157 vdwjidx0 = 2*vdwtype[jnr+0];
159 /**************************
160 * CALCULATE INTERACTIONS *
161 **************************/
166 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
167 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
169 /* Calculate table index by multiplying r with table scale and truncate to integer */
175 /* REACTION-FIELD ELECTROSTATICS */
176 velec = qq00*(rinv00+krf*rsq00-crf);
177 felec = qq00*(rinv00*rinvsq00-krf2);
179 /* CUBIC SPLINE TABLE DISPERSION */
183 Geps = vfeps*vftab[vfitab+2];
184 Heps2 = vfeps*vfeps*vftab[vfitab+3];
188 FF = Fp+Geps+2.0*Heps2;
191 /* CUBIC SPLINE TABLE REPULSION */
194 Geps = vfeps*vftab[vfitab+6];
195 Heps2 = vfeps*vfeps*vftab[vfitab+7];
199 FF = Fp+Geps+2.0*Heps2;
202 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
204 /* Update potential sums from outer loop */
210 /* Calculate temporary vectorial force */
215 /* Update vectorial force */
219 f[j_coord_offset+DIM*0+XX] -= tx;
220 f[j_coord_offset+DIM*0+YY] -= ty;
221 f[j_coord_offset+DIM*0+ZZ] -= tz;
223 /* Inner loop uses 66 flops */
225 /* End of innermost loop */
228 f[i_coord_offset+DIM*0+XX] += fix0;
229 f[i_coord_offset+DIM*0+YY] += fiy0;
230 f[i_coord_offset+DIM*0+ZZ] += fiz0;
234 fshift[i_shift_offset+XX] += tx;
235 fshift[i_shift_offset+YY] += ty;
236 fshift[i_shift_offset+ZZ] += tz;
239 /* Update potential energies */
240 kernel_data->energygrp_elec[ggid] += velecsum;
241 kernel_data->energygrp_vdw[ggid] += vvdwsum;
243 /* Increment number of inner iterations */
244 inneriter += j_index_end - j_index_start;
246 /* Outer loop uses 15 flops */
249 /* Increment number of outer iterations */
252 /* Update outer/inner flops */
254 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*66);
257 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomP1P1_F_c
258 * Electrostatics interaction: ReactionField
259 * VdW interaction: CubicSplineTable
260 * Geometry: Particle-Particle
261 * Calculate force/pot: Force
264 nb_kernel_ElecRF_VdwCSTab_GeomP1P1_F_c
265 (t_nblist * gmx_restrict nlist,
266 rvec * gmx_restrict xx,
267 rvec * gmx_restrict ff,
268 t_forcerec * gmx_restrict fr,
269 t_mdatoms * gmx_restrict mdatoms,
270 nb_kernel_data_t * gmx_restrict kernel_data,
271 t_nrnb * gmx_restrict nrnb)
273 int i_shift_offset,i_coord_offset,j_coord_offset;
274 int j_index_start,j_index_end;
275 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
276 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
277 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
278 real *shiftvec,*fshift,*x,*f;
280 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
282 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
283 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
284 real velec,felec,velecsum,facel,crf,krf,krf2;
287 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
291 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
299 jindex = nlist->jindex;
301 shiftidx = nlist->shift;
303 shiftvec = fr->shift_vec[0];
304 fshift = fr->fshift[0];
306 charge = mdatoms->chargeA;
310 nvdwtype = fr->ntype;
312 vdwtype = mdatoms->typeA;
314 vftab = kernel_data->table_vdw->data;
315 vftabscale = kernel_data->table_vdw->scale;
320 /* Start outer loop over neighborlists */
321 for(iidx=0; iidx<nri; iidx++)
323 /* Load shift vector for this list */
324 i_shift_offset = DIM*shiftidx[iidx];
325 shX = shiftvec[i_shift_offset+XX];
326 shY = shiftvec[i_shift_offset+YY];
327 shZ = shiftvec[i_shift_offset+ZZ];
329 /* Load limits for loop over neighbors */
330 j_index_start = jindex[iidx];
331 j_index_end = jindex[iidx+1];
333 /* Get outer coordinate index */
335 i_coord_offset = DIM*inr;
337 /* Load i particle coords and add shift vector */
338 ix0 = shX + x[i_coord_offset+DIM*0+XX];
339 iy0 = shY + x[i_coord_offset+DIM*0+YY];
340 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
346 /* Load parameters for i particles */
347 iq0 = facel*charge[inr+0];
348 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
350 /* Start inner kernel loop */
351 for(jidx=j_index_start; jidx<j_index_end; jidx++)
353 /* Get j neighbor index, and coordinate index */
355 j_coord_offset = DIM*jnr;
357 /* load j atom coordinates */
358 jx0 = x[j_coord_offset+DIM*0+XX];
359 jy0 = x[j_coord_offset+DIM*0+YY];
360 jz0 = x[j_coord_offset+DIM*0+ZZ];
362 /* Calculate displacement vector */
367 /* Calculate squared distance and things based on it */
368 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
370 rinv00 = gmx_invsqrt(rsq00);
372 rinvsq00 = rinv00*rinv00;
374 /* Load parameters for j particles */
376 vdwjidx0 = 2*vdwtype[jnr+0];
378 /**************************
379 * CALCULATE INTERACTIONS *
380 **************************/
385 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
386 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
388 /* Calculate table index by multiplying r with table scale and truncate to integer */
394 /* REACTION-FIELD ELECTROSTATICS */
395 felec = qq00*(rinv00*rinvsq00-krf2);
397 /* CUBIC SPLINE TABLE DISPERSION */
400 Geps = vfeps*vftab[vfitab+2];
401 Heps2 = vfeps*vfeps*vftab[vfitab+3];
403 FF = Fp+Geps+2.0*Heps2;
406 /* CUBIC SPLINE TABLE REPULSION */
408 Geps = vfeps*vftab[vfitab+6];
409 Heps2 = vfeps*vfeps*vftab[vfitab+7];
411 FF = Fp+Geps+2.0*Heps2;
413 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
417 /* Calculate temporary vectorial force */
422 /* Update vectorial force */
426 f[j_coord_offset+DIM*0+XX] -= tx;
427 f[j_coord_offset+DIM*0+YY] -= ty;
428 f[j_coord_offset+DIM*0+ZZ] -= tz;
430 /* Inner loop uses 53 flops */
432 /* End of innermost loop */
435 f[i_coord_offset+DIM*0+XX] += fix0;
436 f[i_coord_offset+DIM*0+YY] += fiy0;
437 f[i_coord_offset+DIM*0+ZZ] += fiz0;
441 fshift[i_shift_offset+XX] += tx;
442 fshift[i_shift_offset+YY] += ty;
443 fshift[i_shift_offset+ZZ] += tz;
445 /* Increment number of inner iterations */
446 inneriter += j_index_end - j_index_start;
448 /* Outer loop uses 13 flops */
451 /* Increment number of outer iterations */
454 /* Update outer/inner flops */
456 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*53);