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_VdwLJ_GeomW4W4_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwLJ_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->data;
126 vftabscale = kernel_data->table_elec->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 rinv11 = gmx_invsqrt(rsq11);
268 rinv12 = gmx_invsqrt(rsq12);
269 rinv13 = gmx_invsqrt(rsq13);
270 rinv21 = gmx_invsqrt(rsq21);
271 rinv22 = gmx_invsqrt(rsq22);
272 rinv23 = gmx_invsqrt(rsq23);
273 rinv31 = gmx_invsqrt(rsq31);
274 rinv32 = gmx_invsqrt(rsq32);
275 rinv33 = gmx_invsqrt(rsq33);
277 rinvsq00 = 1.0/rsq00;
279 /**************************
280 * CALCULATE INTERACTIONS *
281 **************************/
283 /* LENNARD-JONES DISPERSION/REPULSION */
285 rinvsix = rinvsq00*rinvsq00*rinvsq00;
286 vvdw6 = c6_00*rinvsix;
287 vvdw12 = c12_00*rinvsix*rinvsix;
288 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
289 fvdw = (vvdw12-vvdw6)*rinvsq00;
291 /* 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 = -qq11*FF*vftabscale*rinv11;
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 = -qq12*FF*vftabscale*rinv12;
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 = -qq13*FF*vftabscale*rinv13;
414 /* Update potential sums from outer loop */
419 /* Calculate temporary vectorial force */
424 /* Update vectorial force */
428 f[j_coord_offset+DIM*3+XX] -= tx;
429 f[j_coord_offset+DIM*3+YY] -= ty;
430 f[j_coord_offset+DIM*3+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 = -qq21*FF*vftabscale*rinv21;
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 = -qq22*FF*vftabscale*rinv22;
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 = -qq23*FF*vftabscale*rinv23;
537 /* Update potential sums from outer loop */
542 /* Calculate temporary vectorial force */
547 /* Update vectorial force */
551 f[j_coord_offset+DIM*3+XX] -= tx;
552 f[j_coord_offset+DIM*3+YY] -= ty;
553 f[j_coord_offset+DIM*3+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 = -qq31*FF*vftabscale*rinv31;
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 = -qq32*FF*vftabscale*rinv32;
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 /**************************
638 * CALCULATE INTERACTIONS *
639 **************************/
643 /* Calculate table index by multiplying r with table scale and truncate to integer */
649 /* CUBIC SPLINE TABLE ELECTROSTATICS */
652 Geps = vfeps*vftab[vfitab+2];
653 Heps2 = vfeps*vfeps*vftab[vfitab+3];
657 FF = Fp+Geps+2.0*Heps2;
658 felec = -qq33*FF*vftabscale*rinv33;
660 /* Update potential sums from outer loop */
665 /* Calculate temporary vectorial force */
670 /* Update vectorial force */
674 f[j_coord_offset+DIM*3+XX] -= tx;
675 f[j_coord_offset+DIM*3+YY] -= ty;
676 f[j_coord_offset+DIM*3+ZZ] -= tz;
678 /* Inner loop uses 401 flops */
680 /* End of innermost loop */
683 f[i_coord_offset+DIM*0+XX] += fix0;
684 f[i_coord_offset+DIM*0+YY] += fiy0;
685 f[i_coord_offset+DIM*0+ZZ] += fiz0;
689 f[i_coord_offset+DIM*1+XX] += fix1;
690 f[i_coord_offset+DIM*1+YY] += fiy1;
691 f[i_coord_offset+DIM*1+ZZ] += fiz1;
695 f[i_coord_offset+DIM*2+XX] += fix2;
696 f[i_coord_offset+DIM*2+YY] += fiy2;
697 f[i_coord_offset+DIM*2+ZZ] += fiz2;
701 f[i_coord_offset+DIM*3+XX] += fix3;
702 f[i_coord_offset+DIM*3+YY] += fiy3;
703 f[i_coord_offset+DIM*3+ZZ] += fiz3;
707 fshift[i_shift_offset+XX] += tx;
708 fshift[i_shift_offset+YY] += ty;
709 fshift[i_shift_offset+ZZ] += tz;
712 /* Update potential energies */
713 kernel_data->energygrp_elec[ggid] += velecsum;
714 kernel_data->energygrp_vdw[ggid] += vvdwsum;
716 /* Increment number of inner iterations */
717 inneriter += j_index_end - j_index_start;
719 /* Outer loop uses 41 flops */
722 /* Increment number of outer iterations */
725 /* Update outer/inner flops */
727 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*401);
730 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_F_c
731 * Electrostatics interaction: CubicSplineTable
732 * VdW interaction: LennardJones
733 * Geometry: Water4-Water4
734 * Calculate force/pot: Force
737 nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_F_c
738 (t_nblist * gmx_restrict nlist,
739 rvec * gmx_restrict xx,
740 rvec * gmx_restrict ff,
741 t_forcerec * gmx_restrict fr,
742 t_mdatoms * gmx_restrict mdatoms,
743 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
744 t_nrnb * gmx_restrict nrnb)
746 int i_shift_offset,i_coord_offset,j_coord_offset;
747 int j_index_start,j_index_end;
748 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
749 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
750 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
751 real *shiftvec,*fshift,*x,*f;
753 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
755 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
757 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
759 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
761 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
763 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
765 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
767 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
768 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
769 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
770 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
771 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
772 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
773 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
774 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
775 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
776 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
777 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
778 real velec,felec,velecsum,facel,crf,krf,krf2;
781 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
785 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
793 jindex = nlist->jindex;
795 shiftidx = nlist->shift;
797 shiftvec = fr->shift_vec[0];
798 fshift = fr->fshift[0];
800 charge = mdatoms->chargeA;
801 nvdwtype = fr->ntype;
803 vdwtype = mdatoms->typeA;
805 vftab = kernel_data->table_elec->data;
806 vftabscale = kernel_data->table_elec->scale;
808 /* Setup water-specific parameters */
809 inr = nlist->iinr[0];
810 iq1 = facel*charge[inr+1];
811 iq2 = facel*charge[inr+2];
812 iq3 = facel*charge[inr+3];
813 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
818 vdwjidx0 = 2*vdwtype[inr+0];
819 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
820 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
834 /* Start outer loop over neighborlists */
835 for(iidx=0; iidx<nri; iidx++)
837 /* Load shift vector for this list */
838 i_shift_offset = DIM*shiftidx[iidx];
839 shX = shiftvec[i_shift_offset+XX];
840 shY = shiftvec[i_shift_offset+YY];
841 shZ = shiftvec[i_shift_offset+ZZ];
843 /* Load limits for loop over neighbors */
844 j_index_start = jindex[iidx];
845 j_index_end = jindex[iidx+1];
847 /* Get outer coordinate index */
849 i_coord_offset = DIM*inr;
851 /* Load i particle coords and add shift vector */
852 ix0 = shX + x[i_coord_offset+DIM*0+XX];
853 iy0 = shY + x[i_coord_offset+DIM*0+YY];
854 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
855 ix1 = shX + x[i_coord_offset+DIM*1+XX];
856 iy1 = shY + x[i_coord_offset+DIM*1+YY];
857 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
858 ix2 = shX + x[i_coord_offset+DIM*2+XX];
859 iy2 = shY + x[i_coord_offset+DIM*2+YY];
860 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
861 ix3 = shX + x[i_coord_offset+DIM*3+XX];
862 iy3 = shY + x[i_coord_offset+DIM*3+YY];
863 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
878 /* Start inner kernel loop */
879 for(jidx=j_index_start; jidx<j_index_end; jidx++)
881 /* Get j neighbor index, and coordinate index */
883 j_coord_offset = DIM*jnr;
885 /* load j atom coordinates */
886 jx0 = x[j_coord_offset+DIM*0+XX];
887 jy0 = x[j_coord_offset+DIM*0+YY];
888 jz0 = x[j_coord_offset+DIM*0+ZZ];
889 jx1 = x[j_coord_offset+DIM*1+XX];
890 jy1 = x[j_coord_offset+DIM*1+YY];
891 jz1 = x[j_coord_offset+DIM*1+ZZ];
892 jx2 = x[j_coord_offset+DIM*2+XX];
893 jy2 = x[j_coord_offset+DIM*2+YY];
894 jz2 = x[j_coord_offset+DIM*2+ZZ];
895 jx3 = x[j_coord_offset+DIM*3+XX];
896 jy3 = x[j_coord_offset+DIM*3+YY];
897 jz3 = x[j_coord_offset+DIM*3+ZZ];
899 /* Calculate displacement vector */
931 /* Calculate squared distance and things based on it */
932 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
933 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
934 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
935 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
936 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
937 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
938 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
939 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
940 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
941 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
943 rinv11 = gmx_invsqrt(rsq11);
944 rinv12 = gmx_invsqrt(rsq12);
945 rinv13 = gmx_invsqrt(rsq13);
946 rinv21 = gmx_invsqrt(rsq21);
947 rinv22 = gmx_invsqrt(rsq22);
948 rinv23 = gmx_invsqrt(rsq23);
949 rinv31 = gmx_invsqrt(rsq31);
950 rinv32 = gmx_invsqrt(rsq32);
951 rinv33 = gmx_invsqrt(rsq33);
953 rinvsq00 = 1.0/rsq00;
955 /**************************
956 * CALCULATE INTERACTIONS *
957 **************************/
959 /* LENNARD-JONES DISPERSION/REPULSION */
961 rinvsix = rinvsq00*rinvsq00*rinvsq00;
962 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
966 /* Calculate temporary vectorial force */
971 /* Update vectorial force */
975 f[j_coord_offset+DIM*0+XX] -= tx;
976 f[j_coord_offset+DIM*0+YY] -= ty;
977 f[j_coord_offset+DIM*0+ZZ] -= tz;
979 /**************************
980 * CALCULATE INTERACTIONS *
981 **************************/
985 /* Calculate table index by multiplying r with table scale and truncate to integer */
991 /* CUBIC SPLINE TABLE ELECTROSTATICS */
993 Geps = vfeps*vftab[vfitab+2];
994 Heps2 = vfeps*vfeps*vftab[vfitab+3];
996 FF = Fp+Geps+2.0*Heps2;
997 felec = -qq11*FF*vftabscale*rinv11;
1001 /* Calculate temporary vectorial force */
1006 /* Update vectorial force */
1010 f[j_coord_offset+DIM*1+XX] -= tx;
1011 f[j_coord_offset+DIM*1+YY] -= ty;
1012 f[j_coord_offset+DIM*1+ZZ] -= tz;
1014 /**************************
1015 * CALCULATE INTERACTIONS *
1016 **************************/
1020 /* Calculate table index by multiplying r with table scale and truncate to integer */
1021 rt = r12*vftabscale;
1024 vfitab = 1*4*vfitab;
1026 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1027 F = vftab[vfitab+1];
1028 Geps = vfeps*vftab[vfitab+2];
1029 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1031 FF = Fp+Geps+2.0*Heps2;
1032 felec = -qq12*FF*vftabscale*rinv12;
1036 /* Calculate temporary vectorial force */
1041 /* Update vectorial force */
1045 f[j_coord_offset+DIM*2+XX] -= tx;
1046 f[j_coord_offset+DIM*2+YY] -= ty;
1047 f[j_coord_offset+DIM*2+ZZ] -= tz;
1049 /**************************
1050 * CALCULATE INTERACTIONS *
1051 **************************/
1055 /* Calculate table index by multiplying r with table scale and truncate to integer */
1056 rt = r13*vftabscale;
1059 vfitab = 1*4*vfitab;
1061 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1062 F = vftab[vfitab+1];
1063 Geps = vfeps*vftab[vfitab+2];
1064 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1066 FF = Fp+Geps+2.0*Heps2;
1067 felec = -qq13*FF*vftabscale*rinv13;
1071 /* Calculate temporary vectorial force */
1076 /* Update vectorial force */
1080 f[j_coord_offset+DIM*3+XX] -= tx;
1081 f[j_coord_offset+DIM*3+YY] -= ty;
1082 f[j_coord_offset+DIM*3+ZZ] -= tz;
1084 /**************************
1085 * CALCULATE INTERACTIONS *
1086 **************************/
1090 /* Calculate table index by multiplying r with table scale and truncate to integer */
1091 rt = r21*vftabscale;
1094 vfitab = 1*4*vfitab;
1096 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1097 F = vftab[vfitab+1];
1098 Geps = vfeps*vftab[vfitab+2];
1099 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1101 FF = Fp+Geps+2.0*Heps2;
1102 felec = -qq21*FF*vftabscale*rinv21;
1106 /* Calculate temporary vectorial force */
1111 /* Update vectorial force */
1115 f[j_coord_offset+DIM*1+XX] -= tx;
1116 f[j_coord_offset+DIM*1+YY] -= ty;
1117 f[j_coord_offset+DIM*1+ZZ] -= tz;
1119 /**************************
1120 * CALCULATE INTERACTIONS *
1121 **************************/
1125 /* Calculate table index by multiplying r with table scale and truncate to integer */
1126 rt = r22*vftabscale;
1129 vfitab = 1*4*vfitab;
1131 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1132 F = vftab[vfitab+1];
1133 Geps = vfeps*vftab[vfitab+2];
1134 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1136 FF = Fp+Geps+2.0*Heps2;
1137 felec = -qq22*FF*vftabscale*rinv22;
1141 /* Calculate temporary vectorial force */
1146 /* Update vectorial force */
1150 f[j_coord_offset+DIM*2+XX] -= tx;
1151 f[j_coord_offset+DIM*2+YY] -= ty;
1152 f[j_coord_offset+DIM*2+ZZ] -= tz;
1154 /**************************
1155 * CALCULATE INTERACTIONS *
1156 **************************/
1160 /* Calculate table index by multiplying r with table scale and truncate to integer */
1161 rt = r23*vftabscale;
1164 vfitab = 1*4*vfitab;
1166 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1167 F = vftab[vfitab+1];
1168 Geps = vfeps*vftab[vfitab+2];
1169 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1171 FF = Fp+Geps+2.0*Heps2;
1172 felec = -qq23*FF*vftabscale*rinv23;
1176 /* Calculate temporary vectorial force */
1181 /* Update vectorial force */
1185 f[j_coord_offset+DIM*3+XX] -= tx;
1186 f[j_coord_offset+DIM*3+YY] -= ty;
1187 f[j_coord_offset+DIM*3+ZZ] -= tz;
1189 /**************************
1190 * CALCULATE INTERACTIONS *
1191 **************************/
1195 /* Calculate table index by multiplying r with table scale and truncate to integer */
1196 rt = r31*vftabscale;
1199 vfitab = 1*4*vfitab;
1201 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1202 F = vftab[vfitab+1];
1203 Geps = vfeps*vftab[vfitab+2];
1204 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1206 FF = Fp+Geps+2.0*Heps2;
1207 felec = -qq31*FF*vftabscale*rinv31;
1211 /* Calculate temporary vectorial force */
1216 /* Update vectorial force */
1220 f[j_coord_offset+DIM*1+XX] -= tx;
1221 f[j_coord_offset+DIM*1+YY] -= ty;
1222 f[j_coord_offset+DIM*1+ZZ] -= tz;
1224 /**************************
1225 * CALCULATE INTERACTIONS *
1226 **************************/
1230 /* Calculate table index by multiplying r with table scale and truncate to integer */
1231 rt = r32*vftabscale;
1234 vfitab = 1*4*vfitab;
1236 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1237 F = vftab[vfitab+1];
1238 Geps = vfeps*vftab[vfitab+2];
1239 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1241 FF = Fp+Geps+2.0*Heps2;
1242 felec = -qq32*FF*vftabscale*rinv32;
1246 /* Calculate temporary vectorial force */
1251 /* Update vectorial force */
1255 f[j_coord_offset+DIM*2+XX] -= tx;
1256 f[j_coord_offset+DIM*2+YY] -= ty;
1257 f[j_coord_offset+DIM*2+ZZ] -= tz;
1259 /**************************
1260 * CALCULATE INTERACTIONS *
1261 **************************/
1265 /* Calculate table index by multiplying r with table scale and truncate to integer */
1266 rt = r33*vftabscale;
1269 vfitab = 1*4*vfitab;
1271 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1272 F = vftab[vfitab+1];
1273 Geps = vfeps*vftab[vfitab+2];
1274 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1276 FF = Fp+Geps+2.0*Heps2;
1277 felec = -qq33*FF*vftabscale*rinv33;
1281 /* Calculate temporary vectorial force */
1286 /* Update vectorial force */
1290 f[j_coord_offset+DIM*3+XX] -= tx;
1291 f[j_coord_offset+DIM*3+YY] -= ty;
1292 f[j_coord_offset+DIM*3+ZZ] -= tz;
1294 /* Inner loop uses 360 flops */
1296 /* End of innermost loop */
1299 f[i_coord_offset+DIM*0+XX] += fix0;
1300 f[i_coord_offset+DIM*0+YY] += fiy0;
1301 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1305 f[i_coord_offset+DIM*1+XX] += fix1;
1306 f[i_coord_offset+DIM*1+YY] += fiy1;
1307 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1311 f[i_coord_offset+DIM*2+XX] += fix2;
1312 f[i_coord_offset+DIM*2+YY] += fiy2;
1313 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1317 f[i_coord_offset+DIM*3+XX] += fix3;
1318 f[i_coord_offset+DIM*3+YY] += fiy3;
1319 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1323 fshift[i_shift_offset+XX] += tx;
1324 fshift[i_shift_offset+YY] += ty;
1325 fshift[i_shift_offset+ZZ] += tz;
1327 /* Increment number of inner iterations */
1328 inneriter += j_index_end - j_index_start;
1330 /* Outer loop uses 39 flops */
1333 /* Increment number of outer iterations */
1336 /* Update outer/inner flops */
1338 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*360);