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_ElecNone_VdwLJSw_GeomP1P1_VF_c
35 * Electrostatics interaction: None
36 * VdW interaction: LennardJones
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecNone_VdwLJSw_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;
62 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
65 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
72 jindex = nlist->jindex;
74 shiftidx = nlist->shift;
76 shiftvec = fr->shift_vec[0];
77 fshift = fr->fshift[0];
80 vdwtype = mdatoms->typeA;
83 rcutoff2 = rcutoff*rcutoff;
85 rswitch = fr->rvdw_switch;
86 /* Setup switch parameters */
89 swV4 = 15.0/(d*d*d*d);
90 swV5 = -6.0/(d*d*d*d*d);
92 swF3 = 60.0/(d*d*d*d);
93 swF4 = -30.0/(d*d*d*d*d);
98 /* Start outer loop over neighborlists */
99 for(iidx=0; iidx<nri; iidx++)
101 /* Load shift vector for this list */
102 i_shift_offset = DIM*shiftidx[iidx];
103 shX = shiftvec[i_shift_offset+XX];
104 shY = shiftvec[i_shift_offset+YY];
105 shZ = shiftvec[i_shift_offset+ZZ];
107 /* Load limits for loop over neighbors */
108 j_index_start = jindex[iidx];
109 j_index_end = jindex[iidx+1];
111 /* Get outer coordinate index */
113 i_coord_offset = DIM*inr;
115 /* Load i particle coords and add shift vector */
116 ix0 = shX + x[i_coord_offset+DIM*0+XX];
117 iy0 = shY + x[i_coord_offset+DIM*0+YY];
118 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
124 /* Load parameters for i particles */
125 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
127 /* Reset potential sums */
130 /* Start inner kernel loop */
131 for(jidx=j_index_start; jidx<j_index_end; jidx++)
133 /* Get j neighbor index, and coordinate index */
135 j_coord_offset = DIM*jnr;
137 /* load j atom coordinates */
138 jx0 = x[j_coord_offset+DIM*0+XX];
139 jy0 = x[j_coord_offset+DIM*0+YY];
140 jz0 = x[j_coord_offset+DIM*0+ZZ];
142 /* Calculate displacement vector */
147 /* Calculate squared distance and things based on it */
148 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
150 rinv00 = gmx_invsqrt(rsq00);
152 rinvsq00 = rinv00*rinv00;
154 /* Load parameters for j particles */
155 vdwjidx0 = 2*vdwtype[jnr+0];
157 /**************************
158 * CALCULATE INTERACTIONS *
159 **************************/
166 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
167 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
169 /* LENNARD-JONES DISPERSION/REPULSION */
171 rinvsix = rinvsq00*rinvsq00*rinvsq00;
172 vvdw6 = c6_00*rinvsix;
173 vvdw12 = c12_00*rinvsix*rinvsix;
174 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
175 fvdw = (vvdw12-vvdw6)*rinvsq00;
178 d = (d>0.0) ? d : 0.0;
180 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
182 dsw = d2*(swF2+d*(swF3+d*swF4));
184 /* Evaluate switch function */
185 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
186 fvdw = fvdw*sw - rinv00*vvdw*dsw;
189 /* Update potential sums from outer loop */
194 /* Calculate temporary vectorial force */
199 /* Update vectorial force */
203 f[j_coord_offset+DIM*0+XX] -= tx;
204 f[j_coord_offset+DIM*0+YY] -= ty;
205 f[j_coord_offset+DIM*0+ZZ] -= tz;
209 /* Inner loop uses 53 flops */
211 /* End of innermost loop */
214 f[i_coord_offset+DIM*0+XX] += fix0;
215 f[i_coord_offset+DIM*0+YY] += fiy0;
216 f[i_coord_offset+DIM*0+ZZ] += fiz0;
220 fshift[i_shift_offset+XX] += tx;
221 fshift[i_shift_offset+YY] += ty;
222 fshift[i_shift_offset+ZZ] += tz;
225 /* Update potential energies */
226 kernel_data->energygrp_vdw[ggid] += vvdwsum;
228 /* Increment number of inner iterations */
229 inneriter += j_index_end - j_index_start;
231 /* Outer loop uses 13 flops */
234 /* Increment number of outer iterations */
237 /* Update outer/inner flops */
239 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*53);
242 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_c
243 * Electrostatics interaction: None
244 * VdW interaction: LennardJones
245 * Geometry: Particle-Particle
246 * Calculate force/pot: Force
249 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_c
250 (t_nblist * gmx_restrict nlist,
251 rvec * gmx_restrict xx,
252 rvec * gmx_restrict ff,
253 t_forcerec * gmx_restrict fr,
254 t_mdatoms * gmx_restrict mdatoms,
255 nb_kernel_data_t * gmx_restrict kernel_data,
256 t_nrnb * gmx_restrict nrnb)
258 int i_shift_offset,i_coord_offset,j_coord_offset;
259 int j_index_start,j_index_end;
260 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
261 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
262 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
263 real *shiftvec,*fshift,*x,*f;
265 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
267 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
268 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
270 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
273 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
280 jindex = nlist->jindex;
282 shiftidx = nlist->shift;
284 shiftvec = fr->shift_vec[0];
285 fshift = fr->fshift[0];
286 nvdwtype = fr->ntype;
288 vdwtype = mdatoms->typeA;
291 rcutoff2 = rcutoff*rcutoff;
293 rswitch = fr->rvdw_switch;
294 /* Setup switch parameters */
296 swV3 = -10.0/(d*d*d);
297 swV4 = 15.0/(d*d*d*d);
298 swV5 = -6.0/(d*d*d*d*d);
299 swF2 = -30.0/(d*d*d);
300 swF3 = 60.0/(d*d*d*d);
301 swF4 = -30.0/(d*d*d*d*d);
306 /* Start outer loop over neighborlists */
307 for(iidx=0; iidx<nri; iidx++)
309 /* Load shift vector for this list */
310 i_shift_offset = DIM*shiftidx[iidx];
311 shX = shiftvec[i_shift_offset+XX];
312 shY = shiftvec[i_shift_offset+YY];
313 shZ = shiftvec[i_shift_offset+ZZ];
315 /* Load limits for loop over neighbors */
316 j_index_start = jindex[iidx];
317 j_index_end = jindex[iidx+1];
319 /* Get outer coordinate index */
321 i_coord_offset = DIM*inr;
323 /* Load i particle coords and add shift vector */
324 ix0 = shX + x[i_coord_offset+DIM*0+XX];
325 iy0 = shY + x[i_coord_offset+DIM*0+YY];
326 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
332 /* Load parameters for i particles */
333 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
335 /* Start inner kernel loop */
336 for(jidx=j_index_start; jidx<j_index_end; jidx++)
338 /* Get j neighbor index, and coordinate index */
340 j_coord_offset = DIM*jnr;
342 /* load j atom coordinates */
343 jx0 = x[j_coord_offset+DIM*0+XX];
344 jy0 = x[j_coord_offset+DIM*0+YY];
345 jz0 = x[j_coord_offset+DIM*0+ZZ];
347 /* Calculate displacement vector */
352 /* Calculate squared distance and things based on it */
353 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
355 rinv00 = gmx_invsqrt(rsq00);
357 rinvsq00 = rinv00*rinv00;
359 /* Load parameters for j particles */
360 vdwjidx0 = 2*vdwtype[jnr+0];
362 /**************************
363 * CALCULATE INTERACTIONS *
364 **************************/
371 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
372 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
374 /* LENNARD-JONES DISPERSION/REPULSION */
376 rinvsix = rinvsq00*rinvsq00*rinvsq00;
377 vvdw6 = c6_00*rinvsix;
378 vvdw12 = c12_00*rinvsix*rinvsix;
379 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
380 fvdw = (vvdw12-vvdw6)*rinvsq00;
383 d = (d>0.0) ? d : 0.0;
385 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
387 dsw = d2*(swF2+d*(swF3+d*swF4));
389 /* Evaluate switch function */
390 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
391 fvdw = fvdw*sw - rinv00*vvdw*dsw;
395 /* Calculate temporary vectorial force */
400 /* Update vectorial force */
404 f[j_coord_offset+DIM*0+XX] -= tx;
405 f[j_coord_offset+DIM*0+YY] -= ty;
406 f[j_coord_offset+DIM*0+ZZ] -= tz;
410 /* Inner loop uses 51 flops */
412 /* End of innermost loop */
415 f[i_coord_offset+DIM*0+XX] += fix0;
416 f[i_coord_offset+DIM*0+YY] += fiy0;
417 f[i_coord_offset+DIM*0+ZZ] += fiz0;
421 fshift[i_shift_offset+XX] += tx;
422 fshift[i_shift_offset+YY] += ty;
423 fshift[i_shift_offset+ZZ] += tz;
425 /* Increment number of inner iterations */
426 inneriter += j_index_end - j_index_start;
428 /* Outer loop uses 12 flops */
431 /* Increment number of outer iterations */
434 /* Update outer/inner flops */
436 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*51);