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_GeomW4W4_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
85 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
87 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
88 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
89 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
90 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
91 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
92 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
93 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
94 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
95 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
96 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
97 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
98 real velec,felec,velecsum,facel,crf,krf,krf2;
101 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
105 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
113 jindex = nlist->jindex;
115 shiftidx = nlist->shift;
117 shiftvec = fr->shift_vec[0];
118 fshift = fr->fshift[0];
120 charge = mdatoms->chargeA;
121 nvdwtype = fr->ntype;
123 vdwtype = mdatoms->typeA;
125 vftab = kernel_data->table_elec_vdw->data;
126 vftabscale = kernel_data->table_elec_vdw->scale;
128 /* Setup water-specific parameters */
129 inr = nlist->iinr[0];
130 iq1 = facel*charge[inr+1];
131 iq2 = facel*charge[inr+2];
132 iq3 = facel*charge[inr+3];
133 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
138 vdwjidx0 = 2*vdwtype[inr+0];
139 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
140 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
154 /* Start outer loop over neighborlists */
155 for(iidx=0; iidx<nri; iidx++)
157 /* Load shift vector for this list */
158 i_shift_offset = DIM*shiftidx[iidx];
159 shX = shiftvec[i_shift_offset+XX];
160 shY = shiftvec[i_shift_offset+YY];
161 shZ = shiftvec[i_shift_offset+ZZ];
163 /* Load limits for loop over neighbors */
164 j_index_start = jindex[iidx];
165 j_index_end = jindex[iidx+1];
167 /* Get outer coordinate index */
169 i_coord_offset = DIM*inr;
171 /* Load i particle coords and add shift vector */
172 ix0 = shX + x[i_coord_offset+DIM*0+XX];
173 iy0 = shY + x[i_coord_offset+DIM*0+YY];
174 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
175 ix1 = shX + x[i_coord_offset+DIM*1+XX];
176 iy1 = shY + x[i_coord_offset+DIM*1+YY];
177 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
178 ix2 = shX + x[i_coord_offset+DIM*2+XX];
179 iy2 = shY + x[i_coord_offset+DIM*2+YY];
180 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
181 ix3 = shX + x[i_coord_offset+DIM*3+XX];
182 iy3 = shY + x[i_coord_offset+DIM*3+YY];
183 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
198 /* Reset potential sums */
202 /* Start inner kernel loop */
203 for(jidx=j_index_start; jidx<j_index_end; jidx++)
205 /* Get j neighbor index, and coordinate index */
207 j_coord_offset = DIM*jnr;
209 /* load j atom coordinates */
210 jx0 = x[j_coord_offset+DIM*0+XX];
211 jy0 = x[j_coord_offset+DIM*0+YY];
212 jz0 = x[j_coord_offset+DIM*0+ZZ];
213 jx1 = x[j_coord_offset+DIM*1+XX];
214 jy1 = x[j_coord_offset+DIM*1+YY];
215 jz1 = x[j_coord_offset+DIM*1+ZZ];
216 jx2 = x[j_coord_offset+DIM*2+XX];
217 jy2 = x[j_coord_offset+DIM*2+YY];
218 jz2 = x[j_coord_offset+DIM*2+ZZ];
219 jx3 = x[j_coord_offset+DIM*3+XX];
220 jy3 = x[j_coord_offset+DIM*3+YY];
221 jz3 = x[j_coord_offset+DIM*3+ZZ];
223 /* Calculate displacement vector */
255 /* Calculate squared distance and things based on it */
256 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
257 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
258 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
259 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
260 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
261 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
262 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
263 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
264 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
265 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
267 rinv00 = gmx_invsqrt(rsq00);
268 rinv11 = gmx_invsqrt(rsq11);
269 rinv12 = gmx_invsqrt(rsq12);
270 rinv13 = gmx_invsqrt(rsq13);
271 rinv21 = gmx_invsqrt(rsq21);
272 rinv22 = gmx_invsqrt(rsq22);
273 rinv23 = gmx_invsqrt(rsq23);
274 rinv31 = gmx_invsqrt(rsq31);
275 rinv32 = gmx_invsqrt(rsq32);
276 rinv33 = gmx_invsqrt(rsq33);
278 /**************************
279 * CALCULATE INTERACTIONS *
280 **************************/
284 /* Calculate table index by multiplying r with table scale and truncate to integer */
290 /* CUBIC SPLINE TABLE DISPERSION */
294 Geps = vfeps*vftab[vfitab+2];
295 Heps2 = vfeps*vfeps*vftab[vfitab+3];
299 FF = Fp+Geps+2.0*Heps2;
302 /* CUBIC SPLINE TABLE REPULSION */
305 Geps = vfeps*vftab[vfitab+6];
306 Heps2 = vfeps*vfeps*vftab[vfitab+7];
310 FF = Fp+Geps+2.0*Heps2;
313 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
315 /* Update potential sums from outer loop */
320 /* Calculate temporary vectorial force */
325 /* Update vectorial force */
329 f[j_coord_offset+DIM*0+XX] -= tx;
330 f[j_coord_offset+DIM*0+YY] -= ty;
331 f[j_coord_offset+DIM*0+ZZ] -= tz;
333 /**************************
334 * CALCULATE INTERACTIONS *
335 **************************/
339 /* Calculate table index by multiplying r with table scale and truncate to integer */
345 /* CUBIC SPLINE TABLE ELECTROSTATICS */
348 Geps = vfeps*vftab[vfitab+2];
349 Heps2 = vfeps*vfeps*vftab[vfitab+3];
353 FF = Fp+Geps+2.0*Heps2;
354 felec = -qq11*FF*vftabscale*rinv11;
356 /* Update potential sums from outer loop */
361 /* Calculate temporary vectorial force */
366 /* Update vectorial force */
370 f[j_coord_offset+DIM*1+XX] -= tx;
371 f[j_coord_offset+DIM*1+YY] -= ty;
372 f[j_coord_offset+DIM*1+ZZ] -= tz;
374 /**************************
375 * CALCULATE INTERACTIONS *
376 **************************/
380 /* Calculate table index by multiplying r with table scale and truncate to integer */
386 /* CUBIC SPLINE TABLE ELECTROSTATICS */
389 Geps = vfeps*vftab[vfitab+2];
390 Heps2 = vfeps*vfeps*vftab[vfitab+3];
394 FF = Fp+Geps+2.0*Heps2;
395 felec = -qq12*FF*vftabscale*rinv12;
397 /* Update potential sums from outer loop */
402 /* Calculate temporary vectorial force */
407 /* Update vectorial force */
411 f[j_coord_offset+DIM*2+XX] -= tx;
412 f[j_coord_offset+DIM*2+YY] -= ty;
413 f[j_coord_offset+DIM*2+ZZ] -= tz;
415 /**************************
416 * CALCULATE INTERACTIONS *
417 **************************/
421 /* Calculate table index by multiplying r with table scale and truncate to integer */
427 /* CUBIC SPLINE TABLE ELECTROSTATICS */
430 Geps = vfeps*vftab[vfitab+2];
431 Heps2 = vfeps*vfeps*vftab[vfitab+3];
435 FF = Fp+Geps+2.0*Heps2;
436 felec = -qq13*FF*vftabscale*rinv13;
438 /* Update potential sums from outer loop */
443 /* Calculate temporary vectorial force */
448 /* Update vectorial force */
452 f[j_coord_offset+DIM*3+XX] -= tx;
453 f[j_coord_offset+DIM*3+YY] -= ty;
454 f[j_coord_offset+DIM*3+ZZ] -= tz;
456 /**************************
457 * CALCULATE INTERACTIONS *
458 **************************/
462 /* Calculate table index by multiplying r with table scale and truncate to integer */
468 /* CUBIC SPLINE TABLE ELECTROSTATICS */
471 Geps = vfeps*vftab[vfitab+2];
472 Heps2 = vfeps*vfeps*vftab[vfitab+3];
476 FF = Fp+Geps+2.0*Heps2;
477 felec = -qq21*FF*vftabscale*rinv21;
479 /* Update potential sums from outer loop */
484 /* Calculate temporary vectorial force */
489 /* Update vectorial force */
493 f[j_coord_offset+DIM*1+XX] -= tx;
494 f[j_coord_offset+DIM*1+YY] -= ty;
495 f[j_coord_offset+DIM*1+ZZ] -= tz;
497 /**************************
498 * CALCULATE INTERACTIONS *
499 **************************/
503 /* Calculate table index by multiplying r with table scale and truncate to integer */
509 /* CUBIC SPLINE TABLE ELECTROSTATICS */
512 Geps = vfeps*vftab[vfitab+2];
513 Heps2 = vfeps*vfeps*vftab[vfitab+3];
517 FF = Fp+Geps+2.0*Heps2;
518 felec = -qq22*FF*vftabscale*rinv22;
520 /* Update potential sums from outer loop */
525 /* Calculate temporary vectorial force */
530 /* Update vectorial force */
534 f[j_coord_offset+DIM*2+XX] -= tx;
535 f[j_coord_offset+DIM*2+YY] -= ty;
536 f[j_coord_offset+DIM*2+ZZ] -= tz;
538 /**************************
539 * CALCULATE INTERACTIONS *
540 **************************/
544 /* Calculate table index by multiplying r with table scale and truncate to integer */
550 /* CUBIC SPLINE TABLE ELECTROSTATICS */
553 Geps = vfeps*vftab[vfitab+2];
554 Heps2 = vfeps*vfeps*vftab[vfitab+3];
558 FF = Fp+Geps+2.0*Heps2;
559 felec = -qq23*FF*vftabscale*rinv23;
561 /* Update potential sums from outer loop */
566 /* Calculate temporary vectorial force */
571 /* Update vectorial force */
575 f[j_coord_offset+DIM*3+XX] -= tx;
576 f[j_coord_offset+DIM*3+YY] -= ty;
577 f[j_coord_offset+DIM*3+ZZ] -= tz;
579 /**************************
580 * CALCULATE INTERACTIONS *
581 **************************/
585 /* Calculate table index by multiplying r with table scale and truncate to integer */
591 /* CUBIC SPLINE TABLE ELECTROSTATICS */
594 Geps = vfeps*vftab[vfitab+2];
595 Heps2 = vfeps*vfeps*vftab[vfitab+3];
599 FF = Fp+Geps+2.0*Heps2;
600 felec = -qq31*FF*vftabscale*rinv31;
602 /* Update potential sums from outer loop */
607 /* Calculate temporary vectorial force */
612 /* Update vectorial force */
616 f[j_coord_offset+DIM*1+XX] -= tx;
617 f[j_coord_offset+DIM*1+YY] -= ty;
618 f[j_coord_offset+DIM*1+ZZ] -= tz;
620 /**************************
621 * CALCULATE INTERACTIONS *
622 **************************/
626 /* Calculate table index by multiplying r with table scale and truncate to integer */
632 /* CUBIC SPLINE TABLE ELECTROSTATICS */
635 Geps = vfeps*vftab[vfitab+2];
636 Heps2 = vfeps*vfeps*vftab[vfitab+3];
640 FF = Fp+Geps+2.0*Heps2;
641 felec = -qq32*FF*vftabscale*rinv32;
643 /* Update potential sums from outer loop */
648 /* Calculate temporary vectorial force */
653 /* Update vectorial force */
657 f[j_coord_offset+DIM*2+XX] -= tx;
658 f[j_coord_offset+DIM*2+YY] -= ty;
659 f[j_coord_offset+DIM*2+ZZ] -= tz;
661 /**************************
662 * CALCULATE INTERACTIONS *
663 **************************/
667 /* Calculate table index by multiplying r with table scale and truncate to integer */
673 /* CUBIC SPLINE TABLE ELECTROSTATICS */
676 Geps = vfeps*vftab[vfitab+2];
677 Heps2 = vfeps*vfeps*vftab[vfitab+3];
681 FF = Fp+Geps+2.0*Heps2;
682 felec = -qq33*FF*vftabscale*rinv33;
684 /* Update potential sums from outer loop */
689 /* Calculate temporary vectorial force */
694 /* Update vectorial force */
698 f[j_coord_offset+DIM*3+XX] -= tx;
699 f[j_coord_offset+DIM*3+YY] -= ty;
700 f[j_coord_offset+DIM*3+ZZ] -= tz;
702 /* Inner loop uses 424 flops */
704 /* End of innermost loop */
707 f[i_coord_offset+DIM*0+XX] += fix0;
708 f[i_coord_offset+DIM*0+YY] += fiy0;
709 f[i_coord_offset+DIM*0+ZZ] += fiz0;
713 f[i_coord_offset+DIM*1+XX] += fix1;
714 f[i_coord_offset+DIM*1+YY] += fiy1;
715 f[i_coord_offset+DIM*1+ZZ] += fiz1;
719 f[i_coord_offset+DIM*2+XX] += fix2;
720 f[i_coord_offset+DIM*2+YY] += fiy2;
721 f[i_coord_offset+DIM*2+ZZ] += fiz2;
725 f[i_coord_offset+DIM*3+XX] += fix3;
726 f[i_coord_offset+DIM*3+YY] += fiy3;
727 f[i_coord_offset+DIM*3+ZZ] += fiz3;
731 fshift[i_shift_offset+XX] += tx;
732 fshift[i_shift_offset+YY] += ty;
733 fshift[i_shift_offset+ZZ] += tz;
736 /* Update potential energies */
737 kernel_data->energygrp_elec[ggid] += velecsum;
738 kernel_data->energygrp_vdw[ggid] += vvdwsum;
740 /* Increment number of inner iterations */
741 inneriter += j_index_end - j_index_start;
743 /* Outer loop uses 41 flops */
746 /* Increment number of outer iterations */
749 /* Update outer/inner flops */
751 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*424);
754 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_F_c
755 * Electrostatics interaction: CubicSplineTable
756 * VdW interaction: CubicSplineTable
757 * Geometry: Water4-Water4
758 * Calculate force/pot: Force
761 nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_F_c
762 (t_nblist * gmx_restrict nlist,
763 rvec * gmx_restrict xx,
764 rvec * gmx_restrict ff,
765 t_forcerec * gmx_restrict fr,
766 t_mdatoms * gmx_restrict mdatoms,
767 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
768 t_nrnb * gmx_restrict nrnb)
770 int i_shift_offset,i_coord_offset,j_coord_offset;
771 int j_index_start,j_index_end;
772 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
773 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
774 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
775 real *shiftvec,*fshift,*x,*f;
777 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
779 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
781 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
783 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
785 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
787 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
789 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
791 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
792 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
793 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
794 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
795 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
796 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
797 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
798 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
799 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
800 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
801 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
802 real velec,felec,velecsum,facel,crf,krf,krf2;
805 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
809 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
817 jindex = nlist->jindex;
819 shiftidx = nlist->shift;
821 shiftvec = fr->shift_vec[0];
822 fshift = fr->fshift[0];
824 charge = mdatoms->chargeA;
825 nvdwtype = fr->ntype;
827 vdwtype = mdatoms->typeA;
829 vftab = kernel_data->table_elec_vdw->data;
830 vftabscale = kernel_data->table_elec_vdw->scale;
832 /* Setup water-specific parameters */
833 inr = nlist->iinr[0];
834 iq1 = facel*charge[inr+1];
835 iq2 = facel*charge[inr+2];
836 iq3 = facel*charge[inr+3];
837 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
842 vdwjidx0 = 2*vdwtype[inr+0];
843 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
844 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
858 /* Start outer loop over neighborlists */
859 for(iidx=0; iidx<nri; iidx++)
861 /* Load shift vector for this list */
862 i_shift_offset = DIM*shiftidx[iidx];
863 shX = shiftvec[i_shift_offset+XX];
864 shY = shiftvec[i_shift_offset+YY];
865 shZ = shiftvec[i_shift_offset+ZZ];
867 /* Load limits for loop over neighbors */
868 j_index_start = jindex[iidx];
869 j_index_end = jindex[iidx+1];
871 /* Get outer coordinate index */
873 i_coord_offset = DIM*inr;
875 /* Load i particle coords and add shift vector */
876 ix0 = shX + x[i_coord_offset+DIM*0+XX];
877 iy0 = shY + x[i_coord_offset+DIM*0+YY];
878 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
879 ix1 = shX + x[i_coord_offset+DIM*1+XX];
880 iy1 = shY + x[i_coord_offset+DIM*1+YY];
881 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
882 ix2 = shX + x[i_coord_offset+DIM*2+XX];
883 iy2 = shY + x[i_coord_offset+DIM*2+YY];
884 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
885 ix3 = shX + x[i_coord_offset+DIM*3+XX];
886 iy3 = shY + x[i_coord_offset+DIM*3+YY];
887 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
902 /* Start inner kernel loop */
903 for(jidx=j_index_start; jidx<j_index_end; jidx++)
905 /* Get j neighbor index, and coordinate index */
907 j_coord_offset = DIM*jnr;
909 /* load j atom coordinates */
910 jx0 = x[j_coord_offset+DIM*0+XX];
911 jy0 = x[j_coord_offset+DIM*0+YY];
912 jz0 = x[j_coord_offset+DIM*0+ZZ];
913 jx1 = x[j_coord_offset+DIM*1+XX];
914 jy1 = x[j_coord_offset+DIM*1+YY];
915 jz1 = x[j_coord_offset+DIM*1+ZZ];
916 jx2 = x[j_coord_offset+DIM*2+XX];
917 jy2 = x[j_coord_offset+DIM*2+YY];
918 jz2 = x[j_coord_offset+DIM*2+ZZ];
919 jx3 = x[j_coord_offset+DIM*3+XX];
920 jy3 = x[j_coord_offset+DIM*3+YY];
921 jz3 = x[j_coord_offset+DIM*3+ZZ];
923 /* Calculate displacement vector */
955 /* Calculate squared distance and things based on it */
956 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
957 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
958 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
959 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
960 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
961 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
962 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
963 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
964 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
965 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
967 rinv00 = gmx_invsqrt(rsq00);
968 rinv11 = gmx_invsqrt(rsq11);
969 rinv12 = gmx_invsqrt(rsq12);
970 rinv13 = gmx_invsqrt(rsq13);
971 rinv21 = gmx_invsqrt(rsq21);
972 rinv22 = gmx_invsqrt(rsq22);
973 rinv23 = gmx_invsqrt(rsq23);
974 rinv31 = gmx_invsqrt(rsq31);
975 rinv32 = gmx_invsqrt(rsq32);
976 rinv33 = gmx_invsqrt(rsq33);
978 /**************************
979 * CALCULATE INTERACTIONS *
980 **************************/
984 /* Calculate table index by multiplying r with table scale and truncate to integer */
990 /* CUBIC SPLINE TABLE DISPERSION */
993 Geps = vfeps*vftab[vfitab+2];
994 Heps2 = vfeps*vfeps*vftab[vfitab+3];
996 FF = Fp+Geps+2.0*Heps2;
999 /* CUBIC SPLINE TABLE REPULSION */
1000 F = vftab[vfitab+5];
1001 Geps = vfeps*vftab[vfitab+6];
1002 Heps2 = vfeps*vfeps*vftab[vfitab+7];
1004 FF = Fp+Geps+2.0*Heps2;
1006 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
1010 /* Calculate temporary vectorial force */
1015 /* Update vectorial force */
1019 f[j_coord_offset+DIM*0+XX] -= tx;
1020 f[j_coord_offset+DIM*0+YY] -= ty;
1021 f[j_coord_offset+DIM*0+ZZ] -= tz;
1023 /**************************
1024 * CALCULATE INTERACTIONS *
1025 **************************/
1029 /* Calculate table index by multiplying r with table scale and truncate to integer */
1030 rt = r11*vftabscale;
1033 vfitab = 3*4*vfitab;
1035 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1036 F = vftab[vfitab+1];
1037 Geps = vfeps*vftab[vfitab+2];
1038 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1040 FF = Fp+Geps+2.0*Heps2;
1041 felec = -qq11*FF*vftabscale*rinv11;
1045 /* Calculate temporary vectorial force */
1050 /* Update vectorial force */
1054 f[j_coord_offset+DIM*1+XX] -= tx;
1055 f[j_coord_offset+DIM*1+YY] -= ty;
1056 f[j_coord_offset+DIM*1+ZZ] -= tz;
1058 /**************************
1059 * CALCULATE INTERACTIONS *
1060 **************************/
1064 /* Calculate table index by multiplying r with table scale and truncate to integer */
1065 rt = r12*vftabscale;
1068 vfitab = 3*4*vfitab;
1070 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1071 F = vftab[vfitab+1];
1072 Geps = vfeps*vftab[vfitab+2];
1073 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1075 FF = Fp+Geps+2.0*Heps2;
1076 felec = -qq12*FF*vftabscale*rinv12;
1080 /* Calculate temporary vectorial force */
1085 /* Update vectorial force */
1089 f[j_coord_offset+DIM*2+XX] -= tx;
1090 f[j_coord_offset+DIM*2+YY] -= ty;
1091 f[j_coord_offset+DIM*2+ZZ] -= tz;
1093 /**************************
1094 * CALCULATE INTERACTIONS *
1095 **************************/
1099 /* Calculate table index by multiplying r with table scale and truncate to integer */
1100 rt = r13*vftabscale;
1103 vfitab = 3*4*vfitab;
1105 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1106 F = vftab[vfitab+1];
1107 Geps = vfeps*vftab[vfitab+2];
1108 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1110 FF = Fp+Geps+2.0*Heps2;
1111 felec = -qq13*FF*vftabscale*rinv13;
1115 /* Calculate temporary vectorial force */
1120 /* Update vectorial force */
1124 f[j_coord_offset+DIM*3+XX] -= tx;
1125 f[j_coord_offset+DIM*3+YY] -= ty;
1126 f[j_coord_offset+DIM*3+ZZ] -= tz;
1128 /**************************
1129 * CALCULATE INTERACTIONS *
1130 **************************/
1134 /* Calculate table index by multiplying r with table scale and truncate to integer */
1135 rt = r21*vftabscale;
1138 vfitab = 3*4*vfitab;
1140 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1141 F = vftab[vfitab+1];
1142 Geps = vfeps*vftab[vfitab+2];
1143 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1145 FF = Fp+Geps+2.0*Heps2;
1146 felec = -qq21*FF*vftabscale*rinv21;
1150 /* Calculate temporary vectorial force */
1155 /* Update vectorial force */
1159 f[j_coord_offset+DIM*1+XX] -= tx;
1160 f[j_coord_offset+DIM*1+YY] -= ty;
1161 f[j_coord_offset+DIM*1+ZZ] -= tz;
1163 /**************************
1164 * CALCULATE INTERACTIONS *
1165 **************************/
1169 /* Calculate table index by multiplying r with table scale and truncate to integer */
1170 rt = r22*vftabscale;
1173 vfitab = 3*4*vfitab;
1175 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1176 F = vftab[vfitab+1];
1177 Geps = vfeps*vftab[vfitab+2];
1178 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1180 FF = Fp+Geps+2.0*Heps2;
1181 felec = -qq22*FF*vftabscale*rinv22;
1185 /* Calculate temporary vectorial force */
1190 /* Update vectorial force */
1194 f[j_coord_offset+DIM*2+XX] -= tx;
1195 f[j_coord_offset+DIM*2+YY] -= ty;
1196 f[j_coord_offset+DIM*2+ZZ] -= tz;
1198 /**************************
1199 * CALCULATE INTERACTIONS *
1200 **************************/
1204 /* Calculate table index by multiplying r with table scale and truncate to integer */
1205 rt = r23*vftabscale;
1208 vfitab = 3*4*vfitab;
1210 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1211 F = vftab[vfitab+1];
1212 Geps = vfeps*vftab[vfitab+2];
1213 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1215 FF = Fp+Geps+2.0*Heps2;
1216 felec = -qq23*FF*vftabscale*rinv23;
1220 /* Calculate temporary vectorial force */
1225 /* Update vectorial force */
1229 f[j_coord_offset+DIM*3+XX] -= tx;
1230 f[j_coord_offset+DIM*3+YY] -= ty;
1231 f[j_coord_offset+DIM*3+ZZ] -= tz;
1233 /**************************
1234 * CALCULATE INTERACTIONS *
1235 **************************/
1239 /* Calculate table index by multiplying r with table scale and truncate to integer */
1240 rt = r31*vftabscale;
1243 vfitab = 3*4*vfitab;
1245 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1246 F = vftab[vfitab+1];
1247 Geps = vfeps*vftab[vfitab+2];
1248 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1250 FF = Fp+Geps+2.0*Heps2;
1251 felec = -qq31*FF*vftabscale*rinv31;
1255 /* Calculate temporary vectorial force */
1260 /* Update vectorial force */
1264 f[j_coord_offset+DIM*1+XX] -= tx;
1265 f[j_coord_offset+DIM*1+YY] -= ty;
1266 f[j_coord_offset+DIM*1+ZZ] -= tz;
1268 /**************************
1269 * CALCULATE INTERACTIONS *
1270 **************************/
1274 /* Calculate table index by multiplying r with table scale and truncate to integer */
1275 rt = r32*vftabscale;
1278 vfitab = 3*4*vfitab;
1280 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1281 F = vftab[vfitab+1];
1282 Geps = vfeps*vftab[vfitab+2];
1283 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1285 FF = Fp+Geps+2.0*Heps2;
1286 felec = -qq32*FF*vftabscale*rinv32;
1290 /* Calculate temporary vectorial force */
1295 /* Update vectorial force */
1299 f[j_coord_offset+DIM*2+XX] -= tx;
1300 f[j_coord_offset+DIM*2+YY] -= ty;
1301 f[j_coord_offset+DIM*2+ZZ] -= tz;
1303 /**************************
1304 * CALCULATE INTERACTIONS *
1305 **************************/
1309 /* Calculate table index by multiplying r with table scale and truncate to integer */
1310 rt = r33*vftabscale;
1313 vfitab = 3*4*vfitab;
1315 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1316 F = vftab[vfitab+1];
1317 Geps = vfeps*vftab[vfitab+2];
1318 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1320 FF = Fp+Geps+2.0*Heps2;
1321 felec = -qq33*FF*vftabscale*rinv33;
1325 /* Calculate temporary vectorial force */
1330 /* Update vectorial force */
1334 f[j_coord_offset+DIM*3+XX] -= tx;
1335 f[j_coord_offset+DIM*3+YY] -= ty;
1336 f[j_coord_offset+DIM*3+ZZ] -= tz;
1338 /* Inner loop uses 380 flops */
1340 /* End of innermost loop */
1343 f[i_coord_offset+DIM*0+XX] += fix0;
1344 f[i_coord_offset+DIM*0+YY] += fiy0;
1345 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1349 f[i_coord_offset+DIM*1+XX] += fix1;
1350 f[i_coord_offset+DIM*1+YY] += fiy1;
1351 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1355 f[i_coord_offset+DIM*2+XX] += fix2;
1356 f[i_coord_offset+DIM*2+YY] += fiy2;
1357 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1361 f[i_coord_offset+DIM*3+XX] += fix3;
1362 f[i_coord_offset+DIM*3+YY] += fiy3;
1363 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1367 fshift[i_shift_offset+XX] += tx;
1368 fshift[i_shift_offset+YY] += ty;
1369 fshift[i_shift_offset+ZZ] += tz;
1371 /* Increment number of inner iterations */
1372 inneriter += j_index_end - j_index_start;
1374 /* Outer loop uses 39 flops */
1377 /* Increment number of outer iterations */
1380 /* Update outer/inner flops */
1382 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*380);