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 "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_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;
124 nvdwtype = fr->ntype;
126 vdwtype = mdatoms->typeA;
128 vftab = kernel_data->table_vdw->data;
129 vftabscale = kernel_data->table_vdw->scale;
131 /* Setup water-specific parameters */
132 inr = nlist->iinr[0];
133 iq1 = facel*charge[inr+1];
134 iq2 = facel*charge[inr+2];
135 iq3 = facel*charge[inr+3];
136 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
141 vdwjidx0 = 2*vdwtype[inr+0];
142 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
143 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
154 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
155 rcutoff = fr->rcoulomb;
156 rcutoff2 = rcutoff*rcutoff;
161 /* Start outer loop over neighborlists */
162 for(iidx=0; iidx<nri; iidx++)
164 /* Load shift vector for this list */
165 i_shift_offset = DIM*shiftidx[iidx];
166 shX = shiftvec[i_shift_offset+XX];
167 shY = shiftvec[i_shift_offset+YY];
168 shZ = shiftvec[i_shift_offset+ZZ];
170 /* Load limits for loop over neighbors */
171 j_index_start = jindex[iidx];
172 j_index_end = jindex[iidx+1];
174 /* Get outer coordinate index */
176 i_coord_offset = DIM*inr;
178 /* Load i particle coords and add shift vector */
179 ix0 = shX + x[i_coord_offset+DIM*0+XX];
180 iy0 = shY + x[i_coord_offset+DIM*0+YY];
181 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
182 ix1 = shX + x[i_coord_offset+DIM*1+XX];
183 iy1 = shY + x[i_coord_offset+DIM*1+YY];
184 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
185 ix2 = shX + x[i_coord_offset+DIM*2+XX];
186 iy2 = shY + x[i_coord_offset+DIM*2+YY];
187 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
188 ix3 = shX + x[i_coord_offset+DIM*3+XX];
189 iy3 = shY + x[i_coord_offset+DIM*3+YY];
190 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
205 /* Reset potential sums */
209 /* Start inner kernel loop */
210 for(jidx=j_index_start; jidx<j_index_end; jidx++)
212 /* Get j neighbor index, and coordinate index */
214 j_coord_offset = DIM*jnr;
216 /* load j atom coordinates */
217 jx0 = x[j_coord_offset+DIM*0+XX];
218 jy0 = x[j_coord_offset+DIM*0+YY];
219 jz0 = x[j_coord_offset+DIM*0+ZZ];
220 jx1 = x[j_coord_offset+DIM*1+XX];
221 jy1 = x[j_coord_offset+DIM*1+YY];
222 jz1 = x[j_coord_offset+DIM*1+ZZ];
223 jx2 = x[j_coord_offset+DIM*2+XX];
224 jy2 = x[j_coord_offset+DIM*2+YY];
225 jz2 = x[j_coord_offset+DIM*2+ZZ];
226 jx3 = x[j_coord_offset+DIM*3+XX];
227 jy3 = x[j_coord_offset+DIM*3+YY];
228 jz3 = x[j_coord_offset+DIM*3+ZZ];
230 /* Calculate displacement vector */
262 /* Calculate squared distance and things based on it */
263 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
264 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
265 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
266 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
267 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
268 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
269 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
270 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
271 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
272 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
274 rinv00 = gmx_invsqrt(rsq00);
275 rinv11 = gmx_invsqrt(rsq11);
276 rinv12 = gmx_invsqrt(rsq12);
277 rinv13 = gmx_invsqrt(rsq13);
278 rinv21 = gmx_invsqrt(rsq21);
279 rinv22 = gmx_invsqrt(rsq22);
280 rinv23 = gmx_invsqrt(rsq23);
281 rinv31 = gmx_invsqrt(rsq31);
282 rinv32 = gmx_invsqrt(rsq32);
283 rinv33 = gmx_invsqrt(rsq33);
285 rinvsq11 = rinv11*rinv11;
286 rinvsq12 = rinv12*rinv12;
287 rinvsq13 = rinv13*rinv13;
288 rinvsq21 = rinv21*rinv21;
289 rinvsq22 = rinv22*rinv22;
290 rinvsq23 = rinv23*rinv23;
291 rinvsq31 = rinv31*rinv31;
292 rinvsq32 = rinv32*rinv32;
293 rinvsq33 = rinv33*rinv33;
295 /**************************
296 * CALCULATE INTERACTIONS *
297 **************************/
304 /* Calculate table index by multiplying r with table scale and truncate to integer */
310 /* CUBIC SPLINE TABLE DISPERSION */
314 Geps = vfeps*vftab[vfitab+2];
315 Heps2 = vfeps*vfeps*vftab[vfitab+3];
319 FF = Fp+Geps+2.0*Heps2;
322 /* CUBIC SPLINE TABLE REPULSION */
325 Geps = vfeps*vftab[vfitab+6];
326 Heps2 = vfeps*vfeps*vftab[vfitab+7];
330 FF = Fp+Geps+2.0*Heps2;
333 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
335 /* Update potential sums from outer loop */
340 /* Calculate temporary vectorial force */
345 /* Update vectorial force */
349 f[j_coord_offset+DIM*0+XX] -= tx;
350 f[j_coord_offset+DIM*0+YY] -= ty;
351 f[j_coord_offset+DIM*0+ZZ] -= tz;
355 /**************************
356 * CALCULATE INTERACTIONS *
357 **************************/
362 /* REACTION-FIELD ELECTROSTATICS */
363 velec = qq11*(rinv11+krf*rsq11-crf);
364 felec = qq11*(rinv11*rinvsq11-krf2);
366 /* Update potential sums from outer loop */
371 /* Calculate temporary vectorial force */
376 /* Update vectorial force */
380 f[j_coord_offset+DIM*1+XX] -= tx;
381 f[j_coord_offset+DIM*1+YY] -= ty;
382 f[j_coord_offset+DIM*1+ZZ] -= tz;
386 /**************************
387 * CALCULATE INTERACTIONS *
388 **************************/
393 /* REACTION-FIELD ELECTROSTATICS */
394 velec = qq12*(rinv12+krf*rsq12-crf);
395 felec = qq12*(rinv12*rinvsq12-krf2);
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;
417 /**************************
418 * CALCULATE INTERACTIONS *
419 **************************/
424 /* REACTION-FIELD ELECTROSTATICS */
425 velec = qq13*(rinv13+krf*rsq13-crf);
426 felec = qq13*(rinv13*rinvsq13-krf2);
428 /* Update potential sums from outer loop */
433 /* Calculate temporary vectorial force */
438 /* Update vectorial force */
442 f[j_coord_offset+DIM*3+XX] -= tx;
443 f[j_coord_offset+DIM*3+YY] -= ty;
444 f[j_coord_offset+DIM*3+ZZ] -= tz;
448 /**************************
449 * CALCULATE INTERACTIONS *
450 **************************/
455 /* REACTION-FIELD ELECTROSTATICS */
456 velec = qq21*(rinv21+krf*rsq21-crf);
457 felec = qq21*(rinv21*rinvsq21-krf2);
459 /* Update potential sums from outer loop */
464 /* Calculate temporary vectorial force */
469 /* Update vectorial force */
473 f[j_coord_offset+DIM*1+XX] -= tx;
474 f[j_coord_offset+DIM*1+YY] -= ty;
475 f[j_coord_offset+DIM*1+ZZ] -= tz;
479 /**************************
480 * CALCULATE INTERACTIONS *
481 **************************/
486 /* REACTION-FIELD ELECTROSTATICS */
487 velec = qq22*(rinv22+krf*rsq22-crf);
488 felec = qq22*(rinv22*rinvsq22-krf2);
490 /* Update potential sums from outer loop */
495 /* Calculate temporary vectorial force */
500 /* Update vectorial force */
504 f[j_coord_offset+DIM*2+XX] -= tx;
505 f[j_coord_offset+DIM*2+YY] -= ty;
506 f[j_coord_offset+DIM*2+ZZ] -= tz;
510 /**************************
511 * CALCULATE INTERACTIONS *
512 **************************/
517 /* REACTION-FIELD ELECTROSTATICS */
518 velec = qq23*(rinv23+krf*rsq23-crf);
519 felec = qq23*(rinv23*rinvsq23-krf2);
521 /* Update potential sums from outer loop */
526 /* Calculate temporary vectorial force */
531 /* Update vectorial force */
535 f[j_coord_offset+DIM*3+XX] -= tx;
536 f[j_coord_offset+DIM*3+YY] -= ty;
537 f[j_coord_offset+DIM*3+ZZ] -= tz;
541 /**************************
542 * CALCULATE INTERACTIONS *
543 **************************/
548 /* REACTION-FIELD ELECTROSTATICS */
549 velec = qq31*(rinv31+krf*rsq31-crf);
550 felec = qq31*(rinv31*rinvsq31-krf2);
552 /* Update potential sums from outer loop */
557 /* Calculate temporary vectorial force */
562 /* Update vectorial force */
566 f[j_coord_offset+DIM*1+XX] -= tx;
567 f[j_coord_offset+DIM*1+YY] -= ty;
568 f[j_coord_offset+DIM*1+ZZ] -= tz;
572 /**************************
573 * CALCULATE INTERACTIONS *
574 **************************/
579 /* REACTION-FIELD ELECTROSTATICS */
580 velec = qq32*(rinv32+krf*rsq32-crf);
581 felec = qq32*(rinv32*rinvsq32-krf2);
583 /* Update potential sums from outer loop */
588 /* Calculate temporary vectorial force */
593 /* Update vectorial force */
597 f[j_coord_offset+DIM*2+XX] -= tx;
598 f[j_coord_offset+DIM*2+YY] -= ty;
599 f[j_coord_offset+DIM*2+ZZ] -= tz;
603 /**************************
604 * CALCULATE INTERACTIONS *
605 **************************/
610 /* REACTION-FIELD ELECTROSTATICS */
611 velec = qq33*(rinv33+krf*rsq33-crf);
612 felec = qq33*(rinv33*rinvsq33-krf2);
614 /* Update potential sums from outer loop */
619 /* Calculate temporary vectorial force */
624 /* Update vectorial force */
628 f[j_coord_offset+DIM*3+XX] -= tx;
629 f[j_coord_offset+DIM*3+YY] -= ty;
630 f[j_coord_offset+DIM*3+ZZ] -= tz;
634 /* Inner loop uses 334 flops */
636 /* End of innermost loop */
639 f[i_coord_offset+DIM*0+XX] += fix0;
640 f[i_coord_offset+DIM*0+YY] += fiy0;
641 f[i_coord_offset+DIM*0+ZZ] += fiz0;
645 f[i_coord_offset+DIM*1+XX] += fix1;
646 f[i_coord_offset+DIM*1+YY] += fiy1;
647 f[i_coord_offset+DIM*1+ZZ] += fiz1;
651 f[i_coord_offset+DIM*2+XX] += fix2;
652 f[i_coord_offset+DIM*2+YY] += fiy2;
653 f[i_coord_offset+DIM*2+ZZ] += fiz2;
657 f[i_coord_offset+DIM*3+XX] += fix3;
658 f[i_coord_offset+DIM*3+YY] += fiy3;
659 f[i_coord_offset+DIM*3+ZZ] += fiz3;
663 fshift[i_shift_offset+XX] += tx;
664 fshift[i_shift_offset+YY] += ty;
665 fshift[i_shift_offset+ZZ] += tz;
668 /* Update potential energies */
669 kernel_data->energygrp_elec[ggid] += velecsum;
670 kernel_data->energygrp_vdw[ggid] += vvdwsum;
672 /* Increment number of inner iterations */
673 inneriter += j_index_end - j_index_start;
675 /* Outer loop uses 41 flops */
678 /* Increment number of outer iterations */
681 /* Update outer/inner flops */
683 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*334);
686 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_c
687 * Electrostatics interaction: ReactionField
688 * VdW interaction: CubicSplineTable
689 * Geometry: Water4-Water4
690 * Calculate force/pot: Force
693 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_c
694 (t_nblist * gmx_restrict nlist,
695 rvec * gmx_restrict xx,
696 rvec * gmx_restrict ff,
697 t_forcerec * gmx_restrict fr,
698 t_mdatoms * gmx_restrict mdatoms,
699 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
700 t_nrnb * gmx_restrict nrnb)
702 int i_shift_offset,i_coord_offset,j_coord_offset;
703 int j_index_start,j_index_end;
704 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
705 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
706 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
707 real *shiftvec,*fshift,*x,*f;
709 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
711 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
713 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
715 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
717 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
719 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
721 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
723 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
724 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
725 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
726 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
727 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
728 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
729 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
730 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
731 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
732 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
733 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
734 real velec,felec,velecsum,facel,crf,krf,krf2;
737 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
741 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
749 jindex = nlist->jindex;
751 shiftidx = nlist->shift;
753 shiftvec = fr->shift_vec[0];
754 fshift = fr->fshift[0];
756 charge = mdatoms->chargeA;
760 nvdwtype = fr->ntype;
762 vdwtype = mdatoms->typeA;
764 vftab = kernel_data->table_vdw->data;
765 vftabscale = kernel_data->table_vdw->scale;
767 /* Setup water-specific parameters */
768 inr = nlist->iinr[0];
769 iq1 = facel*charge[inr+1];
770 iq2 = facel*charge[inr+2];
771 iq3 = facel*charge[inr+3];
772 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
777 vdwjidx0 = 2*vdwtype[inr+0];
778 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
779 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
790 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
791 rcutoff = fr->rcoulomb;
792 rcutoff2 = rcutoff*rcutoff;
797 /* Start outer loop over neighborlists */
798 for(iidx=0; iidx<nri; iidx++)
800 /* Load shift vector for this list */
801 i_shift_offset = DIM*shiftidx[iidx];
802 shX = shiftvec[i_shift_offset+XX];
803 shY = shiftvec[i_shift_offset+YY];
804 shZ = shiftvec[i_shift_offset+ZZ];
806 /* Load limits for loop over neighbors */
807 j_index_start = jindex[iidx];
808 j_index_end = jindex[iidx+1];
810 /* Get outer coordinate index */
812 i_coord_offset = DIM*inr;
814 /* Load i particle coords and add shift vector */
815 ix0 = shX + x[i_coord_offset+DIM*0+XX];
816 iy0 = shY + x[i_coord_offset+DIM*0+YY];
817 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
818 ix1 = shX + x[i_coord_offset+DIM*1+XX];
819 iy1 = shY + x[i_coord_offset+DIM*1+YY];
820 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
821 ix2 = shX + x[i_coord_offset+DIM*2+XX];
822 iy2 = shY + x[i_coord_offset+DIM*2+YY];
823 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
824 ix3 = shX + x[i_coord_offset+DIM*3+XX];
825 iy3 = shY + x[i_coord_offset+DIM*3+YY];
826 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
841 /* Start inner kernel loop */
842 for(jidx=j_index_start; jidx<j_index_end; jidx++)
844 /* Get j neighbor index, and coordinate index */
846 j_coord_offset = DIM*jnr;
848 /* load j atom coordinates */
849 jx0 = x[j_coord_offset+DIM*0+XX];
850 jy0 = x[j_coord_offset+DIM*0+YY];
851 jz0 = x[j_coord_offset+DIM*0+ZZ];
852 jx1 = x[j_coord_offset+DIM*1+XX];
853 jy1 = x[j_coord_offset+DIM*1+YY];
854 jz1 = x[j_coord_offset+DIM*1+ZZ];
855 jx2 = x[j_coord_offset+DIM*2+XX];
856 jy2 = x[j_coord_offset+DIM*2+YY];
857 jz2 = x[j_coord_offset+DIM*2+ZZ];
858 jx3 = x[j_coord_offset+DIM*3+XX];
859 jy3 = x[j_coord_offset+DIM*3+YY];
860 jz3 = x[j_coord_offset+DIM*3+ZZ];
862 /* Calculate displacement vector */
894 /* Calculate squared distance and things based on it */
895 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
896 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
897 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
898 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
899 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
900 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
901 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
902 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
903 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
904 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
906 rinv00 = gmx_invsqrt(rsq00);
907 rinv11 = gmx_invsqrt(rsq11);
908 rinv12 = gmx_invsqrt(rsq12);
909 rinv13 = gmx_invsqrt(rsq13);
910 rinv21 = gmx_invsqrt(rsq21);
911 rinv22 = gmx_invsqrt(rsq22);
912 rinv23 = gmx_invsqrt(rsq23);
913 rinv31 = gmx_invsqrt(rsq31);
914 rinv32 = gmx_invsqrt(rsq32);
915 rinv33 = gmx_invsqrt(rsq33);
917 rinvsq11 = rinv11*rinv11;
918 rinvsq12 = rinv12*rinv12;
919 rinvsq13 = rinv13*rinv13;
920 rinvsq21 = rinv21*rinv21;
921 rinvsq22 = rinv22*rinv22;
922 rinvsq23 = rinv23*rinv23;
923 rinvsq31 = rinv31*rinv31;
924 rinvsq32 = rinv32*rinv32;
925 rinvsq33 = rinv33*rinv33;
927 /**************************
928 * CALCULATE INTERACTIONS *
929 **************************/
936 /* Calculate table index by multiplying r with table scale and truncate to integer */
942 /* CUBIC SPLINE TABLE DISPERSION */
945 Geps = vfeps*vftab[vfitab+2];
946 Heps2 = vfeps*vfeps*vftab[vfitab+3];
948 FF = Fp+Geps+2.0*Heps2;
951 /* CUBIC SPLINE TABLE REPULSION */
953 Geps = vfeps*vftab[vfitab+6];
954 Heps2 = vfeps*vfeps*vftab[vfitab+7];
956 FF = Fp+Geps+2.0*Heps2;
958 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
962 /* Calculate temporary vectorial force */
967 /* Update vectorial force */
971 f[j_coord_offset+DIM*0+XX] -= tx;
972 f[j_coord_offset+DIM*0+YY] -= ty;
973 f[j_coord_offset+DIM*0+ZZ] -= tz;
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
984 /* REACTION-FIELD ELECTROSTATICS */
985 felec = qq11*(rinv11*rinvsq11-krf2);
989 /* Calculate temporary vectorial force */
994 /* Update vectorial force */
998 f[j_coord_offset+DIM*1+XX] -= tx;
999 f[j_coord_offset+DIM*1+YY] -= ty;
1000 f[j_coord_offset+DIM*1+ZZ] -= tz;
1004 /**************************
1005 * CALCULATE INTERACTIONS *
1006 **************************/
1011 /* REACTION-FIELD ELECTROSTATICS */
1012 felec = qq12*(rinv12*rinvsq12-krf2);
1016 /* Calculate temporary vectorial force */
1021 /* Update vectorial force */
1025 f[j_coord_offset+DIM*2+XX] -= tx;
1026 f[j_coord_offset+DIM*2+YY] -= ty;
1027 f[j_coord_offset+DIM*2+ZZ] -= tz;
1031 /**************************
1032 * CALCULATE INTERACTIONS *
1033 **************************/
1038 /* REACTION-FIELD ELECTROSTATICS */
1039 felec = qq13*(rinv13*rinvsq13-krf2);
1043 /* Calculate temporary vectorial force */
1048 /* Update vectorial force */
1052 f[j_coord_offset+DIM*3+XX] -= tx;
1053 f[j_coord_offset+DIM*3+YY] -= ty;
1054 f[j_coord_offset+DIM*3+ZZ] -= tz;
1058 /**************************
1059 * CALCULATE INTERACTIONS *
1060 **************************/
1065 /* REACTION-FIELD ELECTROSTATICS */
1066 felec = qq21*(rinv21*rinvsq21-krf2);
1070 /* Calculate temporary vectorial force */
1075 /* Update vectorial force */
1079 f[j_coord_offset+DIM*1+XX] -= tx;
1080 f[j_coord_offset+DIM*1+YY] -= ty;
1081 f[j_coord_offset+DIM*1+ZZ] -= tz;
1085 /**************************
1086 * CALCULATE INTERACTIONS *
1087 **************************/
1092 /* REACTION-FIELD ELECTROSTATICS */
1093 felec = qq22*(rinv22*rinvsq22-krf2);
1097 /* Calculate temporary vectorial force */
1102 /* Update vectorial force */
1106 f[j_coord_offset+DIM*2+XX] -= tx;
1107 f[j_coord_offset+DIM*2+YY] -= ty;
1108 f[j_coord_offset+DIM*2+ZZ] -= tz;
1112 /**************************
1113 * CALCULATE INTERACTIONS *
1114 **************************/
1119 /* REACTION-FIELD ELECTROSTATICS */
1120 felec = qq23*(rinv23*rinvsq23-krf2);
1124 /* Calculate temporary vectorial force */
1129 /* Update vectorial force */
1133 f[j_coord_offset+DIM*3+XX] -= tx;
1134 f[j_coord_offset+DIM*3+YY] -= ty;
1135 f[j_coord_offset+DIM*3+ZZ] -= tz;
1139 /**************************
1140 * CALCULATE INTERACTIONS *
1141 **************************/
1146 /* REACTION-FIELD ELECTROSTATICS */
1147 felec = qq31*(rinv31*rinvsq31-krf2);
1151 /* Calculate temporary vectorial force */
1156 /* Update vectorial force */
1160 f[j_coord_offset+DIM*1+XX] -= tx;
1161 f[j_coord_offset+DIM*1+YY] -= ty;
1162 f[j_coord_offset+DIM*1+ZZ] -= tz;
1166 /**************************
1167 * CALCULATE INTERACTIONS *
1168 **************************/
1173 /* REACTION-FIELD ELECTROSTATICS */
1174 felec = qq32*(rinv32*rinvsq32-krf2);
1178 /* Calculate temporary vectorial force */
1183 /* Update vectorial force */
1187 f[j_coord_offset+DIM*2+XX] -= tx;
1188 f[j_coord_offset+DIM*2+YY] -= ty;
1189 f[j_coord_offset+DIM*2+ZZ] -= tz;
1193 /**************************
1194 * CALCULATE INTERACTIONS *
1195 **************************/
1200 /* REACTION-FIELD ELECTROSTATICS */
1201 felec = qq33*(rinv33*rinvsq33-krf2);
1205 /* Calculate temporary vectorial force */
1210 /* Update vectorial force */
1214 f[j_coord_offset+DIM*3+XX] -= tx;
1215 f[j_coord_offset+DIM*3+YY] -= ty;
1216 f[j_coord_offset+DIM*3+ZZ] -= tz;
1220 /* Inner loop uses 281 flops */
1222 /* End of innermost loop */
1225 f[i_coord_offset+DIM*0+XX] += fix0;
1226 f[i_coord_offset+DIM*0+YY] += fiy0;
1227 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1231 f[i_coord_offset+DIM*1+XX] += fix1;
1232 f[i_coord_offset+DIM*1+YY] += fiy1;
1233 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1237 f[i_coord_offset+DIM*2+XX] += fix2;
1238 f[i_coord_offset+DIM*2+YY] += fiy2;
1239 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1243 f[i_coord_offset+DIM*3+XX] += fix3;
1244 f[i_coord_offset+DIM*3+YY] += fiy3;
1245 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1249 fshift[i_shift_offset+XX] += tx;
1250 fshift[i_shift_offset+YY] += ty;
1251 fshift[i_shift_offset+ZZ] += tz;
1253 /* Increment number of inner iterations */
1254 inneriter += j_index_end - j_index_start;
1256 /* Outer loop uses 39 flops */
1259 /* Increment number of outer iterations */
1262 /* Update outer/inner flops */
1264 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*281);