2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
65 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
67 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
69 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
71 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
72 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
73 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
74 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
75 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
76 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
77 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
78 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
79 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
80 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
81 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
82 real velec,felec,velecsum,facel,crf,krf,krf2;
85 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
89 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
97 jindex = nlist->jindex;
99 shiftidx = nlist->shift;
101 shiftvec = fr->shift_vec[0];
102 fshift = fr->fshift[0];
104 charge = mdatoms->chargeA;
105 nvdwtype = fr->ntype;
107 vdwtype = mdatoms->typeA;
109 vftab = kernel_data->table_elec->data;
110 vftabscale = kernel_data->table_elec->scale;
112 /* Setup water-specific parameters */
113 inr = nlist->iinr[0];
114 iq1 = facel*charge[inr+1];
115 iq2 = facel*charge[inr+2];
116 iq3 = facel*charge[inr+3];
117 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
122 vdwjidx0 = 2*vdwtype[inr+0];
123 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
124 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
138 /* Start outer loop over neighborlists */
139 for(iidx=0; iidx<nri; iidx++)
141 /* Load shift vector for this list */
142 i_shift_offset = DIM*shiftidx[iidx];
143 shX = shiftvec[i_shift_offset+XX];
144 shY = shiftvec[i_shift_offset+YY];
145 shZ = shiftvec[i_shift_offset+ZZ];
147 /* Load limits for loop over neighbors */
148 j_index_start = jindex[iidx];
149 j_index_end = jindex[iidx+1];
151 /* Get outer coordinate index */
153 i_coord_offset = DIM*inr;
155 /* Load i particle coords and add shift vector */
156 ix0 = shX + x[i_coord_offset+DIM*0+XX];
157 iy0 = shY + x[i_coord_offset+DIM*0+YY];
158 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
159 ix1 = shX + x[i_coord_offset+DIM*1+XX];
160 iy1 = shY + x[i_coord_offset+DIM*1+YY];
161 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
162 ix2 = shX + x[i_coord_offset+DIM*2+XX];
163 iy2 = shY + x[i_coord_offset+DIM*2+YY];
164 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
165 ix3 = shX + x[i_coord_offset+DIM*3+XX];
166 iy3 = shY + x[i_coord_offset+DIM*3+YY];
167 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
182 /* Reset potential sums */
186 /* Start inner kernel loop */
187 for(jidx=j_index_start; jidx<j_index_end; jidx++)
189 /* Get j neighbor index, and coordinate index */
191 j_coord_offset = DIM*jnr;
193 /* load j atom coordinates */
194 jx0 = x[j_coord_offset+DIM*0+XX];
195 jy0 = x[j_coord_offset+DIM*0+YY];
196 jz0 = x[j_coord_offset+DIM*0+ZZ];
197 jx1 = x[j_coord_offset+DIM*1+XX];
198 jy1 = x[j_coord_offset+DIM*1+YY];
199 jz1 = x[j_coord_offset+DIM*1+ZZ];
200 jx2 = x[j_coord_offset+DIM*2+XX];
201 jy2 = x[j_coord_offset+DIM*2+YY];
202 jz2 = x[j_coord_offset+DIM*2+ZZ];
203 jx3 = x[j_coord_offset+DIM*3+XX];
204 jy3 = x[j_coord_offset+DIM*3+YY];
205 jz3 = x[j_coord_offset+DIM*3+ZZ];
207 /* Calculate displacement vector */
239 /* Calculate squared distance and things based on it */
240 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
241 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
242 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
243 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
244 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
245 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
246 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
247 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
248 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
249 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
251 rinv11 = gmx_invsqrt(rsq11);
252 rinv12 = gmx_invsqrt(rsq12);
253 rinv13 = gmx_invsqrt(rsq13);
254 rinv21 = gmx_invsqrt(rsq21);
255 rinv22 = gmx_invsqrt(rsq22);
256 rinv23 = gmx_invsqrt(rsq23);
257 rinv31 = gmx_invsqrt(rsq31);
258 rinv32 = gmx_invsqrt(rsq32);
259 rinv33 = gmx_invsqrt(rsq33);
261 rinvsq00 = 1.0/rsq00;
263 /**************************
264 * CALCULATE INTERACTIONS *
265 **************************/
267 /* LENNARD-JONES DISPERSION/REPULSION */
269 rinvsix = rinvsq00*rinvsq00*rinvsq00;
270 vvdw6 = c6_00*rinvsix;
271 vvdw12 = c12_00*rinvsix*rinvsix;
272 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
273 fvdw = (vvdw12-vvdw6)*rinvsq00;
275 /* Update potential sums from outer loop */
280 /* Calculate temporary vectorial force */
285 /* Update vectorial force */
289 f[j_coord_offset+DIM*0+XX] -= tx;
290 f[j_coord_offset+DIM*0+YY] -= ty;
291 f[j_coord_offset+DIM*0+ZZ] -= tz;
293 /**************************
294 * CALCULATE INTERACTIONS *
295 **************************/
299 /* Calculate table index by multiplying r with table scale and truncate to integer */
305 /* CUBIC SPLINE TABLE ELECTROSTATICS */
308 Geps = vfeps*vftab[vfitab+2];
309 Heps2 = vfeps*vfeps*vftab[vfitab+3];
313 FF = Fp+Geps+2.0*Heps2;
314 felec = -qq11*FF*vftabscale*rinv11;
316 /* Update potential sums from outer loop */
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*1+XX] -= tx;
331 f[j_coord_offset+DIM*1+YY] -= ty;
332 f[j_coord_offset+DIM*1+ZZ] -= tz;
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
340 /* Calculate table index by multiplying r with table scale and truncate to integer */
346 /* CUBIC SPLINE TABLE ELECTROSTATICS */
349 Geps = vfeps*vftab[vfitab+2];
350 Heps2 = vfeps*vfeps*vftab[vfitab+3];
354 FF = Fp+Geps+2.0*Heps2;
355 felec = -qq12*FF*vftabscale*rinv12;
357 /* Update potential sums from outer loop */
362 /* Calculate temporary vectorial force */
367 /* Update vectorial force */
371 f[j_coord_offset+DIM*2+XX] -= tx;
372 f[j_coord_offset+DIM*2+YY] -= ty;
373 f[j_coord_offset+DIM*2+ZZ] -= tz;
375 /**************************
376 * CALCULATE INTERACTIONS *
377 **************************/
381 /* Calculate table index by multiplying r with table scale and truncate to integer */
387 /* CUBIC SPLINE TABLE ELECTROSTATICS */
390 Geps = vfeps*vftab[vfitab+2];
391 Heps2 = vfeps*vfeps*vftab[vfitab+3];
395 FF = Fp+Geps+2.0*Heps2;
396 felec = -qq13*FF*vftabscale*rinv13;
398 /* Update potential sums from outer loop */
403 /* Calculate temporary vectorial force */
408 /* Update vectorial force */
412 f[j_coord_offset+DIM*3+XX] -= tx;
413 f[j_coord_offset+DIM*3+YY] -= ty;
414 f[j_coord_offset+DIM*3+ZZ] -= tz;
416 /**************************
417 * CALCULATE INTERACTIONS *
418 **************************/
422 /* Calculate table index by multiplying r with table scale and truncate to integer */
428 /* CUBIC SPLINE TABLE ELECTROSTATICS */
431 Geps = vfeps*vftab[vfitab+2];
432 Heps2 = vfeps*vfeps*vftab[vfitab+3];
436 FF = Fp+Geps+2.0*Heps2;
437 felec = -qq21*FF*vftabscale*rinv21;
439 /* Update potential sums from outer loop */
444 /* Calculate temporary vectorial force */
449 /* Update vectorial force */
453 f[j_coord_offset+DIM*1+XX] -= tx;
454 f[j_coord_offset+DIM*1+YY] -= ty;
455 f[j_coord_offset+DIM*1+ZZ] -= tz;
457 /**************************
458 * CALCULATE INTERACTIONS *
459 **************************/
463 /* Calculate table index by multiplying r with table scale and truncate to integer */
469 /* CUBIC SPLINE TABLE ELECTROSTATICS */
472 Geps = vfeps*vftab[vfitab+2];
473 Heps2 = vfeps*vfeps*vftab[vfitab+3];
477 FF = Fp+Geps+2.0*Heps2;
478 felec = -qq22*FF*vftabscale*rinv22;
480 /* Update potential sums from outer loop */
485 /* Calculate temporary vectorial force */
490 /* Update vectorial force */
494 f[j_coord_offset+DIM*2+XX] -= tx;
495 f[j_coord_offset+DIM*2+YY] -= ty;
496 f[j_coord_offset+DIM*2+ZZ] -= tz;
498 /**************************
499 * CALCULATE INTERACTIONS *
500 **************************/
504 /* Calculate table index by multiplying r with table scale and truncate to integer */
510 /* CUBIC SPLINE TABLE ELECTROSTATICS */
513 Geps = vfeps*vftab[vfitab+2];
514 Heps2 = vfeps*vfeps*vftab[vfitab+3];
518 FF = Fp+Geps+2.0*Heps2;
519 felec = -qq23*FF*vftabscale*rinv23;
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;
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
545 /* Calculate table index by multiplying r with table scale and truncate to integer */
551 /* CUBIC SPLINE TABLE ELECTROSTATICS */
554 Geps = vfeps*vftab[vfitab+2];
555 Heps2 = vfeps*vfeps*vftab[vfitab+3];
559 FF = Fp+Geps+2.0*Heps2;
560 felec = -qq31*FF*vftabscale*rinv31;
562 /* Update potential sums from outer loop */
567 /* Calculate temporary vectorial force */
572 /* Update vectorial force */
576 f[j_coord_offset+DIM*1+XX] -= tx;
577 f[j_coord_offset+DIM*1+YY] -= ty;
578 f[j_coord_offset+DIM*1+ZZ] -= tz;
580 /**************************
581 * CALCULATE INTERACTIONS *
582 **************************/
586 /* Calculate table index by multiplying r with table scale and truncate to integer */
592 /* CUBIC SPLINE TABLE ELECTROSTATICS */
595 Geps = vfeps*vftab[vfitab+2];
596 Heps2 = vfeps*vfeps*vftab[vfitab+3];
600 FF = Fp+Geps+2.0*Heps2;
601 felec = -qq32*FF*vftabscale*rinv32;
603 /* Update potential sums from outer loop */
608 /* Calculate temporary vectorial force */
613 /* Update vectorial force */
617 f[j_coord_offset+DIM*2+XX] -= tx;
618 f[j_coord_offset+DIM*2+YY] -= ty;
619 f[j_coord_offset+DIM*2+ZZ] -= tz;
621 /**************************
622 * CALCULATE INTERACTIONS *
623 **************************/
627 /* Calculate table index by multiplying r with table scale and truncate to integer */
633 /* CUBIC SPLINE TABLE ELECTROSTATICS */
636 Geps = vfeps*vftab[vfitab+2];
637 Heps2 = vfeps*vfeps*vftab[vfitab+3];
641 FF = Fp+Geps+2.0*Heps2;
642 felec = -qq33*FF*vftabscale*rinv33;
644 /* Update potential sums from outer loop */
649 /* Calculate temporary vectorial force */
654 /* Update vectorial force */
658 f[j_coord_offset+DIM*3+XX] -= tx;
659 f[j_coord_offset+DIM*3+YY] -= ty;
660 f[j_coord_offset+DIM*3+ZZ] -= tz;
662 /* Inner loop uses 401 flops */
664 /* End of innermost loop */
667 f[i_coord_offset+DIM*0+XX] += fix0;
668 f[i_coord_offset+DIM*0+YY] += fiy0;
669 f[i_coord_offset+DIM*0+ZZ] += fiz0;
673 f[i_coord_offset+DIM*1+XX] += fix1;
674 f[i_coord_offset+DIM*1+YY] += fiy1;
675 f[i_coord_offset+DIM*1+ZZ] += fiz1;
679 f[i_coord_offset+DIM*2+XX] += fix2;
680 f[i_coord_offset+DIM*2+YY] += fiy2;
681 f[i_coord_offset+DIM*2+ZZ] += fiz2;
685 f[i_coord_offset+DIM*3+XX] += fix3;
686 f[i_coord_offset+DIM*3+YY] += fiy3;
687 f[i_coord_offset+DIM*3+ZZ] += fiz3;
691 fshift[i_shift_offset+XX] += tx;
692 fshift[i_shift_offset+YY] += ty;
693 fshift[i_shift_offset+ZZ] += tz;
696 /* Update potential energies */
697 kernel_data->energygrp_elec[ggid] += velecsum;
698 kernel_data->energygrp_vdw[ggid] += vvdwsum;
700 /* Increment number of inner iterations */
701 inneriter += j_index_end - j_index_start;
703 /* Outer loop uses 41 flops */
706 /* Increment number of outer iterations */
709 /* Update outer/inner flops */
711 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*401);
714 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_F_c
715 * Electrostatics interaction: CubicSplineTable
716 * VdW interaction: LennardJones
717 * Geometry: Water4-Water4
718 * Calculate force/pot: Force
721 nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_F_c
722 (t_nblist * gmx_restrict nlist,
723 rvec * gmx_restrict xx,
724 rvec * gmx_restrict ff,
725 t_forcerec * gmx_restrict fr,
726 t_mdatoms * gmx_restrict mdatoms,
727 nb_kernel_data_t * gmx_restrict kernel_data,
728 t_nrnb * gmx_restrict nrnb)
730 int i_shift_offset,i_coord_offset,j_coord_offset;
731 int j_index_start,j_index_end;
732 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
733 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
734 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
735 real *shiftvec,*fshift,*x,*f;
737 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
739 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
741 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
743 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
745 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
747 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
749 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
751 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
752 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
753 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
754 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
755 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
756 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
757 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
758 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
759 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
760 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
761 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
762 real velec,felec,velecsum,facel,crf,krf,krf2;
765 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
769 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
777 jindex = nlist->jindex;
779 shiftidx = nlist->shift;
781 shiftvec = fr->shift_vec[0];
782 fshift = fr->fshift[0];
784 charge = mdatoms->chargeA;
785 nvdwtype = fr->ntype;
787 vdwtype = mdatoms->typeA;
789 vftab = kernel_data->table_elec->data;
790 vftabscale = kernel_data->table_elec->scale;
792 /* Setup water-specific parameters */
793 inr = nlist->iinr[0];
794 iq1 = facel*charge[inr+1];
795 iq2 = facel*charge[inr+2];
796 iq3 = facel*charge[inr+3];
797 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
802 vdwjidx0 = 2*vdwtype[inr+0];
803 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
804 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
818 /* Start outer loop over neighborlists */
819 for(iidx=0; iidx<nri; iidx++)
821 /* Load shift vector for this list */
822 i_shift_offset = DIM*shiftidx[iidx];
823 shX = shiftvec[i_shift_offset+XX];
824 shY = shiftvec[i_shift_offset+YY];
825 shZ = shiftvec[i_shift_offset+ZZ];
827 /* Load limits for loop over neighbors */
828 j_index_start = jindex[iidx];
829 j_index_end = jindex[iidx+1];
831 /* Get outer coordinate index */
833 i_coord_offset = DIM*inr;
835 /* Load i particle coords and add shift vector */
836 ix0 = shX + x[i_coord_offset+DIM*0+XX];
837 iy0 = shY + x[i_coord_offset+DIM*0+YY];
838 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
839 ix1 = shX + x[i_coord_offset+DIM*1+XX];
840 iy1 = shY + x[i_coord_offset+DIM*1+YY];
841 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
842 ix2 = shX + x[i_coord_offset+DIM*2+XX];
843 iy2 = shY + x[i_coord_offset+DIM*2+YY];
844 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
845 ix3 = shX + x[i_coord_offset+DIM*3+XX];
846 iy3 = shY + x[i_coord_offset+DIM*3+YY];
847 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
862 /* Start inner kernel loop */
863 for(jidx=j_index_start; jidx<j_index_end; jidx++)
865 /* Get j neighbor index, and coordinate index */
867 j_coord_offset = DIM*jnr;
869 /* load j atom coordinates */
870 jx0 = x[j_coord_offset+DIM*0+XX];
871 jy0 = x[j_coord_offset+DIM*0+YY];
872 jz0 = x[j_coord_offset+DIM*0+ZZ];
873 jx1 = x[j_coord_offset+DIM*1+XX];
874 jy1 = x[j_coord_offset+DIM*1+YY];
875 jz1 = x[j_coord_offset+DIM*1+ZZ];
876 jx2 = x[j_coord_offset+DIM*2+XX];
877 jy2 = x[j_coord_offset+DIM*2+YY];
878 jz2 = x[j_coord_offset+DIM*2+ZZ];
879 jx3 = x[j_coord_offset+DIM*3+XX];
880 jy3 = x[j_coord_offset+DIM*3+YY];
881 jz3 = x[j_coord_offset+DIM*3+ZZ];
883 /* Calculate displacement vector */
915 /* Calculate squared distance and things based on it */
916 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
917 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
918 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
919 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
920 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
921 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
922 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
923 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
924 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
925 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
927 rinv11 = gmx_invsqrt(rsq11);
928 rinv12 = gmx_invsqrt(rsq12);
929 rinv13 = gmx_invsqrt(rsq13);
930 rinv21 = gmx_invsqrt(rsq21);
931 rinv22 = gmx_invsqrt(rsq22);
932 rinv23 = gmx_invsqrt(rsq23);
933 rinv31 = gmx_invsqrt(rsq31);
934 rinv32 = gmx_invsqrt(rsq32);
935 rinv33 = gmx_invsqrt(rsq33);
937 rinvsq00 = 1.0/rsq00;
939 /**************************
940 * CALCULATE INTERACTIONS *
941 **************************/
943 /* LENNARD-JONES DISPERSION/REPULSION */
945 rinvsix = rinvsq00*rinvsq00*rinvsq00;
946 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
950 /* Calculate temporary vectorial force */
955 /* Update vectorial force */
959 f[j_coord_offset+DIM*0+XX] -= tx;
960 f[j_coord_offset+DIM*0+YY] -= ty;
961 f[j_coord_offset+DIM*0+ZZ] -= tz;
963 /**************************
964 * CALCULATE INTERACTIONS *
965 **************************/
969 /* Calculate table index by multiplying r with table scale and truncate to integer */
975 /* CUBIC SPLINE TABLE ELECTROSTATICS */
977 Geps = vfeps*vftab[vfitab+2];
978 Heps2 = vfeps*vfeps*vftab[vfitab+3];
980 FF = Fp+Geps+2.0*Heps2;
981 felec = -qq11*FF*vftabscale*rinv11;
985 /* Calculate temporary vectorial force */
990 /* Update vectorial force */
994 f[j_coord_offset+DIM*1+XX] -= tx;
995 f[j_coord_offset+DIM*1+YY] -= ty;
996 f[j_coord_offset+DIM*1+ZZ] -= tz;
998 /**************************
999 * CALCULATE INTERACTIONS *
1000 **************************/
1004 /* Calculate table index by multiplying r with table scale and truncate to integer */
1005 rt = r12*vftabscale;
1008 vfitab = 1*4*vfitab;
1010 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1011 F = vftab[vfitab+1];
1012 Geps = vfeps*vftab[vfitab+2];
1013 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1015 FF = Fp+Geps+2.0*Heps2;
1016 felec = -qq12*FF*vftabscale*rinv12;
1020 /* Calculate temporary vectorial force */
1025 /* Update vectorial force */
1029 f[j_coord_offset+DIM*2+XX] -= tx;
1030 f[j_coord_offset+DIM*2+YY] -= ty;
1031 f[j_coord_offset+DIM*2+ZZ] -= tz;
1033 /**************************
1034 * CALCULATE INTERACTIONS *
1035 **************************/
1039 /* Calculate table index by multiplying r with table scale and truncate to integer */
1040 rt = r13*vftabscale;
1043 vfitab = 1*4*vfitab;
1045 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1046 F = vftab[vfitab+1];
1047 Geps = vfeps*vftab[vfitab+2];
1048 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1050 FF = Fp+Geps+2.0*Heps2;
1051 felec = -qq13*FF*vftabscale*rinv13;
1055 /* Calculate temporary vectorial force */
1060 /* Update vectorial force */
1064 f[j_coord_offset+DIM*3+XX] -= tx;
1065 f[j_coord_offset+DIM*3+YY] -= ty;
1066 f[j_coord_offset+DIM*3+ZZ] -= tz;
1068 /**************************
1069 * CALCULATE INTERACTIONS *
1070 **************************/
1074 /* Calculate table index by multiplying r with table scale and truncate to integer */
1075 rt = r21*vftabscale;
1078 vfitab = 1*4*vfitab;
1080 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1081 F = vftab[vfitab+1];
1082 Geps = vfeps*vftab[vfitab+2];
1083 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1085 FF = Fp+Geps+2.0*Heps2;
1086 felec = -qq21*FF*vftabscale*rinv21;
1090 /* Calculate temporary vectorial force */
1095 /* Update vectorial force */
1099 f[j_coord_offset+DIM*1+XX] -= tx;
1100 f[j_coord_offset+DIM*1+YY] -= ty;
1101 f[j_coord_offset+DIM*1+ZZ] -= tz;
1103 /**************************
1104 * CALCULATE INTERACTIONS *
1105 **************************/
1109 /* Calculate table index by multiplying r with table scale and truncate to integer */
1110 rt = r22*vftabscale;
1113 vfitab = 1*4*vfitab;
1115 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1116 F = vftab[vfitab+1];
1117 Geps = vfeps*vftab[vfitab+2];
1118 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1120 FF = Fp+Geps+2.0*Heps2;
1121 felec = -qq22*FF*vftabscale*rinv22;
1125 /* Calculate temporary vectorial force */
1130 /* Update vectorial force */
1134 f[j_coord_offset+DIM*2+XX] -= tx;
1135 f[j_coord_offset+DIM*2+YY] -= ty;
1136 f[j_coord_offset+DIM*2+ZZ] -= tz;
1138 /**************************
1139 * CALCULATE INTERACTIONS *
1140 **************************/
1144 /* Calculate table index by multiplying r with table scale and truncate to integer */
1145 rt = r23*vftabscale;
1148 vfitab = 1*4*vfitab;
1150 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1151 F = vftab[vfitab+1];
1152 Geps = vfeps*vftab[vfitab+2];
1153 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1155 FF = Fp+Geps+2.0*Heps2;
1156 felec = -qq23*FF*vftabscale*rinv23;
1160 /* Calculate temporary vectorial force */
1165 /* Update vectorial force */
1169 f[j_coord_offset+DIM*3+XX] -= tx;
1170 f[j_coord_offset+DIM*3+YY] -= ty;
1171 f[j_coord_offset+DIM*3+ZZ] -= tz;
1173 /**************************
1174 * CALCULATE INTERACTIONS *
1175 **************************/
1179 /* Calculate table index by multiplying r with table scale and truncate to integer */
1180 rt = r31*vftabscale;
1183 vfitab = 1*4*vfitab;
1185 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1186 F = vftab[vfitab+1];
1187 Geps = vfeps*vftab[vfitab+2];
1188 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1190 FF = Fp+Geps+2.0*Heps2;
1191 felec = -qq31*FF*vftabscale*rinv31;
1195 /* Calculate temporary vectorial force */
1200 /* Update vectorial force */
1204 f[j_coord_offset+DIM*1+XX] -= tx;
1205 f[j_coord_offset+DIM*1+YY] -= ty;
1206 f[j_coord_offset+DIM*1+ZZ] -= tz;
1208 /**************************
1209 * CALCULATE INTERACTIONS *
1210 **************************/
1214 /* Calculate table index by multiplying r with table scale and truncate to integer */
1215 rt = r32*vftabscale;
1218 vfitab = 1*4*vfitab;
1220 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1221 F = vftab[vfitab+1];
1222 Geps = vfeps*vftab[vfitab+2];
1223 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1225 FF = Fp+Geps+2.0*Heps2;
1226 felec = -qq32*FF*vftabscale*rinv32;
1230 /* Calculate temporary vectorial force */
1235 /* Update vectorial force */
1239 f[j_coord_offset+DIM*2+XX] -= tx;
1240 f[j_coord_offset+DIM*2+YY] -= ty;
1241 f[j_coord_offset+DIM*2+ZZ] -= tz;
1243 /**************************
1244 * CALCULATE INTERACTIONS *
1245 **************************/
1249 /* Calculate table index by multiplying r with table scale and truncate to integer */
1250 rt = r33*vftabscale;
1253 vfitab = 1*4*vfitab;
1255 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1256 F = vftab[vfitab+1];
1257 Geps = vfeps*vftab[vfitab+2];
1258 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1260 FF = Fp+Geps+2.0*Heps2;
1261 felec = -qq33*FF*vftabscale*rinv33;
1265 /* Calculate temporary vectorial force */
1270 /* Update vectorial force */
1274 f[j_coord_offset+DIM*3+XX] -= tx;
1275 f[j_coord_offset+DIM*3+YY] -= ty;
1276 f[j_coord_offset+DIM*3+ZZ] -= tz;
1278 /* Inner loop uses 360 flops */
1280 /* End of innermost loop */
1283 f[i_coord_offset+DIM*0+XX] += fix0;
1284 f[i_coord_offset+DIM*0+YY] += fiy0;
1285 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1289 f[i_coord_offset+DIM*1+XX] += fix1;
1290 f[i_coord_offset+DIM*1+YY] += fiy1;
1291 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1295 f[i_coord_offset+DIM*2+XX] += fix2;
1296 f[i_coord_offset+DIM*2+YY] += fiy2;
1297 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1301 f[i_coord_offset+DIM*3+XX] += fix3;
1302 f[i_coord_offset+DIM*3+YY] += fiy3;
1303 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1307 fshift[i_shift_offset+XX] += tx;
1308 fshift[i_shift_offset+YY] += ty;
1309 fshift[i_shift_offset+ZZ] += tz;
1311 /* Increment number of inner iterations */
1312 inneriter += j_index_end - j_index_start;
1314 /* Outer loop uses 39 flops */
1317 /* Increment number of outer iterations */
1320 /* Update outer/inner flops */
1322 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*360);