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_ElecGB_VdwCSTab_GeomP1P1_VF_c
35 * Electrostatics interaction: GeneralizedBorn
36 * VdW interaction: CubicSplineTable
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecGB_VdwCSTab_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 vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
65 real *invsqrta,*dvda,*gbtab;
67 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
71 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
79 jindex = nlist->jindex;
81 shiftidx = nlist->shift;
83 shiftvec = fr->shift_vec[0];
84 fshift = fr->fshift[0];
86 charge = mdatoms->chargeA;
89 vdwtype = mdatoms->typeA;
91 vftab = kernel_data->table_vdw->data;
92 vftabscale = kernel_data->table_vdw->scale;
94 invsqrta = fr->invsqrta;
96 gbtabscale = fr->gbtab.scale;
97 gbtab = fr->gbtab.data;
98 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
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 isai0 = invsqrta[inr+0];
132 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
134 /* Reset potential sums */
140 /* Start inner kernel loop */
141 for(jidx=j_index_start; jidx<j_index_end; jidx++)
143 /* Get j neighbor index, and coordinate index */
145 j_coord_offset = DIM*jnr;
147 /* load j atom coordinates */
148 jx0 = x[j_coord_offset+DIM*0+XX];
149 jy0 = x[j_coord_offset+DIM*0+YY];
150 jz0 = x[j_coord_offset+DIM*0+ZZ];
152 /* Calculate displacement vector */
157 /* Calculate squared distance and things based on it */
158 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
160 rinv00 = gmx_invsqrt(rsq00);
162 /* Load parameters for j particles */
164 isaj0 = invsqrta[jnr+0];
165 vdwjidx0 = 2*vdwtype[jnr+0];
167 /**************************
168 * CALCULATE INTERACTIONS *
169 **************************/
174 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
175 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
177 /* Calculate table index by multiplying r with table scale and truncate to integer */
183 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
184 isaprod = isai0*isaj0;
185 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
186 gbscale = isaprod*gbtabscale;
189 /* Calculate generalized born table index - this is a separate table from the normal one,
190 * but we use the same procedure by multiplying r with scale and truncating to integer.
199 Geps = gbeps*gbtab[gbitab+2];
200 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
205 FF = Fp+Geps+2.0*Heps2;
206 fgb = gbqqfactor*FF*gbscale;
207 dvdatmp = -0.5*(vgb+fgb*r00);
208 dvdasum = dvdasum + dvdatmp;
209 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
211 felec = (velec*rinv00-fgb)*rinv00;
213 /* CUBIC SPLINE TABLE DISPERSION */
217 Geps = vfeps*vftab[vfitab+2];
218 Heps2 = vfeps*vfeps*vftab[vfitab+3];
222 FF = Fp+Geps+2.0*Heps2;
225 /* CUBIC SPLINE TABLE REPULSION */
228 Geps = vfeps*vftab[vfitab+6];
229 Heps2 = vfeps*vfeps*vftab[vfitab+7];
233 FF = Fp+Geps+2.0*Heps2;
236 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
238 /* Update potential sums from outer loop */
245 /* Calculate temporary vectorial force */
250 /* Update vectorial force */
254 f[j_coord_offset+DIM*0+XX] -= tx;
255 f[j_coord_offset+DIM*0+YY] -= ty;
256 f[j_coord_offset+DIM*0+ZZ] -= tz;
258 /* Inner loop uses 91 flops */
260 /* End of innermost loop */
263 f[i_coord_offset+DIM*0+XX] += fix0;
264 f[i_coord_offset+DIM*0+YY] += fiy0;
265 f[i_coord_offset+DIM*0+ZZ] += fiz0;
269 fshift[i_shift_offset+XX] += tx;
270 fshift[i_shift_offset+YY] += ty;
271 fshift[i_shift_offset+ZZ] += tz;
274 /* Update potential energies */
275 kernel_data->energygrp_elec[ggid] += velecsum;
276 kernel_data->energygrp_polarization[ggid] += vgbsum;
277 kernel_data->energygrp_vdw[ggid] += vvdwsum;
278 dvda[nri] = dvda[nri] + dvdasum*isai0*isai0;
280 /* Increment number of inner iterations */
281 inneriter += j_index_end - j_index_start;
283 /* Outer loop uses 16 flops */
286 /* Increment number of outer iterations */
289 /* Update outer/inner flops */
291 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*16 + inneriter*91);
294 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_c
295 * Electrostatics interaction: GeneralizedBorn
296 * VdW interaction: CubicSplineTable
297 * Geometry: Particle-Particle
298 * Calculate force/pot: Force
301 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_c
302 (t_nblist * gmx_restrict nlist,
303 rvec * gmx_restrict xx,
304 rvec * gmx_restrict ff,
305 t_forcerec * gmx_restrict fr,
306 t_mdatoms * gmx_restrict mdatoms,
307 nb_kernel_data_t * gmx_restrict kernel_data,
308 t_nrnb * gmx_restrict nrnb)
310 int i_shift_offset,i_coord_offset,j_coord_offset;
311 int j_index_start,j_index_end;
312 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
313 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
314 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
315 real *shiftvec,*fshift,*x,*f;
317 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
319 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
320 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
321 real velec,felec,velecsum,facel,crf,krf,krf2;
324 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
325 real *invsqrta,*dvda,*gbtab;
327 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
331 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
339 jindex = nlist->jindex;
341 shiftidx = nlist->shift;
343 shiftvec = fr->shift_vec[0];
344 fshift = fr->fshift[0];
346 charge = mdatoms->chargeA;
347 nvdwtype = fr->ntype;
349 vdwtype = mdatoms->typeA;
351 vftab = kernel_data->table_vdw->data;
352 vftabscale = kernel_data->table_vdw->scale;
354 invsqrta = fr->invsqrta;
356 gbtabscale = fr->gbtab.scale;
357 gbtab = fr->gbtab.data;
358 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
363 /* Start outer loop over neighborlists */
364 for(iidx=0; iidx<nri; iidx++)
366 /* Load shift vector for this list */
367 i_shift_offset = DIM*shiftidx[iidx];
368 shX = shiftvec[i_shift_offset+XX];
369 shY = shiftvec[i_shift_offset+YY];
370 shZ = shiftvec[i_shift_offset+ZZ];
372 /* Load limits for loop over neighbors */
373 j_index_start = jindex[iidx];
374 j_index_end = jindex[iidx+1];
376 /* Get outer coordinate index */
378 i_coord_offset = DIM*inr;
380 /* Load i particle coords and add shift vector */
381 ix0 = shX + x[i_coord_offset+DIM*0+XX];
382 iy0 = shY + x[i_coord_offset+DIM*0+YY];
383 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
389 /* Load parameters for i particles */
390 iq0 = facel*charge[inr+0];
391 isai0 = invsqrta[inr+0];
392 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
396 /* Start inner kernel loop */
397 for(jidx=j_index_start; jidx<j_index_end; jidx++)
399 /* Get j neighbor index, and coordinate index */
401 j_coord_offset = DIM*jnr;
403 /* load j atom coordinates */
404 jx0 = x[j_coord_offset+DIM*0+XX];
405 jy0 = x[j_coord_offset+DIM*0+YY];
406 jz0 = x[j_coord_offset+DIM*0+ZZ];
408 /* Calculate displacement vector */
413 /* Calculate squared distance and things based on it */
414 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
416 rinv00 = gmx_invsqrt(rsq00);
418 /* Load parameters for j particles */
420 isaj0 = invsqrta[jnr+0];
421 vdwjidx0 = 2*vdwtype[jnr+0];
423 /**************************
424 * CALCULATE INTERACTIONS *
425 **************************/
430 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
431 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
433 /* Calculate table index by multiplying r with table scale and truncate to integer */
439 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
440 isaprod = isai0*isaj0;
441 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
442 gbscale = isaprod*gbtabscale;
445 /* Calculate generalized born table index - this is a separate table from the normal one,
446 * but we use the same procedure by multiplying r with scale and truncating to integer.
455 Geps = gbeps*gbtab[gbitab+2];
456 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
461 FF = Fp+Geps+2.0*Heps2;
462 fgb = gbqqfactor*FF*gbscale;
463 dvdatmp = -0.5*(vgb+fgb*r00);
464 dvdasum = dvdasum + dvdatmp;
465 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
467 felec = (velec*rinv00-fgb)*rinv00;
469 /* CUBIC SPLINE TABLE DISPERSION */
473 Geps = vfeps*vftab[vfitab+2];
474 Heps2 = vfeps*vfeps*vftab[vfitab+3];
476 FF = Fp+Geps+2.0*Heps2;
479 /* CUBIC SPLINE TABLE REPULSION */
482 Geps = vfeps*vftab[vfitab+6];
483 Heps2 = vfeps*vfeps*vftab[vfitab+7];
485 FF = Fp+Geps+2.0*Heps2;
487 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
491 /* Calculate temporary vectorial force */
496 /* Update vectorial force */
500 f[j_coord_offset+DIM*0+XX] -= tx;
501 f[j_coord_offset+DIM*0+YY] -= ty;
502 f[j_coord_offset+DIM*0+ZZ] -= tz;
504 /* Inner loop uses 81 flops */
506 /* End of innermost loop */
509 f[i_coord_offset+DIM*0+XX] += fix0;
510 f[i_coord_offset+DIM*0+YY] += fiy0;
511 f[i_coord_offset+DIM*0+ZZ] += fiz0;
515 fshift[i_shift_offset+XX] += tx;
516 fshift[i_shift_offset+YY] += ty;
517 fshift[i_shift_offset+ZZ] += tz;
519 dvda[nri] = dvda[nri] + dvdasum*isai0*isai0;
521 /* Increment number of inner iterations */
522 inneriter += j_index_end - j_index_start;
524 /* Outer loop uses 13 flops */
527 /* Increment number of outer iterations */
530 /* Update outer/inner flops */
532 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*81);