2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_VF_c
51 * Electrostatics interaction: GeneralizedBorn
52 * VdW interaction: CubicSplineTable
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
77 real velec,felec,velecsum,facel,crf,krf,krf2;
80 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
81 real *invsqrta,*dvda,*gbtab;
83 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
87 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
95 jindex = nlist->jindex;
97 shiftidx = nlist->shift;
99 shiftvec = fr->shift_vec[0];
100 fshift = fr->fshift[0];
102 charge = mdatoms->chargeA;
103 nvdwtype = fr->ntype;
105 vdwtype = mdatoms->typeA;
107 vftab = kernel_data->table_vdw->data;
108 vftabscale = kernel_data->table_vdw->scale;
110 invsqrta = fr->invsqrta;
112 gbtabscale = fr->gbtab.scale;
113 gbtab = fr->gbtab.data;
114 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
119 /* Start outer loop over neighborlists */
120 for(iidx=0; iidx<nri; iidx++)
122 /* Load shift vector for this list */
123 i_shift_offset = DIM*shiftidx[iidx];
124 shX = shiftvec[i_shift_offset+XX];
125 shY = shiftvec[i_shift_offset+YY];
126 shZ = shiftvec[i_shift_offset+ZZ];
128 /* Load limits for loop over neighbors */
129 j_index_start = jindex[iidx];
130 j_index_end = jindex[iidx+1];
132 /* Get outer coordinate index */
134 i_coord_offset = DIM*inr;
136 /* Load i particle coords and add shift vector */
137 ix0 = shX + x[i_coord_offset+DIM*0+XX];
138 iy0 = shY + x[i_coord_offset+DIM*0+YY];
139 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
145 /* Load parameters for i particles */
146 iq0 = facel*charge[inr+0];
147 isai0 = invsqrta[inr+0];
148 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
150 /* Reset potential sums */
156 /* Start inner kernel loop */
157 for(jidx=j_index_start; jidx<j_index_end; jidx++)
159 /* Get j neighbor index, and coordinate index */
161 j_coord_offset = DIM*jnr;
163 /* load j atom coordinates */
164 jx0 = x[j_coord_offset+DIM*0+XX];
165 jy0 = x[j_coord_offset+DIM*0+YY];
166 jz0 = x[j_coord_offset+DIM*0+ZZ];
168 /* Calculate displacement vector */
173 /* Calculate squared distance and things based on it */
174 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
176 rinv00 = gmx_invsqrt(rsq00);
178 /* Load parameters for j particles */
180 isaj0 = invsqrta[jnr+0];
181 vdwjidx0 = 2*vdwtype[jnr+0];
183 /**************************
184 * CALCULATE INTERACTIONS *
185 **************************/
190 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
191 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
193 /* Calculate table index by multiplying r with table scale and truncate to integer */
199 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
200 isaprod = isai0*isaj0;
201 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
202 gbscale = isaprod*gbtabscale;
205 /* Calculate generalized born table index - this is a separate table from the normal one,
206 * but we use the same procedure by multiplying r with scale and truncating to integer.
215 Geps = gbeps*gbtab[gbitab+2];
216 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
221 FF = Fp+Geps+2.0*Heps2;
222 fgb = gbqqfactor*FF*gbscale;
223 dvdatmp = -0.5*(vgb+fgb*r00);
224 dvdasum = dvdasum + dvdatmp;
225 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
227 felec = (velec*rinv00-fgb)*rinv00;
229 /* CUBIC SPLINE TABLE DISPERSION */
233 Geps = vfeps*vftab[vfitab+2];
234 Heps2 = vfeps*vfeps*vftab[vfitab+3];
238 FF = Fp+Geps+2.0*Heps2;
241 /* CUBIC SPLINE TABLE REPULSION */
244 Geps = vfeps*vftab[vfitab+6];
245 Heps2 = vfeps*vfeps*vftab[vfitab+7];
249 FF = Fp+Geps+2.0*Heps2;
252 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
254 /* Update potential sums from outer loop */
261 /* Calculate temporary vectorial force */
266 /* Update vectorial force */
270 f[j_coord_offset+DIM*0+XX] -= tx;
271 f[j_coord_offset+DIM*0+YY] -= ty;
272 f[j_coord_offset+DIM*0+ZZ] -= tz;
274 /* Inner loop uses 91 flops */
276 /* End of innermost loop */
279 f[i_coord_offset+DIM*0+XX] += fix0;
280 f[i_coord_offset+DIM*0+YY] += fiy0;
281 f[i_coord_offset+DIM*0+ZZ] += fiz0;
285 fshift[i_shift_offset+XX] += tx;
286 fshift[i_shift_offset+YY] += ty;
287 fshift[i_shift_offset+ZZ] += tz;
290 /* Update potential energies */
291 kernel_data->energygrp_elec[ggid] += velecsum;
292 kernel_data->energygrp_polarization[ggid] += vgbsum;
293 kernel_data->energygrp_vdw[ggid] += vvdwsum;
294 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
296 /* Increment number of inner iterations */
297 inneriter += j_index_end - j_index_start;
299 /* Outer loop uses 16 flops */
302 /* Increment number of outer iterations */
305 /* Update outer/inner flops */
307 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*16 + inneriter*91);
310 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_c
311 * Electrostatics interaction: GeneralizedBorn
312 * VdW interaction: CubicSplineTable
313 * Geometry: Particle-Particle
314 * Calculate force/pot: Force
317 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_c
318 (t_nblist * gmx_restrict nlist,
319 rvec * gmx_restrict xx,
320 rvec * gmx_restrict ff,
321 t_forcerec * gmx_restrict fr,
322 t_mdatoms * gmx_restrict mdatoms,
323 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
324 t_nrnb * gmx_restrict nrnb)
326 int i_shift_offset,i_coord_offset,j_coord_offset;
327 int j_index_start,j_index_end;
328 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
329 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
330 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
331 real *shiftvec,*fshift,*x,*f;
333 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
335 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
336 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
337 real velec,felec,velecsum,facel,crf,krf,krf2;
340 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
341 real *invsqrta,*dvda,*gbtab;
343 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
347 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
355 jindex = nlist->jindex;
357 shiftidx = nlist->shift;
359 shiftvec = fr->shift_vec[0];
360 fshift = fr->fshift[0];
362 charge = mdatoms->chargeA;
363 nvdwtype = fr->ntype;
365 vdwtype = mdatoms->typeA;
367 vftab = kernel_data->table_vdw->data;
368 vftabscale = kernel_data->table_vdw->scale;
370 invsqrta = fr->invsqrta;
372 gbtabscale = fr->gbtab.scale;
373 gbtab = fr->gbtab.data;
374 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
379 /* Start outer loop over neighborlists */
380 for(iidx=0; iidx<nri; iidx++)
382 /* Load shift vector for this list */
383 i_shift_offset = DIM*shiftidx[iidx];
384 shX = shiftvec[i_shift_offset+XX];
385 shY = shiftvec[i_shift_offset+YY];
386 shZ = shiftvec[i_shift_offset+ZZ];
388 /* Load limits for loop over neighbors */
389 j_index_start = jindex[iidx];
390 j_index_end = jindex[iidx+1];
392 /* Get outer coordinate index */
394 i_coord_offset = DIM*inr;
396 /* Load i particle coords and add shift vector */
397 ix0 = shX + x[i_coord_offset+DIM*0+XX];
398 iy0 = shY + x[i_coord_offset+DIM*0+YY];
399 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
405 /* Load parameters for i particles */
406 iq0 = facel*charge[inr+0];
407 isai0 = invsqrta[inr+0];
408 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
412 /* Start inner kernel loop */
413 for(jidx=j_index_start; jidx<j_index_end; jidx++)
415 /* Get j neighbor index, and coordinate index */
417 j_coord_offset = DIM*jnr;
419 /* load j atom coordinates */
420 jx0 = x[j_coord_offset+DIM*0+XX];
421 jy0 = x[j_coord_offset+DIM*0+YY];
422 jz0 = x[j_coord_offset+DIM*0+ZZ];
424 /* Calculate displacement vector */
429 /* Calculate squared distance and things based on it */
430 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
432 rinv00 = gmx_invsqrt(rsq00);
434 /* Load parameters for j particles */
436 isaj0 = invsqrta[jnr+0];
437 vdwjidx0 = 2*vdwtype[jnr+0];
439 /**************************
440 * CALCULATE INTERACTIONS *
441 **************************/
446 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
447 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
449 /* Calculate table index by multiplying r with table scale and truncate to integer */
455 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
456 isaprod = isai0*isaj0;
457 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
458 gbscale = isaprod*gbtabscale;
461 /* Calculate generalized born table index - this is a separate table from the normal one,
462 * but we use the same procedure by multiplying r with scale and truncating to integer.
471 Geps = gbeps*gbtab[gbitab+2];
472 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
477 FF = Fp+Geps+2.0*Heps2;
478 fgb = gbqqfactor*FF*gbscale;
479 dvdatmp = -0.5*(vgb+fgb*r00);
480 dvdasum = dvdasum + dvdatmp;
481 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
483 felec = (velec*rinv00-fgb)*rinv00;
485 /* CUBIC SPLINE TABLE DISPERSION */
488 Geps = vfeps*vftab[vfitab+2];
489 Heps2 = vfeps*vfeps*vftab[vfitab+3];
491 FF = Fp+Geps+2.0*Heps2;
494 /* CUBIC SPLINE TABLE REPULSION */
496 Geps = vfeps*vftab[vfitab+6];
497 Heps2 = vfeps*vfeps*vftab[vfitab+7];
499 FF = Fp+Geps+2.0*Heps2;
501 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
505 /* Calculate temporary vectorial force */
510 /* Update vectorial force */
514 f[j_coord_offset+DIM*0+XX] -= tx;
515 f[j_coord_offset+DIM*0+YY] -= ty;
516 f[j_coord_offset+DIM*0+ZZ] -= tz;
518 /* Inner loop uses 81 flops */
520 /* End of innermost loop */
523 f[i_coord_offset+DIM*0+XX] += fix0;
524 f[i_coord_offset+DIM*0+YY] += fiy0;
525 f[i_coord_offset+DIM*0+ZZ] += fiz0;
529 fshift[i_shift_offset+XX] += tx;
530 fshift[i_shift_offset+YY] += ty;
531 fshift[i_shift_offset+ZZ] += tz;
533 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
535 /* Increment number of inner iterations */
536 inneriter += j_index_end - j_index_start;
538 /* Outer loop uses 13 flops */
541 /* Increment number of outer iterations */
544 /* Update outer/inner flops */
546 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*81);