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_VdwLJSh_GeomP1P1_VF_c
35 * Electrostatics interaction: None
36 * VdW interaction: LennardJones
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecNone_VdwLJSh_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;
71 jindex = nlist->jindex;
73 shiftidx = nlist->shift;
75 shiftvec = fr->shift_vec[0];
76 fshift = fr->fshift[0];
79 vdwtype = mdatoms->typeA;
82 rcutoff2 = rcutoff*rcutoff;
84 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
90 /* Start outer loop over neighborlists */
91 for(iidx=0; iidx<nri; iidx++)
93 /* Load shift vector for this list */
94 i_shift_offset = DIM*shiftidx[iidx];
95 shX = shiftvec[i_shift_offset+XX];
96 shY = shiftvec[i_shift_offset+YY];
97 shZ = shiftvec[i_shift_offset+ZZ];
99 /* Load limits for loop over neighbors */
100 j_index_start = jindex[iidx];
101 j_index_end = jindex[iidx+1];
103 /* Get outer coordinate index */
105 i_coord_offset = DIM*inr;
107 /* Load i particle coords and add shift vector */
108 ix0 = shX + x[i_coord_offset+DIM*0+XX];
109 iy0 = shY + x[i_coord_offset+DIM*0+YY];
110 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
116 /* Load parameters for i particles */
117 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
119 /* Reset potential sums */
122 /* Start inner kernel loop */
123 for(jidx=j_index_start; jidx<j_index_end; jidx++)
125 /* Get j neighbor index, and coordinate index */
127 j_coord_offset = DIM*jnr;
129 /* load j atom coordinates */
130 jx0 = x[j_coord_offset+DIM*0+XX];
131 jy0 = x[j_coord_offset+DIM*0+YY];
132 jz0 = x[j_coord_offset+DIM*0+ZZ];
134 /* Calculate displacement vector */
139 /* Calculate squared distance and things based on it */
140 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
142 rinvsq00 = 1.0/rsq00;
144 /* Load parameters for j particles */
145 vdwjidx0 = 2*vdwtype[jnr+0];
147 /**************************
148 * CALCULATE INTERACTIONS *
149 **************************/
154 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
155 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
157 /* LENNARD-JONES DISPERSION/REPULSION */
159 rinvsix = rinvsq00*rinvsq00*rinvsq00;
160 vvdw6 = c6_00*rinvsix;
161 vvdw12 = c12_00*rinvsix*rinvsix;
162 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
163 fvdw = (vvdw12-vvdw6)*rinvsq00;
165 /* Update potential sums from outer loop */
170 /* Calculate temporary vectorial force */
175 /* Update vectorial force */
179 f[j_coord_offset+DIM*0+XX] -= tx;
180 f[j_coord_offset+DIM*0+YY] -= ty;
181 f[j_coord_offset+DIM*0+ZZ] -= tz;
185 /* Inner loop uses 37 flops */
187 /* End of innermost loop */
190 f[i_coord_offset+DIM*0+XX] += fix0;
191 f[i_coord_offset+DIM*0+YY] += fiy0;
192 f[i_coord_offset+DIM*0+ZZ] += fiz0;
196 fshift[i_shift_offset+XX] += tx;
197 fshift[i_shift_offset+YY] += ty;
198 fshift[i_shift_offset+ZZ] += tz;
201 /* Update potential energies */
202 kernel_data->energygrp_vdw[ggid] += vvdwsum;
204 /* Increment number of inner iterations */
205 inneriter += j_index_end - j_index_start;
207 /* Outer loop uses 13 flops */
210 /* Increment number of outer iterations */
213 /* Update outer/inner flops */
215 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*37);
218 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_c
219 * Electrostatics interaction: None
220 * VdW interaction: LennardJones
221 * Geometry: Particle-Particle
222 * Calculate force/pot: Force
225 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_c
226 (t_nblist * gmx_restrict nlist,
227 rvec * gmx_restrict xx,
228 rvec * gmx_restrict ff,
229 t_forcerec * gmx_restrict fr,
230 t_mdatoms * gmx_restrict mdatoms,
231 nb_kernel_data_t * gmx_restrict kernel_data,
232 t_nrnb * gmx_restrict nrnb)
234 int i_shift_offset,i_coord_offset,j_coord_offset;
235 int j_index_start,j_index_end;
236 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
237 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
238 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
239 real *shiftvec,*fshift,*x,*f;
241 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
243 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
244 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
246 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
255 jindex = nlist->jindex;
257 shiftidx = nlist->shift;
259 shiftvec = fr->shift_vec[0];
260 fshift = fr->fshift[0];
261 nvdwtype = fr->ntype;
263 vdwtype = mdatoms->typeA;
266 rcutoff2 = rcutoff*rcutoff;
268 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
274 /* Start outer loop over neighborlists */
275 for(iidx=0; iidx<nri; iidx++)
277 /* Load shift vector for this list */
278 i_shift_offset = DIM*shiftidx[iidx];
279 shX = shiftvec[i_shift_offset+XX];
280 shY = shiftvec[i_shift_offset+YY];
281 shZ = shiftvec[i_shift_offset+ZZ];
283 /* Load limits for loop over neighbors */
284 j_index_start = jindex[iidx];
285 j_index_end = jindex[iidx+1];
287 /* Get outer coordinate index */
289 i_coord_offset = DIM*inr;
291 /* Load i particle coords and add shift vector */
292 ix0 = shX + x[i_coord_offset+DIM*0+XX];
293 iy0 = shY + x[i_coord_offset+DIM*0+YY];
294 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
300 /* Load parameters for i particles */
301 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
303 /* Start inner kernel loop */
304 for(jidx=j_index_start; jidx<j_index_end; jidx++)
306 /* Get j neighbor index, and coordinate index */
308 j_coord_offset = DIM*jnr;
310 /* load j atom coordinates */
311 jx0 = x[j_coord_offset+DIM*0+XX];
312 jy0 = x[j_coord_offset+DIM*0+YY];
313 jz0 = x[j_coord_offset+DIM*0+ZZ];
315 /* Calculate displacement vector */
320 /* Calculate squared distance and things based on it */
321 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
323 rinvsq00 = 1.0/rsq00;
325 /* Load parameters for j particles */
326 vdwjidx0 = 2*vdwtype[jnr+0];
328 /**************************
329 * CALCULATE INTERACTIONS *
330 **************************/
335 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
336 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
338 /* LENNARD-JONES DISPERSION/REPULSION */
340 rinvsix = rinvsq00*rinvsq00*rinvsq00;
341 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
345 /* Calculate temporary vectorial force */
350 /* Update vectorial force */
354 f[j_coord_offset+DIM*0+XX] -= tx;
355 f[j_coord_offset+DIM*0+YY] -= ty;
356 f[j_coord_offset+DIM*0+ZZ] -= tz;
360 /* Inner loop uses 27 flops */
362 /* End of innermost loop */
365 f[i_coord_offset+DIM*0+XX] += fix0;
366 f[i_coord_offset+DIM*0+YY] += fiy0;
367 f[i_coord_offset+DIM*0+ZZ] += fiz0;
371 fshift[i_shift_offset+XX] += tx;
372 fshift[i_shift_offset+YY] += ty;
373 fshift[i_shift_offset+ZZ] += tz;
375 /* Increment number of inner iterations */
376 inneriter += j_index_end - j_index_start;
378 /* Outer loop uses 12 flops */
381 /* Increment number of outer iterations */
384 /* Update outer/inner flops */
386 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*27);