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_VdwLJ_GeomW3W3_VF_c
49 * Electrostatics interaction: CubicSplineTable
50 * VdW interaction: LennardJones
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCSTab_VdwLJ_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->data;
119 vftabscale = kernel_data->table_elec->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 rinvsq00 = rinv00*rinv00;
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 /* LENNARD-JONES DISPERSION/REPULSION */
284 rinvsix = rinvsq00*rinvsq00*rinvsq00;
285 vvdw6 = c6_00*rinvsix;
286 vvdw12 = c12_00*rinvsix*rinvsix;
287 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
288 fvdw = (vvdw12-vvdw6)*rinvsq00;
290 /* Update potential sums from outer loop */
296 /* Calculate temporary vectorial force */
301 /* Update vectorial force */
305 f[j_coord_offset+DIM*0+XX] -= tx;
306 f[j_coord_offset+DIM*0+YY] -= ty;
307 f[j_coord_offset+DIM*0+ZZ] -= tz;
309 /**************************
310 * CALCULATE INTERACTIONS *
311 **************************/
315 /* Calculate table index by multiplying r with table scale and truncate to integer */
321 /* CUBIC SPLINE TABLE ELECTROSTATICS */
324 Geps = vfeps*vftab[vfitab+2];
325 Heps2 = vfeps*vfeps*vftab[vfitab+3];
329 FF = Fp+Geps+2.0*Heps2;
330 felec = -qq01*FF*vftabscale*rinv01;
332 /* Update potential sums from outer loop */
337 /* Calculate temporary vectorial force */
342 /* Update vectorial force */
346 f[j_coord_offset+DIM*1+XX] -= tx;
347 f[j_coord_offset+DIM*1+YY] -= ty;
348 f[j_coord_offset+DIM*1+ZZ] -= tz;
350 /**************************
351 * CALCULATE INTERACTIONS *
352 **************************/
356 /* Calculate table index by multiplying r with table scale and truncate to integer */
362 /* CUBIC SPLINE TABLE ELECTROSTATICS */
365 Geps = vfeps*vftab[vfitab+2];
366 Heps2 = vfeps*vfeps*vftab[vfitab+3];
370 FF = Fp+Geps+2.0*Heps2;
371 felec = -qq02*FF*vftabscale*rinv02;
373 /* Update potential sums from outer loop */
378 /* Calculate temporary vectorial force */
383 /* Update vectorial force */
387 f[j_coord_offset+DIM*2+XX] -= tx;
388 f[j_coord_offset+DIM*2+YY] -= ty;
389 f[j_coord_offset+DIM*2+ZZ] -= tz;
391 /**************************
392 * CALCULATE INTERACTIONS *
393 **************************/
397 /* Calculate table index by multiplying r with table scale and truncate to integer */
403 /* CUBIC SPLINE TABLE ELECTROSTATICS */
406 Geps = vfeps*vftab[vfitab+2];
407 Heps2 = vfeps*vfeps*vftab[vfitab+3];
411 FF = Fp+Geps+2.0*Heps2;
412 felec = -qq10*FF*vftabscale*rinv10;
414 /* Update potential sums from outer loop */
419 /* Calculate temporary vectorial force */
424 /* Update vectorial force */
428 f[j_coord_offset+DIM*0+XX] -= tx;
429 f[j_coord_offset+DIM*0+YY] -= ty;
430 f[j_coord_offset+DIM*0+ZZ] -= tz;
432 /**************************
433 * CALCULATE INTERACTIONS *
434 **************************/
438 /* Calculate table index by multiplying r with table scale and truncate to integer */
444 /* CUBIC SPLINE TABLE ELECTROSTATICS */
447 Geps = vfeps*vftab[vfitab+2];
448 Heps2 = vfeps*vfeps*vftab[vfitab+3];
452 FF = Fp+Geps+2.0*Heps2;
453 felec = -qq11*FF*vftabscale*rinv11;
455 /* Update potential sums from outer loop */
460 /* Calculate temporary vectorial force */
465 /* Update vectorial force */
469 f[j_coord_offset+DIM*1+XX] -= tx;
470 f[j_coord_offset+DIM*1+YY] -= ty;
471 f[j_coord_offset+DIM*1+ZZ] -= tz;
473 /**************************
474 * CALCULATE INTERACTIONS *
475 **************************/
479 /* Calculate table index by multiplying r with table scale and truncate to integer */
485 /* CUBIC SPLINE TABLE ELECTROSTATICS */
488 Geps = vfeps*vftab[vfitab+2];
489 Heps2 = vfeps*vfeps*vftab[vfitab+3];
493 FF = Fp+Geps+2.0*Heps2;
494 felec = -qq12*FF*vftabscale*rinv12;
496 /* Update potential sums from outer loop */
501 /* Calculate temporary vectorial force */
506 /* Update vectorial force */
510 f[j_coord_offset+DIM*2+XX] -= tx;
511 f[j_coord_offset+DIM*2+YY] -= ty;
512 f[j_coord_offset+DIM*2+ZZ] -= tz;
514 /**************************
515 * CALCULATE INTERACTIONS *
516 **************************/
520 /* Calculate table index by multiplying r with table scale and truncate to integer */
526 /* CUBIC SPLINE TABLE ELECTROSTATICS */
529 Geps = vfeps*vftab[vfitab+2];
530 Heps2 = vfeps*vfeps*vftab[vfitab+3];
534 FF = Fp+Geps+2.0*Heps2;
535 felec = -qq20*FF*vftabscale*rinv20;
537 /* Update potential sums from outer loop */
542 /* Calculate temporary vectorial force */
547 /* Update vectorial force */
551 f[j_coord_offset+DIM*0+XX] -= tx;
552 f[j_coord_offset+DIM*0+YY] -= ty;
553 f[j_coord_offset+DIM*0+ZZ] -= tz;
555 /**************************
556 * CALCULATE INTERACTIONS *
557 **************************/
561 /* Calculate table index by multiplying r with table scale and truncate to integer */
567 /* CUBIC SPLINE TABLE ELECTROSTATICS */
570 Geps = vfeps*vftab[vfitab+2];
571 Heps2 = vfeps*vfeps*vftab[vfitab+3];
575 FF = Fp+Geps+2.0*Heps2;
576 felec = -qq21*FF*vftabscale*rinv21;
578 /* Update potential sums from outer loop */
583 /* Calculate temporary vectorial force */
588 /* Update vectorial force */
592 f[j_coord_offset+DIM*1+XX] -= tx;
593 f[j_coord_offset+DIM*1+YY] -= ty;
594 f[j_coord_offset+DIM*1+ZZ] -= tz;
596 /**************************
597 * CALCULATE INTERACTIONS *
598 **************************/
602 /* Calculate table index by multiplying r with table scale and truncate to integer */
608 /* CUBIC SPLINE TABLE ELECTROSTATICS */
611 Geps = vfeps*vftab[vfitab+2];
612 Heps2 = vfeps*vfeps*vftab[vfitab+3];
616 FF = Fp+Geps+2.0*Heps2;
617 felec = -qq22*FF*vftabscale*rinv22;
619 /* Update potential sums from outer loop */
624 /* Calculate temporary vectorial force */
629 /* Update vectorial force */
633 f[j_coord_offset+DIM*2+XX] -= tx;
634 f[j_coord_offset+DIM*2+YY] -= ty;
635 f[j_coord_offset+DIM*2+ZZ] -= tz;
637 /* Inner loop uses 382 flops */
639 /* End of innermost loop */
642 f[i_coord_offset+DIM*0+XX] += fix0;
643 f[i_coord_offset+DIM*0+YY] += fiy0;
644 f[i_coord_offset+DIM*0+ZZ] += fiz0;
648 f[i_coord_offset+DIM*1+XX] += fix1;
649 f[i_coord_offset+DIM*1+YY] += fiy1;
650 f[i_coord_offset+DIM*1+ZZ] += fiz1;
654 f[i_coord_offset+DIM*2+XX] += fix2;
655 f[i_coord_offset+DIM*2+YY] += fiy2;
656 f[i_coord_offset+DIM*2+ZZ] += fiz2;
660 fshift[i_shift_offset+XX] += tx;
661 fshift[i_shift_offset+YY] += ty;
662 fshift[i_shift_offset+ZZ] += tz;
665 /* Update potential energies */
666 kernel_data->energygrp_elec[ggid] += velecsum;
667 kernel_data->energygrp_vdw[ggid] += vvdwsum;
669 /* Increment number of inner iterations */
670 inneriter += j_index_end - j_index_start;
672 /* Outer loop uses 32 flops */
675 /* Increment number of outer iterations */
678 /* Update outer/inner flops */
680 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*382);
683 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW3W3_F_c
684 * Electrostatics interaction: CubicSplineTable
685 * VdW interaction: LennardJones
686 * Geometry: Water3-Water3
687 * Calculate force/pot: Force
690 nb_kernel_ElecCSTab_VdwLJ_GeomW3W3_F_c
691 (t_nblist * gmx_restrict nlist,
692 rvec * gmx_restrict xx,
693 rvec * gmx_restrict ff,
694 t_forcerec * gmx_restrict fr,
695 t_mdatoms * gmx_restrict mdatoms,
696 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
697 t_nrnb * gmx_restrict nrnb)
699 int i_shift_offset,i_coord_offset,j_coord_offset;
700 int j_index_start,j_index_end;
701 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
702 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
703 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
704 real *shiftvec,*fshift,*x,*f;
706 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
708 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
710 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
712 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
714 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
716 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
717 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
718 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
719 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
720 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
721 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
722 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
723 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
724 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
725 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
726 real velec,felec,velecsum,facel,crf,krf,krf2;
729 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
733 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
741 jindex = nlist->jindex;
743 shiftidx = nlist->shift;
745 shiftvec = fr->shift_vec[0];
746 fshift = fr->fshift[0];
748 charge = mdatoms->chargeA;
749 nvdwtype = fr->ntype;
751 vdwtype = mdatoms->typeA;
753 vftab = kernel_data->table_elec->data;
754 vftabscale = kernel_data->table_elec->scale;
756 /* Setup water-specific parameters */
757 inr = nlist->iinr[0];
758 iq0 = facel*charge[inr+0];
759 iq1 = facel*charge[inr+1];
760 iq2 = facel*charge[inr+2];
761 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
766 vdwjidx0 = 2*vdwtype[inr+0];
768 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
769 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
782 /* Start outer loop over neighborlists */
783 for(iidx=0; iidx<nri; iidx++)
785 /* Load shift vector for this list */
786 i_shift_offset = DIM*shiftidx[iidx];
787 shX = shiftvec[i_shift_offset+XX];
788 shY = shiftvec[i_shift_offset+YY];
789 shZ = shiftvec[i_shift_offset+ZZ];
791 /* Load limits for loop over neighbors */
792 j_index_start = jindex[iidx];
793 j_index_end = jindex[iidx+1];
795 /* Get outer coordinate index */
797 i_coord_offset = DIM*inr;
799 /* Load i particle coords and add shift vector */
800 ix0 = shX + x[i_coord_offset+DIM*0+XX];
801 iy0 = shY + x[i_coord_offset+DIM*0+YY];
802 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
803 ix1 = shX + x[i_coord_offset+DIM*1+XX];
804 iy1 = shY + x[i_coord_offset+DIM*1+YY];
805 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
806 ix2 = shX + x[i_coord_offset+DIM*2+XX];
807 iy2 = shY + x[i_coord_offset+DIM*2+YY];
808 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
820 /* Start inner kernel loop */
821 for(jidx=j_index_start; jidx<j_index_end; jidx++)
823 /* Get j neighbor index, and coordinate index */
825 j_coord_offset = DIM*jnr;
827 /* load j atom coordinates */
828 jx0 = x[j_coord_offset+DIM*0+XX];
829 jy0 = x[j_coord_offset+DIM*0+YY];
830 jz0 = x[j_coord_offset+DIM*0+ZZ];
831 jx1 = x[j_coord_offset+DIM*1+XX];
832 jy1 = x[j_coord_offset+DIM*1+YY];
833 jz1 = x[j_coord_offset+DIM*1+ZZ];
834 jx2 = x[j_coord_offset+DIM*2+XX];
835 jy2 = x[j_coord_offset+DIM*2+YY];
836 jz2 = x[j_coord_offset+DIM*2+ZZ];
838 /* Calculate displacement vector */
867 /* Calculate squared distance and things based on it */
868 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
869 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
870 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
871 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
872 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
873 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
874 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
875 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
876 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
878 rinv00 = gmx_invsqrt(rsq00);
879 rinv01 = gmx_invsqrt(rsq01);
880 rinv02 = gmx_invsqrt(rsq02);
881 rinv10 = gmx_invsqrt(rsq10);
882 rinv11 = gmx_invsqrt(rsq11);
883 rinv12 = gmx_invsqrt(rsq12);
884 rinv20 = gmx_invsqrt(rsq20);
885 rinv21 = gmx_invsqrt(rsq21);
886 rinv22 = gmx_invsqrt(rsq22);
888 rinvsq00 = rinv00*rinv00;
890 /**************************
891 * CALCULATE INTERACTIONS *
892 **************************/
896 /* Calculate table index by multiplying r with table scale and truncate to integer */
902 /* CUBIC SPLINE TABLE ELECTROSTATICS */
904 Geps = vfeps*vftab[vfitab+2];
905 Heps2 = vfeps*vfeps*vftab[vfitab+3];
907 FF = Fp+Geps+2.0*Heps2;
908 felec = -qq00*FF*vftabscale*rinv00;
910 /* LENNARD-JONES DISPERSION/REPULSION */
912 rinvsix = rinvsq00*rinvsq00*rinvsq00;
913 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
917 /* Calculate temporary vectorial force */
922 /* Update vectorial force */
926 f[j_coord_offset+DIM*0+XX] -= tx;
927 f[j_coord_offset+DIM*0+YY] -= ty;
928 f[j_coord_offset+DIM*0+ZZ] -= tz;
930 /**************************
931 * CALCULATE INTERACTIONS *
932 **************************/
936 /* Calculate table index by multiplying r with table scale and truncate to integer */
942 /* CUBIC SPLINE TABLE ELECTROSTATICS */
944 Geps = vfeps*vftab[vfitab+2];
945 Heps2 = vfeps*vfeps*vftab[vfitab+3];
947 FF = Fp+Geps+2.0*Heps2;
948 felec = -qq01*FF*vftabscale*rinv01;
952 /* Calculate temporary vectorial force */
957 /* Update vectorial force */
961 f[j_coord_offset+DIM*1+XX] -= tx;
962 f[j_coord_offset+DIM*1+YY] -= ty;
963 f[j_coord_offset+DIM*1+ZZ] -= tz;
965 /**************************
966 * CALCULATE INTERACTIONS *
967 **************************/
971 /* Calculate table index by multiplying r with table scale and truncate to integer */
977 /* CUBIC SPLINE TABLE ELECTROSTATICS */
979 Geps = vfeps*vftab[vfitab+2];
980 Heps2 = vfeps*vfeps*vftab[vfitab+3];
982 FF = Fp+Geps+2.0*Heps2;
983 felec = -qq02*FF*vftabscale*rinv02;
987 /* Calculate temporary vectorial force */
992 /* Update vectorial force */
996 f[j_coord_offset+DIM*2+XX] -= tx;
997 f[j_coord_offset+DIM*2+YY] -= ty;
998 f[j_coord_offset+DIM*2+ZZ] -= tz;
1000 /**************************
1001 * CALCULATE INTERACTIONS *
1002 **************************/
1006 /* Calculate table index by multiplying r with table scale and truncate to integer */
1007 rt = r10*vftabscale;
1010 vfitab = 1*4*vfitab;
1012 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1013 F = vftab[vfitab+1];
1014 Geps = vfeps*vftab[vfitab+2];
1015 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1017 FF = Fp+Geps+2.0*Heps2;
1018 felec = -qq10*FF*vftabscale*rinv10;
1022 /* Calculate temporary vectorial force */
1027 /* Update vectorial force */
1031 f[j_coord_offset+DIM*0+XX] -= tx;
1032 f[j_coord_offset+DIM*0+YY] -= ty;
1033 f[j_coord_offset+DIM*0+ZZ] -= tz;
1035 /**************************
1036 * CALCULATE INTERACTIONS *
1037 **************************/
1041 /* Calculate table index by multiplying r with table scale and truncate to integer */
1042 rt = r11*vftabscale;
1045 vfitab = 1*4*vfitab;
1047 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1048 F = vftab[vfitab+1];
1049 Geps = vfeps*vftab[vfitab+2];
1050 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1052 FF = Fp+Geps+2.0*Heps2;
1053 felec = -qq11*FF*vftabscale*rinv11;
1057 /* Calculate temporary vectorial force */
1062 /* Update vectorial force */
1066 f[j_coord_offset+DIM*1+XX] -= tx;
1067 f[j_coord_offset+DIM*1+YY] -= ty;
1068 f[j_coord_offset+DIM*1+ZZ] -= tz;
1070 /**************************
1071 * CALCULATE INTERACTIONS *
1072 **************************/
1076 /* Calculate table index by multiplying r with table scale and truncate to integer */
1077 rt = r12*vftabscale;
1080 vfitab = 1*4*vfitab;
1082 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1083 F = vftab[vfitab+1];
1084 Geps = vfeps*vftab[vfitab+2];
1085 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1087 FF = Fp+Geps+2.0*Heps2;
1088 felec = -qq12*FF*vftabscale*rinv12;
1092 /* Calculate temporary vectorial force */
1097 /* Update vectorial force */
1101 f[j_coord_offset+DIM*2+XX] -= tx;
1102 f[j_coord_offset+DIM*2+YY] -= ty;
1103 f[j_coord_offset+DIM*2+ZZ] -= tz;
1105 /**************************
1106 * CALCULATE INTERACTIONS *
1107 **************************/
1111 /* Calculate table index by multiplying r with table scale and truncate to integer */
1112 rt = r20*vftabscale;
1115 vfitab = 1*4*vfitab;
1117 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1118 F = vftab[vfitab+1];
1119 Geps = vfeps*vftab[vfitab+2];
1120 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1122 FF = Fp+Geps+2.0*Heps2;
1123 felec = -qq20*FF*vftabscale*rinv20;
1127 /* Calculate temporary vectorial force */
1132 /* Update vectorial force */
1136 f[j_coord_offset+DIM*0+XX] -= tx;
1137 f[j_coord_offset+DIM*0+YY] -= ty;
1138 f[j_coord_offset+DIM*0+ZZ] -= tz;
1140 /**************************
1141 * CALCULATE INTERACTIONS *
1142 **************************/
1146 /* Calculate table index by multiplying r with table scale and truncate to integer */
1147 rt = r21*vftabscale;
1150 vfitab = 1*4*vfitab;
1152 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1153 F = vftab[vfitab+1];
1154 Geps = vfeps*vftab[vfitab+2];
1155 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1157 FF = Fp+Geps+2.0*Heps2;
1158 felec = -qq21*FF*vftabscale*rinv21;
1162 /* Calculate temporary vectorial force */
1167 /* Update vectorial force */
1171 f[j_coord_offset+DIM*1+XX] -= tx;
1172 f[j_coord_offset+DIM*1+YY] -= ty;
1173 f[j_coord_offset+DIM*1+ZZ] -= tz;
1175 /**************************
1176 * CALCULATE INTERACTIONS *
1177 **************************/
1181 /* Calculate table index by multiplying r with table scale and truncate to integer */
1182 rt = r22*vftabscale;
1185 vfitab = 1*4*vfitab;
1187 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1188 F = vftab[vfitab+1];
1189 Geps = vfeps*vftab[vfitab+2];
1190 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1192 FF = Fp+Geps+2.0*Heps2;
1193 felec = -qq22*FF*vftabscale*rinv22;
1197 /* Calculate temporary vectorial force */
1202 /* Update vectorial force */
1206 f[j_coord_offset+DIM*2+XX] -= tx;
1207 f[j_coord_offset+DIM*2+YY] -= ty;
1208 f[j_coord_offset+DIM*2+ZZ] -= tz;
1210 /* Inner loop uses 341 flops */
1212 /* End of innermost loop */
1215 f[i_coord_offset+DIM*0+XX] += fix0;
1216 f[i_coord_offset+DIM*0+YY] += fiy0;
1217 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1221 f[i_coord_offset+DIM*1+XX] += fix1;
1222 f[i_coord_offset+DIM*1+YY] += fiy1;
1223 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1227 f[i_coord_offset+DIM*2+XX] += fix2;
1228 f[i_coord_offset+DIM*2+YY] += fiy2;
1229 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1233 fshift[i_shift_offset+XX] += tx;
1234 fshift[i_shift_offset+YY] += ty;
1235 fshift[i_shift_offset+ZZ] += tz;
1237 /* Increment number of inner iterations */
1238 inneriter += j_index_end - j_index_start;
1240 /* Outer loop uses 30 flops */
1243 /* Increment number of outer iterations */
1246 /* Update outer/inner flops */
1248 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*341);