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_ElecCoul_VdwCSTab_GeomP1P1_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: CubicSplineTable
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_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_vdw->data;
89 vftabscale = kernel_data->table_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 rinvsq00 = rinv00*rinv00;
152 /* Load parameters for j particles */
154 vdwjidx0 = 2*vdwtype[jnr+0];
156 /**************************
157 * CALCULATE INTERACTIONS *
158 **************************/
163 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
164 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
166 /* Calculate table index by multiplying r with table scale and truncate to integer */
172 /* COULOMB ELECTROSTATICS */
174 felec = velec*rinvsq00;
176 /* CUBIC SPLINE TABLE DISPERSION */
180 Geps = vfeps*vftab[vfitab+2];
181 Heps2 = vfeps*vfeps*vftab[vfitab+3];
185 FF = Fp+Geps+2.0*Heps2;
188 /* CUBIC SPLINE TABLE REPULSION */
191 Geps = vfeps*vftab[vfitab+6];
192 Heps2 = vfeps*vfeps*vftab[vfitab+7];
196 FF = Fp+Geps+2.0*Heps2;
199 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
201 /* Update potential sums from outer loop */
207 /* Calculate temporary vectorial force */
212 /* Update vectorial force */
216 f[j_coord_offset+DIM*0+XX] -= tx;
217 f[j_coord_offset+DIM*0+YY] -= ty;
218 f[j_coord_offset+DIM*0+ZZ] -= tz;
220 /* Inner loop uses 62 flops */
222 /* End of innermost loop */
225 f[i_coord_offset+DIM*0+XX] += fix0;
226 f[i_coord_offset+DIM*0+YY] += fiy0;
227 f[i_coord_offset+DIM*0+ZZ] += fiz0;
231 fshift[i_shift_offset+XX] += tx;
232 fshift[i_shift_offset+YY] += ty;
233 fshift[i_shift_offset+ZZ] += tz;
236 /* Update potential energies */
237 kernel_data->energygrp_elec[ggid] += velecsum;
238 kernel_data->energygrp_vdw[ggid] += vvdwsum;
240 /* Increment number of inner iterations */
241 inneriter += j_index_end - j_index_start;
243 /* Outer loop uses 15 flops */
246 /* Increment number of outer iterations */
249 /* Update outer/inner flops */
251 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*62);
254 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomP1P1_F_c
255 * Electrostatics interaction: Coulomb
256 * VdW interaction: CubicSplineTable
257 * Geometry: Particle-Particle
258 * Calculate force/pot: Force
261 nb_kernel_ElecCoul_VdwCSTab_GeomP1P1_F_c
262 (t_nblist * gmx_restrict nlist,
263 rvec * gmx_restrict xx,
264 rvec * gmx_restrict ff,
265 t_forcerec * gmx_restrict fr,
266 t_mdatoms * gmx_restrict mdatoms,
267 nb_kernel_data_t * gmx_restrict kernel_data,
268 t_nrnb * gmx_restrict nrnb)
270 int i_shift_offset,i_coord_offset,j_coord_offset;
271 int j_index_start,j_index_end;
272 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
273 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
274 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
275 real *shiftvec,*fshift,*x,*f;
277 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
279 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
280 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
281 real velec,felec,velecsum,facel,crf,krf,krf2;
284 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
288 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
296 jindex = nlist->jindex;
298 shiftidx = nlist->shift;
300 shiftvec = fr->shift_vec[0];
301 fshift = fr->fshift[0];
303 charge = mdatoms->chargeA;
304 nvdwtype = fr->ntype;
306 vdwtype = mdatoms->typeA;
308 vftab = kernel_data->table_vdw->data;
309 vftabscale = kernel_data->table_vdw->scale;
314 /* Start outer loop over neighborlists */
315 for(iidx=0; iidx<nri; iidx++)
317 /* Load shift vector for this list */
318 i_shift_offset = DIM*shiftidx[iidx];
319 shX = shiftvec[i_shift_offset+XX];
320 shY = shiftvec[i_shift_offset+YY];
321 shZ = shiftvec[i_shift_offset+ZZ];
323 /* Load limits for loop over neighbors */
324 j_index_start = jindex[iidx];
325 j_index_end = jindex[iidx+1];
327 /* Get outer coordinate index */
329 i_coord_offset = DIM*inr;
331 /* Load i particle coords and add shift vector */
332 ix0 = shX + x[i_coord_offset+DIM*0+XX];
333 iy0 = shY + x[i_coord_offset+DIM*0+YY];
334 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
340 /* Load parameters for i particles */
341 iq0 = facel*charge[inr+0];
342 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
344 /* Start inner kernel loop */
345 for(jidx=j_index_start; jidx<j_index_end; jidx++)
347 /* Get j neighbor index, and coordinate index */
349 j_coord_offset = DIM*jnr;
351 /* load j atom coordinates */
352 jx0 = x[j_coord_offset+DIM*0+XX];
353 jy0 = x[j_coord_offset+DIM*0+YY];
354 jz0 = x[j_coord_offset+DIM*0+ZZ];
356 /* Calculate displacement vector */
361 /* Calculate squared distance and things based on it */
362 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
364 rinv00 = gmx_invsqrt(rsq00);
366 rinvsq00 = rinv00*rinv00;
368 /* Load parameters for j particles */
370 vdwjidx0 = 2*vdwtype[jnr+0];
372 /**************************
373 * CALCULATE INTERACTIONS *
374 **************************/
379 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
380 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
382 /* Calculate table index by multiplying r with table scale and truncate to integer */
388 /* COULOMB ELECTROSTATICS */
390 felec = velec*rinvsq00;
392 /* CUBIC SPLINE TABLE DISPERSION */
396 Geps = vfeps*vftab[vfitab+2];
397 Heps2 = vfeps*vfeps*vftab[vfitab+3];
399 FF = Fp+Geps+2.0*Heps2;
402 /* CUBIC SPLINE TABLE REPULSION */
405 Geps = vfeps*vftab[vfitab+6];
406 Heps2 = vfeps*vfeps*vftab[vfitab+7];
408 FF = Fp+Geps+2.0*Heps2;
410 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
414 /* Calculate temporary vectorial force */
419 /* Update vectorial force */
423 f[j_coord_offset+DIM*0+XX] -= tx;
424 f[j_coord_offset+DIM*0+YY] -= ty;
425 f[j_coord_offset+DIM*0+ZZ] -= tz;
427 /* Inner loop uses 53 flops */
429 /* End of innermost loop */
432 f[i_coord_offset+DIM*0+XX] += fix0;
433 f[i_coord_offset+DIM*0+YY] += fiy0;
434 f[i_coord_offset+DIM*0+ZZ] += fiz0;
438 fshift[i_shift_offset+XX] += tx;
439 fshift[i_shift_offset+YY] += ty;
440 fshift[i_shift_offset+ZZ] += tz;
442 /* Increment number of inner iterations */
443 inneriter += j_index_end - j_index_start;
445 /* Outer loop uses 13 flops */
448 /* Increment number of outer iterations */
451 /* Update outer/inner flops */
453 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*53);