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_GeomW3W3_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: Buckingham
37 * Geometry: Water3-Water3
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwBham_GeomW3W3_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;
65 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
67 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
68 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
69 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
70 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
71 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
72 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
73 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
74 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
75 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
76 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
77 real velec,felec,velecsum,facel,crf,krf,krf2;
80 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
84 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
92 jindex = nlist->jindex;
94 shiftidx = nlist->shift;
96 shiftvec = fr->shift_vec[0];
97 fshift = fr->fshift[0];
99 charge = mdatoms->chargeA;
100 nvdwtype = fr->ntype;
102 vdwtype = mdatoms->typeA;
104 vftab = kernel_data->table_elec->data;
105 vftabscale = kernel_data->table_elec->scale;
107 /* Setup water-specific parameters */
108 inr = nlist->iinr[0];
109 iq0 = facel*charge[inr+0];
110 iq1 = facel*charge[inr+1];
111 iq2 = facel*charge[inr+2];
112 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
117 vdwjidx0 = 3*vdwtype[inr+0];
119 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
120 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
121 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
134 /* Start outer loop over neighborlists */
135 for(iidx=0; iidx<nri; iidx++)
137 /* Load shift vector for this list */
138 i_shift_offset = DIM*shiftidx[iidx];
139 shX = shiftvec[i_shift_offset+XX];
140 shY = shiftvec[i_shift_offset+YY];
141 shZ = shiftvec[i_shift_offset+ZZ];
143 /* Load limits for loop over neighbors */
144 j_index_start = jindex[iidx];
145 j_index_end = jindex[iidx+1];
147 /* Get outer coordinate index */
149 i_coord_offset = DIM*inr;
151 /* Load i particle coords and add shift vector */
152 ix0 = shX + x[i_coord_offset+DIM*0+XX];
153 iy0 = shY + x[i_coord_offset+DIM*0+YY];
154 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
155 ix1 = shX + x[i_coord_offset+DIM*1+XX];
156 iy1 = shY + x[i_coord_offset+DIM*1+YY];
157 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
158 ix2 = shX + x[i_coord_offset+DIM*2+XX];
159 iy2 = shY + x[i_coord_offset+DIM*2+YY];
160 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
172 /* Reset potential sums */
176 /* Start inner kernel loop */
177 for(jidx=j_index_start; jidx<j_index_end; jidx++)
179 /* Get j neighbor index, and coordinate index */
181 j_coord_offset = DIM*jnr;
183 /* load j atom coordinates */
184 jx0 = x[j_coord_offset+DIM*0+XX];
185 jy0 = x[j_coord_offset+DIM*0+YY];
186 jz0 = x[j_coord_offset+DIM*0+ZZ];
187 jx1 = x[j_coord_offset+DIM*1+XX];
188 jy1 = x[j_coord_offset+DIM*1+YY];
189 jz1 = x[j_coord_offset+DIM*1+ZZ];
190 jx2 = x[j_coord_offset+DIM*2+XX];
191 jy2 = x[j_coord_offset+DIM*2+YY];
192 jz2 = x[j_coord_offset+DIM*2+ZZ];
194 /* Calculate displacement vector */
223 /* Calculate squared distance and things based on it */
224 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
225 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
226 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
227 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
228 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
229 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
230 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
231 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
232 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
234 rinv00 = gmx_invsqrt(rsq00);
235 rinv01 = gmx_invsqrt(rsq01);
236 rinv02 = gmx_invsqrt(rsq02);
237 rinv10 = gmx_invsqrt(rsq10);
238 rinv11 = gmx_invsqrt(rsq11);
239 rinv12 = gmx_invsqrt(rsq12);
240 rinv20 = gmx_invsqrt(rsq20);
241 rinv21 = gmx_invsqrt(rsq21);
242 rinv22 = gmx_invsqrt(rsq22);
244 rinvsq00 = rinv00*rinv00;
246 /**************************
247 * CALCULATE INTERACTIONS *
248 **************************/
252 /* Calculate table index by multiplying r with table scale and truncate to integer */
258 /* CUBIC SPLINE TABLE ELECTROSTATICS */
261 Geps = vfeps*vftab[vfitab+2];
262 Heps2 = vfeps*vfeps*vftab[vfitab+3];
266 FF = Fp+Geps+2.0*Heps2;
267 felec = -qq00*FF*vftabscale*rinv00;
269 /* BUCKINGHAM DISPERSION/REPULSION */
270 rinvsix = rinvsq00*rinvsq00*rinvsq00;
271 vvdw6 = c6_00*rinvsix;
273 vvdwexp = cexp1_00*exp(-br);
274 vvdw = vvdwexp - vvdw6*(1.0/6.0);
275 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
277 /* Update potential sums from outer loop */
283 /* Calculate temporary vectorial force */
288 /* Update vectorial force */
292 f[j_coord_offset+DIM*0+XX] -= tx;
293 f[j_coord_offset+DIM*0+YY] -= ty;
294 f[j_coord_offset+DIM*0+ZZ] -= tz;
296 /**************************
297 * CALCULATE INTERACTIONS *
298 **************************/
302 /* Calculate table index by multiplying r with table scale and truncate to integer */
308 /* CUBIC SPLINE TABLE ELECTROSTATICS */
311 Geps = vfeps*vftab[vfitab+2];
312 Heps2 = vfeps*vfeps*vftab[vfitab+3];
316 FF = Fp+Geps+2.0*Heps2;
317 felec = -qq01*FF*vftabscale*rinv01;
319 /* Update potential sums from outer loop */
324 /* Calculate temporary vectorial force */
329 /* Update vectorial force */
333 f[j_coord_offset+DIM*1+XX] -= tx;
334 f[j_coord_offset+DIM*1+YY] -= ty;
335 f[j_coord_offset+DIM*1+ZZ] -= tz;
337 /**************************
338 * CALCULATE INTERACTIONS *
339 **************************/
343 /* Calculate table index by multiplying r with table scale and truncate to integer */
349 /* CUBIC SPLINE TABLE ELECTROSTATICS */
352 Geps = vfeps*vftab[vfitab+2];
353 Heps2 = vfeps*vfeps*vftab[vfitab+3];
357 FF = Fp+Geps+2.0*Heps2;
358 felec = -qq02*FF*vftabscale*rinv02;
360 /* Update potential sums from outer loop */
365 /* Calculate temporary vectorial force */
370 /* Update vectorial force */
374 f[j_coord_offset+DIM*2+XX] -= tx;
375 f[j_coord_offset+DIM*2+YY] -= ty;
376 f[j_coord_offset+DIM*2+ZZ] -= tz;
378 /**************************
379 * CALCULATE INTERACTIONS *
380 **************************/
384 /* Calculate table index by multiplying r with table scale and truncate to integer */
390 /* CUBIC SPLINE TABLE ELECTROSTATICS */
393 Geps = vfeps*vftab[vfitab+2];
394 Heps2 = vfeps*vfeps*vftab[vfitab+3];
398 FF = Fp+Geps+2.0*Heps2;
399 felec = -qq10*FF*vftabscale*rinv10;
401 /* Update potential sums from outer loop */
406 /* Calculate temporary vectorial force */
411 /* Update vectorial force */
415 f[j_coord_offset+DIM*0+XX] -= tx;
416 f[j_coord_offset+DIM*0+YY] -= ty;
417 f[j_coord_offset+DIM*0+ZZ] -= tz;
419 /**************************
420 * CALCULATE INTERACTIONS *
421 **************************/
425 /* Calculate table index by multiplying r with table scale and truncate to integer */
431 /* CUBIC SPLINE TABLE ELECTROSTATICS */
434 Geps = vfeps*vftab[vfitab+2];
435 Heps2 = vfeps*vfeps*vftab[vfitab+3];
439 FF = Fp+Geps+2.0*Heps2;
440 felec = -qq11*FF*vftabscale*rinv11;
442 /* Update potential sums from outer loop */
447 /* Calculate temporary vectorial force */
452 /* Update vectorial force */
456 f[j_coord_offset+DIM*1+XX] -= tx;
457 f[j_coord_offset+DIM*1+YY] -= ty;
458 f[j_coord_offset+DIM*1+ZZ] -= tz;
460 /**************************
461 * CALCULATE INTERACTIONS *
462 **************************/
466 /* Calculate table index by multiplying r with table scale and truncate to integer */
472 /* CUBIC SPLINE TABLE ELECTROSTATICS */
475 Geps = vfeps*vftab[vfitab+2];
476 Heps2 = vfeps*vfeps*vftab[vfitab+3];
480 FF = Fp+Geps+2.0*Heps2;
481 felec = -qq12*FF*vftabscale*rinv12;
483 /* Update potential sums from outer loop */
488 /* Calculate temporary vectorial force */
493 /* Update vectorial force */
497 f[j_coord_offset+DIM*2+XX] -= tx;
498 f[j_coord_offset+DIM*2+YY] -= ty;
499 f[j_coord_offset+DIM*2+ZZ] -= tz;
501 /**************************
502 * CALCULATE INTERACTIONS *
503 **************************/
507 /* Calculate table index by multiplying r with table scale and truncate to integer */
513 /* CUBIC SPLINE TABLE ELECTROSTATICS */
516 Geps = vfeps*vftab[vfitab+2];
517 Heps2 = vfeps*vfeps*vftab[vfitab+3];
521 FF = Fp+Geps+2.0*Heps2;
522 felec = -qq20*FF*vftabscale*rinv20;
524 /* Update potential sums from outer loop */
529 /* Calculate temporary vectorial force */
534 /* Update vectorial force */
538 f[j_coord_offset+DIM*0+XX] -= tx;
539 f[j_coord_offset+DIM*0+YY] -= ty;
540 f[j_coord_offset+DIM*0+ZZ] -= tz;
542 /**************************
543 * CALCULATE INTERACTIONS *
544 **************************/
548 /* Calculate table index by multiplying r with table scale and truncate to integer */
554 /* CUBIC SPLINE TABLE ELECTROSTATICS */
557 Geps = vfeps*vftab[vfitab+2];
558 Heps2 = vfeps*vfeps*vftab[vfitab+3];
562 FF = Fp+Geps+2.0*Heps2;
563 felec = -qq21*FF*vftabscale*rinv21;
565 /* Update potential sums from outer loop */
570 /* Calculate temporary vectorial force */
575 /* Update vectorial force */
579 f[j_coord_offset+DIM*1+XX] -= tx;
580 f[j_coord_offset+DIM*1+YY] -= ty;
581 f[j_coord_offset+DIM*1+ZZ] -= tz;
583 /**************************
584 * CALCULATE INTERACTIONS *
585 **************************/
589 /* Calculate table index by multiplying r with table scale and truncate to integer */
595 /* CUBIC SPLINE TABLE ELECTROSTATICS */
598 Geps = vfeps*vftab[vfitab+2];
599 Heps2 = vfeps*vfeps*vftab[vfitab+3];
603 FF = Fp+Geps+2.0*Heps2;
604 felec = -qq22*FF*vftabscale*rinv22;
606 /* Update potential sums from outer loop */
611 /* Calculate temporary vectorial force */
616 /* Update vectorial force */
620 f[j_coord_offset+DIM*2+XX] -= tx;
621 f[j_coord_offset+DIM*2+YY] -= ty;
622 f[j_coord_offset+DIM*2+ZZ] -= tz;
624 /* Inner loop uses 408 flops */
626 /* End of innermost loop */
629 f[i_coord_offset+DIM*0+XX] += fix0;
630 f[i_coord_offset+DIM*0+YY] += fiy0;
631 f[i_coord_offset+DIM*0+ZZ] += fiz0;
635 f[i_coord_offset+DIM*1+XX] += fix1;
636 f[i_coord_offset+DIM*1+YY] += fiy1;
637 f[i_coord_offset+DIM*1+ZZ] += fiz1;
641 f[i_coord_offset+DIM*2+XX] += fix2;
642 f[i_coord_offset+DIM*2+YY] += fiy2;
643 f[i_coord_offset+DIM*2+ZZ] += fiz2;
647 fshift[i_shift_offset+XX] += tx;
648 fshift[i_shift_offset+YY] += ty;
649 fshift[i_shift_offset+ZZ] += tz;
652 /* Update potential energies */
653 kernel_data->energygrp_elec[ggid] += velecsum;
654 kernel_data->energygrp_vdw[ggid] += vvdwsum;
656 /* Increment number of inner iterations */
657 inneriter += j_index_end - j_index_start;
659 /* Outer loop uses 32 flops */
662 /* Increment number of outer iterations */
665 /* Update outer/inner flops */
667 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*408);
670 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3W3_F_c
671 * Electrostatics interaction: CubicSplineTable
672 * VdW interaction: Buckingham
673 * Geometry: Water3-Water3
674 * Calculate force/pot: Force
677 nb_kernel_ElecCSTab_VdwBham_GeomW3W3_F_c
678 (t_nblist * gmx_restrict nlist,
679 rvec * gmx_restrict xx,
680 rvec * gmx_restrict ff,
681 t_forcerec * gmx_restrict fr,
682 t_mdatoms * gmx_restrict mdatoms,
683 nb_kernel_data_t * gmx_restrict kernel_data,
684 t_nrnb * gmx_restrict nrnb)
686 int i_shift_offset,i_coord_offset,j_coord_offset;
687 int j_index_start,j_index_end;
688 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
689 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
690 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
691 real *shiftvec,*fshift,*x,*f;
693 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
695 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
697 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
699 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
701 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
703 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
704 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
705 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
706 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
707 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
708 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
709 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
710 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
711 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
712 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
713 real velec,felec,velecsum,facel,crf,krf,krf2;
716 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
720 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
728 jindex = nlist->jindex;
730 shiftidx = nlist->shift;
732 shiftvec = fr->shift_vec[0];
733 fshift = fr->fshift[0];
735 charge = mdatoms->chargeA;
736 nvdwtype = fr->ntype;
738 vdwtype = mdatoms->typeA;
740 vftab = kernel_data->table_elec->data;
741 vftabscale = kernel_data->table_elec->scale;
743 /* Setup water-specific parameters */
744 inr = nlist->iinr[0];
745 iq0 = facel*charge[inr+0];
746 iq1 = facel*charge[inr+1];
747 iq2 = facel*charge[inr+2];
748 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
753 vdwjidx0 = 3*vdwtype[inr+0];
755 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
756 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
757 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
770 /* Start outer loop over neighborlists */
771 for(iidx=0; iidx<nri; iidx++)
773 /* Load shift vector for this list */
774 i_shift_offset = DIM*shiftidx[iidx];
775 shX = shiftvec[i_shift_offset+XX];
776 shY = shiftvec[i_shift_offset+YY];
777 shZ = shiftvec[i_shift_offset+ZZ];
779 /* Load limits for loop over neighbors */
780 j_index_start = jindex[iidx];
781 j_index_end = jindex[iidx+1];
783 /* Get outer coordinate index */
785 i_coord_offset = DIM*inr;
787 /* Load i particle coords and add shift vector */
788 ix0 = shX + x[i_coord_offset+DIM*0+XX];
789 iy0 = shY + x[i_coord_offset+DIM*0+YY];
790 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
791 ix1 = shX + x[i_coord_offset+DIM*1+XX];
792 iy1 = shY + x[i_coord_offset+DIM*1+YY];
793 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
794 ix2 = shX + x[i_coord_offset+DIM*2+XX];
795 iy2 = shY + x[i_coord_offset+DIM*2+YY];
796 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
808 /* Start inner kernel loop */
809 for(jidx=j_index_start; jidx<j_index_end; jidx++)
811 /* Get j neighbor index, and coordinate index */
813 j_coord_offset = DIM*jnr;
815 /* load j atom coordinates */
816 jx0 = x[j_coord_offset+DIM*0+XX];
817 jy0 = x[j_coord_offset+DIM*0+YY];
818 jz0 = x[j_coord_offset+DIM*0+ZZ];
819 jx1 = x[j_coord_offset+DIM*1+XX];
820 jy1 = x[j_coord_offset+DIM*1+YY];
821 jz1 = x[j_coord_offset+DIM*1+ZZ];
822 jx2 = x[j_coord_offset+DIM*2+XX];
823 jy2 = x[j_coord_offset+DIM*2+YY];
824 jz2 = x[j_coord_offset+DIM*2+ZZ];
826 /* Calculate displacement vector */
855 /* Calculate squared distance and things based on it */
856 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
857 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
858 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
859 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
860 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
861 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
862 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
863 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
864 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
866 rinv00 = gmx_invsqrt(rsq00);
867 rinv01 = gmx_invsqrt(rsq01);
868 rinv02 = gmx_invsqrt(rsq02);
869 rinv10 = gmx_invsqrt(rsq10);
870 rinv11 = gmx_invsqrt(rsq11);
871 rinv12 = gmx_invsqrt(rsq12);
872 rinv20 = gmx_invsqrt(rsq20);
873 rinv21 = gmx_invsqrt(rsq21);
874 rinv22 = gmx_invsqrt(rsq22);
876 rinvsq00 = rinv00*rinv00;
878 /**************************
879 * CALCULATE INTERACTIONS *
880 **************************/
884 /* Calculate table index by multiplying r with table scale and truncate to integer */
890 /* CUBIC SPLINE TABLE ELECTROSTATICS */
893 Geps = vfeps*vftab[vfitab+2];
894 Heps2 = vfeps*vfeps*vftab[vfitab+3];
896 FF = Fp+Geps+2.0*Heps2;
897 felec = -qq00*FF*vftabscale*rinv00;
899 /* BUCKINGHAM DISPERSION/REPULSION */
900 rinvsix = rinvsq00*rinvsq00*rinvsq00;
901 vvdw6 = c6_00*rinvsix;
903 vvdwexp = cexp1_00*exp(-br);
904 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
908 /* Calculate temporary vectorial force */
913 /* Update vectorial force */
917 f[j_coord_offset+DIM*0+XX] -= tx;
918 f[j_coord_offset+DIM*0+YY] -= ty;
919 f[j_coord_offset+DIM*0+ZZ] -= tz;
921 /**************************
922 * CALCULATE INTERACTIONS *
923 **************************/
927 /* Calculate table index by multiplying r with table scale and truncate to integer */
933 /* CUBIC SPLINE TABLE ELECTROSTATICS */
936 Geps = vfeps*vftab[vfitab+2];
937 Heps2 = vfeps*vfeps*vftab[vfitab+3];
939 FF = Fp+Geps+2.0*Heps2;
940 felec = -qq01*FF*vftabscale*rinv01;
944 /* Calculate temporary vectorial force */
949 /* Update vectorial force */
953 f[j_coord_offset+DIM*1+XX] -= tx;
954 f[j_coord_offset+DIM*1+YY] -= ty;
955 f[j_coord_offset+DIM*1+ZZ] -= tz;
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
963 /* Calculate table index by multiplying r with table scale and truncate to integer */
969 /* CUBIC SPLINE TABLE ELECTROSTATICS */
972 Geps = vfeps*vftab[vfitab+2];
973 Heps2 = vfeps*vfeps*vftab[vfitab+3];
975 FF = Fp+Geps+2.0*Heps2;
976 felec = -qq02*FF*vftabscale*rinv02;
980 /* Calculate temporary vectorial force */
985 /* Update vectorial force */
989 f[j_coord_offset+DIM*2+XX] -= tx;
990 f[j_coord_offset+DIM*2+YY] -= ty;
991 f[j_coord_offset+DIM*2+ZZ] -= tz;
993 /**************************
994 * CALCULATE INTERACTIONS *
995 **************************/
999 /* Calculate table index by multiplying r with table scale and truncate to integer */
1000 rt = r10*vftabscale;
1003 vfitab = 1*4*vfitab;
1005 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1007 F = vftab[vfitab+1];
1008 Geps = vfeps*vftab[vfitab+2];
1009 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1011 FF = Fp+Geps+2.0*Heps2;
1012 felec = -qq10*FF*vftabscale*rinv10;
1016 /* Calculate temporary vectorial force */
1021 /* Update vectorial force */
1025 f[j_coord_offset+DIM*0+XX] -= tx;
1026 f[j_coord_offset+DIM*0+YY] -= ty;
1027 f[j_coord_offset+DIM*0+ZZ] -= tz;
1029 /**************************
1030 * CALCULATE INTERACTIONS *
1031 **************************/
1035 /* Calculate table index by multiplying r with table scale and truncate to integer */
1036 rt = r11*vftabscale;
1039 vfitab = 1*4*vfitab;
1041 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1043 F = vftab[vfitab+1];
1044 Geps = vfeps*vftab[vfitab+2];
1045 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1047 FF = Fp+Geps+2.0*Heps2;
1048 felec = -qq11*FF*vftabscale*rinv11;
1052 /* Calculate temporary vectorial force */
1057 /* Update vectorial force */
1061 f[j_coord_offset+DIM*1+XX] -= tx;
1062 f[j_coord_offset+DIM*1+YY] -= ty;
1063 f[j_coord_offset+DIM*1+ZZ] -= tz;
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1071 /* Calculate table index by multiplying r with table scale and truncate to integer */
1072 rt = r12*vftabscale;
1075 vfitab = 1*4*vfitab;
1077 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1079 F = vftab[vfitab+1];
1080 Geps = vfeps*vftab[vfitab+2];
1081 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1083 FF = Fp+Geps+2.0*Heps2;
1084 felec = -qq12*FF*vftabscale*rinv12;
1088 /* Calculate temporary vectorial force */
1093 /* Update vectorial force */
1097 f[j_coord_offset+DIM*2+XX] -= tx;
1098 f[j_coord_offset+DIM*2+YY] -= ty;
1099 f[j_coord_offset+DIM*2+ZZ] -= tz;
1101 /**************************
1102 * CALCULATE INTERACTIONS *
1103 **************************/
1107 /* Calculate table index by multiplying r with table scale and truncate to integer */
1108 rt = r20*vftabscale;
1111 vfitab = 1*4*vfitab;
1113 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1115 F = vftab[vfitab+1];
1116 Geps = vfeps*vftab[vfitab+2];
1117 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1119 FF = Fp+Geps+2.0*Heps2;
1120 felec = -qq20*FF*vftabscale*rinv20;
1124 /* Calculate temporary vectorial force */
1129 /* Update vectorial force */
1133 f[j_coord_offset+DIM*0+XX] -= tx;
1134 f[j_coord_offset+DIM*0+YY] -= ty;
1135 f[j_coord_offset+DIM*0+ZZ] -= tz;
1137 /**************************
1138 * CALCULATE INTERACTIONS *
1139 **************************/
1143 /* Calculate table index by multiplying r with table scale and truncate to integer */
1144 rt = r21*vftabscale;
1147 vfitab = 1*4*vfitab;
1149 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1151 F = vftab[vfitab+1];
1152 Geps = vfeps*vftab[vfitab+2];
1153 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1155 FF = Fp+Geps+2.0*Heps2;
1156 felec = -qq21*FF*vftabscale*rinv21;
1160 /* Calculate temporary vectorial force */
1165 /* Update vectorial force */
1169 f[j_coord_offset+DIM*1+XX] -= tx;
1170 f[j_coord_offset+DIM*1+YY] -= ty;
1171 f[j_coord_offset+DIM*1+ZZ] -= tz;
1173 /**************************
1174 * CALCULATE INTERACTIONS *
1175 **************************/
1179 /* Calculate table index by multiplying r with table scale and truncate to integer */
1180 rt = r22*vftabscale;
1183 vfitab = 1*4*vfitab;
1185 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1187 F = vftab[vfitab+1];
1188 Geps = vfeps*vftab[vfitab+2];
1189 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1191 FF = Fp+Geps+2.0*Heps2;
1192 felec = -qq22*FF*vftabscale*rinv22;
1196 /* Calculate temporary vectorial force */
1201 /* Update vectorial force */
1205 f[j_coord_offset+DIM*2+XX] -= tx;
1206 f[j_coord_offset+DIM*2+YY] -= ty;
1207 f[j_coord_offset+DIM*2+ZZ] -= tz;
1209 /* Inner loop uses 369 flops */
1211 /* End of innermost loop */
1214 f[i_coord_offset+DIM*0+XX] += fix0;
1215 f[i_coord_offset+DIM*0+YY] += fiy0;
1216 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1220 f[i_coord_offset+DIM*1+XX] += fix1;
1221 f[i_coord_offset+DIM*1+YY] += fiy1;
1222 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1226 f[i_coord_offset+DIM*2+XX] += fix2;
1227 f[i_coord_offset+DIM*2+YY] += fiy2;
1228 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1232 fshift[i_shift_offset+XX] += tx;
1233 fshift[i_shift_offset+YY] += ty;
1234 fshift[i_shift_offset+ZZ] += tz;
1236 /* Increment number of inner iterations */
1237 inneriter += j_index_end - j_index_start;
1239 /* Outer loop uses 30 flops */
1242 /* Increment number of outer iterations */
1245 /* Update outer/inner flops */
1247 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*369);