2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * 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 "types/simple.h"
50 * GROMACS nonbonded kernel: nb_kernel_ElecGB_VdwLJ_GeomP1P1_VF_c
51 * Electrostatics interaction: GeneralizedBorn
52 * VdW interaction: LennardJones
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecGB_VdwLJ_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_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 invsqrta = fr->invsqrta;
109 gbtabscale = fr->gbtab.scale;
110 gbtab = fr->gbtab.data;
111 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
116 /* Start outer loop over neighborlists */
117 for(iidx=0; iidx<nri; iidx++)
119 /* Load shift vector for this list */
120 i_shift_offset = DIM*shiftidx[iidx];
121 shX = shiftvec[i_shift_offset+XX];
122 shY = shiftvec[i_shift_offset+YY];
123 shZ = shiftvec[i_shift_offset+ZZ];
125 /* Load limits for loop over neighbors */
126 j_index_start = jindex[iidx];
127 j_index_end = jindex[iidx+1];
129 /* Get outer coordinate index */
131 i_coord_offset = DIM*inr;
133 /* Load i particle coords and add shift vector */
134 ix0 = shX + x[i_coord_offset+DIM*0+XX];
135 iy0 = shY + x[i_coord_offset+DIM*0+YY];
136 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
142 /* Load parameters for i particles */
143 iq0 = facel*charge[inr+0];
144 isai0 = invsqrta[inr+0];
145 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
147 /* Reset potential sums */
152 printf("inr=%d\n",inr);
153 /* Start inner kernel loop */
154 for(jidx=j_index_start; jidx<j_index_end; jidx++)
156 /* Get j neighbor index, and coordinate index */
158 j_coord_offset = DIM*jnr;
160 /* load j atom coordinates */
161 jx0 = x[j_coord_offset+DIM*0+XX];
162 jy0 = x[j_coord_offset+DIM*0+YY];
163 jz0 = x[j_coord_offset+DIM*0+ZZ];
165 /* Calculate displacement vector */
170 /* Calculate squared distance and things based on it */
171 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
173 rinv00 = gmx_invsqrt(rsq00);
175 rinvsq00 = rinv00*rinv00;
177 /* Load parameters for j particles */
179 isaj0 = invsqrta[jnr+0];
180 vdwjidx0 = 2*vdwtype[jnr+0];
182 /**************************
183 * CALCULATE INTERACTIONS *
184 **************************/
189 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
190 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
192 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
193 isaprod = isai0*isaj0;
194 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
195 gbscale = isaprod*gbtabscale;
198 /* Calculate generalized born table index - this is a separate table from the normal one,
199 * but we use the same procedure by multiplying r with scale and truncating to integer.
208 Geps = gbeps*gbtab[gbitab+2];
209 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
214 FF = Fp+Geps+2.0*Heps2;
215 fgb = gbqqfactor*FF*gbscale;
216 printf(" jnr=%d fgb=%g\n",jnr,fgb);
217 dvdatmp = -0.5*(vgb+fgb*r00);
218 dvdasum = dvdasum + dvdatmp;
219 printf(" dvdatmp=%g\n",dvdatmp);
220 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
221 printf(" dvda, jcontrib=%g\n",dvdatmp*isaj0*isaj0);
223 felec = (velec*rinv00-fgb)*rinv00;
225 /* LENNARD-JONES DISPERSION/REPULSION */
227 rinvsix = rinvsq00*rinvsq00*rinvsq00;
228 vvdw6 = c6_00*rinvsix;
229 vvdw12 = c12_00*rinvsix*rinvsix;
230 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
231 fvdw = (vvdw12-vvdw6)*rinvsq00;
233 /* Update potential sums from outer loop */
240 /* Calculate temporary vectorial force */
245 /* Update vectorial force */
249 f[j_coord_offset+DIM*0+XX] -= tx;
250 f[j_coord_offset+DIM*0+YY] -= ty;
251 f[j_coord_offset+DIM*0+ZZ] -= tz;
253 /* Inner loop uses 71 flops */
255 /* End of innermost loop */
258 f[i_coord_offset+DIM*0+XX] += fix0;
259 f[i_coord_offset+DIM*0+YY] += fiy0;
260 f[i_coord_offset+DIM*0+ZZ] += fiz0;
264 fshift[i_shift_offset+XX] += tx;
265 fshift[i_shift_offset+YY] += ty;
266 fshift[i_shift_offset+ZZ] += tz;
269 /* Update potential energies */
270 kernel_data->energygrp_elec[ggid] += velecsum;
271 kernel_data->energygrp_polarization[ggid] += vgbsum;
272 kernel_data->energygrp_vdw[ggid] += vvdwsum;
273 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
275 /* Increment number of inner iterations */
276 inneriter += j_index_end - j_index_start;
278 /* Outer loop uses 16 flops */
281 /* Increment number of outer iterations */
284 /* Update outer/inner flops */
286 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*16 + inneriter*71);
289 * GROMACS nonbonded kernel: nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_c
290 * Electrostatics interaction: GeneralizedBorn
291 * VdW interaction: LennardJones
292 * Geometry: Particle-Particle
293 * Calculate force/pot: Force
296 nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_c
297 (t_nblist * gmx_restrict nlist,
298 rvec * gmx_restrict xx,
299 rvec * gmx_restrict ff,
300 t_forcerec * gmx_restrict fr,
301 t_mdatoms * gmx_restrict mdatoms,
302 nb_kernel_data_t * gmx_restrict kernel_data,
303 t_nrnb * gmx_restrict nrnb)
305 int i_shift_offset,i_coord_offset,j_coord_offset;
306 int j_index_start,j_index_end;
307 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
308 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
309 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
310 real *shiftvec,*fshift,*x,*f;
312 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
314 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
315 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
316 real velec,felec,velecsum,facel,crf,krf,krf2;
319 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
320 real *invsqrta,*dvda,*gbtab;
322 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
326 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
334 jindex = nlist->jindex;
336 shiftidx = nlist->shift;
338 shiftvec = fr->shift_vec[0];
339 fshift = fr->fshift[0];
341 charge = mdatoms->chargeA;
342 nvdwtype = fr->ntype;
344 vdwtype = mdatoms->typeA;
346 invsqrta = fr->invsqrta;
348 gbtabscale = fr->gbtab.scale;
349 gbtab = fr->gbtab.data;
350 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
355 /* Start outer loop over neighborlists */
356 for(iidx=0; iidx<nri; iidx++)
358 /* Load shift vector for this list */
359 i_shift_offset = DIM*shiftidx[iidx];
360 shX = shiftvec[i_shift_offset+XX];
361 shY = shiftvec[i_shift_offset+YY];
362 shZ = shiftvec[i_shift_offset+ZZ];
364 /* Load limits for loop over neighbors */
365 j_index_start = jindex[iidx];
366 j_index_end = jindex[iidx+1];
368 /* Get outer coordinate index */
370 i_coord_offset = DIM*inr;
372 /* Load i particle coords and add shift vector */
373 ix0 = shX + x[i_coord_offset+DIM*0+XX];
374 iy0 = shY + x[i_coord_offset+DIM*0+YY];
375 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
381 /* Load parameters for i particles */
382 iq0 = facel*charge[inr+0];
383 isai0 = invsqrta[inr+0];
384 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
388 /* Start inner kernel loop */
389 for(jidx=j_index_start; jidx<j_index_end; jidx++)
391 /* Get j neighbor index, and coordinate index */
393 j_coord_offset = DIM*jnr;
395 /* load j atom coordinates */
396 jx0 = x[j_coord_offset+DIM*0+XX];
397 jy0 = x[j_coord_offset+DIM*0+YY];
398 jz0 = x[j_coord_offset+DIM*0+ZZ];
400 /* Calculate displacement vector */
405 /* Calculate squared distance and things based on it */
406 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
408 rinv00 = gmx_invsqrt(rsq00);
410 rinvsq00 = rinv00*rinv00;
412 /* Load parameters for j particles */
414 isaj0 = invsqrta[jnr+0];
415 vdwjidx0 = 2*vdwtype[jnr+0];
417 /**************************
418 * CALCULATE INTERACTIONS *
419 **************************/
424 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
425 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
427 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
428 isaprod = isai0*isaj0;
429 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
430 gbscale = isaprod*gbtabscale;
433 /* Calculate generalized born table index - this is a separate table from the normal one,
434 * but we use the same procedure by multiplying r with scale and truncating to integer.
443 Geps = gbeps*gbtab[gbitab+2];
444 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
449 FF = Fp+Geps+2.0*Heps2;
450 fgb = gbqqfactor*FF*gbscale;
451 dvdatmp = -0.5*(vgb+fgb*r00);
452 dvdasum = dvdasum + dvdatmp;
453 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
455 felec = (velec*rinv00-fgb)*rinv00;
457 /* LENNARD-JONES DISPERSION/REPULSION */
459 rinvsix = rinvsq00*rinvsq00*rinvsq00;
460 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
464 /* Calculate temporary vectorial force */
469 /* Update vectorial force */
473 f[j_coord_offset+DIM*0+XX] -= tx;
474 f[j_coord_offset+DIM*0+YY] -= ty;
475 f[j_coord_offset+DIM*0+ZZ] -= tz;
477 /* Inner loop uses 64 flops */
479 /* End of innermost loop */
482 f[i_coord_offset+DIM*0+XX] += fix0;
483 f[i_coord_offset+DIM*0+YY] += fiy0;
484 f[i_coord_offset+DIM*0+ZZ] += fiz0;
488 fshift[i_shift_offset+XX] += tx;
489 fshift[i_shift_offset+YY] += ty;
490 fshift[i_shift_offset+ZZ] += tz;
492 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
494 /* Increment number of inner iterations */
495 inneriter += j_index_end - j_index_start;
497 /* Outer loop uses 13 flops */
500 /* Increment number of outer iterations */
503 /* Update outer/inner flops */
505 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*64);