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_VdwLJ_GeomP1P1_VF_c
35 * Electrostatics interaction: None
36 * VdW interaction: LennardJones
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecNone_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;
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;
84 /* Start outer loop over neighborlists */
85 for(iidx=0; iidx<nri; iidx++)
87 /* Load shift vector for this list */
88 i_shift_offset = DIM*shiftidx[iidx];
89 shX = shiftvec[i_shift_offset+XX];
90 shY = shiftvec[i_shift_offset+YY];
91 shZ = shiftvec[i_shift_offset+ZZ];
93 /* Load limits for loop over neighbors */
94 j_index_start = jindex[iidx];
95 j_index_end = jindex[iidx+1];
97 /* Get outer coordinate index */
99 i_coord_offset = DIM*inr;
101 /* Load i particle coords and add shift vector */
102 ix0 = shX + x[i_coord_offset+DIM*0+XX];
103 iy0 = shY + x[i_coord_offset+DIM*0+YY];
104 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
110 /* Load parameters for i particles */
111 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
113 /* Reset potential sums */
116 /* Start inner kernel loop */
117 for(jidx=j_index_start; jidx<j_index_end; jidx++)
119 /* Get j neighbor index, and coordinate index */
121 j_coord_offset = DIM*jnr;
123 /* load j atom coordinates */
124 jx0 = x[j_coord_offset+DIM*0+XX];
125 jy0 = x[j_coord_offset+DIM*0+YY];
126 jz0 = x[j_coord_offset+DIM*0+ZZ];
128 /* Calculate displacement vector */
133 /* Calculate squared distance and things based on it */
134 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
136 rinvsq00 = 1.0/rsq00;
138 /* Load parameters for j particles */
139 vdwjidx0 = 2*vdwtype[jnr+0];
141 /**************************
142 * CALCULATE INTERACTIONS *
143 **************************/
145 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
146 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
148 /* LENNARD-JONES DISPERSION/REPULSION */
150 rinvsix = rinvsq00*rinvsq00*rinvsq00;
151 vvdw6 = c6_00*rinvsix;
152 vvdw12 = c12_00*rinvsix*rinvsix;
153 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
154 fvdw = (vvdw12-vvdw6)*rinvsq00;
156 /* Update potential sums from outer loop */
161 /* Calculate temporary vectorial force */
166 /* Update vectorial force */
170 f[j_coord_offset+DIM*0+XX] -= tx;
171 f[j_coord_offset+DIM*0+YY] -= ty;
172 f[j_coord_offset+DIM*0+ZZ] -= tz;
174 /* Inner loop uses 32 flops */
176 /* End of innermost loop */
179 f[i_coord_offset+DIM*0+XX] += fix0;
180 f[i_coord_offset+DIM*0+YY] += fiy0;
181 f[i_coord_offset+DIM*0+ZZ] += fiz0;
185 fshift[i_shift_offset+XX] += tx;
186 fshift[i_shift_offset+YY] += ty;
187 fshift[i_shift_offset+ZZ] += tz;
190 /* Update potential energies */
191 kernel_data->energygrp_vdw[ggid] += vvdwsum;
193 /* Increment number of inner iterations */
194 inneriter += j_index_end - j_index_start;
196 /* Outer loop uses 13 flops */
199 /* Increment number of outer iterations */
202 /* Update outer/inner flops */
204 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*32);
207 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_c
208 * Electrostatics interaction: None
209 * VdW interaction: LennardJones
210 * Geometry: Particle-Particle
211 * Calculate force/pot: Force
214 nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_c
215 (t_nblist * gmx_restrict nlist,
216 rvec * gmx_restrict xx,
217 rvec * gmx_restrict ff,
218 t_forcerec * gmx_restrict fr,
219 t_mdatoms * gmx_restrict mdatoms,
220 nb_kernel_data_t * gmx_restrict kernel_data,
221 t_nrnb * gmx_restrict nrnb)
223 int i_shift_offset,i_coord_offset,j_coord_offset;
224 int j_index_start,j_index_end;
225 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
226 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
227 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
228 real *shiftvec,*fshift,*x,*f;
230 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
232 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
233 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
235 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
244 jindex = nlist->jindex;
246 shiftidx = nlist->shift;
248 shiftvec = fr->shift_vec[0];
249 fshift = fr->fshift[0];
250 nvdwtype = fr->ntype;
252 vdwtype = mdatoms->typeA;
257 /* Start outer loop over neighborlists */
258 for(iidx=0; iidx<nri; iidx++)
260 /* Load shift vector for this list */
261 i_shift_offset = DIM*shiftidx[iidx];
262 shX = shiftvec[i_shift_offset+XX];
263 shY = shiftvec[i_shift_offset+YY];
264 shZ = shiftvec[i_shift_offset+ZZ];
266 /* Load limits for loop over neighbors */
267 j_index_start = jindex[iidx];
268 j_index_end = jindex[iidx+1];
270 /* Get outer coordinate index */
272 i_coord_offset = DIM*inr;
274 /* Load i particle coords and add shift vector */
275 ix0 = shX + x[i_coord_offset+DIM*0+XX];
276 iy0 = shY + x[i_coord_offset+DIM*0+YY];
277 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
283 /* Load parameters for i particles */
284 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
286 /* Start inner kernel loop */
287 for(jidx=j_index_start; jidx<j_index_end; jidx++)
289 /* Get j neighbor index, and coordinate index */
291 j_coord_offset = DIM*jnr;
293 /* load j atom coordinates */
294 jx0 = x[j_coord_offset+DIM*0+XX];
295 jy0 = x[j_coord_offset+DIM*0+YY];
296 jz0 = x[j_coord_offset+DIM*0+ZZ];
298 /* Calculate displacement vector */
303 /* Calculate squared distance and things based on it */
304 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
306 rinvsq00 = 1.0/rsq00;
308 /* Load parameters for j particles */
309 vdwjidx0 = 2*vdwtype[jnr+0];
311 /**************************
312 * CALCULATE INTERACTIONS *
313 **************************/
315 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
316 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
318 /* LENNARD-JONES DISPERSION/REPULSION */
320 rinvsix = rinvsq00*rinvsq00*rinvsq00;
321 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
325 /* Calculate temporary vectorial force */
330 /* Update vectorial force */
334 f[j_coord_offset+DIM*0+XX] -= tx;
335 f[j_coord_offset+DIM*0+YY] -= ty;
336 f[j_coord_offset+DIM*0+ZZ] -= tz;
338 /* Inner loop uses 27 flops */
340 /* End of innermost loop */
343 f[i_coord_offset+DIM*0+XX] += fix0;
344 f[i_coord_offset+DIM*0+YY] += fiy0;
345 f[i_coord_offset+DIM*0+ZZ] += fiz0;
349 fshift[i_shift_offset+XX] += tx;
350 fshift[i_shift_offset+YY] += ty;
351 fshift[i_shift_offset+ZZ] += tz;
353 /* Increment number of inner iterations */
354 inneriter += j_index_end - j_index_start;
356 /* Outer loop uses 12 flops */
359 /* Increment number of outer iterations */
362 /* Update outer/inner flops */
364 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*27);