2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "gromacs/math/vec.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
100 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
108 jindex = nlist->jindex;
110 shiftidx = nlist->shift;
112 shiftvec = fr->shift_vec[0];
113 fshift = fr->fshift[0];
115 charge = mdatoms->chargeA;
116 nvdwtype = fr->ntype;
118 vdwtype = mdatoms->typeA;
120 vftab = kernel_data->table_elec_vdw->data;
121 vftabscale = kernel_data->table_elec_vdw->scale;
123 /* Setup water-specific parameters */
124 inr = nlist->iinr[0];
125 iq0 = facel*charge[inr+0];
126 iq1 = facel*charge[inr+1];
127 iq2 = facel*charge[inr+2];
128 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
133 vdwjidx0 = 2*vdwtype[inr+0];
135 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
136 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
149 /* Start outer loop over neighborlists */
150 for(iidx=0; iidx<nri; iidx++)
152 /* Load shift vector for this list */
153 i_shift_offset = DIM*shiftidx[iidx];
154 shX = shiftvec[i_shift_offset+XX];
155 shY = shiftvec[i_shift_offset+YY];
156 shZ = shiftvec[i_shift_offset+ZZ];
158 /* Load limits for loop over neighbors */
159 j_index_start = jindex[iidx];
160 j_index_end = jindex[iidx+1];
162 /* Get outer coordinate index */
164 i_coord_offset = DIM*inr;
166 /* Load i particle coords and add shift vector */
167 ix0 = shX + x[i_coord_offset+DIM*0+XX];
168 iy0 = shY + x[i_coord_offset+DIM*0+YY];
169 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
170 ix1 = shX + x[i_coord_offset+DIM*1+XX];
171 iy1 = shY + x[i_coord_offset+DIM*1+YY];
172 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
173 ix2 = shX + x[i_coord_offset+DIM*2+XX];
174 iy2 = shY + x[i_coord_offset+DIM*2+YY];
175 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
187 /* Reset potential sums */
191 /* Start inner kernel loop */
192 for(jidx=j_index_start; jidx<j_index_end; jidx++)
194 /* Get j neighbor index, and coordinate index */
196 j_coord_offset = DIM*jnr;
198 /* load j atom coordinates */
199 jx0 = x[j_coord_offset+DIM*0+XX];
200 jy0 = x[j_coord_offset+DIM*0+YY];
201 jz0 = x[j_coord_offset+DIM*0+ZZ];
202 jx1 = x[j_coord_offset+DIM*1+XX];
203 jy1 = x[j_coord_offset+DIM*1+YY];
204 jz1 = x[j_coord_offset+DIM*1+ZZ];
205 jx2 = x[j_coord_offset+DIM*2+XX];
206 jy2 = x[j_coord_offset+DIM*2+YY];
207 jz2 = x[j_coord_offset+DIM*2+ZZ];
209 /* Calculate displacement vector */
238 /* Calculate squared distance and things based on it */
239 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
240 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
241 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
242 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
243 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
244 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
245 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
246 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
247 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
249 rinv00 = gmx_invsqrt(rsq00);
250 rinv01 = gmx_invsqrt(rsq01);
251 rinv02 = gmx_invsqrt(rsq02);
252 rinv10 = gmx_invsqrt(rsq10);
253 rinv11 = gmx_invsqrt(rsq11);
254 rinv12 = gmx_invsqrt(rsq12);
255 rinv20 = gmx_invsqrt(rsq20);
256 rinv21 = gmx_invsqrt(rsq21);
257 rinv22 = gmx_invsqrt(rsq22);
259 /**************************
260 * CALCULATE INTERACTIONS *
261 **************************/
265 /* Calculate table index by multiplying r with table scale and truncate to integer */
271 /* CUBIC SPLINE TABLE ELECTROSTATICS */
274 Geps = vfeps*vftab[vfitab+2];
275 Heps2 = vfeps*vfeps*vftab[vfitab+3];
279 FF = Fp+Geps+2.0*Heps2;
280 felec = -qq00*FF*vftabscale*rinv00;
282 /* CUBIC SPLINE TABLE DISPERSION */
286 Geps = vfeps*vftab[vfitab+2];
287 Heps2 = vfeps*vfeps*vftab[vfitab+3];
291 FF = Fp+Geps+2.0*Heps2;
294 /* CUBIC SPLINE TABLE REPULSION */
297 Geps = vfeps*vftab[vfitab+6];
298 Heps2 = vfeps*vfeps*vftab[vfitab+7];
302 FF = Fp+Geps+2.0*Heps2;
305 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
307 /* Update potential sums from outer loop */
313 /* Calculate temporary vectorial force */
318 /* Update vectorial force */
322 f[j_coord_offset+DIM*0+XX] -= tx;
323 f[j_coord_offset+DIM*0+YY] -= ty;
324 f[j_coord_offset+DIM*0+ZZ] -= tz;
326 /**************************
327 * CALCULATE INTERACTIONS *
328 **************************/
332 /* Calculate table index by multiplying r with table scale and truncate to integer */
338 /* CUBIC SPLINE TABLE ELECTROSTATICS */
341 Geps = vfeps*vftab[vfitab+2];
342 Heps2 = vfeps*vfeps*vftab[vfitab+3];
346 FF = Fp+Geps+2.0*Heps2;
347 felec = -qq01*FF*vftabscale*rinv01;
349 /* Update potential sums from outer loop */
354 /* Calculate temporary vectorial force */
359 /* Update vectorial force */
363 f[j_coord_offset+DIM*1+XX] -= tx;
364 f[j_coord_offset+DIM*1+YY] -= ty;
365 f[j_coord_offset+DIM*1+ZZ] -= tz;
367 /**************************
368 * CALCULATE INTERACTIONS *
369 **************************/
373 /* Calculate table index by multiplying r with table scale and truncate to integer */
379 /* CUBIC SPLINE TABLE ELECTROSTATICS */
382 Geps = vfeps*vftab[vfitab+2];
383 Heps2 = vfeps*vfeps*vftab[vfitab+3];
387 FF = Fp+Geps+2.0*Heps2;
388 felec = -qq02*FF*vftabscale*rinv02;
390 /* Update potential sums from outer loop */
395 /* Calculate temporary vectorial force */
400 /* Update vectorial force */
404 f[j_coord_offset+DIM*2+XX] -= tx;
405 f[j_coord_offset+DIM*2+YY] -= ty;
406 f[j_coord_offset+DIM*2+ZZ] -= tz;
408 /**************************
409 * CALCULATE INTERACTIONS *
410 **************************/
414 /* Calculate table index by multiplying r with table scale and truncate to integer */
420 /* CUBIC SPLINE TABLE ELECTROSTATICS */
423 Geps = vfeps*vftab[vfitab+2];
424 Heps2 = vfeps*vfeps*vftab[vfitab+3];
428 FF = Fp+Geps+2.0*Heps2;
429 felec = -qq10*FF*vftabscale*rinv10;
431 /* Update potential sums from outer loop */
436 /* Calculate temporary vectorial force */
441 /* Update vectorial force */
445 f[j_coord_offset+DIM*0+XX] -= tx;
446 f[j_coord_offset+DIM*0+YY] -= ty;
447 f[j_coord_offset+DIM*0+ZZ] -= tz;
449 /**************************
450 * CALCULATE INTERACTIONS *
451 **************************/
455 /* Calculate table index by multiplying r with table scale and truncate to integer */
461 /* CUBIC SPLINE TABLE ELECTROSTATICS */
464 Geps = vfeps*vftab[vfitab+2];
465 Heps2 = vfeps*vfeps*vftab[vfitab+3];
469 FF = Fp+Geps+2.0*Heps2;
470 felec = -qq11*FF*vftabscale*rinv11;
472 /* Update potential sums from outer loop */
477 /* Calculate temporary vectorial force */
482 /* Update vectorial force */
486 f[j_coord_offset+DIM*1+XX] -= tx;
487 f[j_coord_offset+DIM*1+YY] -= ty;
488 f[j_coord_offset+DIM*1+ZZ] -= tz;
490 /**************************
491 * CALCULATE INTERACTIONS *
492 **************************/
496 /* Calculate table index by multiplying r with table scale and truncate to integer */
502 /* CUBIC SPLINE TABLE ELECTROSTATICS */
505 Geps = vfeps*vftab[vfitab+2];
506 Heps2 = vfeps*vfeps*vftab[vfitab+3];
510 FF = Fp+Geps+2.0*Heps2;
511 felec = -qq12*FF*vftabscale*rinv12;
513 /* Update potential sums from outer loop */
518 /* Calculate temporary vectorial force */
523 /* Update vectorial force */
527 f[j_coord_offset+DIM*2+XX] -= tx;
528 f[j_coord_offset+DIM*2+YY] -= ty;
529 f[j_coord_offset+DIM*2+ZZ] -= tz;
531 /**************************
532 * CALCULATE INTERACTIONS *
533 **************************/
537 /* Calculate table index by multiplying r with table scale and truncate to integer */
543 /* CUBIC SPLINE TABLE ELECTROSTATICS */
546 Geps = vfeps*vftab[vfitab+2];
547 Heps2 = vfeps*vfeps*vftab[vfitab+3];
551 FF = Fp+Geps+2.0*Heps2;
552 felec = -qq20*FF*vftabscale*rinv20;
554 /* Update potential sums from outer loop */
559 /* Calculate temporary vectorial force */
564 /* Update vectorial force */
568 f[j_coord_offset+DIM*0+XX] -= tx;
569 f[j_coord_offset+DIM*0+YY] -= ty;
570 f[j_coord_offset+DIM*0+ZZ] -= tz;
572 /**************************
573 * CALCULATE INTERACTIONS *
574 **************************/
578 /* Calculate table index by multiplying r with table scale and truncate to integer */
584 /* CUBIC SPLINE TABLE ELECTROSTATICS */
587 Geps = vfeps*vftab[vfitab+2];
588 Heps2 = vfeps*vfeps*vftab[vfitab+3];
592 FF = Fp+Geps+2.0*Heps2;
593 felec = -qq21*FF*vftabscale*rinv21;
595 /* Update potential sums from outer loop */
600 /* Calculate temporary vectorial force */
605 /* Update vectorial force */
609 f[j_coord_offset+DIM*1+XX] -= tx;
610 f[j_coord_offset+DIM*1+YY] -= ty;
611 f[j_coord_offset+DIM*1+ZZ] -= tz;
613 /**************************
614 * CALCULATE INTERACTIONS *
615 **************************/
619 /* Calculate table index by multiplying r with table scale and truncate to integer */
625 /* CUBIC SPLINE TABLE ELECTROSTATICS */
628 Geps = vfeps*vftab[vfitab+2];
629 Heps2 = vfeps*vfeps*vftab[vfitab+3];
633 FF = Fp+Geps+2.0*Heps2;
634 felec = -qq22*FF*vftabscale*rinv22;
636 /* Update potential sums from outer loop */
641 /* Calculate temporary vectorial force */
646 /* Update vectorial force */
650 f[j_coord_offset+DIM*2+XX] -= tx;
651 f[j_coord_offset+DIM*2+YY] -= ty;
652 f[j_coord_offset+DIM*2+ZZ] -= tz;
654 /* Inner loop uses 400 flops */
656 /* End of innermost loop */
659 f[i_coord_offset+DIM*0+XX] += fix0;
660 f[i_coord_offset+DIM*0+YY] += fiy0;
661 f[i_coord_offset+DIM*0+ZZ] += fiz0;
665 f[i_coord_offset+DIM*1+XX] += fix1;
666 f[i_coord_offset+DIM*1+YY] += fiy1;
667 f[i_coord_offset+DIM*1+ZZ] += fiz1;
671 f[i_coord_offset+DIM*2+XX] += fix2;
672 f[i_coord_offset+DIM*2+YY] += fiy2;
673 f[i_coord_offset+DIM*2+ZZ] += fiz2;
677 fshift[i_shift_offset+XX] += tx;
678 fshift[i_shift_offset+YY] += ty;
679 fshift[i_shift_offset+ZZ] += tz;
682 /* Update potential energies */
683 kernel_data->energygrp_elec[ggid] += velecsum;
684 kernel_data->energygrp_vdw[ggid] += vvdwsum;
686 /* Increment number of inner iterations */
687 inneriter += j_index_end - j_index_start;
689 /* Outer loop uses 32 flops */
692 /* Increment number of outer iterations */
695 /* Update outer/inner flops */
697 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*400);
700 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_F_c
701 * Electrostatics interaction: CubicSplineTable
702 * VdW interaction: CubicSplineTable
703 * Geometry: Water3-Water3
704 * Calculate force/pot: Force
707 nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_F_c
708 (t_nblist * gmx_restrict nlist,
709 rvec * gmx_restrict xx,
710 rvec * gmx_restrict ff,
711 t_forcerec * gmx_restrict fr,
712 t_mdatoms * gmx_restrict mdatoms,
713 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
714 t_nrnb * gmx_restrict nrnb)
716 int i_shift_offset,i_coord_offset,j_coord_offset;
717 int j_index_start,j_index_end;
718 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
719 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
720 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
721 real *shiftvec,*fshift,*x,*f;
723 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
725 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
727 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
729 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
731 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
733 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
734 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
735 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
736 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
737 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
738 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
739 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
740 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
741 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
742 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
743 real velec,felec,velecsum,facel,crf,krf,krf2;
746 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
750 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
758 jindex = nlist->jindex;
760 shiftidx = nlist->shift;
762 shiftvec = fr->shift_vec[0];
763 fshift = fr->fshift[0];
765 charge = mdatoms->chargeA;
766 nvdwtype = fr->ntype;
768 vdwtype = mdatoms->typeA;
770 vftab = kernel_data->table_elec_vdw->data;
771 vftabscale = kernel_data->table_elec_vdw->scale;
773 /* Setup water-specific parameters */
774 inr = nlist->iinr[0];
775 iq0 = facel*charge[inr+0];
776 iq1 = facel*charge[inr+1];
777 iq2 = facel*charge[inr+2];
778 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
783 vdwjidx0 = 2*vdwtype[inr+0];
785 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
786 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
799 /* Start outer loop over neighborlists */
800 for(iidx=0; iidx<nri; iidx++)
802 /* Load shift vector for this list */
803 i_shift_offset = DIM*shiftidx[iidx];
804 shX = shiftvec[i_shift_offset+XX];
805 shY = shiftvec[i_shift_offset+YY];
806 shZ = shiftvec[i_shift_offset+ZZ];
808 /* Load limits for loop over neighbors */
809 j_index_start = jindex[iidx];
810 j_index_end = jindex[iidx+1];
812 /* Get outer coordinate index */
814 i_coord_offset = DIM*inr;
816 /* Load i particle coords and add shift vector */
817 ix0 = shX + x[i_coord_offset+DIM*0+XX];
818 iy0 = shY + x[i_coord_offset+DIM*0+YY];
819 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
820 ix1 = shX + x[i_coord_offset+DIM*1+XX];
821 iy1 = shY + x[i_coord_offset+DIM*1+YY];
822 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
823 ix2 = shX + x[i_coord_offset+DIM*2+XX];
824 iy2 = shY + x[i_coord_offset+DIM*2+YY];
825 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
837 /* Start inner kernel loop */
838 for(jidx=j_index_start; jidx<j_index_end; jidx++)
840 /* Get j neighbor index, and coordinate index */
842 j_coord_offset = DIM*jnr;
844 /* load j atom coordinates */
845 jx0 = x[j_coord_offset+DIM*0+XX];
846 jy0 = x[j_coord_offset+DIM*0+YY];
847 jz0 = x[j_coord_offset+DIM*0+ZZ];
848 jx1 = x[j_coord_offset+DIM*1+XX];
849 jy1 = x[j_coord_offset+DIM*1+YY];
850 jz1 = x[j_coord_offset+DIM*1+ZZ];
851 jx2 = x[j_coord_offset+DIM*2+XX];
852 jy2 = x[j_coord_offset+DIM*2+YY];
853 jz2 = x[j_coord_offset+DIM*2+ZZ];
855 /* Calculate displacement vector */
884 /* Calculate squared distance and things based on it */
885 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
886 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
887 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
888 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
889 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
890 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
891 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
892 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
893 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
895 rinv00 = gmx_invsqrt(rsq00);
896 rinv01 = gmx_invsqrt(rsq01);
897 rinv02 = gmx_invsqrt(rsq02);
898 rinv10 = gmx_invsqrt(rsq10);
899 rinv11 = gmx_invsqrt(rsq11);
900 rinv12 = gmx_invsqrt(rsq12);
901 rinv20 = gmx_invsqrt(rsq20);
902 rinv21 = gmx_invsqrt(rsq21);
903 rinv22 = gmx_invsqrt(rsq22);
905 /**************************
906 * CALCULATE INTERACTIONS *
907 **************************/
911 /* Calculate table index by multiplying r with table scale and truncate to integer */
917 /* CUBIC SPLINE TABLE ELECTROSTATICS */
919 Geps = vfeps*vftab[vfitab+2];
920 Heps2 = vfeps*vfeps*vftab[vfitab+3];
922 FF = Fp+Geps+2.0*Heps2;
923 felec = -qq00*FF*vftabscale*rinv00;
925 /* CUBIC SPLINE TABLE DISPERSION */
928 Geps = vfeps*vftab[vfitab+2];
929 Heps2 = vfeps*vfeps*vftab[vfitab+3];
931 FF = Fp+Geps+2.0*Heps2;
934 /* CUBIC SPLINE TABLE REPULSION */
936 Geps = vfeps*vftab[vfitab+6];
937 Heps2 = vfeps*vfeps*vftab[vfitab+7];
939 FF = Fp+Geps+2.0*Heps2;
941 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
945 /* Calculate temporary vectorial force */
950 /* Update vectorial force */
954 f[j_coord_offset+DIM*0+XX] -= tx;
955 f[j_coord_offset+DIM*0+YY] -= ty;
956 f[j_coord_offset+DIM*0+ZZ] -= tz;
958 /**************************
959 * CALCULATE INTERACTIONS *
960 **************************/
964 /* Calculate table index by multiplying r with table scale and truncate to integer */
970 /* 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 = -qq01*FF*vftabscale*rinv01;
980 /* Calculate temporary vectorial force */
985 /* Update vectorial force */
989 f[j_coord_offset+DIM*1+XX] -= tx;
990 f[j_coord_offset+DIM*1+YY] -= ty;
991 f[j_coord_offset+DIM*1+ZZ] -= tz;
993 /**************************
994 * CALCULATE INTERACTIONS *
995 **************************/
999 /* Calculate table index by multiplying r with table scale and truncate to integer */
1000 rt = r02*vftabscale;
1003 vfitab = 3*4*vfitab;
1005 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1006 F = vftab[vfitab+1];
1007 Geps = vfeps*vftab[vfitab+2];
1008 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1010 FF = Fp+Geps+2.0*Heps2;
1011 felec = -qq02*FF*vftabscale*rinv02;
1015 /* Calculate temporary vectorial force */
1020 /* Update vectorial force */
1024 f[j_coord_offset+DIM*2+XX] -= tx;
1025 f[j_coord_offset+DIM*2+YY] -= ty;
1026 f[j_coord_offset+DIM*2+ZZ] -= tz;
1028 /**************************
1029 * CALCULATE INTERACTIONS *
1030 **************************/
1034 /* Calculate table index by multiplying r with table scale and truncate to integer */
1035 rt = r10*vftabscale;
1038 vfitab = 3*4*vfitab;
1040 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1041 F = vftab[vfitab+1];
1042 Geps = vfeps*vftab[vfitab+2];
1043 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1045 FF = Fp+Geps+2.0*Heps2;
1046 felec = -qq10*FF*vftabscale*rinv10;
1050 /* Calculate temporary vectorial force */
1055 /* Update vectorial force */
1059 f[j_coord_offset+DIM*0+XX] -= tx;
1060 f[j_coord_offset+DIM*0+YY] -= ty;
1061 f[j_coord_offset+DIM*0+ZZ] -= tz;
1063 /**************************
1064 * CALCULATE INTERACTIONS *
1065 **************************/
1069 /* Calculate table index by multiplying r with table scale and truncate to integer */
1070 rt = r11*vftabscale;
1073 vfitab = 3*4*vfitab;
1075 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1076 F = vftab[vfitab+1];
1077 Geps = vfeps*vftab[vfitab+2];
1078 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1080 FF = Fp+Geps+2.0*Heps2;
1081 felec = -qq11*FF*vftabscale*rinv11;
1085 /* Calculate temporary vectorial force */
1090 /* Update vectorial force */
1094 f[j_coord_offset+DIM*1+XX] -= tx;
1095 f[j_coord_offset+DIM*1+YY] -= ty;
1096 f[j_coord_offset+DIM*1+ZZ] -= tz;
1098 /**************************
1099 * CALCULATE INTERACTIONS *
1100 **************************/
1104 /* Calculate table index by multiplying r with table scale and truncate to integer */
1105 rt = r12*vftabscale;
1108 vfitab = 3*4*vfitab;
1110 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1111 F = vftab[vfitab+1];
1112 Geps = vfeps*vftab[vfitab+2];
1113 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1115 FF = Fp+Geps+2.0*Heps2;
1116 felec = -qq12*FF*vftabscale*rinv12;
1120 /* Calculate temporary vectorial force */
1125 /* Update vectorial force */
1129 f[j_coord_offset+DIM*2+XX] -= tx;
1130 f[j_coord_offset+DIM*2+YY] -= ty;
1131 f[j_coord_offset+DIM*2+ZZ] -= tz;
1133 /**************************
1134 * CALCULATE INTERACTIONS *
1135 **************************/
1139 /* Calculate table index by multiplying r with table scale and truncate to integer */
1140 rt = r20*vftabscale;
1143 vfitab = 3*4*vfitab;
1145 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1146 F = vftab[vfitab+1];
1147 Geps = vfeps*vftab[vfitab+2];
1148 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1150 FF = Fp+Geps+2.0*Heps2;
1151 felec = -qq20*FF*vftabscale*rinv20;
1155 /* Calculate temporary vectorial force */
1160 /* Update vectorial force */
1164 f[j_coord_offset+DIM*0+XX] -= tx;
1165 f[j_coord_offset+DIM*0+YY] -= ty;
1166 f[j_coord_offset+DIM*0+ZZ] -= tz;
1168 /**************************
1169 * CALCULATE INTERACTIONS *
1170 **************************/
1174 /* Calculate table index by multiplying r with table scale and truncate to integer */
1175 rt = r21*vftabscale;
1178 vfitab = 3*4*vfitab;
1180 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1181 F = vftab[vfitab+1];
1182 Geps = vfeps*vftab[vfitab+2];
1183 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1185 FF = Fp+Geps+2.0*Heps2;
1186 felec = -qq21*FF*vftabscale*rinv21;
1190 /* Calculate temporary vectorial force */
1195 /* Update vectorial force */
1199 f[j_coord_offset+DIM*1+XX] -= tx;
1200 f[j_coord_offset+DIM*1+YY] -= ty;
1201 f[j_coord_offset+DIM*1+ZZ] -= tz;
1203 /**************************
1204 * CALCULATE INTERACTIONS *
1205 **************************/
1209 /* Calculate table index by multiplying r with table scale and truncate to integer */
1210 rt = r22*vftabscale;
1213 vfitab = 3*4*vfitab;
1215 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1216 F = vftab[vfitab+1];
1217 Geps = vfeps*vftab[vfitab+2];
1218 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1220 FF = Fp+Geps+2.0*Heps2;
1221 felec = -qq22*FF*vftabscale*rinv22;
1225 /* Calculate temporary vectorial force */
1230 /* Update vectorial force */
1234 f[j_coord_offset+DIM*2+XX] -= tx;
1235 f[j_coord_offset+DIM*2+YY] -= ty;
1236 f[j_coord_offset+DIM*2+ZZ] -= tz;
1238 /* Inner loop uses 356 flops */
1240 /* End of innermost loop */
1243 f[i_coord_offset+DIM*0+XX] += fix0;
1244 f[i_coord_offset+DIM*0+YY] += fiy0;
1245 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1249 f[i_coord_offset+DIM*1+XX] += fix1;
1250 f[i_coord_offset+DIM*1+YY] += fiy1;
1251 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1255 f[i_coord_offset+DIM*2+XX] += fix2;
1256 f[i_coord_offset+DIM*2+YY] += fiy2;
1257 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1261 fshift[i_shift_offset+XX] += tx;
1262 fshift[i_shift_offset+YY] += ty;
1263 fshift[i_shift_offset+ZZ] += tz;
1265 /* Increment number of inner iterations */
1266 inneriter += j_index_end - j_index_start;
1268 /* Outer loop uses 30 flops */
1271 /* Increment number of outer iterations */
1274 /* Update outer/inner flops */
1276 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*356);