2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW3W3_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: LennardJones
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwLJ_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->data;
121 vftabscale = kernel_data->table_elec->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 rinvsq00 = rinv00*rinv00;
261 /**************************
262 * CALCULATE INTERACTIONS *
263 **************************/
267 /* Calculate table index by multiplying r with table scale and truncate to integer */
273 /* CUBIC SPLINE TABLE ELECTROSTATICS */
276 Geps = vfeps*vftab[vfitab+2];
277 Heps2 = vfeps*vfeps*vftab[vfitab+3];
281 FF = Fp+Geps+2.0*Heps2;
282 felec = -qq00*FF*vftabscale*rinv00;
284 /* LENNARD-JONES DISPERSION/REPULSION */
286 rinvsix = rinvsq00*rinvsq00*rinvsq00;
287 vvdw6 = c6_00*rinvsix;
288 vvdw12 = c12_00*rinvsix*rinvsix;
289 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
290 fvdw = (vvdw12-vvdw6)*rinvsq00;
292 /* Update potential sums from outer loop */
298 /* Calculate temporary vectorial force */
303 /* Update vectorial force */
307 f[j_coord_offset+DIM*0+XX] -= tx;
308 f[j_coord_offset+DIM*0+YY] -= ty;
309 f[j_coord_offset+DIM*0+ZZ] -= tz;
311 /**************************
312 * CALCULATE INTERACTIONS *
313 **************************/
317 /* Calculate table index by multiplying r with table scale and truncate to integer */
323 /* CUBIC SPLINE TABLE ELECTROSTATICS */
326 Geps = vfeps*vftab[vfitab+2];
327 Heps2 = vfeps*vfeps*vftab[vfitab+3];
331 FF = Fp+Geps+2.0*Heps2;
332 felec = -qq01*FF*vftabscale*rinv01;
334 /* Update potential sums from outer loop */
339 /* Calculate temporary vectorial force */
344 /* Update vectorial force */
348 f[j_coord_offset+DIM*1+XX] -= tx;
349 f[j_coord_offset+DIM*1+YY] -= ty;
350 f[j_coord_offset+DIM*1+ZZ] -= tz;
352 /**************************
353 * CALCULATE INTERACTIONS *
354 **************************/
358 /* Calculate table index by multiplying r with table scale and truncate to integer */
364 /* CUBIC SPLINE TABLE ELECTROSTATICS */
367 Geps = vfeps*vftab[vfitab+2];
368 Heps2 = vfeps*vfeps*vftab[vfitab+3];
372 FF = Fp+Geps+2.0*Heps2;
373 felec = -qq02*FF*vftabscale*rinv02;
375 /* Update potential sums from outer loop */
380 /* Calculate temporary vectorial force */
385 /* Update vectorial force */
389 f[j_coord_offset+DIM*2+XX] -= tx;
390 f[j_coord_offset+DIM*2+YY] -= ty;
391 f[j_coord_offset+DIM*2+ZZ] -= tz;
393 /**************************
394 * CALCULATE INTERACTIONS *
395 **************************/
399 /* Calculate table index by multiplying r with table scale and truncate to integer */
405 /* CUBIC SPLINE TABLE ELECTROSTATICS */
408 Geps = vfeps*vftab[vfitab+2];
409 Heps2 = vfeps*vfeps*vftab[vfitab+3];
413 FF = Fp+Geps+2.0*Heps2;
414 felec = -qq10*FF*vftabscale*rinv10;
416 /* Update potential sums from outer loop */
421 /* Calculate temporary vectorial force */
426 /* Update vectorial force */
430 f[j_coord_offset+DIM*0+XX] -= tx;
431 f[j_coord_offset+DIM*0+YY] -= ty;
432 f[j_coord_offset+DIM*0+ZZ] -= tz;
434 /**************************
435 * CALCULATE INTERACTIONS *
436 **************************/
440 /* Calculate table index by multiplying r with table scale and truncate to integer */
446 /* CUBIC SPLINE TABLE ELECTROSTATICS */
449 Geps = vfeps*vftab[vfitab+2];
450 Heps2 = vfeps*vfeps*vftab[vfitab+3];
454 FF = Fp+Geps+2.0*Heps2;
455 felec = -qq11*FF*vftabscale*rinv11;
457 /* Update potential sums from outer loop */
462 /* Calculate temporary vectorial force */
467 /* Update vectorial force */
471 f[j_coord_offset+DIM*1+XX] -= tx;
472 f[j_coord_offset+DIM*1+YY] -= ty;
473 f[j_coord_offset+DIM*1+ZZ] -= tz;
475 /**************************
476 * CALCULATE INTERACTIONS *
477 **************************/
481 /* Calculate table index by multiplying r with table scale and truncate to integer */
487 /* CUBIC SPLINE TABLE ELECTROSTATICS */
490 Geps = vfeps*vftab[vfitab+2];
491 Heps2 = vfeps*vfeps*vftab[vfitab+3];
495 FF = Fp+Geps+2.0*Heps2;
496 felec = -qq12*FF*vftabscale*rinv12;
498 /* Update potential sums from outer loop */
503 /* Calculate temporary vectorial force */
508 /* Update vectorial force */
512 f[j_coord_offset+DIM*2+XX] -= tx;
513 f[j_coord_offset+DIM*2+YY] -= ty;
514 f[j_coord_offset+DIM*2+ZZ] -= tz;
516 /**************************
517 * CALCULATE INTERACTIONS *
518 **************************/
522 /* Calculate table index by multiplying r with table scale and truncate to integer */
528 /* CUBIC SPLINE TABLE ELECTROSTATICS */
531 Geps = vfeps*vftab[vfitab+2];
532 Heps2 = vfeps*vfeps*vftab[vfitab+3];
536 FF = Fp+Geps+2.0*Heps2;
537 felec = -qq20*FF*vftabscale*rinv20;
539 /* Update potential sums from outer loop */
544 /* Calculate temporary vectorial force */
549 /* Update vectorial force */
553 f[j_coord_offset+DIM*0+XX] -= tx;
554 f[j_coord_offset+DIM*0+YY] -= ty;
555 f[j_coord_offset+DIM*0+ZZ] -= tz;
557 /**************************
558 * CALCULATE INTERACTIONS *
559 **************************/
563 /* Calculate table index by multiplying r with table scale and truncate to integer */
569 /* CUBIC SPLINE TABLE ELECTROSTATICS */
572 Geps = vfeps*vftab[vfitab+2];
573 Heps2 = vfeps*vfeps*vftab[vfitab+3];
577 FF = Fp+Geps+2.0*Heps2;
578 felec = -qq21*FF*vftabscale*rinv21;
580 /* Update potential sums from outer loop */
585 /* Calculate temporary vectorial force */
590 /* Update vectorial force */
594 f[j_coord_offset+DIM*1+XX] -= tx;
595 f[j_coord_offset+DIM*1+YY] -= ty;
596 f[j_coord_offset+DIM*1+ZZ] -= tz;
598 /**************************
599 * CALCULATE INTERACTIONS *
600 **************************/
604 /* Calculate table index by multiplying r with table scale and truncate to integer */
610 /* CUBIC SPLINE TABLE ELECTROSTATICS */
613 Geps = vfeps*vftab[vfitab+2];
614 Heps2 = vfeps*vfeps*vftab[vfitab+3];
618 FF = Fp+Geps+2.0*Heps2;
619 felec = -qq22*FF*vftabscale*rinv22;
621 /* Update potential sums from outer loop */
626 /* Calculate temporary vectorial force */
631 /* Update vectorial force */
635 f[j_coord_offset+DIM*2+XX] -= tx;
636 f[j_coord_offset+DIM*2+YY] -= ty;
637 f[j_coord_offset+DIM*2+ZZ] -= tz;
639 /* Inner loop uses 382 flops */
641 /* End of innermost loop */
644 f[i_coord_offset+DIM*0+XX] += fix0;
645 f[i_coord_offset+DIM*0+YY] += fiy0;
646 f[i_coord_offset+DIM*0+ZZ] += fiz0;
650 f[i_coord_offset+DIM*1+XX] += fix1;
651 f[i_coord_offset+DIM*1+YY] += fiy1;
652 f[i_coord_offset+DIM*1+ZZ] += fiz1;
656 f[i_coord_offset+DIM*2+XX] += fix2;
657 f[i_coord_offset+DIM*2+YY] += fiy2;
658 f[i_coord_offset+DIM*2+ZZ] += fiz2;
662 fshift[i_shift_offset+XX] += tx;
663 fshift[i_shift_offset+YY] += ty;
664 fshift[i_shift_offset+ZZ] += tz;
667 /* Update potential energies */
668 kernel_data->energygrp_elec[ggid] += velecsum;
669 kernel_data->energygrp_vdw[ggid] += vvdwsum;
671 /* Increment number of inner iterations */
672 inneriter += j_index_end - j_index_start;
674 /* Outer loop uses 32 flops */
677 /* Increment number of outer iterations */
680 /* Update outer/inner flops */
682 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*382);
685 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW3W3_F_c
686 * Electrostatics interaction: CubicSplineTable
687 * VdW interaction: LennardJones
688 * Geometry: Water3-Water3
689 * Calculate force/pot: Force
692 nb_kernel_ElecCSTab_VdwLJ_GeomW3W3_F_c
693 (t_nblist * gmx_restrict nlist,
694 rvec * gmx_restrict xx,
695 rvec * gmx_restrict ff,
696 t_forcerec * gmx_restrict fr,
697 t_mdatoms * gmx_restrict mdatoms,
698 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
699 t_nrnb * gmx_restrict nrnb)
701 int i_shift_offset,i_coord_offset,j_coord_offset;
702 int j_index_start,j_index_end;
703 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
704 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
705 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
706 real *shiftvec,*fshift,*x,*f;
708 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
710 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
712 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
714 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
716 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
718 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
719 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
720 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
721 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
722 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
723 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
724 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
725 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
726 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
727 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
728 real velec,felec,velecsum,facel,crf,krf,krf2;
731 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
735 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
743 jindex = nlist->jindex;
745 shiftidx = nlist->shift;
747 shiftvec = fr->shift_vec[0];
748 fshift = fr->fshift[0];
750 charge = mdatoms->chargeA;
751 nvdwtype = fr->ntype;
753 vdwtype = mdatoms->typeA;
755 vftab = kernel_data->table_elec->data;
756 vftabscale = kernel_data->table_elec->scale;
758 /* Setup water-specific parameters */
759 inr = nlist->iinr[0];
760 iq0 = facel*charge[inr+0];
761 iq1 = facel*charge[inr+1];
762 iq2 = facel*charge[inr+2];
763 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
768 vdwjidx0 = 2*vdwtype[inr+0];
770 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
771 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
784 /* Start outer loop over neighborlists */
785 for(iidx=0; iidx<nri; iidx++)
787 /* Load shift vector for this list */
788 i_shift_offset = DIM*shiftidx[iidx];
789 shX = shiftvec[i_shift_offset+XX];
790 shY = shiftvec[i_shift_offset+YY];
791 shZ = shiftvec[i_shift_offset+ZZ];
793 /* Load limits for loop over neighbors */
794 j_index_start = jindex[iidx];
795 j_index_end = jindex[iidx+1];
797 /* Get outer coordinate index */
799 i_coord_offset = DIM*inr;
801 /* Load i particle coords and add shift vector */
802 ix0 = shX + x[i_coord_offset+DIM*0+XX];
803 iy0 = shY + x[i_coord_offset+DIM*0+YY];
804 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
805 ix1 = shX + x[i_coord_offset+DIM*1+XX];
806 iy1 = shY + x[i_coord_offset+DIM*1+YY];
807 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
808 ix2 = shX + x[i_coord_offset+DIM*2+XX];
809 iy2 = shY + x[i_coord_offset+DIM*2+YY];
810 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
822 /* Start inner kernel loop */
823 for(jidx=j_index_start; jidx<j_index_end; jidx++)
825 /* Get j neighbor index, and coordinate index */
827 j_coord_offset = DIM*jnr;
829 /* load j atom coordinates */
830 jx0 = x[j_coord_offset+DIM*0+XX];
831 jy0 = x[j_coord_offset+DIM*0+YY];
832 jz0 = x[j_coord_offset+DIM*0+ZZ];
833 jx1 = x[j_coord_offset+DIM*1+XX];
834 jy1 = x[j_coord_offset+DIM*1+YY];
835 jz1 = x[j_coord_offset+DIM*1+ZZ];
836 jx2 = x[j_coord_offset+DIM*2+XX];
837 jy2 = x[j_coord_offset+DIM*2+YY];
838 jz2 = x[j_coord_offset+DIM*2+ZZ];
840 /* Calculate displacement vector */
869 /* Calculate squared distance and things based on it */
870 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
871 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
872 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
873 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
874 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
875 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
876 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
877 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
878 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
880 rinv00 = gmx_invsqrt(rsq00);
881 rinv01 = gmx_invsqrt(rsq01);
882 rinv02 = gmx_invsqrt(rsq02);
883 rinv10 = gmx_invsqrt(rsq10);
884 rinv11 = gmx_invsqrt(rsq11);
885 rinv12 = gmx_invsqrt(rsq12);
886 rinv20 = gmx_invsqrt(rsq20);
887 rinv21 = gmx_invsqrt(rsq21);
888 rinv22 = gmx_invsqrt(rsq22);
890 rinvsq00 = rinv00*rinv00;
892 /**************************
893 * CALCULATE INTERACTIONS *
894 **************************/
898 /* Calculate table index by multiplying r with table scale and truncate to integer */
904 /* CUBIC SPLINE TABLE ELECTROSTATICS */
906 Geps = vfeps*vftab[vfitab+2];
907 Heps2 = vfeps*vfeps*vftab[vfitab+3];
909 FF = Fp+Geps+2.0*Heps2;
910 felec = -qq00*FF*vftabscale*rinv00;
912 /* LENNARD-JONES DISPERSION/REPULSION */
914 rinvsix = rinvsq00*rinvsq00*rinvsq00;
915 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
919 /* Calculate temporary vectorial force */
924 /* Update vectorial force */
928 f[j_coord_offset+DIM*0+XX] -= tx;
929 f[j_coord_offset+DIM*0+YY] -= ty;
930 f[j_coord_offset+DIM*0+ZZ] -= tz;
932 /**************************
933 * CALCULATE INTERACTIONS *
934 **************************/
938 /* Calculate table index by multiplying r with table scale and truncate to integer */
944 /* CUBIC SPLINE TABLE ELECTROSTATICS */
946 Geps = vfeps*vftab[vfitab+2];
947 Heps2 = vfeps*vfeps*vftab[vfitab+3];
949 FF = Fp+Geps+2.0*Heps2;
950 felec = -qq01*FF*vftabscale*rinv01;
954 /* Calculate temporary vectorial force */
959 /* Update vectorial force */
963 f[j_coord_offset+DIM*1+XX] -= tx;
964 f[j_coord_offset+DIM*1+YY] -= ty;
965 f[j_coord_offset+DIM*1+ZZ] -= tz;
967 /**************************
968 * CALCULATE INTERACTIONS *
969 **************************/
973 /* Calculate table index by multiplying r with table scale and truncate to integer */
979 /* CUBIC SPLINE TABLE ELECTROSTATICS */
981 Geps = vfeps*vftab[vfitab+2];
982 Heps2 = vfeps*vfeps*vftab[vfitab+3];
984 FF = Fp+Geps+2.0*Heps2;
985 felec = -qq02*FF*vftabscale*rinv02;
989 /* Calculate temporary vectorial force */
994 /* Update vectorial force */
998 f[j_coord_offset+DIM*2+XX] -= tx;
999 f[j_coord_offset+DIM*2+YY] -= ty;
1000 f[j_coord_offset+DIM*2+ZZ] -= tz;
1002 /**************************
1003 * CALCULATE INTERACTIONS *
1004 **************************/
1008 /* Calculate table index by multiplying r with table scale and truncate to integer */
1009 rt = r10*vftabscale;
1012 vfitab = 1*4*vfitab;
1014 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1015 F = vftab[vfitab+1];
1016 Geps = vfeps*vftab[vfitab+2];
1017 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1019 FF = Fp+Geps+2.0*Heps2;
1020 felec = -qq10*FF*vftabscale*rinv10;
1024 /* Calculate temporary vectorial force */
1029 /* Update vectorial force */
1033 f[j_coord_offset+DIM*0+XX] -= tx;
1034 f[j_coord_offset+DIM*0+YY] -= ty;
1035 f[j_coord_offset+DIM*0+ZZ] -= tz;
1037 /**************************
1038 * CALCULATE INTERACTIONS *
1039 **************************/
1043 /* Calculate table index by multiplying r with table scale and truncate to integer */
1044 rt = r11*vftabscale;
1047 vfitab = 1*4*vfitab;
1049 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1050 F = vftab[vfitab+1];
1051 Geps = vfeps*vftab[vfitab+2];
1052 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1054 FF = Fp+Geps+2.0*Heps2;
1055 felec = -qq11*FF*vftabscale*rinv11;
1059 /* Calculate temporary vectorial force */
1064 /* Update vectorial force */
1068 f[j_coord_offset+DIM*1+XX] -= tx;
1069 f[j_coord_offset+DIM*1+YY] -= ty;
1070 f[j_coord_offset+DIM*1+ZZ] -= tz;
1072 /**************************
1073 * CALCULATE INTERACTIONS *
1074 **************************/
1078 /* Calculate table index by multiplying r with table scale and truncate to integer */
1079 rt = r12*vftabscale;
1082 vfitab = 1*4*vfitab;
1084 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1085 F = vftab[vfitab+1];
1086 Geps = vfeps*vftab[vfitab+2];
1087 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1089 FF = Fp+Geps+2.0*Heps2;
1090 felec = -qq12*FF*vftabscale*rinv12;
1094 /* Calculate temporary vectorial force */
1099 /* Update vectorial force */
1103 f[j_coord_offset+DIM*2+XX] -= tx;
1104 f[j_coord_offset+DIM*2+YY] -= ty;
1105 f[j_coord_offset+DIM*2+ZZ] -= tz;
1107 /**************************
1108 * CALCULATE INTERACTIONS *
1109 **************************/
1113 /* Calculate table index by multiplying r with table scale and truncate to integer */
1114 rt = r20*vftabscale;
1117 vfitab = 1*4*vfitab;
1119 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1120 F = vftab[vfitab+1];
1121 Geps = vfeps*vftab[vfitab+2];
1122 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1124 FF = Fp+Geps+2.0*Heps2;
1125 felec = -qq20*FF*vftabscale*rinv20;
1129 /* Calculate temporary vectorial force */
1134 /* Update vectorial force */
1138 f[j_coord_offset+DIM*0+XX] -= tx;
1139 f[j_coord_offset+DIM*0+YY] -= ty;
1140 f[j_coord_offset+DIM*0+ZZ] -= tz;
1142 /**************************
1143 * CALCULATE INTERACTIONS *
1144 **************************/
1148 /* Calculate table index by multiplying r with table scale and truncate to integer */
1149 rt = r21*vftabscale;
1152 vfitab = 1*4*vfitab;
1154 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1155 F = vftab[vfitab+1];
1156 Geps = vfeps*vftab[vfitab+2];
1157 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1159 FF = Fp+Geps+2.0*Heps2;
1160 felec = -qq21*FF*vftabscale*rinv21;
1164 /* Calculate temporary vectorial force */
1169 /* Update vectorial force */
1173 f[j_coord_offset+DIM*1+XX] -= tx;
1174 f[j_coord_offset+DIM*1+YY] -= ty;
1175 f[j_coord_offset+DIM*1+ZZ] -= tz;
1177 /**************************
1178 * CALCULATE INTERACTIONS *
1179 **************************/
1183 /* Calculate table index by multiplying r with table scale and truncate to integer */
1184 rt = r22*vftabscale;
1187 vfitab = 1*4*vfitab;
1189 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1190 F = vftab[vfitab+1];
1191 Geps = vfeps*vftab[vfitab+2];
1192 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1194 FF = Fp+Geps+2.0*Heps2;
1195 felec = -qq22*FF*vftabscale*rinv22;
1199 /* Calculate temporary vectorial force */
1204 /* Update vectorial force */
1208 f[j_coord_offset+DIM*2+XX] -= tx;
1209 f[j_coord_offset+DIM*2+YY] -= ty;
1210 f[j_coord_offset+DIM*2+ZZ] -= tz;
1212 /* Inner loop uses 341 flops */
1214 /* End of innermost loop */
1217 f[i_coord_offset+DIM*0+XX] += fix0;
1218 f[i_coord_offset+DIM*0+YY] += fiy0;
1219 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1223 f[i_coord_offset+DIM*1+XX] += fix1;
1224 f[i_coord_offset+DIM*1+YY] += fiy1;
1225 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1229 f[i_coord_offset+DIM*2+XX] += fix2;
1230 f[i_coord_offset+DIM*2+YY] += fiy2;
1231 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1235 fshift[i_shift_offset+XX] += tx;
1236 fshift[i_shift_offset+YY] += ty;
1237 fshift[i_shift_offset+ZZ] += tz;
1239 /* Increment number of inner iterations */
1240 inneriter += j_index_end - j_index_start;
1242 /* Outer loop uses 30 flops */
1245 /* Increment number of outer iterations */
1248 /* Update outer/inner flops */
1250 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*341);