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 */
977 Geps = vfeps*vftab[vfitab+2];
978 Heps2 = vfeps*vfeps*vftab[vfitab+3];
980 FF = Fp+Geps+2.0*Heps2;
983 /* CUBIC SPLINE TABLE REPULSION */
985 Geps = vfeps*vftab[vfitab+6];
986 Heps2 = vfeps*vfeps*vftab[vfitab+7];
988 FF = Fp+Geps+2.0*Heps2;
990 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
994 /* Calculate temporary vectorial force */
999 /* Update vectorial force */
1003 f[j_coord_offset+DIM*0+XX] -= tx;
1004 f[j_coord_offset+DIM*0+YY] -= ty;
1005 f[j_coord_offset+DIM*0+ZZ] -= tz;
1007 /**************************
1008 * CALCULATE INTERACTIONS *
1009 **************************/
1013 /* Calculate table index by multiplying r with table scale and truncate to integer */
1014 rt = r11*vftabscale;
1017 vfitab = 3*4*vfitab;
1019 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1020 F = vftab[vfitab+1];
1021 Geps = vfeps*vftab[vfitab+2];
1022 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1024 FF = Fp+Geps+2.0*Heps2;
1025 felec = -qq11*FF*vftabscale*rinv11;
1029 /* Calculate temporary vectorial force */
1034 /* Update vectorial force */
1038 f[j_coord_offset+DIM*1+XX] -= tx;
1039 f[j_coord_offset+DIM*1+YY] -= ty;
1040 f[j_coord_offset+DIM*1+ZZ] -= tz;
1042 /**************************
1043 * CALCULATE INTERACTIONS *
1044 **************************/
1048 /* Calculate table index by multiplying r with table scale and truncate to integer */
1049 rt = r12*vftabscale;
1052 vfitab = 3*4*vfitab;
1054 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1055 F = vftab[vfitab+1];
1056 Geps = vfeps*vftab[vfitab+2];
1057 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1059 FF = Fp+Geps+2.0*Heps2;
1060 felec = -qq12*FF*vftabscale*rinv12;
1064 /* Calculate temporary vectorial force */
1069 /* Update vectorial force */
1073 f[j_coord_offset+DIM*2+XX] -= tx;
1074 f[j_coord_offset+DIM*2+YY] -= ty;
1075 f[j_coord_offset+DIM*2+ZZ] -= tz;
1077 /**************************
1078 * CALCULATE INTERACTIONS *
1079 **************************/
1083 /* Calculate table index by multiplying r with table scale and truncate to integer */
1084 rt = r13*vftabscale;
1087 vfitab = 3*4*vfitab;
1089 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1090 F = vftab[vfitab+1];
1091 Geps = vfeps*vftab[vfitab+2];
1092 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1094 FF = Fp+Geps+2.0*Heps2;
1095 felec = -qq13*FF*vftabscale*rinv13;
1099 /* Calculate temporary vectorial force */
1104 /* Update vectorial force */
1108 f[j_coord_offset+DIM*3+XX] -= tx;
1109 f[j_coord_offset+DIM*3+YY] -= ty;
1110 f[j_coord_offset+DIM*3+ZZ] -= tz;
1112 /**************************
1113 * CALCULATE INTERACTIONS *
1114 **************************/
1118 /* Calculate table index by multiplying r with table scale and truncate to integer */
1119 rt = r21*vftabscale;
1122 vfitab = 3*4*vfitab;
1124 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1125 F = vftab[vfitab+1];
1126 Geps = vfeps*vftab[vfitab+2];
1127 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1129 FF = Fp+Geps+2.0*Heps2;
1130 felec = -qq21*FF*vftabscale*rinv21;
1134 /* Calculate temporary vectorial force */
1139 /* Update vectorial force */
1143 f[j_coord_offset+DIM*1+XX] -= tx;
1144 f[j_coord_offset+DIM*1+YY] -= ty;
1145 f[j_coord_offset+DIM*1+ZZ] -= tz;
1147 /**************************
1148 * CALCULATE INTERACTIONS *
1149 **************************/
1153 /* Calculate table index by multiplying r with table scale and truncate to integer */
1154 rt = r22*vftabscale;
1157 vfitab = 3*4*vfitab;
1159 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1160 F = vftab[vfitab+1];
1161 Geps = vfeps*vftab[vfitab+2];
1162 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1164 FF = Fp+Geps+2.0*Heps2;
1165 felec = -qq22*FF*vftabscale*rinv22;
1169 /* Calculate temporary vectorial force */
1174 /* Update vectorial force */
1178 f[j_coord_offset+DIM*2+XX] -= tx;
1179 f[j_coord_offset+DIM*2+YY] -= ty;
1180 f[j_coord_offset+DIM*2+ZZ] -= tz;
1182 /**************************
1183 * CALCULATE INTERACTIONS *
1184 **************************/
1188 /* Calculate table index by multiplying r with table scale and truncate to integer */
1189 rt = r23*vftabscale;
1192 vfitab = 3*4*vfitab;
1194 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1195 F = vftab[vfitab+1];
1196 Geps = vfeps*vftab[vfitab+2];
1197 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1199 FF = Fp+Geps+2.0*Heps2;
1200 felec = -qq23*FF*vftabscale*rinv23;
1204 /* Calculate temporary vectorial force */
1209 /* Update vectorial force */
1213 f[j_coord_offset+DIM*3+XX] -= tx;
1214 f[j_coord_offset+DIM*3+YY] -= ty;
1215 f[j_coord_offset+DIM*3+ZZ] -= tz;
1217 /**************************
1218 * CALCULATE INTERACTIONS *
1219 **************************/
1223 /* Calculate table index by multiplying r with table scale and truncate to integer */
1224 rt = r31*vftabscale;
1227 vfitab = 3*4*vfitab;
1229 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1230 F = vftab[vfitab+1];
1231 Geps = vfeps*vftab[vfitab+2];
1232 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1234 FF = Fp+Geps+2.0*Heps2;
1235 felec = -qq31*FF*vftabscale*rinv31;
1239 /* Calculate temporary vectorial force */
1244 /* Update vectorial force */
1248 f[j_coord_offset+DIM*1+XX] -= tx;
1249 f[j_coord_offset+DIM*1+YY] -= ty;
1250 f[j_coord_offset+DIM*1+ZZ] -= tz;
1252 /**************************
1253 * CALCULATE INTERACTIONS *
1254 **************************/
1258 /* Calculate table index by multiplying r with table scale and truncate to integer */
1259 rt = r32*vftabscale;
1262 vfitab = 3*4*vfitab;
1264 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1265 F = vftab[vfitab+1];
1266 Geps = vfeps*vftab[vfitab+2];
1267 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1269 FF = Fp+Geps+2.0*Heps2;
1270 felec = -qq32*FF*vftabscale*rinv32;
1274 /* Calculate temporary vectorial force */
1279 /* Update vectorial force */
1283 f[j_coord_offset+DIM*2+XX] -= tx;
1284 f[j_coord_offset+DIM*2+YY] -= ty;
1285 f[j_coord_offset+DIM*2+ZZ] -= tz;
1287 /**************************
1288 * CALCULATE INTERACTIONS *
1289 **************************/
1293 /* Calculate table index by multiplying r with table scale and truncate to integer */
1294 rt = r33*vftabscale;
1297 vfitab = 3*4*vfitab;
1299 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1300 F = vftab[vfitab+1];
1301 Geps = vfeps*vftab[vfitab+2];
1302 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1304 FF = Fp+Geps+2.0*Heps2;
1305 felec = -qq33*FF*vftabscale*rinv33;
1309 /* Calculate temporary vectorial force */
1314 /* Update vectorial force */
1318 f[j_coord_offset+DIM*3+XX] -= tx;
1319 f[j_coord_offset+DIM*3+YY] -= ty;
1320 f[j_coord_offset+DIM*3+ZZ] -= tz;
1322 /* Inner loop uses 380 flops */
1324 /* End of innermost loop */
1327 f[i_coord_offset+DIM*0+XX] += fix0;
1328 f[i_coord_offset+DIM*0+YY] += fiy0;
1329 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1333 f[i_coord_offset+DIM*1+XX] += fix1;
1334 f[i_coord_offset+DIM*1+YY] += fiy1;
1335 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1339 f[i_coord_offset+DIM*2+XX] += fix2;
1340 f[i_coord_offset+DIM*2+YY] += fiy2;
1341 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1345 f[i_coord_offset+DIM*3+XX] += fix3;
1346 f[i_coord_offset+DIM*3+YY] += fiy3;
1347 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1351 fshift[i_shift_offset+XX] += tx;
1352 fshift[i_shift_offset+YY] += ty;
1353 fshift[i_shift_offset+ZZ] += tz;
1355 /* Increment number of inner iterations */
1356 inneriter += j_index_end - j_index_start;
1358 /* Outer loop uses 39 flops */
1361 /* Increment number of outer iterations */
1364 /* Update outer/inner flops */
1366 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*380);