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_ElecCSTab_VdwBham_GeomP1P1_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: Buckingham
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_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 rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
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 vftab = kernel_data->table_elec->data;
89 vftabscale = kernel_data->table_elec->scale;
94 /* Start outer loop over neighborlists */
95 for(iidx=0; iidx<nri; iidx++)
97 /* Load shift vector for this list */
98 i_shift_offset = DIM*shiftidx[iidx];
99 shX = shiftvec[i_shift_offset+XX];
100 shY = shiftvec[i_shift_offset+YY];
101 shZ = shiftvec[i_shift_offset+ZZ];
103 /* Load limits for loop over neighbors */
104 j_index_start = jindex[iidx];
105 j_index_end = jindex[iidx+1];
107 /* Get outer coordinate index */
109 i_coord_offset = DIM*inr;
111 /* Load i particle coords and add shift vector */
112 ix0 = shX + x[i_coord_offset+DIM*0+XX];
113 iy0 = shY + x[i_coord_offset+DIM*0+YY];
114 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
120 /* Load parameters for i particles */
121 iq0 = facel*charge[inr+0];
122 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
124 /* Reset potential sums */
128 /* Start inner kernel loop */
129 for(jidx=j_index_start; jidx<j_index_end; jidx++)
131 /* Get j neighbor index, and coordinate index */
133 j_coord_offset = DIM*jnr;
135 /* load j atom coordinates */
136 jx0 = x[j_coord_offset+DIM*0+XX];
137 jy0 = x[j_coord_offset+DIM*0+YY];
138 jz0 = x[j_coord_offset+DIM*0+ZZ];
140 /* Calculate displacement vector */
145 /* Calculate squared distance and things based on it */
146 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
148 rinv00 = gmx_invsqrt(rsq00);
150 rinvsq00 = rinv00*rinv00;
152 /* Load parameters for j particles */
154 vdwjidx0 = 3*vdwtype[jnr+0];
156 /**************************
157 * CALCULATE INTERACTIONS *
158 **************************/
163 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
164 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
165 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
167 /* Calculate table index by multiplying r with table scale and truncate to integer */
173 /* CUBIC SPLINE TABLE ELECTROSTATICS */
176 Geps = vfeps*vftab[vfitab+2];
177 Heps2 = vfeps*vfeps*vftab[vfitab+3];
181 FF = Fp+Geps+2.0*Heps2;
182 felec = -qq00*FF*vftabscale*rinv00;
184 /* BUCKINGHAM DISPERSION/REPULSION */
185 rinvsix = rinvsq00*rinvsq00*rinvsq00;
186 vvdw6 = c6_00*rinvsix;
188 vvdwexp = cexp1_00*exp(-br);
189 vvdw = vvdwexp - vvdw6*(1.0/6.0);
190 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
192 /* Update potential sums from outer loop */
198 /* Calculate temporary vectorial force */
203 /* Update vectorial force */
207 f[j_coord_offset+DIM*0+XX] -= tx;
208 f[j_coord_offset+DIM*0+YY] -= ty;
209 f[j_coord_offset+DIM*0+ZZ] -= tz;
211 /* Inner loop uses 81 flops */
213 /* End of innermost loop */
216 f[i_coord_offset+DIM*0+XX] += fix0;
217 f[i_coord_offset+DIM*0+YY] += fiy0;
218 f[i_coord_offset+DIM*0+ZZ] += fiz0;
222 fshift[i_shift_offset+XX] += tx;
223 fshift[i_shift_offset+YY] += ty;
224 fshift[i_shift_offset+ZZ] += tz;
227 /* Update potential energies */
228 kernel_data->energygrp_elec[ggid] += velecsum;
229 kernel_data->energygrp_vdw[ggid] += vvdwsum;
231 /* Increment number of inner iterations */
232 inneriter += j_index_end - j_index_start;
234 /* Outer loop uses 15 flops */
237 /* Increment number of outer iterations */
240 /* Update outer/inner flops */
242 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*81);
245 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomP1P1_F_c
246 * Electrostatics interaction: CubicSplineTable
247 * VdW interaction: Buckingham
248 * Geometry: Particle-Particle
249 * Calculate force/pot: Force
252 nb_kernel_ElecCSTab_VdwBham_GeomP1P1_F_c
253 (t_nblist * gmx_restrict nlist,
254 rvec * gmx_restrict xx,
255 rvec * gmx_restrict ff,
256 t_forcerec * gmx_restrict fr,
257 t_mdatoms * gmx_restrict mdatoms,
258 nb_kernel_data_t * gmx_restrict kernel_data,
259 t_nrnb * gmx_restrict nrnb)
261 int i_shift_offset,i_coord_offset,j_coord_offset;
262 int j_index_start,j_index_end;
263 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
264 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
265 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
266 real *shiftvec,*fshift,*x,*f;
268 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
270 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
271 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
272 real velec,felec,velecsum,facel,crf,krf,krf2;
275 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
279 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
287 jindex = nlist->jindex;
289 shiftidx = nlist->shift;
291 shiftvec = fr->shift_vec[0];
292 fshift = fr->fshift[0];
294 charge = mdatoms->chargeA;
295 nvdwtype = fr->ntype;
297 vdwtype = mdatoms->typeA;
299 vftab = kernel_data->table_elec->data;
300 vftabscale = kernel_data->table_elec->scale;
305 /* Start outer loop over neighborlists */
306 for(iidx=0; iidx<nri; iidx++)
308 /* Load shift vector for this list */
309 i_shift_offset = DIM*shiftidx[iidx];
310 shX = shiftvec[i_shift_offset+XX];
311 shY = shiftvec[i_shift_offset+YY];
312 shZ = shiftvec[i_shift_offset+ZZ];
314 /* Load limits for loop over neighbors */
315 j_index_start = jindex[iidx];
316 j_index_end = jindex[iidx+1];
318 /* Get outer coordinate index */
320 i_coord_offset = DIM*inr;
322 /* Load i particle coords and add shift vector */
323 ix0 = shX + x[i_coord_offset+DIM*0+XX];
324 iy0 = shY + x[i_coord_offset+DIM*0+YY];
325 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
331 /* Load parameters for i particles */
332 iq0 = facel*charge[inr+0];
333 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
335 /* Start inner kernel loop */
336 for(jidx=j_index_start; jidx<j_index_end; jidx++)
338 /* Get j neighbor index, and coordinate index */
340 j_coord_offset = DIM*jnr;
342 /* load j atom coordinates */
343 jx0 = x[j_coord_offset+DIM*0+XX];
344 jy0 = x[j_coord_offset+DIM*0+YY];
345 jz0 = x[j_coord_offset+DIM*0+ZZ];
347 /* Calculate displacement vector */
352 /* Calculate squared distance and things based on it */
353 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
355 rinv00 = gmx_invsqrt(rsq00);
357 rinvsq00 = rinv00*rinv00;
359 /* Load parameters for j particles */
361 vdwjidx0 = 3*vdwtype[jnr+0];
363 /**************************
364 * CALCULATE INTERACTIONS *
365 **************************/
370 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
371 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
372 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
374 /* Calculate table index by multiplying r with table scale and truncate to integer */
380 /* CUBIC SPLINE TABLE ELECTROSTATICS */
383 Geps = vfeps*vftab[vfitab+2];
384 Heps2 = vfeps*vfeps*vftab[vfitab+3];
386 FF = Fp+Geps+2.0*Heps2;
387 felec = -qq00*FF*vftabscale*rinv00;
389 /* BUCKINGHAM DISPERSION/REPULSION */
390 rinvsix = rinvsq00*rinvsq00*rinvsq00;
391 vvdw6 = c6_00*rinvsix;
393 vvdwexp = cexp1_00*exp(-br);
394 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
398 /* Calculate temporary vectorial force */
403 /* Update vectorial force */
407 f[j_coord_offset+DIM*0+XX] -= tx;
408 f[j_coord_offset+DIM*0+YY] -= ty;
409 f[j_coord_offset+DIM*0+ZZ] -= tz;
411 /* Inner loop uses 74 flops */
413 /* End of innermost loop */
416 f[i_coord_offset+DIM*0+XX] += fix0;
417 f[i_coord_offset+DIM*0+YY] += fiy0;
418 f[i_coord_offset+DIM*0+ZZ] += fiz0;
422 fshift[i_shift_offset+XX] += tx;
423 fshift[i_shift_offset+YY] += ty;
424 fshift[i_shift_offset+ZZ] += tz;
426 /* Increment number of inner iterations */
427 inneriter += j_index_end - j_index_start;
429 /* Outer loop uses 13 flops */
432 /* Increment number of outer iterations */
435 /* Update outer/inner flops */
437 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*74);