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.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_VF_c
49 * Electrostatics interaction: GeneralizedBorn
50 * VdW interaction: CubicSplineTable
51 * Geometry: Particle-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
75 real velec,felec,velecsum,facel,crf,krf,krf2;
78 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
79 real *invsqrta,*dvda,*gbtab;
81 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
85 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
93 jindex = nlist->jindex;
95 shiftidx = nlist->shift;
97 shiftvec = fr->shift_vec[0];
98 fshift = fr->fshift[0];
100 charge = mdatoms->chargeA;
101 nvdwtype = fr->ntype;
103 vdwtype = mdatoms->typeA;
105 vftab = kernel_data->table_vdw->data;
106 vftabscale = kernel_data->table_vdw->scale;
108 invsqrta = fr->invsqrta;
110 gbtabscale = fr->gbtab.scale;
111 gbtab = fr->gbtab.data;
112 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
117 /* Start outer loop over neighborlists */
118 for(iidx=0; iidx<nri; iidx++)
120 /* Load shift vector for this list */
121 i_shift_offset = DIM*shiftidx[iidx];
122 shX = shiftvec[i_shift_offset+XX];
123 shY = shiftvec[i_shift_offset+YY];
124 shZ = shiftvec[i_shift_offset+ZZ];
126 /* Load limits for loop over neighbors */
127 j_index_start = jindex[iidx];
128 j_index_end = jindex[iidx+1];
130 /* Get outer coordinate index */
132 i_coord_offset = DIM*inr;
134 /* Load i particle coords and add shift vector */
135 ix0 = shX + x[i_coord_offset+DIM*0+XX];
136 iy0 = shY + x[i_coord_offset+DIM*0+YY];
137 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
143 /* Load parameters for i particles */
144 iq0 = facel*charge[inr+0];
145 isai0 = invsqrta[inr+0];
146 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
148 /* Reset potential sums */
154 /* Start inner kernel loop */
155 for(jidx=j_index_start; jidx<j_index_end; jidx++)
157 /* Get j neighbor index, and coordinate index */
159 j_coord_offset = DIM*jnr;
161 /* load j atom coordinates */
162 jx0 = x[j_coord_offset+DIM*0+XX];
163 jy0 = x[j_coord_offset+DIM*0+YY];
164 jz0 = x[j_coord_offset+DIM*0+ZZ];
166 /* Calculate displacement vector */
171 /* Calculate squared distance and things based on it */
172 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
174 rinv00 = gmx_invsqrt(rsq00);
176 /* Load parameters for j particles */
178 isaj0 = invsqrta[jnr+0];
179 vdwjidx0 = 2*vdwtype[jnr+0];
181 /**************************
182 * CALCULATE INTERACTIONS *
183 **************************/
188 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
189 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
191 /* Calculate table index by multiplying r with table scale and truncate to integer */
197 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
198 isaprod = isai0*isaj0;
199 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
200 gbscale = isaprod*gbtabscale;
203 /* Calculate generalized born table index - this is a separate table from the normal one,
204 * but we use the same procedure by multiplying r with scale and truncating to integer.
213 Geps = gbeps*gbtab[gbitab+2];
214 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
219 FF = Fp+Geps+2.0*Heps2;
220 fgb = gbqqfactor*FF*gbscale;
221 dvdatmp = -0.5*(vgb+fgb*r00);
222 dvdasum = dvdasum + dvdatmp;
223 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
225 felec = (velec*rinv00-fgb)*rinv00;
227 /* CUBIC SPLINE TABLE DISPERSION */
231 Geps = vfeps*vftab[vfitab+2];
232 Heps2 = vfeps*vfeps*vftab[vfitab+3];
236 FF = Fp+Geps+2.0*Heps2;
239 /* CUBIC SPLINE TABLE REPULSION */
242 Geps = vfeps*vftab[vfitab+6];
243 Heps2 = vfeps*vfeps*vftab[vfitab+7];
247 FF = Fp+Geps+2.0*Heps2;
250 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
252 /* Update potential sums from outer loop */
259 /* Calculate temporary vectorial force */
264 /* Update vectorial force */
268 f[j_coord_offset+DIM*0+XX] -= tx;
269 f[j_coord_offset+DIM*0+YY] -= ty;
270 f[j_coord_offset+DIM*0+ZZ] -= tz;
272 /* Inner loop uses 91 flops */
274 /* End of innermost loop */
277 f[i_coord_offset+DIM*0+XX] += fix0;
278 f[i_coord_offset+DIM*0+YY] += fiy0;
279 f[i_coord_offset+DIM*0+ZZ] += fiz0;
283 fshift[i_shift_offset+XX] += tx;
284 fshift[i_shift_offset+YY] += ty;
285 fshift[i_shift_offset+ZZ] += tz;
288 /* Update potential energies */
289 kernel_data->energygrp_elec[ggid] += velecsum;
290 kernel_data->energygrp_polarization[ggid] += vgbsum;
291 kernel_data->energygrp_vdw[ggid] += vvdwsum;
292 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
294 /* Increment number of inner iterations */
295 inneriter += j_index_end - j_index_start;
297 /* Outer loop uses 16 flops */
300 /* Increment number of outer iterations */
303 /* Update outer/inner flops */
305 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*16 + inneriter*91);
308 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_c
309 * Electrostatics interaction: GeneralizedBorn
310 * VdW interaction: CubicSplineTable
311 * Geometry: Particle-Particle
312 * Calculate force/pot: Force
315 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_c
316 (t_nblist * gmx_restrict nlist,
317 rvec * gmx_restrict xx,
318 rvec * gmx_restrict ff,
319 t_forcerec * gmx_restrict fr,
320 t_mdatoms * gmx_restrict mdatoms,
321 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
322 t_nrnb * gmx_restrict nrnb)
324 int i_shift_offset,i_coord_offset,j_coord_offset;
325 int j_index_start,j_index_end;
326 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
327 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
328 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
329 real *shiftvec,*fshift,*x,*f;
331 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
333 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
334 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
335 real velec,felec,velecsum,facel,crf,krf,krf2;
338 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
339 real *invsqrta,*dvda,*gbtab;
341 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
345 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
353 jindex = nlist->jindex;
355 shiftidx = nlist->shift;
357 shiftvec = fr->shift_vec[0];
358 fshift = fr->fshift[0];
360 charge = mdatoms->chargeA;
361 nvdwtype = fr->ntype;
363 vdwtype = mdatoms->typeA;
365 vftab = kernel_data->table_vdw->data;
366 vftabscale = kernel_data->table_vdw->scale;
368 invsqrta = fr->invsqrta;
370 gbtabscale = fr->gbtab.scale;
371 gbtab = fr->gbtab.data;
372 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
377 /* Start outer loop over neighborlists */
378 for(iidx=0; iidx<nri; iidx++)
380 /* Load shift vector for this list */
381 i_shift_offset = DIM*shiftidx[iidx];
382 shX = shiftvec[i_shift_offset+XX];
383 shY = shiftvec[i_shift_offset+YY];
384 shZ = shiftvec[i_shift_offset+ZZ];
386 /* Load limits for loop over neighbors */
387 j_index_start = jindex[iidx];
388 j_index_end = jindex[iidx+1];
390 /* Get outer coordinate index */
392 i_coord_offset = DIM*inr;
394 /* Load i particle coords and add shift vector */
395 ix0 = shX + x[i_coord_offset+DIM*0+XX];
396 iy0 = shY + x[i_coord_offset+DIM*0+YY];
397 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
403 /* Load parameters for i particles */
404 iq0 = facel*charge[inr+0];
405 isai0 = invsqrta[inr+0];
406 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
410 /* Start inner kernel loop */
411 for(jidx=j_index_start; jidx<j_index_end; jidx++)
413 /* Get j neighbor index, and coordinate index */
415 j_coord_offset = DIM*jnr;
417 /* load j atom coordinates */
418 jx0 = x[j_coord_offset+DIM*0+XX];
419 jy0 = x[j_coord_offset+DIM*0+YY];
420 jz0 = x[j_coord_offset+DIM*0+ZZ];
422 /* Calculate displacement vector */
427 /* Calculate squared distance and things based on it */
428 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
430 rinv00 = gmx_invsqrt(rsq00);
432 /* Load parameters for j particles */
434 isaj0 = invsqrta[jnr+0];
435 vdwjidx0 = 2*vdwtype[jnr+0];
437 /**************************
438 * CALCULATE INTERACTIONS *
439 **************************/
444 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
445 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
447 /* Calculate table index by multiplying r with table scale and truncate to integer */
453 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
454 isaprod = isai0*isaj0;
455 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
456 gbscale = isaprod*gbtabscale;
459 /* Calculate generalized born table index - this is a separate table from the normal one,
460 * but we use the same procedure by multiplying r with scale and truncating to integer.
469 Geps = gbeps*gbtab[gbitab+2];
470 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
475 FF = Fp+Geps+2.0*Heps2;
476 fgb = gbqqfactor*FF*gbscale;
477 dvdatmp = -0.5*(vgb+fgb*r00);
478 dvdasum = dvdasum + dvdatmp;
479 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
481 felec = (velec*rinv00-fgb)*rinv00;
483 /* CUBIC SPLINE TABLE DISPERSION */
486 Geps = vfeps*vftab[vfitab+2];
487 Heps2 = vfeps*vfeps*vftab[vfitab+3];
489 FF = Fp+Geps+2.0*Heps2;
492 /* CUBIC SPLINE TABLE REPULSION */
494 Geps = vfeps*vftab[vfitab+6];
495 Heps2 = vfeps*vfeps*vftab[vfitab+7];
497 FF = Fp+Geps+2.0*Heps2;
499 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
503 /* Calculate temporary vectorial force */
508 /* Update vectorial force */
512 f[j_coord_offset+DIM*0+XX] -= tx;
513 f[j_coord_offset+DIM*0+YY] -= ty;
514 f[j_coord_offset+DIM*0+ZZ] -= tz;
516 /* Inner loop uses 81 flops */
518 /* End of innermost loop */
521 f[i_coord_offset+DIM*0+XX] += fix0;
522 f[i_coord_offset+DIM*0+YY] += fiy0;
523 f[i_coord_offset+DIM*0+ZZ] += fiz0;
527 fshift[i_shift_offset+XX] += tx;
528 fshift[i_shift_offset+YY] += ty;
529 fshift[i_shift_offset+ZZ] += tz;
531 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
533 /* Increment number of inner iterations */
534 inneriter += j_index_end - j_index_start;
536 /* Outer loop uses 13 flops */
539 /* Increment number of outer iterations */
542 /* Update outer/inner flops */
544 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*81);