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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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;
85 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
86 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
87 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
88 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
89 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
90 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
91 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
92 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
93 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
94 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
95 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
96 real velec,felec,velecsum,facel,crf,krf,krf2;
99 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
103 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
118 charge = mdatoms->chargeA;
122 nvdwtype = fr->ntype;
124 vdwtype = mdatoms->typeA;
126 vftab = kernel_data->table_vdw->data;
127 vftabscale = kernel_data->table_vdw->scale;
129 /* Setup water-specific parameters */
130 inr = nlist->iinr[0];
131 iq1 = facel*charge[inr+1];
132 iq2 = facel*charge[inr+2];
133 iq3 = facel*charge[inr+3];
134 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
139 vdwjidx0 = 2*vdwtype[inr+0];
140 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
141 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
152 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
153 rcutoff = fr->rcoulomb;
154 rcutoff2 = rcutoff*rcutoff;
159 /* Start outer loop over neighborlists */
160 for(iidx=0; iidx<nri; iidx++)
162 /* Load shift vector for this list */
163 i_shift_offset = DIM*shiftidx[iidx];
164 shX = shiftvec[i_shift_offset+XX];
165 shY = shiftvec[i_shift_offset+YY];
166 shZ = shiftvec[i_shift_offset+ZZ];
168 /* Load limits for loop over neighbors */
169 j_index_start = jindex[iidx];
170 j_index_end = jindex[iidx+1];
172 /* Get outer coordinate index */
174 i_coord_offset = DIM*inr;
176 /* Load i particle coords and add shift vector */
177 ix0 = shX + x[i_coord_offset+DIM*0+XX];
178 iy0 = shY + x[i_coord_offset+DIM*0+YY];
179 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
180 ix1 = shX + x[i_coord_offset+DIM*1+XX];
181 iy1 = shY + x[i_coord_offset+DIM*1+YY];
182 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
183 ix2 = shX + x[i_coord_offset+DIM*2+XX];
184 iy2 = shY + x[i_coord_offset+DIM*2+YY];
185 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
186 ix3 = shX + x[i_coord_offset+DIM*3+XX];
187 iy3 = shY + x[i_coord_offset+DIM*3+YY];
188 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
203 /* Reset potential sums */
207 /* Start inner kernel loop */
208 for(jidx=j_index_start; jidx<j_index_end; jidx++)
210 /* Get j neighbor index, and coordinate index */
212 j_coord_offset = DIM*jnr;
214 /* load j atom coordinates */
215 jx0 = x[j_coord_offset+DIM*0+XX];
216 jy0 = x[j_coord_offset+DIM*0+YY];
217 jz0 = x[j_coord_offset+DIM*0+ZZ];
218 jx1 = x[j_coord_offset+DIM*1+XX];
219 jy1 = x[j_coord_offset+DIM*1+YY];
220 jz1 = x[j_coord_offset+DIM*1+ZZ];
221 jx2 = x[j_coord_offset+DIM*2+XX];
222 jy2 = x[j_coord_offset+DIM*2+YY];
223 jz2 = x[j_coord_offset+DIM*2+ZZ];
224 jx3 = x[j_coord_offset+DIM*3+XX];
225 jy3 = x[j_coord_offset+DIM*3+YY];
226 jz3 = x[j_coord_offset+DIM*3+ZZ];
228 /* Calculate displacement vector */
260 /* Calculate squared distance and things based on it */
261 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
262 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
263 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
264 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
265 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
266 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
267 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
268 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
269 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
270 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
272 rinv00 = gmx_invsqrt(rsq00);
273 rinv11 = gmx_invsqrt(rsq11);
274 rinv12 = gmx_invsqrt(rsq12);
275 rinv13 = gmx_invsqrt(rsq13);
276 rinv21 = gmx_invsqrt(rsq21);
277 rinv22 = gmx_invsqrt(rsq22);
278 rinv23 = gmx_invsqrt(rsq23);
279 rinv31 = gmx_invsqrt(rsq31);
280 rinv32 = gmx_invsqrt(rsq32);
281 rinv33 = gmx_invsqrt(rsq33);
283 rinvsq11 = rinv11*rinv11;
284 rinvsq12 = rinv12*rinv12;
285 rinvsq13 = rinv13*rinv13;
286 rinvsq21 = rinv21*rinv21;
287 rinvsq22 = rinv22*rinv22;
288 rinvsq23 = rinv23*rinv23;
289 rinvsq31 = rinv31*rinv31;
290 rinvsq32 = rinv32*rinv32;
291 rinvsq33 = rinv33*rinv33;
293 /**************************
294 * CALCULATE INTERACTIONS *
295 **************************/
302 /* Calculate table index by multiplying r with table scale and truncate to integer */
308 /* CUBIC SPLINE TABLE DISPERSION */
312 Geps = vfeps*vftab[vfitab+2];
313 Heps2 = vfeps*vfeps*vftab[vfitab+3];
317 FF = Fp+Geps+2.0*Heps2;
320 /* CUBIC SPLINE TABLE REPULSION */
323 Geps = vfeps*vftab[vfitab+6];
324 Heps2 = vfeps*vfeps*vftab[vfitab+7];
328 FF = Fp+Geps+2.0*Heps2;
331 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
333 /* Update potential sums from outer loop */
338 /* Calculate temporary vectorial force */
343 /* Update vectorial force */
347 f[j_coord_offset+DIM*0+XX] -= tx;
348 f[j_coord_offset+DIM*0+YY] -= ty;
349 f[j_coord_offset+DIM*0+ZZ] -= tz;
353 /**************************
354 * CALCULATE INTERACTIONS *
355 **************************/
360 /* REACTION-FIELD ELECTROSTATICS */
361 velec = qq11*(rinv11+krf*rsq11-crf);
362 felec = qq11*(rinv11*rinvsq11-krf2);
364 /* Update potential sums from outer loop */
369 /* Calculate temporary vectorial force */
374 /* Update vectorial force */
378 f[j_coord_offset+DIM*1+XX] -= tx;
379 f[j_coord_offset+DIM*1+YY] -= ty;
380 f[j_coord_offset+DIM*1+ZZ] -= tz;
384 /**************************
385 * CALCULATE INTERACTIONS *
386 **************************/
391 /* REACTION-FIELD ELECTROSTATICS */
392 velec = qq12*(rinv12+krf*rsq12-crf);
393 felec = qq12*(rinv12*rinvsq12-krf2);
395 /* Update potential sums from outer loop */
400 /* Calculate temporary vectorial force */
405 /* Update vectorial force */
409 f[j_coord_offset+DIM*2+XX] -= tx;
410 f[j_coord_offset+DIM*2+YY] -= ty;
411 f[j_coord_offset+DIM*2+ZZ] -= tz;
415 /**************************
416 * CALCULATE INTERACTIONS *
417 **************************/
422 /* REACTION-FIELD ELECTROSTATICS */
423 velec = qq13*(rinv13+krf*rsq13-crf);
424 felec = qq13*(rinv13*rinvsq13-krf2);
426 /* Update potential sums from outer loop */
431 /* Calculate temporary vectorial force */
436 /* Update vectorial force */
440 f[j_coord_offset+DIM*3+XX] -= tx;
441 f[j_coord_offset+DIM*3+YY] -= ty;
442 f[j_coord_offset+DIM*3+ZZ] -= tz;
446 /**************************
447 * CALCULATE INTERACTIONS *
448 **************************/
453 /* REACTION-FIELD ELECTROSTATICS */
454 velec = qq21*(rinv21+krf*rsq21-crf);
455 felec = qq21*(rinv21*rinvsq21-krf2);
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;
477 /**************************
478 * CALCULATE INTERACTIONS *
479 **************************/
484 /* REACTION-FIELD ELECTROSTATICS */
485 velec = qq22*(rinv22+krf*rsq22-crf);
486 felec = qq22*(rinv22*rinvsq22-krf2);
488 /* Update potential sums from outer loop */
493 /* Calculate temporary vectorial force */
498 /* Update vectorial force */
502 f[j_coord_offset+DIM*2+XX] -= tx;
503 f[j_coord_offset+DIM*2+YY] -= ty;
504 f[j_coord_offset+DIM*2+ZZ] -= tz;
508 /**************************
509 * CALCULATE INTERACTIONS *
510 **************************/
515 /* REACTION-FIELD ELECTROSTATICS */
516 velec = qq23*(rinv23+krf*rsq23-crf);
517 felec = qq23*(rinv23*rinvsq23-krf2);
519 /* Update potential sums from outer loop */
524 /* Calculate temporary vectorial force */
529 /* Update vectorial force */
533 f[j_coord_offset+DIM*3+XX] -= tx;
534 f[j_coord_offset+DIM*3+YY] -= ty;
535 f[j_coord_offset+DIM*3+ZZ] -= tz;
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
546 /* REACTION-FIELD ELECTROSTATICS */
547 velec = qq31*(rinv31+krf*rsq31-crf);
548 felec = qq31*(rinv31*rinvsq31-krf2);
550 /* Update potential sums from outer loop */
555 /* Calculate temporary vectorial force */
560 /* Update vectorial force */
564 f[j_coord_offset+DIM*1+XX] -= tx;
565 f[j_coord_offset+DIM*1+YY] -= ty;
566 f[j_coord_offset+DIM*1+ZZ] -= tz;
570 /**************************
571 * CALCULATE INTERACTIONS *
572 **************************/
577 /* REACTION-FIELD ELECTROSTATICS */
578 velec = qq32*(rinv32+krf*rsq32-crf);
579 felec = qq32*(rinv32*rinvsq32-krf2);
581 /* Update potential sums from outer loop */
586 /* Calculate temporary vectorial force */
591 /* Update vectorial force */
595 f[j_coord_offset+DIM*2+XX] -= tx;
596 f[j_coord_offset+DIM*2+YY] -= ty;
597 f[j_coord_offset+DIM*2+ZZ] -= tz;
601 /**************************
602 * CALCULATE INTERACTIONS *
603 **************************/
608 /* REACTION-FIELD ELECTROSTATICS */
609 velec = qq33*(rinv33+krf*rsq33-crf);
610 felec = qq33*(rinv33*rinvsq33-krf2);
612 /* Update potential sums from outer loop */
617 /* Calculate temporary vectorial force */
622 /* Update vectorial force */
626 f[j_coord_offset+DIM*3+XX] -= tx;
627 f[j_coord_offset+DIM*3+YY] -= ty;
628 f[j_coord_offset+DIM*3+ZZ] -= tz;
632 /* Inner loop uses 334 flops */
634 /* End of innermost loop */
637 f[i_coord_offset+DIM*0+XX] += fix0;
638 f[i_coord_offset+DIM*0+YY] += fiy0;
639 f[i_coord_offset+DIM*0+ZZ] += fiz0;
643 f[i_coord_offset+DIM*1+XX] += fix1;
644 f[i_coord_offset+DIM*1+YY] += fiy1;
645 f[i_coord_offset+DIM*1+ZZ] += fiz1;
649 f[i_coord_offset+DIM*2+XX] += fix2;
650 f[i_coord_offset+DIM*2+YY] += fiy2;
651 f[i_coord_offset+DIM*2+ZZ] += fiz2;
655 f[i_coord_offset+DIM*3+XX] += fix3;
656 f[i_coord_offset+DIM*3+YY] += fiy3;
657 f[i_coord_offset+DIM*3+ZZ] += fiz3;
661 fshift[i_shift_offset+XX] += tx;
662 fshift[i_shift_offset+YY] += ty;
663 fshift[i_shift_offset+ZZ] += tz;
666 /* Update potential energies */
667 kernel_data->energygrp_elec[ggid] += velecsum;
668 kernel_data->energygrp_vdw[ggid] += vvdwsum;
670 /* Increment number of inner iterations */
671 inneriter += j_index_end - j_index_start;
673 /* Outer loop uses 41 flops */
676 /* Increment number of outer iterations */
679 /* Update outer/inner flops */
681 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*334);
684 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_c
685 * Electrostatics interaction: ReactionField
686 * VdW interaction: CubicSplineTable
687 * Geometry: Water4-Water4
688 * Calculate force/pot: Force
691 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_c
692 (t_nblist * gmx_restrict nlist,
693 rvec * gmx_restrict xx,
694 rvec * gmx_restrict ff,
695 t_forcerec * gmx_restrict fr,
696 t_mdatoms * gmx_restrict mdatoms,
697 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
698 t_nrnb * gmx_restrict nrnb)
700 int i_shift_offset,i_coord_offset,j_coord_offset;
701 int j_index_start,j_index_end;
702 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
703 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
704 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
705 real *shiftvec,*fshift,*x,*f;
707 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
709 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
711 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
713 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
715 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
717 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
719 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
721 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
722 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
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 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
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 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
729 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
730 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
731 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
732 real velec,felec,velecsum,facel,crf,krf,krf2;
735 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
739 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
747 jindex = nlist->jindex;
749 shiftidx = nlist->shift;
751 shiftvec = fr->shift_vec[0];
752 fshift = fr->fshift[0];
754 charge = mdatoms->chargeA;
758 nvdwtype = fr->ntype;
760 vdwtype = mdatoms->typeA;
762 vftab = kernel_data->table_vdw->data;
763 vftabscale = kernel_data->table_vdw->scale;
765 /* Setup water-specific parameters */
766 inr = nlist->iinr[0];
767 iq1 = facel*charge[inr+1];
768 iq2 = facel*charge[inr+2];
769 iq3 = facel*charge[inr+3];
770 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
775 vdwjidx0 = 2*vdwtype[inr+0];
776 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
777 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
788 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
789 rcutoff = fr->rcoulomb;
790 rcutoff2 = rcutoff*rcutoff;
795 /* Start outer loop over neighborlists */
796 for(iidx=0; iidx<nri; iidx++)
798 /* Load shift vector for this list */
799 i_shift_offset = DIM*shiftidx[iidx];
800 shX = shiftvec[i_shift_offset+XX];
801 shY = shiftvec[i_shift_offset+YY];
802 shZ = shiftvec[i_shift_offset+ZZ];
804 /* Load limits for loop over neighbors */
805 j_index_start = jindex[iidx];
806 j_index_end = jindex[iidx+1];
808 /* Get outer coordinate index */
810 i_coord_offset = DIM*inr;
812 /* Load i particle coords and add shift vector */
813 ix0 = shX + x[i_coord_offset+DIM*0+XX];
814 iy0 = shY + x[i_coord_offset+DIM*0+YY];
815 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
816 ix1 = shX + x[i_coord_offset+DIM*1+XX];
817 iy1 = shY + x[i_coord_offset+DIM*1+YY];
818 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
819 ix2 = shX + x[i_coord_offset+DIM*2+XX];
820 iy2 = shY + x[i_coord_offset+DIM*2+YY];
821 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
822 ix3 = shX + x[i_coord_offset+DIM*3+XX];
823 iy3 = shY + x[i_coord_offset+DIM*3+YY];
824 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
839 /* Start inner kernel loop */
840 for(jidx=j_index_start; jidx<j_index_end; jidx++)
842 /* Get j neighbor index, and coordinate index */
844 j_coord_offset = DIM*jnr;
846 /* load j atom coordinates */
847 jx0 = x[j_coord_offset+DIM*0+XX];
848 jy0 = x[j_coord_offset+DIM*0+YY];
849 jz0 = x[j_coord_offset+DIM*0+ZZ];
850 jx1 = x[j_coord_offset+DIM*1+XX];
851 jy1 = x[j_coord_offset+DIM*1+YY];
852 jz1 = x[j_coord_offset+DIM*1+ZZ];
853 jx2 = x[j_coord_offset+DIM*2+XX];
854 jy2 = x[j_coord_offset+DIM*2+YY];
855 jz2 = x[j_coord_offset+DIM*2+ZZ];
856 jx3 = x[j_coord_offset+DIM*3+XX];
857 jy3 = x[j_coord_offset+DIM*3+YY];
858 jz3 = x[j_coord_offset+DIM*3+ZZ];
860 /* Calculate displacement vector */
892 /* Calculate squared distance and things based on it */
893 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
894 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
895 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
896 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
897 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
898 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
899 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
900 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
901 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
902 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
904 rinv00 = gmx_invsqrt(rsq00);
905 rinv11 = gmx_invsqrt(rsq11);
906 rinv12 = gmx_invsqrt(rsq12);
907 rinv13 = gmx_invsqrt(rsq13);
908 rinv21 = gmx_invsqrt(rsq21);
909 rinv22 = gmx_invsqrt(rsq22);
910 rinv23 = gmx_invsqrt(rsq23);
911 rinv31 = gmx_invsqrt(rsq31);
912 rinv32 = gmx_invsqrt(rsq32);
913 rinv33 = gmx_invsqrt(rsq33);
915 rinvsq11 = rinv11*rinv11;
916 rinvsq12 = rinv12*rinv12;
917 rinvsq13 = rinv13*rinv13;
918 rinvsq21 = rinv21*rinv21;
919 rinvsq22 = rinv22*rinv22;
920 rinvsq23 = rinv23*rinv23;
921 rinvsq31 = rinv31*rinv31;
922 rinvsq32 = rinv32*rinv32;
923 rinvsq33 = rinv33*rinv33;
925 /**************************
926 * CALCULATE INTERACTIONS *
927 **************************/
934 /* Calculate table index by multiplying r with table scale and truncate to integer */
940 /* CUBIC SPLINE TABLE DISPERSION */
943 Geps = vfeps*vftab[vfitab+2];
944 Heps2 = vfeps*vfeps*vftab[vfitab+3];
946 FF = Fp+Geps+2.0*Heps2;
949 /* CUBIC SPLINE TABLE REPULSION */
951 Geps = vfeps*vftab[vfitab+6];
952 Heps2 = vfeps*vfeps*vftab[vfitab+7];
954 FF = Fp+Geps+2.0*Heps2;
956 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
960 /* Calculate temporary vectorial force */
965 /* Update vectorial force */
969 f[j_coord_offset+DIM*0+XX] -= tx;
970 f[j_coord_offset+DIM*0+YY] -= ty;
971 f[j_coord_offset+DIM*0+ZZ] -= tz;
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
982 /* REACTION-FIELD ELECTROSTATICS */
983 felec = qq11*(rinv11*rinvsq11-krf2);
987 /* Calculate temporary vectorial force */
992 /* Update vectorial force */
996 f[j_coord_offset+DIM*1+XX] -= tx;
997 f[j_coord_offset+DIM*1+YY] -= ty;
998 f[j_coord_offset+DIM*1+ZZ] -= tz;
1002 /**************************
1003 * CALCULATE INTERACTIONS *
1004 **************************/
1009 /* REACTION-FIELD ELECTROSTATICS */
1010 felec = qq12*(rinv12*rinvsq12-krf2);
1014 /* Calculate temporary vectorial force */
1019 /* Update vectorial force */
1023 f[j_coord_offset+DIM*2+XX] -= tx;
1024 f[j_coord_offset+DIM*2+YY] -= ty;
1025 f[j_coord_offset+DIM*2+ZZ] -= tz;
1029 /**************************
1030 * CALCULATE INTERACTIONS *
1031 **************************/
1036 /* REACTION-FIELD ELECTROSTATICS */
1037 felec = qq13*(rinv13*rinvsq13-krf2);
1041 /* Calculate temporary vectorial force */
1046 /* Update vectorial force */
1050 f[j_coord_offset+DIM*3+XX] -= tx;
1051 f[j_coord_offset+DIM*3+YY] -= ty;
1052 f[j_coord_offset+DIM*3+ZZ] -= tz;
1056 /**************************
1057 * CALCULATE INTERACTIONS *
1058 **************************/
1063 /* REACTION-FIELD ELECTROSTATICS */
1064 felec = qq21*(rinv21*rinvsq21-krf2);
1068 /* Calculate temporary vectorial force */
1073 /* Update vectorial force */
1077 f[j_coord_offset+DIM*1+XX] -= tx;
1078 f[j_coord_offset+DIM*1+YY] -= ty;
1079 f[j_coord_offset+DIM*1+ZZ] -= tz;
1083 /**************************
1084 * CALCULATE INTERACTIONS *
1085 **************************/
1090 /* REACTION-FIELD ELECTROSTATICS */
1091 felec = qq22*(rinv22*rinvsq22-krf2);
1095 /* Calculate temporary vectorial force */
1100 /* Update vectorial force */
1104 f[j_coord_offset+DIM*2+XX] -= tx;
1105 f[j_coord_offset+DIM*2+YY] -= ty;
1106 f[j_coord_offset+DIM*2+ZZ] -= tz;
1110 /**************************
1111 * CALCULATE INTERACTIONS *
1112 **************************/
1117 /* REACTION-FIELD ELECTROSTATICS */
1118 felec = qq23*(rinv23*rinvsq23-krf2);
1122 /* Calculate temporary vectorial force */
1127 /* Update vectorial force */
1131 f[j_coord_offset+DIM*3+XX] -= tx;
1132 f[j_coord_offset+DIM*3+YY] -= ty;
1133 f[j_coord_offset+DIM*3+ZZ] -= tz;
1137 /**************************
1138 * CALCULATE INTERACTIONS *
1139 **************************/
1144 /* REACTION-FIELD ELECTROSTATICS */
1145 felec = qq31*(rinv31*rinvsq31-krf2);
1149 /* Calculate temporary vectorial force */
1154 /* Update vectorial force */
1158 f[j_coord_offset+DIM*1+XX] -= tx;
1159 f[j_coord_offset+DIM*1+YY] -= ty;
1160 f[j_coord_offset+DIM*1+ZZ] -= tz;
1164 /**************************
1165 * CALCULATE INTERACTIONS *
1166 **************************/
1171 /* REACTION-FIELD ELECTROSTATICS */
1172 felec = qq32*(rinv32*rinvsq32-krf2);
1176 /* Calculate temporary vectorial force */
1181 /* Update vectorial force */
1185 f[j_coord_offset+DIM*2+XX] -= tx;
1186 f[j_coord_offset+DIM*2+YY] -= ty;
1187 f[j_coord_offset+DIM*2+ZZ] -= tz;
1191 /**************************
1192 * CALCULATE INTERACTIONS *
1193 **************************/
1198 /* REACTION-FIELD ELECTROSTATICS */
1199 felec = qq33*(rinv33*rinvsq33-krf2);
1203 /* Calculate temporary vectorial force */
1208 /* Update vectorial force */
1212 f[j_coord_offset+DIM*3+XX] -= tx;
1213 f[j_coord_offset+DIM*3+YY] -= ty;
1214 f[j_coord_offset+DIM*3+ZZ] -= tz;
1218 /* Inner loop uses 281 flops */
1220 /* End of innermost loop */
1223 f[i_coord_offset+DIM*0+XX] += fix0;
1224 f[i_coord_offset+DIM*0+YY] += fiy0;
1225 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1229 f[i_coord_offset+DIM*1+XX] += fix1;
1230 f[i_coord_offset+DIM*1+YY] += fiy1;
1231 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1235 f[i_coord_offset+DIM*2+XX] += fix2;
1236 f[i_coord_offset+DIM*2+YY] += fiy2;
1237 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1241 f[i_coord_offset+DIM*3+XX] += fix3;
1242 f[i_coord_offset+DIM*3+YY] += fiy3;
1243 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1247 fshift[i_shift_offset+XX] += tx;
1248 fshift[i_shift_offset+YY] += ty;
1249 fshift[i_shift_offset+ZZ] += tz;
1251 /* Increment number of inner iterations */
1252 inneriter += j_index_end - j_index_start;
1254 /* Outer loop uses 39 flops */
1257 /* Increment number of outer iterations */
1260 /* Update outer/inner flops */
1262 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*281);