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 */
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 dvdatmp = -0.5*(vgb+fgb*r00);
201 dvdasum = dvdasum + dvdatmp;
202 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
204 felec = (velec*rinv00-fgb)*rinv00;
206 /* LENNARD-JONES DISPERSION/REPULSION */
208 rinvsix = rinvsq00*rinvsq00*rinvsq00;
209 vvdw6 = c6_00*rinvsix;
210 vvdw12 = c12_00*rinvsix*rinvsix;
211 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
212 fvdw = (vvdw12-vvdw6)*rinvsq00;
214 /* Update potential sums from outer loop */
221 /* Calculate temporary vectorial force */
226 /* Update vectorial force */
230 f[j_coord_offset+DIM*0+XX] -= tx;
231 f[j_coord_offset+DIM*0+YY] -= ty;
232 f[j_coord_offset+DIM*0+ZZ] -= tz;
234 /* Inner loop uses 71 flops */
236 /* End of innermost loop */
239 f[i_coord_offset+DIM*0+XX] += fix0;
240 f[i_coord_offset+DIM*0+YY] += fiy0;
241 f[i_coord_offset+DIM*0+ZZ] += fiz0;
245 fshift[i_shift_offset+XX] += tx;
246 fshift[i_shift_offset+YY] += ty;
247 fshift[i_shift_offset+ZZ] += tz;
250 /* Update potential energies */
251 kernel_data->energygrp_elec[ggid] += velecsum;
252 kernel_data->energygrp_polarization[ggid] += vgbsum;
253 kernel_data->energygrp_vdw[ggid] += vvdwsum;
254 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
256 /* Increment number of inner iterations */
257 inneriter += j_index_end - j_index_start;
259 /* Outer loop uses 16 flops */
262 /* Increment number of outer iterations */
265 /* Update outer/inner flops */
267 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*16 + inneriter*71);
270 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_c
271 * Electrostatics interaction: GeneralizedBorn
272 * VdW interaction: LennardJones
273 * Geometry: Particle-Particle
274 * Calculate force/pot: Force
277 nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_c
278 (t_nblist * gmx_restrict nlist,
279 rvec * gmx_restrict xx,
280 rvec * gmx_restrict ff,
281 t_forcerec * gmx_restrict fr,
282 t_mdatoms * gmx_restrict mdatoms,
283 nb_kernel_data_t * gmx_restrict kernel_data,
284 t_nrnb * gmx_restrict nrnb)
286 int i_shift_offset,i_coord_offset,j_coord_offset;
287 int j_index_start,j_index_end;
288 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
289 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
290 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
291 real *shiftvec,*fshift,*x,*f;
293 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
295 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
296 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
297 real velec,felec,velecsum,facel,crf,krf,krf2;
300 real vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,dvdatmp;
301 real *invsqrta,*dvda,*gbtab;
303 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
307 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
315 jindex = nlist->jindex;
317 shiftidx = nlist->shift;
319 shiftvec = fr->shift_vec[0];
320 fshift = fr->fshift[0];
322 charge = mdatoms->chargeA;
323 nvdwtype = fr->ntype;
325 vdwtype = mdatoms->typeA;
327 invsqrta = fr->invsqrta;
329 gbtabscale = fr->gbtab.scale;
330 gbtab = fr->gbtab.data;
331 gbinvepsdiff = (1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent);
336 /* Start outer loop over neighborlists */
337 for(iidx=0; iidx<nri; iidx++)
339 /* Load shift vector for this list */
340 i_shift_offset = DIM*shiftidx[iidx];
341 shX = shiftvec[i_shift_offset+XX];
342 shY = shiftvec[i_shift_offset+YY];
343 shZ = shiftvec[i_shift_offset+ZZ];
345 /* Load limits for loop over neighbors */
346 j_index_start = jindex[iidx];
347 j_index_end = jindex[iidx+1];
349 /* Get outer coordinate index */
351 i_coord_offset = DIM*inr;
353 /* Load i particle coords and add shift vector */
354 ix0 = shX + x[i_coord_offset+DIM*0+XX];
355 iy0 = shY + x[i_coord_offset+DIM*0+YY];
356 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
362 /* Load parameters for i particles */
363 iq0 = facel*charge[inr+0];
364 isai0 = invsqrta[inr+0];
365 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
369 /* Start inner kernel loop */
370 for(jidx=j_index_start; jidx<j_index_end; jidx++)
372 /* Get j neighbor index, and coordinate index */
374 j_coord_offset = DIM*jnr;
376 /* load j atom coordinates */
377 jx0 = x[j_coord_offset+DIM*0+XX];
378 jy0 = x[j_coord_offset+DIM*0+YY];
379 jz0 = x[j_coord_offset+DIM*0+ZZ];
381 /* Calculate displacement vector */
386 /* Calculate squared distance and things based on it */
387 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
389 rinv00 = gmx_invsqrt(rsq00);
391 rinvsq00 = rinv00*rinv00;
393 /* Load parameters for j particles */
395 isaj0 = invsqrta[jnr+0];
396 vdwjidx0 = 2*vdwtype[jnr+0];
398 /**************************
399 * CALCULATE INTERACTIONS *
400 **************************/
405 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
406 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
408 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
409 isaprod = isai0*isaj0;
410 gbqqfactor = isaprod*(-qq00)*gbinvepsdiff;
411 gbscale = isaprod*gbtabscale;
414 /* Calculate generalized born table index - this is a separate table from the normal one,
415 * but we use the same procedure by multiplying r with scale and truncating to integer.
424 Geps = gbeps*gbtab[gbitab+2];
425 Heps2 = gbeps*gbeps*gbtab[gbitab+3];
430 FF = Fp+Geps+2.0*Heps2;
431 fgb = gbqqfactor*FF*gbscale;
432 dvdatmp = -0.5*(vgb+fgb*r00);
433 dvdasum = dvdasum + dvdatmp;
434 dvda[jnr] = dvdaj+dvdatmp*isaj0*isaj0;
436 felec = (velec*rinv00-fgb)*rinv00;
438 /* LENNARD-JONES DISPERSION/REPULSION */
440 rinvsix = rinvsq00*rinvsq00*rinvsq00;
441 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
445 /* Calculate temporary vectorial force */
450 /* Update vectorial force */
454 f[j_coord_offset+DIM*0+XX] -= tx;
455 f[j_coord_offset+DIM*0+YY] -= ty;
456 f[j_coord_offset+DIM*0+ZZ] -= tz;
458 /* Inner loop uses 64 flops */
460 /* End of innermost loop */
463 f[i_coord_offset+DIM*0+XX] += fix0;
464 f[i_coord_offset+DIM*0+YY] += fiy0;
465 f[i_coord_offset+DIM*0+ZZ] += fiz0;
469 fshift[i_shift_offset+XX] += tx;
470 fshift[i_shift_offset+YY] += ty;
471 fshift[i_shift_offset+ZZ] += tz;
473 dvda[inr] = dvda[inr] + dvdasum*isai0*isai0;
475 /* Increment number of inner iterations */
476 inneriter += j_index_end - j_index_start;
478 /* Outer loop uses 13 flops */
481 /* Increment number of outer iterations */
484 /* Update outer/inner flops */
486 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*64);