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_VdwLJ_GeomP1P1_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: LennardJones
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwLJ_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->data;
89 vftabscale = kernel_data->table_elec->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 /* CUBIC SPLINE TABLE ELECTROSTATICS */
175 Geps = vfeps*vftab[vfitab+2];
176 Heps2 = vfeps*vfeps*vftab[vfitab+3];
180 FF = Fp+Geps+2.0*Heps2;
181 felec = -qq00*FF*vftabscale*rinv00;
183 /* LENNARD-JONES DISPERSION/REPULSION */
185 rinvsix = rinvsq00*rinvsq00*rinvsq00;
186 vvdw6 = c6_00*rinvsix;
187 vvdw12 = c12_00*rinvsix*rinvsix;
188 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
189 fvdw = (vvdw12-vvdw6)*rinvsq00;
191 /* Update potential sums from outer loop */
197 /* Calculate temporary vectorial force */
202 /* Update vectorial force */
206 f[j_coord_offset+DIM*0+XX] -= tx;
207 f[j_coord_offset+DIM*0+YY] -= ty;
208 f[j_coord_offset+DIM*0+ZZ] -= tz;
210 /* Inner loop uses 55 flops */
212 /* End of innermost loop */
215 f[i_coord_offset+DIM*0+XX] += fix0;
216 f[i_coord_offset+DIM*0+YY] += fiy0;
217 f[i_coord_offset+DIM*0+ZZ] += fiz0;
221 fshift[i_shift_offset+XX] += tx;
222 fshift[i_shift_offset+YY] += ty;
223 fshift[i_shift_offset+ZZ] += tz;
226 /* Update potential energies */
227 kernel_data->energygrp_elec[ggid] += velecsum;
228 kernel_data->energygrp_vdw[ggid] += vvdwsum;
230 /* Increment number of inner iterations */
231 inneriter += j_index_end - j_index_start;
233 /* Outer loop uses 15 flops */
236 /* Increment number of outer iterations */
239 /* Update outer/inner flops */
241 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*55);
244 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomP1P1_F_c
245 * Electrostatics interaction: CubicSplineTable
246 * VdW interaction: LennardJones
247 * Geometry: Particle-Particle
248 * Calculate force/pot: Force
251 nb_kernel_ElecCSTab_VdwLJ_GeomP1P1_F_c
252 (t_nblist * gmx_restrict nlist,
253 rvec * gmx_restrict xx,
254 rvec * gmx_restrict ff,
255 t_forcerec * gmx_restrict fr,
256 t_mdatoms * gmx_restrict mdatoms,
257 nb_kernel_data_t * gmx_restrict kernel_data,
258 t_nrnb * gmx_restrict nrnb)
260 int i_shift_offset,i_coord_offset,j_coord_offset;
261 int j_index_start,j_index_end;
262 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
263 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
264 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
265 real *shiftvec,*fshift,*x,*f;
267 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
269 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
270 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
271 real velec,felec,velecsum,facel,crf,krf,krf2;
274 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
278 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
286 jindex = nlist->jindex;
288 shiftidx = nlist->shift;
290 shiftvec = fr->shift_vec[0];
291 fshift = fr->fshift[0];
293 charge = mdatoms->chargeA;
294 nvdwtype = fr->ntype;
296 vdwtype = mdatoms->typeA;
298 vftab = kernel_data->table_elec->data;
299 vftabscale = kernel_data->table_elec->scale;
304 /* Start outer loop over neighborlists */
305 for(iidx=0; iidx<nri; iidx++)
307 /* Load shift vector for this list */
308 i_shift_offset = DIM*shiftidx[iidx];
309 shX = shiftvec[i_shift_offset+XX];
310 shY = shiftvec[i_shift_offset+YY];
311 shZ = shiftvec[i_shift_offset+ZZ];
313 /* Load limits for loop over neighbors */
314 j_index_start = jindex[iidx];
315 j_index_end = jindex[iidx+1];
317 /* Get outer coordinate index */
319 i_coord_offset = DIM*inr;
321 /* Load i particle coords and add shift vector */
322 ix0 = shX + x[i_coord_offset+DIM*0+XX];
323 iy0 = shY + x[i_coord_offset+DIM*0+YY];
324 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
330 /* Load parameters for i particles */
331 iq0 = facel*charge[inr+0];
332 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
334 /* Start inner kernel loop */
335 for(jidx=j_index_start; jidx<j_index_end; jidx++)
337 /* Get j neighbor index, and coordinate index */
339 j_coord_offset = DIM*jnr;
341 /* load j atom coordinates */
342 jx0 = x[j_coord_offset+DIM*0+XX];
343 jy0 = x[j_coord_offset+DIM*0+YY];
344 jz0 = x[j_coord_offset+DIM*0+ZZ];
346 /* Calculate displacement vector */
351 /* Calculate squared distance and things based on it */
352 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
354 rinv00 = gmx_invsqrt(rsq00);
356 rinvsq00 = rinv00*rinv00;
358 /* Load parameters for j particles */
360 vdwjidx0 = 2*vdwtype[jnr+0];
362 /**************************
363 * CALCULATE INTERACTIONS *
364 **************************/
369 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
370 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
372 /* Calculate table index by multiplying r with table scale and truncate to integer */
378 /* CUBIC SPLINE TABLE ELECTROSTATICS */
380 Geps = vfeps*vftab[vfitab+2];
381 Heps2 = vfeps*vfeps*vftab[vfitab+3];
383 FF = Fp+Geps+2.0*Heps2;
384 felec = -qq00*FF*vftabscale*rinv00;
386 /* LENNARD-JONES DISPERSION/REPULSION */
388 rinvsix = rinvsq00*rinvsq00*rinvsq00;
389 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
393 /* Calculate temporary vectorial force */
398 /* Update vectorial force */
402 f[j_coord_offset+DIM*0+XX] -= tx;
403 f[j_coord_offset+DIM*0+YY] -= ty;
404 f[j_coord_offset+DIM*0+ZZ] -= tz;
406 /* Inner loop uses 46 flops */
408 /* End of innermost loop */
411 f[i_coord_offset+DIM*0+XX] += fix0;
412 f[i_coord_offset+DIM*0+YY] += fiy0;
413 f[i_coord_offset+DIM*0+ZZ] += fiz0;
417 fshift[i_shift_offset+XX] += tx;
418 fshift[i_shift_offset+YY] += ty;
419 fshift[i_shift_offset+ZZ] += tz;
421 /* Increment number of inner iterations */
422 inneriter += j_index_end - j_index_start;
424 /* Outer loop uses 13 flops */
427 /* Increment number of outer iterations */
430 /* Update outer/inner flops */
432 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*46);