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_VdwBham_GeomP1P1_VF_c
35 * Electrostatics interaction: GeneralizedBorn
36 * VdW interaction: Buckingham
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecGB_VdwBham_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 = 3*nvdwtype*vdwtype[inr+0];
131 /* Reset potential sums */
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 = 3*vdwtype[jnr+0];
166 /**************************
167 * CALCULATE INTERACTIONS *
168 **************************/
173 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
174 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
175 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
177 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
178 isaprod = isai0*isaj0;
179 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
180 gbscale = isaprod*gbtabscale;
183 /* Calculate generalized born table index - this is a separate table from the normal one,
184 * but we use the same procedure by multiplying r with scale and truncating to integer.
193 Geps = gbeps*gbtab[gbitab+2];
194 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
199 FF = Fp+Geps+2.0*Heps2;
200 fgb = gbqqfactor*FF*gbscale;
201 dvdatmp = -0.5*(vgb+fgb*r00);
202 dvdasum = dvdasum + dvdatmp;
203 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
205 felec = (velec*rinv00-fgb)*rinv00;
207 /* BUCKINGHAM DISPERSION/REPULSION */
208 rinvsix = rinvsq00*rinvsq00*rinvsq00;
209 vvdw6 = c6_00*rinvsix;
211 vvdwexp = cexp1_00*exp(-br);
212 vvdw = vvdwexp - vvdw6*(1.0/6.0);
213 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
215 /* Update potential sums from outer loop */
222 /* Calculate temporary vectorial force */
227 /* Update vectorial force */
231 f[j_coord_offset+DIM*0+XX] -= tx;
232 f[j_coord_offset+DIM*0+YY] -= ty;
233 f[j_coord_offset+DIM*0+ZZ] -= tz;
235 /* Inner loop uses 97 flops */
237 /* End of innermost loop */
240 f[i_coord_offset+DIM*0+XX] += fix0;
241 f[i_coord_offset+DIM*0+YY] += fiy0;
242 f[i_coord_offset+DIM*0+ZZ] += fiz0;
246 fshift[i_shift_offset+XX] += tx;
247 fshift[i_shift_offset+YY] += ty;
248 fshift[i_shift_offset+ZZ] += tz;
251 /* Update potential energies */
252 kernel_data->energygrp_elec[ggid] += velecsum;
253 kernel_data->energygrp_polarization[ggid] += vgbsum;
254 kernel_data->energygrp_vdw[ggid] += vvdwsum;
255 dvda[nri] = dvda[nri] + dvdasum*isai0*isai0;
257 /* Increment number of inner iterations */
258 inneriter += j_index_end - j_index_start;
260 /* Outer loop uses 16 flops */
263 /* Increment number of outer iterations */
266 /* Update outer/inner flops */
268 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*16 + inneriter*97);
271 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwBham_GeomP1P1_F_c
272 * Electrostatics interaction: GeneralizedBorn
273 * VdW interaction: Buckingham
274 * Geometry: Particle-Particle
275 * Calculate force/pot: Force
278 nb_kernel_ElecGB_VdwBham_GeomP1P1_F_c
279 (t_nblist * gmx_restrict nlist,
280 rvec * gmx_restrict xx,
281 rvec * gmx_restrict ff,
282 t_forcerec * gmx_restrict fr,
283 t_mdatoms * gmx_restrict mdatoms,
284 nb_kernel_data_t * gmx_restrict kernel_data,
285 t_nrnb * gmx_restrict nrnb)
287 int i_shift_offset,i_coord_offset,j_coord_offset;
288 int j_index_start,j_index_end;
289 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
290 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
291 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
292 real *shiftvec,*fshift,*x,*f;
294 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
296 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
297 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
298 real velec,felec,velecsum,facel,crf,krf,krf2;
301 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
302 real *invsqrta,*dvda,*gbtab;
304 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
308 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
316 jindex = nlist->jindex;
318 shiftidx = nlist->shift;
320 shiftvec = fr->shift_vec[0];
321 fshift = fr->fshift[0];
323 charge = mdatoms->chargeA;
324 nvdwtype = fr->ntype;
326 vdwtype = mdatoms->typeA;
328 invsqrta = fr->invsqrta;
330 gbtabscale = fr->gbtab.scale;
331 gbtab = fr->gbtab.data;
332 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
337 /* Start outer loop over neighborlists */
338 for(iidx=0; iidx<nri; iidx++)
340 /* Load shift vector for this list */
341 i_shift_offset = DIM*shiftidx[iidx];
342 shX = shiftvec[i_shift_offset+XX];
343 shY = shiftvec[i_shift_offset+YY];
344 shZ = shiftvec[i_shift_offset+ZZ];
346 /* Load limits for loop over neighbors */
347 j_index_start = jindex[iidx];
348 j_index_end = jindex[iidx+1];
350 /* Get outer coordinate index */
352 i_coord_offset = DIM*inr;
354 /* Load i particle coords and add shift vector */
355 ix0 = shX + x[i_coord_offset+DIM*0+XX];
356 iy0 = shY + x[i_coord_offset+DIM*0+YY];
357 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
363 /* Load parameters for i particles */
364 iq0 = facel*charge[inr+0];
365 isai0 = invsqrta[inr+0];
366 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
370 /* Start inner kernel loop */
371 for(jidx=j_index_start; jidx<j_index_end; jidx++)
373 /* Get j neighbor index, and coordinate index */
375 j_coord_offset = DIM*jnr;
377 /* load j atom coordinates */
378 jx0 = x[j_coord_offset+DIM*0+XX];
379 jy0 = x[j_coord_offset+DIM*0+YY];
380 jz0 = x[j_coord_offset+DIM*0+ZZ];
382 /* Calculate displacement vector */
387 /* Calculate squared distance and things based on it */
388 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
390 rinv00 = gmx_invsqrt(rsq00);
392 rinvsq00 = rinv00*rinv00;
394 /* Load parameters for j particles */
396 isaj0 = invsqrta[jnr+0];
397 vdwjidx0 = 3*vdwtype[jnr+0];
399 /**************************
400 * CALCULATE INTERACTIONS *
401 **************************/
406 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
407 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
408 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
410 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
411 isaprod = isai0*isaj0;
412 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
413 gbscale = isaprod*gbtabscale;
416 /* Calculate generalized born table index - this is a separate table from the normal one,
417 * but we use the same procedure by multiplying r with scale and truncating to integer.
426 Geps = gbeps*gbtab[gbitab+2];
427 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
432 FF = Fp+Geps+2.0*Heps2;
433 fgb = gbqqfactor*FF*gbscale;
434 dvdatmp = -0.5*(vgb+fgb*r00);
435 dvdasum = dvdasum + dvdatmp;
436 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
438 felec = (velec*rinv00-fgb)*rinv00;
440 /* BUCKINGHAM DISPERSION/REPULSION */
441 rinvsix = rinvsq00*rinvsq00*rinvsq00;
442 vvdw6 = c6_00*rinvsix;
444 vvdwexp = cexp1_00*exp(-br);
445 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
449 /* Calculate temporary vectorial force */
454 /* Update vectorial force */
458 f[j_coord_offset+DIM*0+XX] -= tx;
459 f[j_coord_offset+DIM*0+YY] -= ty;
460 f[j_coord_offset+DIM*0+ZZ] -= tz;
462 /* Inner loop uses 92 flops */
464 /* End of innermost loop */
467 f[i_coord_offset+DIM*0+XX] += fix0;
468 f[i_coord_offset+DIM*0+YY] += fiy0;
469 f[i_coord_offset+DIM*0+ZZ] += fiz0;
473 fshift[i_shift_offset+XX] += tx;
474 fshift[i_shift_offset+YY] += ty;
475 fshift[i_shift_offset+ZZ] += tz;
477 dvda[nri] = dvda[nri] + dvdasum*isai0*isai0;
479 /* Increment number of inner iterations */
480 inneriter += j_index_end - j_index_start;
482 /* Outer loop uses 13 flops */
485 /* Increment number of outer iterations */
488 /* Update outer/inner flops */
490 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*92);