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_ElecEw_VdwLJ_GeomP1P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: LennardJones
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_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 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
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 sh_ewald = fr->ic->sh_ewald;
89 ewtab = fr->ic->tabq_coul_FDV0;
90 ewtabscale = fr->ic->tabq_scale;
91 ewtabhalfspace = 0.5/ewtabscale;
96 /* Start outer loop over neighborlists */
97 for(iidx=0; iidx<nri; iidx++)
99 /* Load shift vector for this list */
100 i_shift_offset = DIM*shiftidx[iidx];
101 shX = shiftvec[i_shift_offset+XX];
102 shY = shiftvec[i_shift_offset+YY];
103 shZ = shiftvec[i_shift_offset+ZZ];
105 /* Load limits for loop over neighbors */
106 j_index_start = jindex[iidx];
107 j_index_end = jindex[iidx+1];
109 /* Get outer coordinate index */
111 i_coord_offset = DIM*inr;
113 /* Load i particle coords and add shift vector */
114 ix0 = shX + x[i_coord_offset+DIM*0+XX];
115 iy0 = shY + x[i_coord_offset+DIM*0+YY];
116 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
122 /* Load parameters for i particles */
123 iq0 = facel*charge[inr+0];
124 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
126 /* 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 */
156 vdwjidx0 = 2*vdwtype[jnr+0];
158 /**************************
159 * CALCULATE INTERACTIONS *
160 **************************/
165 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
166 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
168 /* EWALD ELECTROSTATICS */
170 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
171 ewrt = r00*ewtabscale;
175 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
176 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
177 felec = qq00*rinv00*(rinvsq00-felec);
179 /* LENNARD-JONES DISPERSION/REPULSION */
181 rinvsix = rinvsq00*rinvsq00*rinvsq00;
182 vvdw6 = c6_00*rinvsix;
183 vvdw12 = c12_00*rinvsix*rinvsix;
184 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
185 fvdw = (vvdw12-vvdw6)*rinvsq00;
187 /* Update potential sums from outer loop */
193 /* Calculate temporary vectorial force */
198 /* Update vectorial force */
202 f[j_coord_offset+DIM*0+XX] -= tx;
203 f[j_coord_offset+DIM*0+YY] -= ty;
204 f[j_coord_offset+DIM*0+ZZ] -= tz;
206 /* Inner loop uses 53 flops */
208 /* End of innermost loop */
211 f[i_coord_offset+DIM*0+XX] += fix0;
212 f[i_coord_offset+DIM*0+YY] += fiy0;
213 f[i_coord_offset+DIM*0+ZZ] += fiz0;
217 fshift[i_shift_offset+XX] += tx;
218 fshift[i_shift_offset+YY] += ty;
219 fshift[i_shift_offset+ZZ] += tz;
222 /* Update potential energies */
223 kernel_data->energygrp_elec[ggid] += velecsum;
224 kernel_data->energygrp_vdw[ggid] += vvdwsum;
226 /* Increment number of inner iterations */
227 inneriter += j_index_end - j_index_start;
229 /* Outer loop uses 15 flops */
232 /* Increment number of outer iterations */
235 /* Update outer/inner flops */
237 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*53);
240 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomP1P1_F_c
241 * Electrostatics interaction: Ewald
242 * VdW interaction: LennardJones
243 * Geometry: Particle-Particle
244 * Calculate force/pot: Force
247 nb_kernel_ElecEw_VdwLJ_GeomP1P1_F_c
248 (t_nblist * gmx_restrict nlist,
249 rvec * gmx_restrict xx,
250 rvec * gmx_restrict ff,
251 t_forcerec * gmx_restrict fr,
252 t_mdatoms * gmx_restrict mdatoms,
253 nb_kernel_data_t * gmx_restrict kernel_data,
254 t_nrnb * gmx_restrict nrnb)
256 int i_shift_offset,i_coord_offset,j_coord_offset;
257 int j_index_start,j_index_end;
258 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
259 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
260 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
261 real *shiftvec,*fshift,*x,*f;
263 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
265 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
266 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
267 real velec,felec,velecsum,facel,crf,krf,krf2;
270 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
274 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
282 jindex = nlist->jindex;
284 shiftidx = nlist->shift;
286 shiftvec = fr->shift_vec[0];
287 fshift = fr->fshift[0];
289 charge = mdatoms->chargeA;
290 nvdwtype = fr->ntype;
292 vdwtype = mdatoms->typeA;
294 sh_ewald = fr->ic->sh_ewald;
295 ewtab = fr->ic->tabq_coul_F;
296 ewtabscale = fr->ic->tabq_scale;
297 ewtabhalfspace = 0.5/ewtabscale;
302 /* Start outer loop over neighborlists */
303 for(iidx=0; iidx<nri; iidx++)
305 /* Load shift vector for this list */
306 i_shift_offset = DIM*shiftidx[iidx];
307 shX = shiftvec[i_shift_offset+XX];
308 shY = shiftvec[i_shift_offset+YY];
309 shZ = shiftvec[i_shift_offset+ZZ];
311 /* Load limits for loop over neighbors */
312 j_index_start = jindex[iidx];
313 j_index_end = jindex[iidx+1];
315 /* Get outer coordinate index */
317 i_coord_offset = DIM*inr;
319 /* Load i particle coords and add shift vector */
320 ix0 = shX + x[i_coord_offset+DIM*0+XX];
321 iy0 = shY + x[i_coord_offset+DIM*0+YY];
322 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
328 /* Load parameters for i particles */
329 iq0 = facel*charge[inr+0];
330 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
332 /* Start inner kernel loop */
333 for(jidx=j_index_start; jidx<j_index_end; jidx++)
335 /* Get j neighbor index, and coordinate index */
337 j_coord_offset = DIM*jnr;
339 /* load j atom coordinates */
340 jx0 = x[j_coord_offset+DIM*0+XX];
341 jy0 = x[j_coord_offset+DIM*0+YY];
342 jz0 = x[j_coord_offset+DIM*0+ZZ];
344 /* Calculate displacement vector */
349 /* Calculate squared distance and things based on it */
350 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
352 rinv00 = gmx_invsqrt(rsq00);
354 rinvsq00 = rinv00*rinv00;
356 /* Load parameters for j particles */
358 vdwjidx0 = 2*vdwtype[jnr+0];
360 /**************************
361 * CALCULATE INTERACTIONS *
362 **************************/
367 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
368 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
370 /* EWALD ELECTROSTATICS */
372 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
373 ewrt = r00*ewtabscale;
376 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
377 felec = qq00*rinv00*(rinvsq00-felec);
379 /* LENNARD-JONES DISPERSION/REPULSION */
381 rinvsix = rinvsq00*rinvsq00*rinvsq00;
382 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
386 /* Calculate temporary vectorial force */
391 /* Update vectorial force */
395 f[j_coord_offset+DIM*0+XX] -= tx;
396 f[j_coord_offset+DIM*0+YY] -= ty;
397 f[j_coord_offset+DIM*0+ZZ] -= tz;
399 /* Inner loop uses 41 flops */
401 /* End of innermost loop */
404 f[i_coord_offset+DIM*0+XX] += fix0;
405 f[i_coord_offset+DIM*0+YY] += fiy0;
406 f[i_coord_offset+DIM*0+ZZ] += fiz0;
410 fshift[i_shift_offset+XX] += tx;
411 fshift[i_shift_offset+YY] += ty;
412 fshift[i_shift_offset+ZZ] += tz;
414 /* Increment number of inner iterations */
415 inneriter += j_index_end - j_index_start;
417 /* Outer loop uses 13 flops */
420 /* Increment number of outer iterations */
423 /* Update outer/inner flops */
425 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*41);