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_ElecEwSh_VdwBhamSh_GeomP1P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: Buckingham
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_VdwBhamSh_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;
93 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
94 rcutoff = fr->rcoulomb;
95 rcutoff2 = rcutoff*rcutoff;
97 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
103 /* Start outer loop over neighborlists */
104 for(iidx=0; iidx<nri; iidx++)
106 /* Load shift vector for this list */
107 i_shift_offset = DIM*shiftidx[iidx];
108 shX = shiftvec[i_shift_offset+XX];
109 shY = shiftvec[i_shift_offset+YY];
110 shZ = shiftvec[i_shift_offset+ZZ];
112 /* Load limits for loop over neighbors */
113 j_index_start = jindex[iidx];
114 j_index_end = jindex[iidx+1];
116 /* Get outer coordinate index */
118 i_coord_offset = DIM*inr;
120 /* Load i particle coords and add shift vector */
121 ix0 = shX + x[i_coord_offset+DIM*0+XX];
122 iy0 = shY + x[i_coord_offset+DIM*0+YY];
123 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
129 /* Load parameters for i particles */
130 iq0 = facel*charge[inr+0];
131 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
133 /* Reset potential sums */
137 /* Start inner kernel loop */
138 for(jidx=j_index_start; jidx<j_index_end; jidx++)
140 /* Get j neighbor index, and coordinate index */
142 j_coord_offset = DIM*jnr;
144 /* load j atom coordinates */
145 jx0 = x[j_coord_offset+DIM*0+XX];
146 jy0 = x[j_coord_offset+DIM*0+YY];
147 jz0 = x[j_coord_offset+DIM*0+ZZ];
149 /* Calculate displacement vector */
154 /* Calculate squared distance and things based on it */
155 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
157 rinv00 = gmx_invsqrt(rsq00);
159 rinvsq00 = rinv00*rinv00;
161 /* Load parameters for j particles */
163 vdwjidx0 = 3*vdwtype[jnr+0];
165 /**************************
166 * CALCULATE INTERACTIONS *
167 **************************/
175 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
176 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
177 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
179 /* EWALD ELECTROSTATICS */
181 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
182 ewrt = r00*ewtabscale;
186 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
187 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
188 felec = qq00*rinv00*(rinvsq00-felec);
190 /* BUCKINGHAM DISPERSION/REPULSION */
191 rinvsix = rinvsq00*rinvsq00*rinvsq00;
192 vvdw6 = c6_00*rinvsix;
194 vvdwexp = cexp1_00*exp(-br);
195 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
196 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
198 /* Update potential sums from outer loop */
204 /* Calculate temporary vectorial force */
209 /* Update vectorial force */
213 f[j_coord_offset+DIM*0+XX] -= tx;
214 f[j_coord_offset+DIM*0+YY] -= ty;
215 f[j_coord_offset+DIM*0+ZZ] -= tz;
219 /* Inner loop uses 111 flops */
221 /* End of innermost loop */
224 f[i_coord_offset+DIM*0+XX] += fix0;
225 f[i_coord_offset+DIM*0+YY] += fiy0;
226 f[i_coord_offset+DIM*0+ZZ] += fiz0;
230 fshift[i_shift_offset+XX] += tx;
231 fshift[i_shift_offset+YY] += ty;
232 fshift[i_shift_offset+ZZ] += tz;
235 /* Update potential energies */
236 kernel_data->energygrp_elec[ggid] += velecsum;
237 kernel_data->energygrp_vdw[ggid] += vvdwsum;
239 /* Increment number of inner iterations */
240 inneriter += j_index_end - j_index_start;
242 /* Outer loop uses 15 flops */
245 /* Increment number of outer iterations */
248 /* Update outer/inner flops */
250 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*111);
253 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomP1P1_F_c
254 * Electrostatics interaction: Ewald
255 * VdW interaction: Buckingham
256 * Geometry: Particle-Particle
257 * Calculate force/pot: Force
260 nb_kernel_ElecEwSh_VdwBhamSh_GeomP1P1_F_c
261 (t_nblist * gmx_restrict nlist,
262 rvec * gmx_restrict xx,
263 rvec * gmx_restrict ff,
264 t_forcerec * gmx_restrict fr,
265 t_mdatoms * gmx_restrict mdatoms,
266 nb_kernel_data_t * gmx_restrict kernel_data,
267 t_nrnb * gmx_restrict nrnb)
269 int i_shift_offset,i_coord_offset,j_coord_offset;
270 int j_index_start,j_index_end;
271 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
272 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
273 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
274 real *shiftvec,*fshift,*x,*f;
276 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
278 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
279 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
280 real velec,felec,velecsum,facel,crf,krf,krf2;
283 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
287 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
295 jindex = nlist->jindex;
297 shiftidx = nlist->shift;
299 shiftvec = fr->shift_vec[0];
300 fshift = fr->fshift[0];
302 charge = mdatoms->chargeA;
303 nvdwtype = fr->ntype;
305 vdwtype = mdatoms->typeA;
307 sh_ewald = fr->ic->sh_ewald;
308 ewtab = fr->ic->tabq_coul_F;
309 ewtabscale = fr->ic->tabq_scale;
310 ewtabhalfspace = 0.5/ewtabscale;
312 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
313 rcutoff = fr->rcoulomb;
314 rcutoff2 = rcutoff*rcutoff;
316 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
322 /* Start outer loop over neighborlists */
323 for(iidx=0; iidx<nri; iidx++)
325 /* Load shift vector for this list */
326 i_shift_offset = DIM*shiftidx[iidx];
327 shX = shiftvec[i_shift_offset+XX];
328 shY = shiftvec[i_shift_offset+YY];
329 shZ = shiftvec[i_shift_offset+ZZ];
331 /* Load limits for loop over neighbors */
332 j_index_start = jindex[iidx];
333 j_index_end = jindex[iidx+1];
335 /* Get outer coordinate index */
337 i_coord_offset = DIM*inr;
339 /* Load i particle coords and add shift vector */
340 ix0 = shX + x[i_coord_offset+DIM*0+XX];
341 iy0 = shY + x[i_coord_offset+DIM*0+YY];
342 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
348 /* Load parameters for i particles */
349 iq0 = facel*charge[inr+0];
350 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
352 /* Start inner kernel loop */
353 for(jidx=j_index_start; jidx<j_index_end; jidx++)
355 /* Get j neighbor index, and coordinate index */
357 j_coord_offset = DIM*jnr;
359 /* load j atom coordinates */
360 jx0 = x[j_coord_offset+DIM*0+XX];
361 jy0 = x[j_coord_offset+DIM*0+YY];
362 jz0 = x[j_coord_offset+DIM*0+ZZ];
364 /* Calculate displacement vector */
369 /* Calculate squared distance and things based on it */
370 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
372 rinv00 = gmx_invsqrt(rsq00);
374 rinvsq00 = rinv00*rinv00;
376 /* Load parameters for j particles */
378 vdwjidx0 = 3*vdwtype[jnr+0];
380 /**************************
381 * CALCULATE INTERACTIONS *
382 **************************/
390 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
391 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
392 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
394 /* EWALD ELECTROSTATICS */
396 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
397 ewrt = r00*ewtabscale;
400 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
401 felec = qq00*rinv00*(rinvsq00-felec);
403 /* BUCKINGHAM DISPERSION/REPULSION */
404 rinvsix = rinvsq00*rinvsq00*rinvsq00;
405 vvdw6 = c6_00*rinvsix;
407 vvdwexp = cexp1_00*exp(-br);
408 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
412 /* Calculate temporary vectorial force */
417 /* Update vectorial force */
421 f[j_coord_offset+DIM*0+XX] -= tx;
422 f[j_coord_offset+DIM*0+YY] -= ty;
423 f[j_coord_offset+DIM*0+ZZ] -= tz;
427 /* Inner loop uses 69 flops */
429 /* End of innermost loop */
432 f[i_coord_offset+DIM*0+XX] += fix0;
433 f[i_coord_offset+DIM*0+YY] += fiy0;
434 f[i_coord_offset+DIM*0+ZZ] += fiz0;
438 fshift[i_shift_offset+XX] += tx;
439 fshift[i_shift_offset+YY] += ty;
440 fshift[i_shift_offset+ZZ] += tz;
442 /* Increment number of inner iterations */
443 inneriter += j_index_end - j_index_start;
445 /* Outer loop uses 13 flops */
448 /* Increment number of outer iterations */
451 /* Update outer/inner flops */
453 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*69);