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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_VF_c
49 * Electrostatics interaction: CubicSplineTable
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
98 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
106 jindex = nlist->jindex;
108 shiftidx = nlist->shift;
110 shiftvec = fr->shift_vec[0];
111 fshift = fr->fshift[0];
113 charge = mdatoms->chargeA;
114 nvdwtype = fr->ntype;
116 vdwtype = mdatoms->typeA;
118 vftab = kernel_data->table_elec_vdw->data;
119 vftabscale = kernel_data->table_elec_vdw->scale;
121 /* Setup water-specific parameters */
122 inr = nlist->iinr[0];
123 iq0 = facel*charge[inr+0];
124 iq1 = facel*charge[inr+1];
125 iq2 = facel*charge[inr+2];
126 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
131 vdwjidx0 = 2*vdwtype[inr+0];
133 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
134 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
147 /* Start outer loop over neighborlists */
148 for(iidx=0; iidx<nri; iidx++)
150 /* Load shift vector for this list */
151 i_shift_offset = DIM*shiftidx[iidx];
152 shX = shiftvec[i_shift_offset+XX];
153 shY = shiftvec[i_shift_offset+YY];
154 shZ = shiftvec[i_shift_offset+ZZ];
156 /* Load limits for loop over neighbors */
157 j_index_start = jindex[iidx];
158 j_index_end = jindex[iidx+1];
160 /* Get outer coordinate index */
162 i_coord_offset = DIM*inr;
164 /* Load i particle coords and add shift vector */
165 ix0 = shX + x[i_coord_offset+DIM*0+XX];
166 iy0 = shY + x[i_coord_offset+DIM*0+YY];
167 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
168 ix1 = shX + x[i_coord_offset+DIM*1+XX];
169 iy1 = shY + x[i_coord_offset+DIM*1+YY];
170 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
171 ix2 = shX + x[i_coord_offset+DIM*2+XX];
172 iy2 = shY + x[i_coord_offset+DIM*2+YY];
173 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
185 /* Reset potential sums */
189 /* Start inner kernel loop */
190 for(jidx=j_index_start; jidx<j_index_end; jidx++)
192 /* Get j neighbor index, and coordinate index */
194 j_coord_offset = DIM*jnr;
196 /* load j atom coordinates */
197 jx0 = x[j_coord_offset+DIM*0+XX];
198 jy0 = x[j_coord_offset+DIM*0+YY];
199 jz0 = x[j_coord_offset+DIM*0+ZZ];
200 jx1 = x[j_coord_offset+DIM*1+XX];
201 jy1 = x[j_coord_offset+DIM*1+YY];
202 jz1 = x[j_coord_offset+DIM*1+ZZ];
203 jx2 = x[j_coord_offset+DIM*2+XX];
204 jy2 = x[j_coord_offset+DIM*2+YY];
205 jz2 = x[j_coord_offset+DIM*2+ZZ];
207 /* Calculate displacement vector */
236 /* Calculate squared distance and things based on it */
237 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
238 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
239 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
240 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
241 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
242 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
243 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
244 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
245 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
247 rinv00 = gmx_invsqrt(rsq00);
248 rinv01 = gmx_invsqrt(rsq01);
249 rinv02 = gmx_invsqrt(rsq02);
250 rinv10 = gmx_invsqrt(rsq10);
251 rinv11 = gmx_invsqrt(rsq11);
252 rinv12 = gmx_invsqrt(rsq12);
253 rinv20 = gmx_invsqrt(rsq20);
254 rinv21 = gmx_invsqrt(rsq21);
255 rinv22 = gmx_invsqrt(rsq22);
257 /**************************
258 * CALCULATE INTERACTIONS *
259 **************************/
263 /* Calculate table index by multiplying r with table scale and truncate to integer */
269 /* CUBIC SPLINE TABLE ELECTROSTATICS */
272 Geps = vfeps*vftab[vfitab+2];
273 Heps2 = vfeps*vfeps*vftab[vfitab+3];
277 FF = Fp+Geps+2.0*Heps2;
278 felec = -qq00*FF*vftabscale*rinv00;
280 /* CUBIC SPLINE TABLE DISPERSION */
284 Geps = vfeps*vftab[vfitab+2];
285 Heps2 = vfeps*vfeps*vftab[vfitab+3];
289 FF = Fp+Geps+2.0*Heps2;
292 /* CUBIC SPLINE TABLE REPULSION */
295 Geps = vfeps*vftab[vfitab+6];
296 Heps2 = vfeps*vfeps*vftab[vfitab+7];
300 FF = Fp+Geps+2.0*Heps2;
303 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
305 /* Update potential sums from outer loop */
311 /* Calculate temporary vectorial force */
316 /* Update vectorial force */
320 f[j_coord_offset+DIM*0+XX] -= tx;
321 f[j_coord_offset+DIM*0+YY] -= ty;
322 f[j_coord_offset+DIM*0+ZZ] -= tz;
324 /**************************
325 * CALCULATE INTERACTIONS *
326 **************************/
330 /* Calculate table index by multiplying r with table scale and truncate to integer */
336 /* CUBIC SPLINE TABLE ELECTROSTATICS */
339 Geps = vfeps*vftab[vfitab+2];
340 Heps2 = vfeps*vfeps*vftab[vfitab+3];
344 FF = Fp+Geps+2.0*Heps2;
345 felec = -qq01*FF*vftabscale*rinv01;
347 /* Update potential sums from outer loop */
352 /* Calculate temporary vectorial force */
357 /* Update vectorial force */
361 f[j_coord_offset+DIM*1+XX] -= tx;
362 f[j_coord_offset+DIM*1+YY] -= ty;
363 f[j_coord_offset+DIM*1+ZZ] -= tz;
365 /**************************
366 * CALCULATE INTERACTIONS *
367 **************************/
371 /* Calculate table index by multiplying r with table scale and truncate to integer */
377 /* CUBIC SPLINE TABLE ELECTROSTATICS */
380 Geps = vfeps*vftab[vfitab+2];
381 Heps2 = vfeps*vfeps*vftab[vfitab+3];
385 FF = Fp+Geps+2.0*Heps2;
386 felec = -qq02*FF*vftabscale*rinv02;
388 /* Update potential sums from outer loop */
393 /* Calculate temporary vectorial force */
398 /* Update vectorial force */
402 f[j_coord_offset+DIM*2+XX] -= tx;
403 f[j_coord_offset+DIM*2+YY] -= ty;
404 f[j_coord_offset+DIM*2+ZZ] -= tz;
406 /**************************
407 * CALCULATE INTERACTIONS *
408 **************************/
412 /* Calculate table index by multiplying r with table scale and truncate to integer */
418 /* CUBIC SPLINE TABLE ELECTROSTATICS */
421 Geps = vfeps*vftab[vfitab+2];
422 Heps2 = vfeps*vfeps*vftab[vfitab+3];
426 FF = Fp+Geps+2.0*Heps2;
427 felec = -qq10*FF*vftabscale*rinv10;
429 /* Update potential sums from outer loop */
434 /* Calculate temporary vectorial force */
439 /* Update vectorial force */
443 f[j_coord_offset+DIM*0+XX] -= tx;
444 f[j_coord_offset+DIM*0+YY] -= ty;
445 f[j_coord_offset+DIM*0+ZZ] -= tz;
447 /**************************
448 * CALCULATE INTERACTIONS *
449 **************************/
453 /* Calculate table index by multiplying r with table scale and truncate to integer */
459 /* CUBIC SPLINE TABLE ELECTROSTATICS */
462 Geps = vfeps*vftab[vfitab+2];
463 Heps2 = vfeps*vfeps*vftab[vfitab+3];
467 FF = Fp+Geps+2.0*Heps2;
468 felec = -qq11*FF*vftabscale*rinv11;
470 /* Update potential sums from outer loop */
475 /* Calculate temporary vectorial force */
480 /* Update vectorial force */
484 f[j_coord_offset+DIM*1+XX] -= tx;
485 f[j_coord_offset+DIM*1+YY] -= ty;
486 f[j_coord_offset+DIM*1+ZZ] -= tz;
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
494 /* Calculate table index by multiplying r with table scale and truncate to integer */
500 /* CUBIC SPLINE TABLE ELECTROSTATICS */
503 Geps = vfeps*vftab[vfitab+2];
504 Heps2 = vfeps*vfeps*vftab[vfitab+3];
508 FF = Fp+Geps+2.0*Heps2;
509 felec = -qq12*FF*vftabscale*rinv12;
511 /* Update potential sums from outer loop */
516 /* Calculate temporary vectorial force */
521 /* Update vectorial force */
525 f[j_coord_offset+DIM*2+XX] -= tx;
526 f[j_coord_offset+DIM*2+YY] -= ty;
527 f[j_coord_offset+DIM*2+ZZ] -= tz;
529 /**************************
530 * CALCULATE INTERACTIONS *
531 **************************/
535 /* Calculate table index by multiplying r with table scale and truncate to integer */
541 /* CUBIC SPLINE TABLE ELECTROSTATICS */
544 Geps = vfeps*vftab[vfitab+2];
545 Heps2 = vfeps*vfeps*vftab[vfitab+3];
549 FF = Fp+Geps+2.0*Heps2;
550 felec = -qq20*FF*vftabscale*rinv20;
552 /* Update potential sums from outer loop */
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 **************************/
576 /* Calculate table index by multiplying r with table scale and truncate to integer */
582 /* CUBIC SPLINE TABLE ELECTROSTATICS */
585 Geps = vfeps*vftab[vfitab+2];
586 Heps2 = vfeps*vfeps*vftab[vfitab+3];
590 FF = Fp+Geps+2.0*Heps2;
591 felec = -qq21*FF*vftabscale*rinv21;
593 /* Update potential sums from outer loop */
598 /* Calculate temporary vectorial force */
603 /* Update vectorial force */
607 f[j_coord_offset+DIM*1+XX] -= tx;
608 f[j_coord_offset+DIM*1+YY] -= ty;
609 f[j_coord_offset+DIM*1+ZZ] -= tz;
611 /**************************
612 * CALCULATE INTERACTIONS *
613 **************************/
617 /* Calculate table index by multiplying r with table scale and truncate to integer */
623 /* CUBIC SPLINE TABLE ELECTROSTATICS */
626 Geps = vfeps*vftab[vfitab+2];
627 Heps2 = vfeps*vfeps*vftab[vfitab+3];
631 FF = Fp+Geps+2.0*Heps2;
632 felec = -qq22*FF*vftabscale*rinv22;
634 /* Update potential sums from outer loop */
639 /* Calculate temporary vectorial force */
644 /* Update vectorial force */
648 f[j_coord_offset+DIM*2+XX] -= tx;
649 f[j_coord_offset+DIM*2+YY] -= ty;
650 f[j_coord_offset+DIM*2+ZZ] -= tz;
652 /* Inner loop uses 400 flops */
654 /* End of innermost loop */
657 f[i_coord_offset+DIM*0+XX] += fix0;
658 f[i_coord_offset+DIM*0+YY] += fiy0;
659 f[i_coord_offset+DIM*0+ZZ] += fiz0;
663 f[i_coord_offset+DIM*1+XX] += fix1;
664 f[i_coord_offset+DIM*1+YY] += fiy1;
665 f[i_coord_offset+DIM*1+ZZ] += fiz1;
669 f[i_coord_offset+DIM*2+XX] += fix2;
670 f[i_coord_offset+DIM*2+YY] += fiy2;
671 f[i_coord_offset+DIM*2+ZZ] += fiz2;
675 fshift[i_shift_offset+XX] += tx;
676 fshift[i_shift_offset+YY] += ty;
677 fshift[i_shift_offset+ZZ] += tz;
680 /* Update potential energies */
681 kernel_data->energygrp_elec[ggid] += velecsum;
682 kernel_data->energygrp_vdw[ggid] += vvdwsum;
684 /* Increment number of inner iterations */
685 inneriter += j_index_end - j_index_start;
687 /* Outer loop uses 32 flops */
690 /* Increment number of outer iterations */
693 /* Update outer/inner flops */
695 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*400);
698 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_F_c
699 * Electrostatics interaction: CubicSplineTable
700 * VdW interaction: CubicSplineTable
701 * Geometry: Water3-Water3
702 * Calculate force/pot: Force
705 nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_F_c
706 (t_nblist * gmx_restrict nlist,
707 rvec * gmx_restrict xx,
708 rvec * gmx_restrict ff,
709 t_forcerec * gmx_restrict fr,
710 t_mdatoms * gmx_restrict mdatoms,
711 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
712 t_nrnb * gmx_restrict nrnb)
714 int i_shift_offset,i_coord_offset,j_coord_offset;
715 int j_index_start,j_index_end;
716 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
717 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
718 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
719 real *shiftvec,*fshift,*x,*f;
721 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
723 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
725 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
727 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
729 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
731 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
732 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
733 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
734 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
735 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
736 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
737 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
738 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
739 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
740 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
741 real velec,felec,velecsum,facel,crf,krf,krf2;
744 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
748 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
756 jindex = nlist->jindex;
758 shiftidx = nlist->shift;
760 shiftvec = fr->shift_vec[0];
761 fshift = fr->fshift[0];
763 charge = mdatoms->chargeA;
764 nvdwtype = fr->ntype;
766 vdwtype = mdatoms->typeA;
768 vftab = kernel_data->table_elec_vdw->data;
769 vftabscale = kernel_data->table_elec_vdw->scale;
771 /* Setup water-specific parameters */
772 inr = nlist->iinr[0];
773 iq0 = facel*charge[inr+0];
774 iq1 = facel*charge[inr+1];
775 iq2 = facel*charge[inr+2];
776 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
781 vdwjidx0 = 2*vdwtype[inr+0];
783 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
784 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
797 /* Start outer loop over neighborlists */
798 for(iidx=0; iidx<nri; iidx++)
800 /* Load shift vector for this list */
801 i_shift_offset = DIM*shiftidx[iidx];
802 shX = shiftvec[i_shift_offset+XX];
803 shY = shiftvec[i_shift_offset+YY];
804 shZ = shiftvec[i_shift_offset+ZZ];
806 /* Load limits for loop over neighbors */
807 j_index_start = jindex[iidx];
808 j_index_end = jindex[iidx+1];
810 /* Get outer coordinate index */
812 i_coord_offset = DIM*inr;
814 /* Load i particle coords and add shift vector */
815 ix0 = shX + x[i_coord_offset+DIM*0+XX];
816 iy0 = shY + x[i_coord_offset+DIM*0+YY];
817 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
818 ix1 = shX + x[i_coord_offset+DIM*1+XX];
819 iy1 = shY + x[i_coord_offset+DIM*1+YY];
820 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
821 ix2 = shX + x[i_coord_offset+DIM*2+XX];
822 iy2 = shY + x[i_coord_offset+DIM*2+YY];
823 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
835 /* Start inner kernel loop */
836 for(jidx=j_index_start; jidx<j_index_end; jidx++)
838 /* Get j neighbor index, and coordinate index */
840 j_coord_offset = DIM*jnr;
842 /* load j atom coordinates */
843 jx0 = x[j_coord_offset+DIM*0+XX];
844 jy0 = x[j_coord_offset+DIM*0+YY];
845 jz0 = x[j_coord_offset+DIM*0+ZZ];
846 jx1 = x[j_coord_offset+DIM*1+XX];
847 jy1 = x[j_coord_offset+DIM*1+YY];
848 jz1 = x[j_coord_offset+DIM*1+ZZ];
849 jx2 = x[j_coord_offset+DIM*2+XX];
850 jy2 = x[j_coord_offset+DIM*2+YY];
851 jz2 = x[j_coord_offset+DIM*2+ZZ];
853 /* Calculate displacement vector */
882 /* Calculate squared distance and things based on it */
883 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
884 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
885 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
886 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
887 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
888 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
889 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
890 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
891 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
893 rinv00 = gmx_invsqrt(rsq00);
894 rinv01 = gmx_invsqrt(rsq01);
895 rinv02 = gmx_invsqrt(rsq02);
896 rinv10 = gmx_invsqrt(rsq10);
897 rinv11 = gmx_invsqrt(rsq11);
898 rinv12 = gmx_invsqrt(rsq12);
899 rinv20 = gmx_invsqrt(rsq20);
900 rinv21 = gmx_invsqrt(rsq21);
901 rinv22 = gmx_invsqrt(rsq22);
903 /**************************
904 * CALCULATE INTERACTIONS *
905 **************************/
909 /* Calculate table index by multiplying r with table scale and truncate to integer */
915 /* CUBIC SPLINE TABLE ELECTROSTATICS */
917 Geps = vfeps*vftab[vfitab+2];
918 Heps2 = vfeps*vfeps*vftab[vfitab+3];
920 FF = Fp+Geps+2.0*Heps2;
921 felec = -qq00*FF*vftabscale*rinv00;
923 /* CUBIC SPLINE TABLE DISPERSION */
926 Geps = vfeps*vftab[vfitab+2];
927 Heps2 = vfeps*vfeps*vftab[vfitab+3];
929 FF = Fp+Geps+2.0*Heps2;
932 /* CUBIC SPLINE TABLE REPULSION */
934 Geps = vfeps*vftab[vfitab+6];
935 Heps2 = vfeps*vfeps*vftab[vfitab+7];
937 FF = Fp+Geps+2.0*Heps2;
939 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
943 /* Calculate temporary vectorial force */
948 /* Update vectorial force */
952 f[j_coord_offset+DIM*0+XX] -= tx;
953 f[j_coord_offset+DIM*0+YY] -= ty;
954 f[j_coord_offset+DIM*0+ZZ] -= tz;
956 /**************************
957 * CALCULATE INTERACTIONS *
958 **************************/
962 /* Calculate table index by multiplying r with table scale and truncate to integer */
968 /* CUBIC SPLINE TABLE ELECTROSTATICS */
970 Geps = vfeps*vftab[vfitab+2];
971 Heps2 = vfeps*vfeps*vftab[vfitab+3];
973 FF = Fp+Geps+2.0*Heps2;
974 felec = -qq01*FF*vftabscale*rinv01;
978 /* Calculate temporary vectorial force */
983 /* Update vectorial force */
987 f[j_coord_offset+DIM*1+XX] -= tx;
988 f[j_coord_offset+DIM*1+YY] -= ty;
989 f[j_coord_offset+DIM*1+ZZ] -= tz;
991 /**************************
992 * CALCULATE INTERACTIONS *
993 **************************/
997 /* Calculate table index by multiplying r with table scale and truncate to integer */
1001 vfitab = 3*4*vfitab;
1003 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1004 F = vftab[vfitab+1];
1005 Geps = vfeps*vftab[vfitab+2];
1006 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1008 FF = Fp+Geps+2.0*Heps2;
1009 felec = -qq02*FF*vftabscale*rinv02;
1013 /* Calculate temporary vectorial force */
1018 /* Update vectorial force */
1022 f[j_coord_offset+DIM*2+XX] -= tx;
1023 f[j_coord_offset+DIM*2+YY] -= ty;
1024 f[j_coord_offset+DIM*2+ZZ] -= tz;
1026 /**************************
1027 * CALCULATE INTERACTIONS *
1028 **************************/
1032 /* Calculate table index by multiplying r with table scale and truncate to integer */
1033 rt = r10*vftabscale;
1036 vfitab = 3*4*vfitab;
1038 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1039 F = vftab[vfitab+1];
1040 Geps = vfeps*vftab[vfitab+2];
1041 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1043 FF = Fp+Geps+2.0*Heps2;
1044 felec = -qq10*FF*vftabscale*rinv10;
1048 /* Calculate temporary vectorial force */
1053 /* Update vectorial force */
1057 f[j_coord_offset+DIM*0+XX] -= tx;
1058 f[j_coord_offset+DIM*0+YY] -= ty;
1059 f[j_coord_offset+DIM*0+ZZ] -= tz;
1061 /**************************
1062 * CALCULATE INTERACTIONS *
1063 **************************/
1067 /* Calculate table index by multiplying r with table scale and truncate to integer */
1068 rt = r11*vftabscale;
1071 vfitab = 3*4*vfitab;
1073 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1074 F = vftab[vfitab+1];
1075 Geps = vfeps*vftab[vfitab+2];
1076 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1078 FF = Fp+Geps+2.0*Heps2;
1079 felec = -qq11*FF*vftabscale*rinv11;
1083 /* Calculate temporary vectorial force */
1088 /* Update vectorial force */
1092 f[j_coord_offset+DIM*1+XX] -= tx;
1093 f[j_coord_offset+DIM*1+YY] -= ty;
1094 f[j_coord_offset+DIM*1+ZZ] -= tz;
1096 /**************************
1097 * CALCULATE INTERACTIONS *
1098 **************************/
1102 /* Calculate table index by multiplying r with table scale and truncate to integer */
1103 rt = r12*vftabscale;
1106 vfitab = 3*4*vfitab;
1108 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1109 F = vftab[vfitab+1];
1110 Geps = vfeps*vftab[vfitab+2];
1111 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1113 FF = Fp+Geps+2.0*Heps2;
1114 felec = -qq12*FF*vftabscale*rinv12;
1118 /* Calculate temporary vectorial force */
1123 /* Update vectorial force */
1127 f[j_coord_offset+DIM*2+XX] -= tx;
1128 f[j_coord_offset+DIM*2+YY] -= ty;
1129 f[j_coord_offset+DIM*2+ZZ] -= tz;
1131 /**************************
1132 * CALCULATE INTERACTIONS *
1133 **************************/
1137 /* Calculate table index by multiplying r with table scale and truncate to integer */
1138 rt = r20*vftabscale;
1141 vfitab = 3*4*vfitab;
1143 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1144 F = vftab[vfitab+1];
1145 Geps = vfeps*vftab[vfitab+2];
1146 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1148 FF = Fp+Geps+2.0*Heps2;
1149 felec = -qq20*FF*vftabscale*rinv20;
1153 /* Calculate temporary vectorial force */
1158 /* Update vectorial force */
1162 f[j_coord_offset+DIM*0+XX] -= tx;
1163 f[j_coord_offset+DIM*0+YY] -= ty;
1164 f[j_coord_offset+DIM*0+ZZ] -= tz;
1166 /**************************
1167 * CALCULATE INTERACTIONS *
1168 **************************/
1172 /* Calculate table index by multiplying r with table scale and truncate to integer */
1173 rt = r21*vftabscale;
1176 vfitab = 3*4*vfitab;
1178 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1179 F = vftab[vfitab+1];
1180 Geps = vfeps*vftab[vfitab+2];
1181 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1183 FF = Fp+Geps+2.0*Heps2;
1184 felec = -qq21*FF*vftabscale*rinv21;
1188 /* Calculate temporary vectorial force */
1193 /* Update vectorial force */
1197 f[j_coord_offset+DIM*1+XX] -= tx;
1198 f[j_coord_offset+DIM*1+YY] -= ty;
1199 f[j_coord_offset+DIM*1+ZZ] -= tz;
1201 /**************************
1202 * CALCULATE INTERACTIONS *
1203 **************************/
1207 /* Calculate table index by multiplying r with table scale and truncate to integer */
1208 rt = r22*vftabscale;
1211 vfitab = 3*4*vfitab;
1213 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1214 F = vftab[vfitab+1];
1215 Geps = vfeps*vftab[vfitab+2];
1216 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1218 FF = Fp+Geps+2.0*Heps2;
1219 felec = -qq22*FF*vftabscale*rinv22;
1223 /* Calculate temporary vectorial force */
1228 /* Update vectorial force */
1232 f[j_coord_offset+DIM*2+XX] -= tx;
1233 f[j_coord_offset+DIM*2+YY] -= ty;
1234 f[j_coord_offset+DIM*2+ZZ] -= tz;
1236 /* Inner loop uses 356 flops */
1238 /* End of innermost loop */
1241 f[i_coord_offset+DIM*0+XX] += fix0;
1242 f[i_coord_offset+DIM*0+YY] += fiy0;
1243 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1247 f[i_coord_offset+DIM*1+XX] += fix1;
1248 f[i_coord_offset+DIM*1+YY] += fiy1;
1249 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1253 f[i_coord_offset+DIM*2+XX] += fix2;
1254 f[i_coord_offset+DIM*2+YY] += fiy2;
1255 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1259 fshift[i_shift_offset+XX] += tx;
1260 fshift[i_shift_offset+YY] += ty;
1261 fshift[i_shift_offset+ZZ] += tz;
1263 /* Increment number of inner iterations */
1264 inneriter += j_index_end - j_index_start;
1266 /* Outer loop uses 30 flops */
1269 /* Increment number of outer iterations */
1272 /* Update outer/inner flops */
1274 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*356);