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_VdwCSTab_GeomW4W4_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwCSTab_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_vdw->data;
110 vftabscale = kernel_data->table_elec_vdw->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 rinv00 = gmx_invsqrt(rsq00);
252 rinv11 = gmx_invsqrt(rsq11);
253 rinv12 = gmx_invsqrt(rsq12);
254 rinv13 = gmx_invsqrt(rsq13);
255 rinv21 = gmx_invsqrt(rsq21);
256 rinv22 = gmx_invsqrt(rsq22);
257 rinv23 = gmx_invsqrt(rsq23);
258 rinv31 = gmx_invsqrt(rsq31);
259 rinv32 = gmx_invsqrt(rsq32);
260 rinv33 = gmx_invsqrt(rsq33);
262 /**************************
263 * CALCULATE INTERACTIONS *
264 **************************/
268 /* Calculate table index by multiplying r with table scale and truncate to integer */
274 /* CUBIC SPLINE TABLE DISPERSION */
278 Geps = vfeps*vftab[vfitab+2];
279 Heps2 = vfeps*vfeps*vftab[vfitab+3];
283 FF = Fp+Geps+2.0*Heps2;
286 /* CUBIC SPLINE TABLE REPULSION */
289 Geps = vfeps*vftab[vfitab+6];
290 Heps2 = vfeps*vfeps*vftab[vfitab+7];
294 FF = Fp+Geps+2.0*Heps2;
297 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
299 /* Update potential sums from outer loop */
304 /* Calculate temporary vectorial force */
309 /* Update vectorial force */
313 f[j_coord_offset+DIM*0+XX] -= tx;
314 f[j_coord_offset+DIM*0+YY] -= ty;
315 f[j_coord_offset+DIM*0+ZZ] -= tz;
317 /**************************
318 * CALCULATE INTERACTIONS *
319 **************************/
323 /* Calculate table index by multiplying r with table scale and truncate to integer */
329 /* CUBIC SPLINE TABLE ELECTROSTATICS */
332 Geps = vfeps*vftab[vfitab+2];
333 Heps2 = vfeps*vfeps*vftab[vfitab+3];
337 FF = Fp+Geps+2.0*Heps2;
338 felec = -qq11*FF*vftabscale*rinv11;
340 /* Update potential sums from outer loop */
345 /* Calculate temporary vectorial force */
350 /* Update vectorial force */
354 f[j_coord_offset+DIM*1+XX] -= tx;
355 f[j_coord_offset+DIM*1+YY] -= ty;
356 f[j_coord_offset+DIM*1+ZZ] -= tz;
358 /**************************
359 * CALCULATE INTERACTIONS *
360 **************************/
364 /* Calculate table index by multiplying r with table scale and truncate to integer */
370 /* CUBIC SPLINE TABLE ELECTROSTATICS */
373 Geps = vfeps*vftab[vfitab+2];
374 Heps2 = vfeps*vfeps*vftab[vfitab+3];
378 FF = Fp+Geps+2.0*Heps2;
379 felec = -qq12*FF*vftabscale*rinv12;
381 /* Update potential sums from outer loop */
386 /* Calculate temporary vectorial force */
391 /* Update vectorial force */
395 f[j_coord_offset+DIM*2+XX] -= tx;
396 f[j_coord_offset+DIM*2+YY] -= ty;
397 f[j_coord_offset+DIM*2+ZZ] -= tz;
399 /**************************
400 * CALCULATE INTERACTIONS *
401 **************************/
405 /* Calculate table index by multiplying r with table scale and truncate to integer */
411 /* CUBIC SPLINE TABLE ELECTROSTATICS */
414 Geps = vfeps*vftab[vfitab+2];
415 Heps2 = vfeps*vfeps*vftab[vfitab+3];
419 FF = Fp+Geps+2.0*Heps2;
420 felec = -qq13*FF*vftabscale*rinv13;
422 /* Update potential sums from outer loop */
427 /* Calculate temporary vectorial force */
432 /* Update vectorial force */
436 f[j_coord_offset+DIM*3+XX] -= tx;
437 f[j_coord_offset+DIM*3+YY] -= ty;
438 f[j_coord_offset+DIM*3+ZZ] -= tz;
440 /**************************
441 * CALCULATE INTERACTIONS *
442 **************************/
446 /* Calculate table index by multiplying r with table scale and truncate to integer */
452 /* CUBIC SPLINE TABLE ELECTROSTATICS */
455 Geps = vfeps*vftab[vfitab+2];
456 Heps2 = vfeps*vfeps*vftab[vfitab+3];
460 FF = Fp+Geps+2.0*Heps2;
461 felec = -qq21*FF*vftabscale*rinv21;
463 /* Update potential sums from outer loop */
468 /* Calculate temporary vectorial force */
473 /* Update vectorial force */
477 f[j_coord_offset+DIM*1+XX] -= tx;
478 f[j_coord_offset+DIM*1+YY] -= ty;
479 f[j_coord_offset+DIM*1+ZZ] -= tz;
481 /**************************
482 * CALCULATE INTERACTIONS *
483 **************************/
487 /* Calculate table index by multiplying r with table scale and truncate to integer */
493 /* CUBIC SPLINE TABLE ELECTROSTATICS */
496 Geps = vfeps*vftab[vfitab+2];
497 Heps2 = vfeps*vfeps*vftab[vfitab+3];
501 FF = Fp+Geps+2.0*Heps2;
502 felec = -qq22*FF*vftabscale*rinv22;
504 /* Update potential sums from outer loop */
509 /* Calculate temporary vectorial force */
514 /* Update vectorial force */
518 f[j_coord_offset+DIM*2+XX] -= tx;
519 f[j_coord_offset+DIM*2+YY] -= ty;
520 f[j_coord_offset+DIM*2+ZZ] -= tz;
522 /**************************
523 * CALCULATE INTERACTIONS *
524 **************************/
528 /* Calculate table index by multiplying r with table scale and truncate to integer */
534 /* CUBIC SPLINE TABLE ELECTROSTATICS */
537 Geps = vfeps*vftab[vfitab+2];
538 Heps2 = vfeps*vfeps*vftab[vfitab+3];
542 FF = Fp+Geps+2.0*Heps2;
543 felec = -qq23*FF*vftabscale*rinv23;
545 /* Update potential sums from outer loop */
550 /* Calculate temporary vectorial force */
555 /* Update vectorial force */
559 f[j_coord_offset+DIM*3+XX] -= tx;
560 f[j_coord_offset+DIM*3+YY] -= ty;
561 f[j_coord_offset+DIM*3+ZZ] -= tz;
563 /**************************
564 * CALCULATE INTERACTIONS *
565 **************************/
569 /* Calculate table index by multiplying r with table scale and truncate to integer */
575 /* CUBIC SPLINE TABLE ELECTROSTATICS */
578 Geps = vfeps*vftab[vfitab+2];
579 Heps2 = vfeps*vfeps*vftab[vfitab+3];
583 FF = Fp+Geps+2.0*Heps2;
584 felec = -qq31*FF*vftabscale*rinv31;
586 /* Update potential sums from outer loop */
591 /* Calculate temporary vectorial force */
596 /* Update vectorial force */
600 f[j_coord_offset+DIM*1+XX] -= tx;
601 f[j_coord_offset+DIM*1+YY] -= ty;
602 f[j_coord_offset+DIM*1+ZZ] -= tz;
604 /**************************
605 * CALCULATE INTERACTIONS *
606 **************************/
610 /* Calculate table index by multiplying r with table scale and truncate to integer */
616 /* CUBIC SPLINE TABLE ELECTROSTATICS */
619 Geps = vfeps*vftab[vfitab+2];
620 Heps2 = vfeps*vfeps*vftab[vfitab+3];
624 FF = Fp+Geps+2.0*Heps2;
625 felec = -qq32*FF*vftabscale*rinv32;
627 /* Update potential sums from outer loop */
632 /* Calculate temporary vectorial force */
637 /* Update vectorial force */
641 f[j_coord_offset+DIM*2+XX] -= tx;
642 f[j_coord_offset+DIM*2+YY] -= ty;
643 f[j_coord_offset+DIM*2+ZZ] -= tz;
645 /**************************
646 * CALCULATE INTERACTIONS *
647 **************************/
651 /* Calculate table index by multiplying r with table scale and truncate to integer */
657 /* CUBIC SPLINE TABLE ELECTROSTATICS */
660 Geps = vfeps*vftab[vfitab+2];
661 Heps2 = vfeps*vfeps*vftab[vfitab+3];
665 FF = Fp+Geps+2.0*Heps2;
666 felec = -qq33*FF*vftabscale*rinv33;
668 /* Update potential sums from outer loop */
673 /* Calculate temporary vectorial force */
678 /* Update vectorial force */
682 f[j_coord_offset+DIM*3+XX] -= tx;
683 f[j_coord_offset+DIM*3+YY] -= ty;
684 f[j_coord_offset+DIM*3+ZZ] -= tz;
686 /* Inner loop uses 424 flops */
688 /* End of innermost loop */
691 f[i_coord_offset+DIM*0+XX] += fix0;
692 f[i_coord_offset+DIM*0+YY] += fiy0;
693 f[i_coord_offset+DIM*0+ZZ] += fiz0;
697 f[i_coord_offset+DIM*1+XX] += fix1;
698 f[i_coord_offset+DIM*1+YY] += fiy1;
699 f[i_coord_offset+DIM*1+ZZ] += fiz1;
703 f[i_coord_offset+DIM*2+XX] += fix2;
704 f[i_coord_offset+DIM*2+YY] += fiy2;
705 f[i_coord_offset+DIM*2+ZZ] += fiz2;
709 f[i_coord_offset+DIM*3+XX] += fix3;
710 f[i_coord_offset+DIM*3+YY] += fiy3;
711 f[i_coord_offset+DIM*3+ZZ] += fiz3;
715 fshift[i_shift_offset+XX] += tx;
716 fshift[i_shift_offset+YY] += ty;
717 fshift[i_shift_offset+ZZ] += tz;
720 /* Update potential energies */
721 kernel_data->energygrp_elec[ggid] += velecsum;
722 kernel_data->energygrp_vdw[ggid] += vvdwsum;
724 /* Increment number of inner iterations */
725 inneriter += j_index_end - j_index_start;
727 /* Outer loop uses 41 flops */
730 /* Increment number of outer iterations */
733 /* Update outer/inner flops */
735 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*424);
738 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_F_c
739 * Electrostatics interaction: CubicSplineTable
740 * VdW interaction: CubicSplineTable
741 * Geometry: Water4-Water4
742 * Calculate force/pot: Force
745 nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_F_c
746 (t_nblist * gmx_restrict nlist,
747 rvec * gmx_restrict xx,
748 rvec * gmx_restrict ff,
749 t_forcerec * gmx_restrict fr,
750 t_mdatoms * gmx_restrict mdatoms,
751 nb_kernel_data_t * gmx_restrict kernel_data,
752 t_nrnb * gmx_restrict nrnb)
754 int i_shift_offset,i_coord_offset,j_coord_offset;
755 int j_index_start,j_index_end;
756 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
757 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
758 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
759 real *shiftvec,*fshift,*x,*f;
761 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
763 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
765 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
767 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
769 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
771 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
773 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
775 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
776 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
777 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
778 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
779 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
780 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
781 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
782 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
783 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
784 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
785 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
786 real velec,felec,velecsum,facel,crf,krf,krf2;
789 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
793 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
801 jindex = nlist->jindex;
803 shiftidx = nlist->shift;
805 shiftvec = fr->shift_vec[0];
806 fshift = fr->fshift[0];
808 charge = mdatoms->chargeA;
809 nvdwtype = fr->ntype;
811 vdwtype = mdatoms->typeA;
813 vftab = kernel_data->table_elec_vdw->data;
814 vftabscale = kernel_data->table_elec_vdw->scale;
816 /* Setup water-specific parameters */
817 inr = nlist->iinr[0];
818 iq1 = facel*charge[inr+1];
819 iq2 = facel*charge[inr+2];
820 iq3 = facel*charge[inr+3];
821 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
826 vdwjidx0 = 2*vdwtype[inr+0];
827 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
828 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
842 /* Start outer loop over neighborlists */
843 for(iidx=0; iidx<nri; iidx++)
845 /* Load shift vector for this list */
846 i_shift_offset = DIM*shiftidx[iidx];
847 shX = shiftvec[i_shift_offset+XX];
848 shY = shiftvec[i_shift_offset+YY];
849 shZ = shiftvec[i_shift_offset+ZZ];
851 /* Load limits for loop over neighbors */
852 j_index_start = jindex[iidx];
853 j_index_end = jindex[iidx+1];
855 /* Get outer coordinate index */
857 i_coord_offset = DIM*inr;
859 /* Load i particle coords and add shift vector */
860 ix0 = shX + x[i_coord_offset+DIM*0+XX];
861 iy0 = shY + x[i_coord_offset+DIM*0+YY];
862 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
863 ix1 = shX + x[i_coord_offset+DIM*1+XX];
864 iy1 = shY + x[i_coord_offset+DIM*1+YY];
865 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
866 ix2 = shX + x[i_coord_offset+DIM*2+XX];
867 iy2 = shY + x[i_coord_offset+DIM*2+YY];
868 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
869 ix3 = shX + x[i_coord_offset+DIM*3+XX];
870 iy3 = shY + x[i_coord_offset+DIM*3+YY];
871 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
886 /* Start inner kernel loop */
887 for(jidx=j_index_start; jidx<j_index_end; jidx++)
889 /* Get j neighbor index, and coordinate index */
891 j_coord_offset = DIM*jnr;
893 /* load j atom coordinates */
894 jx0 = x[j_coord_offset+DIM*0+XX];
895 jy0 = x[j_coord_offset+DIM*0+YY];
896 jz0 = x[j_coord_offset+DIM*0+ZZ];
897 jx1 = x[j_coord_offset+DIM*1+XX];
898 jy1 = x[j_coord_offset+DIM*1+YY];
899 jz1 = x[j_coord_offset+DIM*1+ZZ];
900 jx2 = x[j_coord_offset+DIM*2+XX];
901 jy2 = x[j_coord_offset+DIM*2+YY];
902 jz2 = x[j_coord_offset+DIM*2+ZZ];
903 jx3 = x[j_coord_offset+DIM*3+XX];
904 jy3 = x[j_coord_offset+DIM*3+YY];
905 jz3 = x[j_coord_offset+DIM*3+ZZ];
907 /* Calculate displacement vector */
939 /* Calculate squared distance and things based on it */
940 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
941 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
942 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
943 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
944 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
945 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
946 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
947 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
948 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
949 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
951 rinv00 = gmx_invsqrt(rsq00);
952 rinv11 = gmx_invsqrt(rsq11);
953 rinv12 = gmx_invsqrt(rsq12);
954 rinv13 = gmx_invsqrt(rsq13);
955 rinv21 = gmx_invsqrt(rsq21);
956 rinv22 = gmx_invsqrt(rsq22);
957 rinv23 = gmx_invsqrt(rsq23);
958 rinv31 = gmx_invsqrt(rsq31);
959 rinv32 = gmx_invsqrt(rsq32);
960 rinv33 = gmx_invsqrt(rsq33);
962 /**************************
963 * CALCULATE INTERACTIONS *
964 **************************/
968 /* Calculate table index by multiplying r with table scale and truncate to integer */
974 /* CUBIC SPLINE TABLE DISPERSION */
978 Geps = vfeps*vftab[vfitab+2];
979 Heps2 = vfeps*vfeps*vftab[vfitab+3];
981 FF = Fp+Geps+2.0*Heps2;
984 /* CUBIC SPLINE TABLE REPULSION */
987 Geps = vfeps*vftab[vfitab+6];
988 Heps2 = vfeps*vfeps*vftab[vfitab+7];
990 FF = Fp+Geps+2.0*Heps2;
992 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
996 /* Calculate temporary vectorial force */
1001 /* Update vectorial force */
1005 f[j_coord_offset+DIM*0+XX] -= tx;
1006 f[j_coord_offset+DIM*0+YY] -= ty;
1007 f[j_coord_offset+DIM*0+ZZ] -= tz;
1009 /**************************
1010 * CALCULATE INTERACTIONS *
1011 **************************/
1015 /* Calculate table index by multiplying r with table scale and truncate to integer */
1016 rt = r11*vftabscale;
1019 vfitab = 3*4*vfitab;
1021 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1023 F = vftab[vfitab+1];
1024 Geps = vfeps*vftab[vfitab+2];
1025 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1027 FF = Fp+Geps+2.0*Heps2;
1028 felec = -qq11*FF*vftabscale*rinv11;
1032 /* Calculate temporary vectorial force */
1037 /* Update vectorial force */
1041 f[j_coord_offset+DIM*1+XX] -= tx;
1042 f[j_coord_offset+DIM*1+YY] -= ty;
1043 f[j_coord_offset+DIM*1+ZZ] -= tz;
1045 /**************************
1046 * CALCULATE INTERACTIONS *
1047 **************************/
1051 /* Calculate table index by multiplying r with table scale and truncate to integer */
1052 rt = r12*vftabscale;
1055 vfitab = 3*4*vfitab;
1057 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1059 F = vftab[vfitab+1];
1060 Geps = vfeps*vftab[vfitab+2];
1061 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1063 FF = Fp+Geps+2.0*Heps2;
1064 felec = -qq12*FF*vftabscale*rinv12;
1068 /* Calculate temporary vectorial force */
1073 /* Update vectorial force */
1077 f[j_coord_offset+DIM*2+XX] -= tx;
1078 f[j_coord_offset+DIM*2+YY] -= ty;
1079 f[j_coord_offset+DIM*2+ZZ] -= tz;
1081 /**************************
1082 * CALCULATE INTERACTIONS *
1083 **************************/
1087 /* Calculate table index by multiplying r with table scale and truncate to integer */
1088 rt = r13*vftabscale;
1091 vfitab = 3*4*vfitab;
1093 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1095 F = vftab[vfitab+1];
1096 Geps = vfeps*vftab[vfitab+2];
1097 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1099 FF = Fp+Geps+2.0*Heps2;
1100 felec = -qq13*FF*vftabscale*rinv13;
1104 /* Calculate temporary vectorial force */
1109 /* Update vectorial force */
1113 f[j_coord_offset+DIM*3+XX] -= tx;
1114 f[j_coord_offset+DIM*3+YY] -= ty;
1115 f[j_coord_offset+DIM*3+ZZ] -= tz;
1117 /**************************
1118 * CALCULATE INTERACTIONS *
1119 **************************/
1123 /* Calculate table index by multiplying r with table scale and truncate to integer */
1124 rt = r21*vftabscale;
1127 vfitab = 3*4*vfitab;
1129 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1131 F = vftab[vfitab+1];
1132 Geps = vfeps*vftab[vfitab+2];
1133 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1135 FF = Fp+Geps+2.0*Heps2;
1136 felec = -qq21*FF*vftabscale*rinv21;
1140 /* Calculate temporary vectorial force */
1145 /* Update vectorial force */
1149 f[j_coord_offset+DIM*1+XX] -= tx;
1150 f[j_coord_offset+DIM*1+YY] -= ty;
1151 f[j_coord_offset+DIM*1+ZZ] -= tz;
1153 /**************************
1154 * CALCULATE INTERACTIONS *
1155 **************************/
1159 /* Calculate table index by multiplying r with table scale and truncate to integer */
1160 rt = r22*vftabscale;
1163 vfitab = 3*4*vfitab;
1165 /* 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 = -qq22*FF*vftabscale*rinv22;
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;
1189 /**************************
1190 * CALCULATE INTERACTIONS *
1191 **************************/
1195 /* Calculate table index by multiplying r with table scale and truncate to integer */
1196 rt = r23*vftabscale;
1199 vfitab = 3*4*vfitab;
1201 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1203 F = vftab[vfitab+1];
1204 Geps = vfeps*vftab[vfitab+2];
1205 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1207 FF = Fp+Geps+2.0*Heps2;
1208 felec = -qq23*FF*vftabscale*rinv23;
1212 /* Calculate temporary vectorial force */
1217 /* Update vectorial force */
1221 f[j_coord_offset+DIM*3+XX] -= tx;
1222 f[j_coord_offset+DIM*3+YY] -= ty;
1223 f[j_coord_offset+DIM*3+ZZ] -= tz;
1225 /**************************
1226 * CALCULATE INTERACTIONS *
1227 **************************/
1231 /* Calculate table index by multiplying r with table scale and truncate to integer */
1232 rt = r31*vftabscale;
1235 vfitab = 3*4*vfitab;
1237 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1239 F = vftab[vfitab+1];
1240 Geps = vfeps*vftab[vfitab+2];
1241 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1243 FF = Fp+Geps+2.0*Heps2;
1244 felec = -qq31*FF*vftabscale*rinv31;
1248 /* Calculate temporary vectorial force */
1253 /* Update vectorial force */
1257 f[j_coord_offset+DIM*1+XX] -= tx;
1258 f[j_coord_offset+DIM*1+YY] -= ty;
1259 f[j_coord_offset+DIM*1+ZZ] -= tz;
1261 /**************************
1262 * CALCULATE INTERACTIONS *
1263 **************************/
1267 /* Calculate table index by multiplying r with table scale and truncate to integer */
1268 rt = r32*vftabscale;
1271 vfitab = 3*4*vfitab;
1273 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1275 F = vftab[vfitab+1];
1276 Geps = vfeps*vftab[vfitab+2];
1277 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1279 FF = Fp+Geps+2.0*Heps2;
1280 felec = -qq32*FF*vftabscale*rinv32;
1284 /* Calculate temporary vectorial force */
1289 /* Update vectorial force */
1293 f[j_coord_offset+DIM*2+XX] -= tx;
1294 f[j_coord_offset+DIM*2+YY] -= ty;
1295 f[j_coord_offset+DIM*2+ZZ] -= tz;
1297 /**************************
1298 * CALCULATE INTERACTIONS *
1299 **************************/
1303 /* Calculate table index by multiplying r with table scale and truncate to integer */
1304 rt = r33*vftabscale;
1307 vfitab = 3*4*vfitab;
1309 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1311 F = vftab[vfitab+1];
1312 Geps = vfeps*vftab[vfitab+2];
1313 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1315 FF = Fp+Geps+2.0*Heps2;
1316 felec = -qq33*FF*vftabscale*rinv33;
1320 /* Calculate temporary vectorial force */
1325 /* Update vectorial force */
1329 f[j_coord_offset+DIM*3+XX] -= tx;
1330 f[j_coord_offset+DIM*3+YY] -= ty;
1331 f[j_coord_offset+DIM*3+ZZ] -= tz;
1333 /* Inner loop uses 380 flops */
1335 /* End of innermost loop */
1338 f[i_coord_offset+DIM*0+XX] += fix0;
1339 f[i_coord_offset+DIM*0+YY] += fiy0;
1340 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1344 f[i_coord_offset+DIM*1+XX] += fix1;
1345 f[i_coord_offset+DIM*1+YY] += fiy1;
1346 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1350 f[i_coord_offset+DIM*2+XX] += fix2;
1351 f[i_coord_offset+DIM*2+YY] += fiy2;
1352 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1356 f[i_coord_offset+DIM*3+XX] += fix3;
1357 f[i_coord_offset+DIM*3+YY] += fiy3;
1358 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1362 fshift[i_shift_offset+XX] += tx;
1363 fshift[i_shift_offset+YY] += ty;
1364 fshift[i_shift_offset+ZZ] += tz;
1366 /* Increment number of inner iterations */
1367 inneriter += j_index_end - j_index_start;
1369 /* Outer loop uses 39 flops */
1372 /* Increment number of outer iterations */
1375 /* Update outer/inner flops */
1377 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*380);