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_ElecCSTab_VdwBham_GeomW3P1_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: Buckingham
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwBham_GeomW3P1_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
70 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
74 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
82 jindex = nlist->jindex;
84 shiftidx = nlist->shift;
86 shiftvec = fr->shift_vec[0];
87 fshift = fr->fshift[0];
89 charge = mdatoms->chargeA;
92 vdwtype = mdatoms->typeA;
94 vftab = kernel_data->table_elec->data;
95 vftabscale = kernel_data->table_elec->scale;
97 /* Setup water-specific parameters */
99 iq0 = facel*charge[inr+0];
100 iq1 = facel*charge[inr+1];
101 iq2 = facel*charge[inr+2];
102 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
107 /* Start outer loop over neighborlists */
108 for(iidx=0; iidx<nri; iidx++)
110 /* Load shift vector for this list */
111 i_shift_offset = DIM*shiftidx[iidx];
112 shX = shiftvec[i_shift_offset+XX];
113 shY = shiftvec[i_shift_offset+YY];
114 shZ = shiftvec[i_shift_offset+ZZ];
116 /* Load limits for loop over neighbors */
117 j_index_start = jindex[iidx];
118 j_index_end = jindex[iidx+1];
120 /* Get outer coordinate index */
122 i_coord_offset = DIM*inr;
124 /* Load i particle coords and add shift vector */
125 ix0 = shX + x[i_coord_offset+DIM*0+XX];
126 iy0 = shY + x[i_coord_offset+DIM*0+YY];
127 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
128 ix1 = shX + x[i_coord_offset+DIM*1+XX];
129 iy1 = shY + x[i_coord_offset+DIM*1+YY];
130 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
131 ix2 = shX + x[i_coord_offset+DIM*2+XX];
132 iy2 = shY + x[i_coord_offset+DIM*2+YY];
133 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
145 /* Reset potential sums */
149 /* Start inner kernel loop */
150 for(jidx=j_index_start; jidx<j_index_end; jidx++)
152 /* Get j neighbor index, and coordinate index */
154 j_coord_offset = DIM*jnr;
156 /* load j atom coordinates */
157 jx0 = x[j_coord_offset+DIM*0+XX];
158 jy0 = x[j_coord_offset+DIM*0+YY];
159 jz0 = x[j_coord_offset+DIM*0+ZZ];
161 /* Calculate displacement vector */
172 /* Calculate squared distance and things based on it */
173 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
174 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
175 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
177 rinv00 = gmx_invsqrt(rsq00);
178 rinv10 = gmx_invsqrt(rsq10);
179 rinv20 = gmx_invsqrt(rsq20);
181 rinvsq00 = rinv00*rinv00;
183 /* Load parameters for j particles */
185 vdwjidx0 = 3*vdwtype[jnr+0];
187 /**************************
188 * CALCULATE INTERACTIONS *
189 **************************/
194 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
195 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
196 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
198 /* Calculate table index by multiplying r with table scale and truncate to integer */
204 /* CUBIC SPLINE TABLE ELECTROSTATICS */
207 Geps = vfeps*vftab[vfitab+2];
208 Heps2 = vfeps*vfeps*vftab[vfitab+3];
212 FF = Fp+Geps+2.0*Heps2;
213 felec = -qq00*FF*vftabscale*rinv00;
215 /* BUCKINGHAM DISPERSION/REPULSION */
216 rinvsix = rinvsq00*rinvsq00*rinvsq00;
217 vvdw6 = c6_00*rinvsix;
219 vvdwexp = cexp1_00*exp(-br);
220 vvdw = vvdwexp - vvdw6*(1.0/6.0);
221 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
223 /* Update potential sums from outer loop */
229 /* Calculate temporary vectorial force */
234 /* Update vectorial force */
238 f[j_coord_offset+DIM*0+XX] -= tx;
239 f[j_coord_offset+DIM*0+YY] -= ty;
240 f[j_coord_offset+DIM*0+ZZ] -= tz;
242 /**************************
243 * CALCULATE INTERACTIONS *
244 **************************/
250 /* Calculate table index by multiplying r with table scale and truncate to integer */
256 /* CUBIC SPLINE TABLE ELECTROSTATICS */
259 Geps = vfeps*vftab[vfitab+2];
260 Heps2 = vfeps*vfeps*vftab[vfitab+3];
264 FF = Fp+Geps+2.0*Heps2;
265 felec = -qq10*FF*vftabscale*rinv10;
267 /* Update potential sums from outer loop */
272 /* Calculate temporary vectorial force */
277 /* Update vectorial force */
281 f[j_coord_offset+DIM*0+XX] -= tx;
282 f[j_coord_offset+DIM*0+YY] -= ty;
283 f[j_coord_offset+DIM*0+ZZ] -= tz;
285 /**************************
286 * CALCULATE INTERACTIONS *
287 **************************/
293 /* Calculate table index by multiplying r with table scale and truncate to integer */
299 /* CUBIC SPLINE TABLE ELECTROSTATICS */
302 Geps = vfeps*vftab[vfitab+2];
303 Heps2 = vfeps*vfeps*vftab[vfitab+3];
307 FF = Fp+Geps+2.0*Heps2;
308 felec = -qq20*FF*vftabscale*rinv20;
310 /* Update potential sums from outer loop */
315 /* Calculate temporary vectorial force */
320 /* Update vectorial force */
324 f[j_coord_offset+DIM*0+XX] -= tx;
325 f[j_coord_offset+DIM*0+YY] -= ty;
326 f[j_coord_offset+DIM*0+ZZ] -= tz;
328 /* Inner loop uses 165 flops */
330 /* End of innermost loop */
333 f[i_coord_offset+DIM*0+XX] += fix0;
334 f[i_coord_offset+DIM*0+YY] += fiy0;
335 f[i_coord_offset+DIM*0+ZZ] += fiz0;
339 f[i_coord_offset+DIM*1+XX] += fix1;
340 f[i_coord_offset+DIM*1+YY] += fiy1;
341 f[i_coord_offset+DIM*1+ZZ] += fiz1;
345 f[i_coord_offset+DIM*2+XX] += fix2;
346 f[i_coord_offset+DIM*2+YY] += fiy2;
347 f[i_coord_offset+DIM*2+ZZ] += fiz2;
351 fshift[i_shift_offset+XX] += tx;
352 fshift[i_shift_offset+YY] += ty;
353 fshift[i_shift_offset+ZZ] += tz;
356 /* Update potential energies */
357 kernel_data->energygrp_elec[ggid] += velecsum;
358 kernel_data->energygrp_vdw[ggid] += vvdwsum;
360 /* Increment number of inner iterations */
361 inneriter += j_index_end - j_index_start;
363 /* Outer loop uses 32 flops */
366 /* Increment number of outer iterations */
369 /* Update outer/inner flops */
371 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*165);
374 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3P1_F_c
375 * Electrostatics interaction: CubicSplineTable
376 * VdW interaction: Buckingham
377 * Geometry: Water3-Particle
378 * Calculate force/pot: Force
381 nb_kernel_ElecCSTab_VdwBham_GeomW3P1_F_c
382 (t_nblist * gmx_restrict nlist,
383 rvec * gmx_restrict xx,
384 rvec * gmx_restrict ff,
385 t_forcerec * gmx_restrict fr,
386 t_mdatoms * gmx_restrict mdatoms,
387 nb_kernel_data_t * gmx_restrict kernel_data,
388 t_nrnb * gmx_restrict nrnb)
390 int i_shift_offset,i_coord_offset,j_coord_offset;
391 int j_index_start,j_index_end;
392 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
393 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
394 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
395 real *shiftvec,*fshift,*x,*f;
397 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
399 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
401 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
403 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
404 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
405 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
406 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
407 real velec,felec,velecsum,facel,crf,krf,krf2;
410 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
414 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
422 jindex = nlist->jindex;
424 shiftidx = nlist->shift;
426 shiftvec = fr->shift_vec[0];
427 fshift = fr->fshift[0];
429 charge = mdatoms->chargeA;
430 nvdwtype = fr->ntype;
432 vdwtype = mdatoms->typeA;
434 vftab = kernel_data->table_elec->data;
435 vftabscale = kernel_data->table_elec->scale;
437 /* Setup water-specific parameters */
438 inr = nlist->iinr[0];
439 iq0 = facel*charge[inr+0];
440 iq1 = facel*charge[inr+1];
441 iq2 = facel*charge[inr+2];
442 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
447 /* Start outer loop over neighborlists */
448 for(iidx=0; iidx<nri; iidx++)
450 /* Load shift vector for this list */
451 i_shift_offset = DIM*shiftidx[iidx];
452 shX = shiftvec[i_shift_offset+XX];
453 shY = shiftvec[i_shift_offset+YY];
454 shZ = shiftvec[i_shift_offset+ZZ];
456 /* Load limits for loop over neighbors */
457 j_index_start = jindex[iidx];
458 j_index_end = jindex[iidx+1];
460 /* Get outer coordinate index */
462 i_coord_offset = DIM*inr;
464 /* Load i particle coords and add shift vector */
465 ix0 = shX + x[i_coord_offset+DIM*0+XX];
466 iy0 = shY + x[i_coord_offset+DIM*0+YY];
467 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
468 ix1 = shX + x[i_coord_offset+DIM*1+XX];
469 iy1 = shY + x[i_coord_offset+DIM*1+YY];
470 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
471 ix2 = shX + x[i_coord_offset+DIM*2+XX];
472 iy2 = shY + x[i_coord_offset+DIM*2+YY];
473 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
485 /* Start inner kernel loop */
486 for(jidx=j_index_start; jidx<j_index_end; jidx++)
488 /* Get j neighbor index, and coordinate index */
490 j_coord_offset = DIM*jnr;
492 /* load j atom coordinates */
493 jx0 = x[j_coord_offset+DIM*0+XX];
494 jy0 = x[j_coord_offset+DIM*0+YY];
495 jz0 = x[j_coord_offset+DIM*0+ZZ];
497 /* Calculate displacement vector */
508 /* Calculate squared distance and things based on it */
509 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
510 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
511 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
513 rinv00 = gmx_invsqrt(rsq00);
514 rinv10 = gmx_invsqrt(rsq10);
515 rinv20 = gmx_invsqrt(rsq20);
517 rinvsq00 = rinv00*rinv00;
519 /* Load parameters for j particles */
521 vdwjidx0 = 3*vdwtype[jnr+0];
523 /**************************
524 * CALCULATE INTERACTIONS *
525 **************************/
530 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
531 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
532 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
534 /* Calculate table index by multiplying r with table scale and truncate to integer */
540 /* CUBIC SPLINE TABLE ELECTROSTATICS */
542 Geps = vfeps*vftab[vfitab+2];
543 Heps2 = vfeps*vfeps*vftab[vfitab+3];
545 FF = Fp+Geps+2.0*Heps2;
546 felec = -qq00*FF*vftabscale*rinv00;
548 /* BUCKINGHAM DISPERSION/REPULSION */
549 rinvsix = rinvsq00*rinvsq00*rinvsq00;
550 vvdw6 = c6_00*rinvsix;
552 vvdwexp = cexp1_00*exp(-br);
553 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
557 /* Calculate temporary vectorial force */
562 /* Update vectorial force */
566 f[j_coord_offset+DIM*0+XX] -= tx;
567 f[j_coord_offset+DIM*0+YY] -= ty;
568 f[j_coord_offset+DIM*0+ZZ] -= tz;
570 /**************************
571 * CALCULATE INTERACTIONS *
572 **************************/
578 /* Calculate table index by multiplying r with table scale and truncate to integer */
584 /* CUBIC SPLINE TABLE ELECTROSTATICS */
586 Geps = vfeps*vftab[vfitab+2];
587 Heps2 = vfeps*vfeps*vftab[vfitab+3];
589 FF = Fp+Geps+2.0*Heps2;
590 felec = -qq10*FF*vftabscale*rinv10;
594 /* Calculate temporary vectorial force */
599 /* Update vectorial force */
603 f[j_coord_offset+DIM*0+XX] -= tx;
604 f[j_coord_offset+DIM*0+YY] -= ty;
605 f[j_coord_offset+DIM*0+ZZ] -= tz;
607 /**************************
608 * CALCULATE INTERACTIONS *
609 **************************/
615 /* Calculate table index by multiplying r with table scale and truncate to integer */
621 /* CUBIC SPLINE TABLE ELECTROSTATICS */
623 Geps = vfeps*vftab[vfitab+2];
624 Heps2 = vfeps*vfeps*vftab[vfitab+3];
626 FF = Fp+Geps+2.0*Heps2;
627 felec = -qq20*FF*vftabscale*rinv20;
631 /* Calculate temporary vectorial force */
636 /* Update vectorial force */
640 f[j_coord_offset+DIM*0+XX] -= tx;
641 f[j_coord_offset+DIM*0+YY] -= ty;
642 f[j_coord_offset+DIM*0+ZZ] -= tz;
644 /* Inner loop uses 150 flops */
646 /* End of innermost loop */
649 f[i_coord_offset+DIM*0+XX] += fix0;
650 f[i_coord_offset+DIM*0+YY] += fiy0;
651 f[i_coord_offset+DIM*0+ZZ] += fiz0;
655 f[i_coord_offset+DIM*1+XX] += fix1;
656 f[i_coord_offset+DIM*1+YY] += fiy1;
657 f[i_coord_offset+DIM*1+ZZ] += fiz1;
661 f[i_coord_offset+DIM*2+XX] += fix2;
662 f[i_coord_offset+DIM*2+YY] += fiy2;
663 f[i_coord_offset+DIM*2+ZZ] += fiz2;
667 fshift[i_shift_offset+XX] += tx;
668 fshift[i_shift_offset+YY] += ty;
669 fshift[i_shift_offset+ZZ] += tz;
671 /* Increment number of inner iterations */
672 inneriter += j_index_end - j_index_start;
674 /* Outer loop uses 30 flops */
677 /* Increment number of outer iterations */
680 /* Update outer/inner flops */
682 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*150);