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_VdwLJ_GeomP1P1_VF_c
35 * Electrostatics interaction: GeneralizedBorn
36 * VdW interaction: LennardJones
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecGB_VdwLJ_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 invsqrta = fr->invsqrta;
93 gbtabscale = fr->gbtab.scale;
94 gbtab = fr->gbtab.data;
95 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
100 /* Start outer loop over neighborlists */
101 for(iidx=0; iidx<nri; iidx++)
103 /* Load shift vector for this list */
104 i_shift_offset = DIM*shiftidx[iidx];
105 shX = shiftvec[i_shift_offset+XX];
106 shY = shiftvec[i_shift_offset+YY];
107 shZ = shiftvec[i_shift_offset+ZZ];
109 /* Load limits for loop over neighbors */
110 j_index_start = jindex[iidx];
111 j_index_end = jindex[iidx+1];
113 /* Get outer coordinate index */
115 i_coord_offset = DIM*inr;
117 /* Load i particle coords and add shift vector */
118 ix0 = shX + x[i_coord_offset+DIM*0+XX];
119 iy0 = shY + x[i_coord_offset+DIM*0+YY];
120 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
126 /* Load parameters for i particles */
127 iq0 = facel*charge[inr+0];
128 isai0 = invsqrta[inr+0];
129 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
131 /* Reset potential sums */
136 printf("inr=%d\n",inr);
137 /* Start inner kernel loop */
138 for(jidx=j_index_start; jidx<j_index_end; jidx++)
140 /* Get j neighbor index, and coordinate index */
142 j_coord_offset = DIM*jnr;
144 /* load j atom coordinates */
145 jx0 = x[j_coord_offset+DIM*0+XX];
146 jy0 = x[j_coord_offset+DIM*0+YY];
147 jz0 = x[j_coord_offset+DIM*0+ZZ];
149 /* Calculate displacement vector */
154 /* Calculate squared distance and things based on it */
155 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
157 rinv00 = gmx_invsqrt(rsq00);
159 rinvsq00 = rinv00*rinv00;
161 /* Load parameters for j particles */
163 isaj0 = invsqrta[jnr+0];
164 vdwjidx0 = 2*vdwtype[jnr+0];
166 /**************************
167 * CALCULATE INTERACTIONS *
168 **************************/
173 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
174 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
176 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
177 isaprod = isai0*isaj0;
178 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
179 gbscale = isaprod*gbtabscale;
182 /* Calculate generalized born table index - this is a separate table from the normal one,
183 * but we use the same procedure by multiplying r with scale and truncating to integer.
192 Geps = gbeps*gbtab[gbitab+2];
193 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
198 FF = Fp+Geps+2.0*Heps2;
199 fgb = gbqqfactor*FF*gbscale;
200 printf(" jnr=%d fgb=%g\n",jnr,fgb);
201 dvdatmp = -0.5*(vgb+fgb*r00);
202 dvdasum = dvdasum + dvdatmp;
203 printf(" dvdatmp=%g\n",dvdatmp);
204 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
205 printf(" dvda, jcontrib=%g\n",dvdatmp*isaj0*isaj0);
207 felec = (velec*rinv00-fgb)*rinv00;
209 /* LENNARD-JONES DISPERSION/REPULSION */
211 rinvsix = rinvsq00*rinvsq00*rinvsq00;
212 vvdw6 = c6_00*rinvsix;
213 vvdw12 = c12_00*rinvsix*rinvsix;
214 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
215 fvdw = (vvdw12-vvdw6)*rinvsq00;
217 /* Update potential sums from outer loop */
224 /* Calculate temporary vectorial force */
229 /* Update vectorial force */
233 f[j_coord_offset+DIM*0+XX] -= tx;
234 f[j_coord_offset+DIM*0+YY] -= ty;
235 f[j_coord_offset+DIM*0+ZZ] -= tz;
237 /* Inner loop uses 71 flops */
239 /* End of innermost loop */
242 f[i_coord_offset+DIM*0+XX] += fix0;
243 f[i_coord_offset+DIM*0+YY] += fiy0;
244 f[i_coord_offset+DIM*0+ZZ] += fiz0;
248 fshift[i_shift_offset+XX] += tx;
249 fshift[i_shift_offset+YY] += ty;
250 fshift[i_shift_offset+ZZ] += tz;
253 /* Update potential energies */
254 kernel_data->energygrp_elec[ggid] += velecsum;
255 kernel_data->energygrp_polarization[ggid] += vgbsum;
256 kernel_data->energygrp_vdw[ggid] += vvdwsum;
257 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
259 /* Increment number of inner iterations */
260 inneriter += j_index_end - j_index_start;
262 /* Outer loop uses 16 flops */
265 /* Increment number of outer iterations */
268 /* Update outer/inner flops */
270 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*16 + inneriter*71);
273 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_c
274 * Electrostatics interaction: GeneralizedBorn
275 * VdW interaction: LennardJones
276 * Geometry: Particle-Particle
277 * Calculate force/pot: Force
280 nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_c
281 (t_nblist * gmx_restrict nlist,
282 rvec * gmx_restrict xx,
283 rvec * gmx_restrict ff,
284 t_forcerec * gmx_restrict fr,
285 t_mdatoms * gmx_restrict mdatoms,
286 nb_kernel_data_t * gmx_restrict kernel_data,
287 t_nrnb * gmx_restrict nrnb)
289 int i_shift_offset,i_coord_offset,j_coord_offset;
290 int j_index_start,j_index_end;
291 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
292 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
293 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
294 real *shiftvec,*fshift,*x,*f;
296 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
298 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
299 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
300 real velec,felec,velecsum,facel,crf,krf,krf2;
303 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
304 real *invsqrta,*dvda,*gbtab;
306 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
310 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
318 jindex = nlist->jindex;
320 shiftidx = nlist->shift;
322 shiftvec = fr->shift_vec[0];
323 fshift = fr->fshift[0];
325 charge = mdatoms->chargeA;
326 nvdwtype = fr->ntype;
328 vdwtype = mdatoms->typeA;
330 invsqrta = fr->invsqrta;
332 gbtabscale = fr->gbtab.scale;
333 gbtab = fr->gbtab.data;
334 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
339 /* Start outer loop over neighborlists */
340 for(iidx=0; iidx<nri; iidx++)
342 /* Load shift vector for this list */
343 i_shift_offset = DIM*shiftidx[iidx];
344 shX = shiftvec[i_shift_offset+XX];
345 shY = shiftvec[i_shift_offset+YY];
346 shZ = shiftvec[i_shift_offset+ZZ];
348 /* Load limits for loop over neighbors */
349 j_index_start = jindex[iidx];
350 j_index_end = jindex[iidx+1];
352 /* Get outer coordinate index */
354 i_coord_offset = DIM*inr;
356 /* Load i particle coords and add shift vector */
357 ix0 = shX + x[i_coord_offset+DIM*0+XX];
358 iy0 = shY + x[i_coord_offset+DIM*0+YY];
359 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
365 /* Load parameters for i particles */
366 iq0 = facel*charge[inr+0];
367 isai0 = invsqrta[inr+0];
368 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
372 /* Start inner kernel loop */
373 for(jidx=j_index_start; jidx<j_index_end; jidx++)
375 /* Get j neighbor index, and coordinate index */
377 j_coord_offset = DIM*jnr;
379 /* load j atom coordinates */
380 jx0 = x[j_coord_offset+DIM*0+XX];
381 jy0 = x[j_coord_offset+DIM*0+YY];
382 jz0 = x[j_coord_offset+DIM*0+ZZ];
384 /* Calculate displacement vector */
389 /* Calculate squared distance and things based on it */
390 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
392 rinv00 = gmx_invsqrt(rsq00);
394 rinvsq00 = rinv00*rinv00;
396 /* Load parameters for j particles */
398 isaj0 = invsqrta[jnr+0];
399 vdwjidx0 = 2*vdwtype[jnr+0];
401 /**************************
402 * CALCULATE INTERACTIONS *
403 **************************/
408 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
409 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
411 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
412 isaprod = isai0*isaj0;
413 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
414 gbscale = isaprod*gbtabscale;
417 /* Calculate generalized born table index - this is a separate table from the normal one,
418 * but we use the same procedure by multiplying r with scale and truncating to integer.
427 Geps = gbeps*gbtab[gbitab+2];
428 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
433 FF = Fp+Geps+2.0*Heps2;
434 fgb = gbqqfactor*FF*gbscale;
435 dvdatmp = -0.5*(vgb+fgb*r00);
436 dvdasum = dvdasum + dvdatmp;
437 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
439 felec = (velec*rinv00-fgb)*rinv00;
441 /* LENNARD-JONES DISPERSION/REPULSION */
443 rinvsix = rinvsq00*rinvsq00*rinvsq00;
444 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
448 /* Calculate temporary vectorial force */
453 /* Update vectorial force */
457 f[j_coord_offset+DIM*0+XX] -= tx;
458 f[j_coord_offset+DIM*0+YY] -= ty;
459 f[j_coord_offset+DIM*0+ZZ] -= tz;
461 /* Inner loop uses 64 flops */
463 /* End of innermost loop */
466 f[i_coord_offset+DIM*0+XX] += fix0;
467 f[i_coord_offset+DIM*0+YY] += fiy0;
468 f[i_coord_offset+DIM*0+ZZ] += fiz0;
472 fshift[i_shift_offset+XX] += tx;
473 fshift[i_shift_offset+YY] += ty;
474 fshift[i_shift_offset+ZZ] += tz;
476 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
478 /* Increment number of inner iterations */
479 inneriter += j_index_end - j_index_start;
481 /* Outer loop uses 13 flops */
484 /* Increment number of outer iterations */
487 /* Update outer/inner flops */
489 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*64);