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_VdwBham_GeomP1P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: Buckingham
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwBham_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 = 3*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 = 3*vdwtype[jnr+0];
158 /**************************
159 * CALCULATE INTERACTIONS *
160 **************************/
165 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
166 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
167 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
169 /* EWALD ELECTROSTATICS */
171 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
172 ewrt = r00*ewtabscale;
176 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
177 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
178 felec = qq00*rinv00*(rinvsq00-felec);
180 /* BUCKINGHAM DISPERSION/REPULSION */
181 rinvsix = rinvsq00*rinvsq00*rinvsq00;
182 vvdw6 = c6_00*rinvsix;
184 vvdwexp = cexp1_00*exp(-br);
185 vvdw = vvdwexp - vvdw6*(1.0/6.0);
186 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
188 /* 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;
207 /* Inner loop uses 79 flops */
209 /* End of innermost loop */
212 f[i_coord_offset+DIM*0+XX] += fix0;
213 f[i_coord_offset+DIM*0+YY] += fiy0;
214 f[i_coord_offset+DIM*0+ZZ] += fiz0;
218 fshift[i_shift_offset+XX] += tx;
219 fshift[i_shift_offset+YY] += ty;
220 fshift[i_shift_offset+ZZ] += tz;
223 /* Update potential energies */
224 kernel_data->energygrp_elec[ggid] += velecsum;
225 kernel_data->energygrp_vdw[ggid] += vvdwsum;
227 /* Increment number of inner iterations */
228 inneriter += j_index_end - j_index_start;
230 /* Outer loop uses 15 flops */
233 /* Increment number of outer iterations */
236 /* Update outer/inner flops */
238 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*79);
241 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomP1P1_F_c
242 * Electrostatics interaction: Ewald
243 * VdW interaction: Buckingham
244 * Geometry: Particle-Particle
245 * Calculate force/pot: Force
248 nb_kernel_ElecEw_VdwBham_GeomP1P1_F_c
249 (t_nblist * gmx_restrict nlist,
250 rvec * gmx_restrict xx,
251 rvec * gmx_restrict ff,
252 t_forcerec * gmx_restrict fr,
253 t_mdatoms * gmx_restrict mdatoms,
254 nb_kernel_data_t * gmx_restrict kernel_data,
255 t_nrnb * gmx_restrict nrnb)
257 int i_shift_offset,i_coord_offset,j_coord_offset;
258 int j_index_start,j_index_end;
259 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
260 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
261 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
262 real *shiftvec,*fshift,*x,*f;
264 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
266 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
267 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
268 real velec,felec,velecsum,facel,crf,krf,krf2;
271 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
275 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
283 jindex = nlist->jindex;
285 shiftidx = nlist->shift;
287 shiftvec = fr->shift_vec[0];
288 fshift = fr->fshift[0];
290 charge = mdatoms->chargeA;
291 nvdwtype = fr->ntype;
293 vdwtype = mdatoms->typeA;
295 sh_ewald = fr->ic->sh_ewald;
296 ewtab = fr->ic->tabq_coul_F;
297 ewtabscale = fr->ic->tabq_scale;
298 ewtabhalfspace = 0.5/ewtabscale;
303 /* Start outer loop over neighborlists */
304 for(iidx=0; iidx<nri; iidx++)
306 /* Load shift vector for this list */
307 i_shift_offset = DIM*shiftidx[iidx];
308 shX = shiftvec[i_shift_offset+XX];
309 shY = shiftvec[i_shift_offset+YY];
310 shZ = shiftvec[i_shift_offset+ZZ];
312 /* Load limits for loop over neighbors */
313 j_index_start = jindex[iidx];
314 j_index_end = jindex[iidx+1];
316 /* Get outer coordinate index */
318 i_coord_offset = DIM*inr;
320 /* Load i particle coords and add shift vector */
321 ix0 = shX + x[i_coord_offset+DIM*0+XX];
322 iy0 = shY + x[i_coord_offset+DIM*0+YY];
323 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
329 /* Load parameters for i particles */
330 iq0 = facel*charge[inr+0];
331 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
333 /* Start inner kernel loop */
334 for(jidx=j_index_start; jidx<j_index_end; jidx++)
336 /* Get j neighbor index, and coordinate index */
338 j_coord_offset = DIM*jnr;
340 /* load j atom coordinates */
341 jx0 = x[j_coord_offset+DIM*0+XX];
342 jy0 = x[j_coord_offset+DIM*0+YY];
343 jz0 = x[j_coord_offset+DIM*0+ZZ];
345 /* Calculate displacement vector */
350 /* Calculate squared distance and things based on it */
351 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
353 rinv00 = gmx_invsqrt(rsq00);
355 rinvsq00 = rinv00*rinv00;
357 /* Load parameters for j particles */
359 vdwjidx0 = 3*vdwtype[jnr+0];
361 /**************************
362 * CALCULATE INTERACTIONS *
363 **************************/
368 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
369 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
370 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
372 /* EWALD ELECTROSTATICS */
374 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
375 ewrt = r00*ewtabscale;
378 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
379 felec = qq00*rinv00*(rinvsq00-felec);
381 /* BUCKINGHAM DISPERSION/REPULSION */
382 rinvsix = rinvsq00*rinvsq00*rinvsq00;
383 vvdw6 = c6_00*rinvsix;
385 vvdwexp = cexp1_00*exp(-br);
386 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
390 /* Calculate temporary vectorial force */
395 /* Update vectorial force */
399 f[j_coord_offset+DIM*0+XX] -= tx;
400 f[j_coord_offset+DIM*0+YY] -= ty;
401 f[j_coord_offset+DIM*0+ZZ] -= tz;
403 /* Inner loop uses 69 flops */
405 /* End of innermost loop */
408 f[i_coord_offset+DIM*0+XX] += fix0;
409 f[i_coord_offset+DIM*0+YY] += fiy0;
410 f[i_coord_offset+DIM*0+ZZ] += fiz0;
414 fshift[i_shift_offset+XX] += tx;
415 fshift[i_shift_offset+YY] += ty;
416 fshift[i_shift_offset+ZZ] += tz;
418 /* Increment number of inner iterations */
419 inneriter += j_index_end - j_index_start;
421 /* Outer loop uses 13 flops */
424 /* Increment number of outer iterations */
427 /* Update outer/inner flops */
429 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*69);