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_VdwBham_GeomW4W4_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwBham_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 = 3*nvdwtype*vdwtype[inr+0];
122 vdwjidx0 = 3*vdwtype[inr+0];
123 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
124 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
125 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
139 /* Start outer loop over neighborlists */
140 for(iidx=0; iidx<nri; iidx++)
142 /* Load shift vector for this list */
143 i_shift_offset = DIM*shiftidx[iidx];
144 shX = shiftvec[i_shift_offset+XX];
145 shY = shiftvec[i_shift_offset+YY];
146 shZ = shiftvec[i_shift_offset+ZZ];
148 /* Load limits for loop over neighbors */
149 j_index_start = jindex[iidx];
150 j_index_end = jindex[iidx+1];
152 /* Get outer coordinate index */
154 i_coord_offset = DIM*inr;
156 /* Load i particle coords and add shift vector */
157 ix0 = shX + x[i_coord_offset+DIM*0+XX];
158 iy0 = shY + x[i_coord_offset+DIM*0+YY];
159 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
160 ix1 = shX + x[i_coord_offset+DIM*1+XX];
161 iy1 = shY + x[i_coord_offset+DIM*1+YY];
162 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
163 ix2 = shX + x[i_coord_offset+DIM*2+XX];
164 iy2 = shY + x[i_coord_offset+DIM*2+YY];
165 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
166 ix3 = shX + x[i_coord_offset+DIM*3+XX];
167 iy3 = shY + x[i_coord_offset+DIM*3+YY];
168 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
183 /* Reset potential sums */
187 /* Start inner kernel loop */
188 for(jidx=j_index_start; jidx<j_index_end; jidx++)
190 /* Get j neighbor index, and coordinate index */
192 j_coord_offset = DIM*jnr;
194 /* load j atom coordinates */
195 jx0 = x[j_coord_offset+DIM*0+XX];
196 jy0 = x[j_coord_offset+DIM*0+YY];
197 jz0 = x[j_coord_offset+DIM*0+ZZ];
198 jx1 = x[j_coord_offset+DIM*1+XX];
199 jy1 = x[j_coord_offset+DIM*1+YY];
200 jz1 = x[j_coord_offset+DIM*1+ZZ];
201 jx2 = x[j_coord_offset+DIM*2+XX];
202 jy2 = x[j_coord_offset+DIM*2+YY];
203 jz2 = x[j_coord_offset+DIM*2+ZZ];
204 jx3 = x[j_coord_offset+DIM*3+XX];
205 jy3 = x[j_coord_offset+DIM*3+YY];
206 jz3 = x[j_coord_offset+DIM*3+ZZ];
208 /* Calculate displacement vector */
240 /* Calculate squared distance and things based on it */
241 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
242 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
243 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
244 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
245 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
246 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
247 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
248 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
249 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
250 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
252 rinv00 = gmx_invsqrt(rsq00);
253 rinv11 = gmx_invsqrt(rsq11);
254 rinv12 = gmx_invsqrt(rsq12);
255 rinv13 = gmx_invsqrt(rsq13);
256 rinv21 = gmx_invsqrt(rsq21);
257 rinv22 = gmx_invsqrt(rsq22);
258 rinv23 = gmx_invsqrt(rsq23);
259 rinv31 = gmx_invsqrt(rsq31);
260 rinv32 = gmx_invsqrt(rsq32);
261 rinv33 = gmx_invsqrt(rsq33);
263 rinvsq00 = rinv00*rinv00;
265 /**************************
266 * CALCULATE INTERACTIONS *
267 **************************/
271 /* BUCKINGHAM DISPERSION/REPULSION */
272 rinvsix = rinvsq00*rinvsq00*rinvsq00;
273 vvdw6 = c6_00*rinvsix;
275 vvdwexp = cexp1_00*exp(-br);
276 vvdw = vvdwexp - vvdw6*(1.0/6.0);
277 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
279 /* Update potential sums from outer loop */
284 /* Calculate temporary vectorial force */
289 /* Update vectorial force */
293 f[j_coord_offset+DIM*0+XX] -= tx;
294 f[j_coord_offset+DIM*0+YY] -= ty;
295 f[j_coord_offset+DIM*0+ZZ] -= tz;
297 /**************************
298 * CALCULATE INTERACTIONS *
299 **************************/
303 /* Calculate table index by multiplying r with table scale and truncate to integer */
309 /* CUBIC SPLINE TABLE ELECTROSTATICS */
312 Geps = vfeps*vftab[vfitab+2];
313 Heps2 = vfeps*vfeps*vftab[vfitab+3];
317 FF = Fp+Geps+2.0*Heps2;
318 felec = -qq11*FF*vftabscale*rinv11;
320 /* Update potential sums from outer loop */
325 /* Calculate temporary vectorial force */
330 /* Update vectorial force */
334 f[j_coord_offset+DIM*1+XX] -= tx;
335 f[j_coord_offset+DIM*1+YY] -= ty;
336 f[j_coord_offset+DIM*1+ZZ] -= tz;
338 /**************************
339 * CALCULATE INTERACTIONS *
340 **************************/
344 /* Calculate table index by multiplying r with table scale and truncate to integer */
350 /* CUBIC SPLINE TABLE ELECTROSTATICS */
353 Geps = vfeps*vftab[vfitab+2];
354 Heps2 = vfeps*vfeps*vftab[vfitab+3];
358 FF = Fp+Geps+2.0*Heps2;
359 felec = -qq12*FF*vftabscale*rinv12;
361 /* Update potential sums from outer loop */
366 /* Calculate temporary vectorial force */
371 /* Update vectorial force */
375 f[j_coord_offset+DIM*2+XX] -= tx;
376 f[j_coord_offset+DIM*2+YY] -= ty;
377 f[j_coord_offset+DIM*2+ZZ] -= tz;
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
385 /* Calculate table index by multiplying r with table scale and truncate to integer */
391 /* CUBIC SPLINE TABLE ELECTROSTATICS */
394 Geps = vfeps*vftab[vfitab+2];
395 Heps2 = vfeps*vfeps*vftab[vfitab+3];
399 FF = Fp+Geps+2.0*Heps2;
400 felec = -qq13*FF*vftabscale*rinv13;
402 /* Update potential sums from outer loop */
407 /* Calculate temporary vectorial force */
412 /* Update vectorial force */
416 f[j_coord_offset+DIM*3+XX] -= tx;
417 f[j_coord_offset+DIM*3+YY] -= ty;
418 f[j_coord_offset+DIM*3+ZZ] -= tz;
420 /**************************
421 * CALCULATE INTERACTIONS *
422 **************************/
426 /* Calculate table index by multiplying r with table scale and truncate to integer */
432 /* CUBIC SPLINE TABLE ELECTROSTATICS */
435 Geps = vfeps*vftab[vfitab+2];
436 Heps2 = vfeps*vfeps*vftab[vfitab+3];
440 FF = Fp+Geps+2.0*Heps2;
441 felec = -qq21*FF*vftabscale*rinv21;
443 /* Update potential sums from outer loop */
448 /* Calculate temporary vectorial force */
453 /* Update vectorial force */
457 f[j_coord_offset+DIM*1+XX] -= tx;
458 f[j_coord_offset+DIM*1+YY] -= ty;
459 f[j_coord_offset+DIM*1+ZZ] -= tz;
461 /**************************
462 * CALCULATE INTERACTIONS *
463 **************************/
467 /* Calculate table index by multiplying r with table scale and truncate to integer */
473 /* CUBIC SPLINE TABLE ELECTROSTATICS */
476 Geps = vfeps*vftab[vfitab+2];
477 Heps2 = vfeps*vfeps*vftab[vfitab+3];
481 FF = Fp+Geps+2.0*Heps2;
482 felec = -qq22*FF*vftabscale*rinv22;
484 /* Update potential sums from outer loop */
489 /* Calculate temporary vectorial force */
494 /* Update vectorial force */
498 f[j_coord_offset+DIM*2+XX] -= tx;
499 f[j_coord_offset+DIM*2+YY] -= ty;
500 f[j_coord_offset+DIM*2+ZZ] -= tz;
502 /**************************
503 * CALCULATE INTERACTIONS *
504 **************************/
508 /* Calculate table index by multiplying r with table scale and truncate to integer */
514 /* CUBIC SPLINE TABLE ELECTROSTATICS */
517 Geps = vfeps*vftab[vfitab+2];
518 Heps2 = vfeps*vfeps*vftab[vfitab+3];
522 FF = Fp+Geps+2.0*Heps2;
523 felec = -qq23*FF*vftabscale*rinv23;
525 /* Update potential sums from outer loop */
530 /* Calculate temporary vectorial force */
535 /* Update vectorial force */
539 f[j_coord_offset+DIM*3+XX] -= tx;
540 f[j_coord_offset+DIM*3+YY] -= ty;
541 f[j_coord_offset+DIM*3+ZZ] -= tz;
543 /**************************
544 * CALCULATE INTERACTIONS *
545 **************************/
549 /* Calculate table index by multiplying r with table scale and truncate to integer */
555 /* CUBIC SPLINE TABLE ELECTROSTATICS */
558 Geps = vfeps*vftab[vfitab+2];
559 Heps2 = vfeps*vfeps*vftab[vfitab+3];
563 FF = Fp+Geps+2.0*Heps2;
564 felec = -qq31*FF*vftabscale*rinv31;
566 /* Update potential sums from outer loop */
571 /* Calculate temporary vectorial force */
576 /* Update vectorial force */
580 f[j_coord_offset+DIM*1+XX] -= tx;
581 f[j_coord_offset+DIM*1+YY] -= ty;
582 f[j_coord_offset+DIM*1+ZZ] -= tz;
584 /**************************
585 * CALCULATE INTERACTIONS *
586 **************************/
590 /* Calculate table index by multiplying r with table scale and truncate to integer */
596 /* CUBIC SPLINE TABLE ELECTROSTATICS */
599 Geps = vfeps*vftab[vfitab+2];
600 Heps2 = vfeps*vfeps*vftab[vfitab+3];
604 FF = Fp+Geps+2.0*Heps2;
605 felec = -qq32*FF*vftabscale*rinv32;
607 /* Update potential sums from outer loop */
612 /* Calculate temporary vectorial force */
617 /* Update vectorial force */
621 f[j_coord_offset+DIM*2+XX] -= tx;
622 f[j_coord_offset+DIM*2+YY] -= ty;
623 f[j_coord_offset+DIM*2+ZZ] -= tz;
625 /**************************
626 * CALCULATE INTERACTIONS *
627 **************************/
631 /* Calculate table index by multiplying r with table scale and truncate to integer */
637 /* CUBIC SPLINE TABLE ELECTROSTATICS */
640 Geps = vfeps*vftab[vfitab+2];
641 Heps2 = vfeps*vfeps*vftab[vfitab+3];
645 FF = Fp+Geps+2.0*Heps2;
646 felec = -qq33*FF*vftabscale*rinv33;
648 /* Update potential sums from outer loop */
653 /* Calculate temporary vectorial force */
658 /* Update vectorial force */
662 f[j_coord_offset+DIM*3+XX] -= tx;
663 f[j_coord_offset+DIM*3+YY] -= ty;
664 f[j_coord_offset+DIM*3+ZZ] -= tz;
666 /* Inner loop uses 430 flops */
668 /* End of innermost loop */
671 f[i_coord_offset+DIM*0+XX] += fix0;
672 f[i_coord_offset+DIM*0+YY] += fiy0;
673 f[i_coord_offset+DIM*0+ZZ] += fiz0;
677 f[i_coord_offset+DIM*1+XX] += fix1;
678 f[i_coord_offset+DIM*1+YY] += fiy1;
679 f[i_coord_offset+DIM*1+ZZ] += fiz1;
683 f[i_coord_offset+DIM*2+XX] += fix2;
684 f[i_coord_offset+DIM*2+YY] += fiy2;
685 f[i_coord_offset+DIM*2+ZZ] += fiz2;
689 f[i_coord_offset+DIM*3+XX] += fix3;
690 f[i_coord_offset+DIM*3+YY] += fiy3;
691 f[i_coord_offset+DIM*3+ZZ] += fiz3;
695 fshift[i_shift_offset+XX] += tx;
696 fshift[i_shift_offset+YY] += ty;
697 fshift[i_shift_offset+ZZ] += tz;
700 /* Update potential energies */
701 kernel_data->energygrp_elec[ggid] += velecsum;
702 kernel_data->energygrp_vdw[ggid] += vvdwsum;
704 /* Increment number of inner iterations */
705 inneriter += j_index_end - j_index_start;
707 /* Outer loop uses 41 flops */
710 /* Increment number of outer iterations */
713 /* Update outer/inner flops */
715 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*430);
718 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW4W4_F_c
719 * Electrostatics interaction: CubicSplineTable
720 * VdW interaction: Buckingham
721 * Geometry: Water4-Water4
722 * Calculate force/pot: Force
725 nb_kernel_ElecCSTab_VdwBham_GeomW4W4_F_c
726 (t_nblist * gmx_restrict nlist,
727 rvec * gmx_restrict xx,
728 rvec * gmx_restrict ff,
729 t_forcerec * gmx_restrict fr,
730 t_mdatoms * gmx_restrict mdatoms,
731 nb_kernel_data_t * gmx_restrict kernel_data,
732 t_nrnb * gmx_restrict nrnb)
734 int i_shift_offset,i_coord_offset,j_coord_offset;
735 int j_index_start,j_index_end;
736 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
737 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
738 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
739 real *shiftvec,*fshift,*x,*f;
741 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
743 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
745 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
747 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
749 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
751 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
753 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
755 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
756 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
757 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
758 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
759 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
760 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
761 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
762 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
763 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
764 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
765 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
766 real velec,felec,velecsum,facel,crf,krf,krf2;
769 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
773 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
781 jindex = nlist->jindex;
783 shiftidx = nlist->shift;
785 shiftvec = fr->shift_vec[0];
786 fshift = fr->fshift[0];
788 charge = mdatoms->chargeA;
789 nvdwtype = fr->ntype;
791 vdwtype = mdatoms->typeA;
793 vftab = kernel_data->table_elec->data;
794 vftabscale = kernel_data->table_elec->scale;
796 /* Setup water-specific parameters */
797 inr = nlist->iinr[0];
798 iq1 = facel*charge[inr+1];
799 iq2 = facel*charge[inr+2];
800 iq3 = facel*charge[inr+3];
801 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
806 vdwjidx0 = 3*vdwtype[inr+0];
807 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
808 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
809 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
823 /* Start outer loop over neighborlists */
824 for(iidx=0; iidx<nri; iidx++)
826 /* Load shift vector for this list */
827 i_shift_offset = DIM*shiftidx[iidx];
828 shX = shiftvec[i_shift_offset+XX];
829 shY = shiftvec[i_shift_offset+YY];
830 shZ = shiftvec[i_shift_offset+ZZ];
832 /* Load limits for loop over neighbors */
833 j_index_start = jindex[iidx];
834 j_index_end = jindex[iidx+1];
836 /* Get outer coordinate index */
838 i_coord_offset = DIM*inr;
840 /* Load i particle coords and add shift vector */
841 ix0 = shX + x[i_coord_offset+DIM*0+XX];
842 iy0 = shY + x[i_coord_offset+DIM*0+YY];
843 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
844 ix1 = shX + x[i_coord_offset+DIM*1+XX];
845 iy1 = shY + x[i_coord_offset+DIM*1+YY];
846 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
847 ix2 = shX + x[i_coord_offset+DIM*2+XX];
848 iy2 = shY + x[i_coord_offset+DIM*2+YY];
849 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
850 ix3 = shX + x[i_coord_offset+DIM*3+XX];
851 iy3 = shY + x[i_coord_offset+DIM*3+YY];
852 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
867 /* Start inner kernel loop */
868 for(jidx=j_index_start; jidx<j_index_end; jidx++)
870 /* Get j neighbor index, and coordinate index */
872 j_coord_offset = DIM*jnr;
874 /* load j atom coordinates */
875 jx0 = x[j_coord_offset+DIM*0+XX];
876 jy0 = x[j_coord_offset+DIM*0+YY];
877 jz0 = x[j_coord_offset+DIM*0+ZZ];
878 jx1 = x[j_coord_offset+DIM*1+XX];
879 jy1 = x[j_coord_offset+DIM*1+YY];
880 jz1 = x[j_coord_offset+DIM*1+ZZ];
881 jx2 = x[j_coord_offset+DIM*2+XX];
882 jy2 = x[j_coord_offset+DIM*2+YY];
883 jz2 = x[j_coord_offset+DIM*2+ZZ];
884 jx3 = x[j_coord_offset+DIM*3+XX];
885 jy3 = x[j_coord_offset+DIM*3+YY];
886 jz3 = x[j_coord_offset+DIM*3+ZZ];
888 /* Calculate displacement vector */
920 /* Calculate squared distance and things based on it */
921 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
922 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
923 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
924 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
925 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
926 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
927 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
928 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
929 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
930 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
932 rinv00 = gmx_invsqrt(rsq00);
933 rinv11 = gmx_invsqrt(rsq11);
934 rinv12 = gmx_invsqrt(rsq12);
935 rinv13 = gmx_invsqrt(rsq13);
936 rinv21 = gmx_invsqrt(rsq21);
937 rinv22 = gmx_invsqrt(rsq22);
938 rinv23 = gmx_invsqrt(rsq23);
939 rinv31 = gmx_invsqrt(rsq31);
940 rinv32 = gmx_invsqrt(rsq32);
941 rinv33 = gmx_invsqrt(rsq33);
943 rinvsq00 = rinv00*rinv00;
945 /**************************
946 * CALCULATE INTERACTIONS *
947 **************************/
951 /* BUCKINGHAM DISPERSION/REPULSION */
952 rinvsix = rinvsq00*rinvsq00*rinvsq00;
953 vvdw6 = c6_00*rinvsix;
955 vvdwexp = cexp1_00*exp(-br);
956 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
960 /* Calculate temporary vectorial force */
965 /* Update vectorial force */
969 f[j_coord_offset+DIM*0+XX] -= tx;
970 f[j_coord_offset+DIM*0+YY] -= ty;
971 f[j_coord_offset+DIM*0+ZZ] -= tz;
973 /**************************
974 * CALCULATE INTERACTIONS *
975 **************************/
979 /* Calculate table index by multiplying r with table scale and truncate to integer */
985 /* CUBIC SPLINE TABLE ELECTROSTATICS */
988 Geps = vfeps*vftab[vfitab+2];
989 Heps2 = vfeps*vfeps*vftab[vfitab+3];
991 FF = Fp+Geps+2.0*Heps2;
992 felec = -qq11*FF*vftabscale*rinv11;
996 /* Calculate temporary vectorial force */
1001 /* Update vectorial force */
1005 f[j_coord_offset+DIM*1+XX] -= tx;
1006 f[j_coord_offset+DIM*1+YY] -= ty;
1007 f[j_coord_offset+DIM*1+ZZ] -= tz;
1009 /**************************
1010 * CALCULATE INTERACTIONS *
1011 **************************/
1015 /* Calculate table index by multiplying r with table scale and truncate to integer */
1016 rt = r12*vftabscale;
1019 vfitab = 1*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 = -qq12*FF*vftabscale*rinv12;
1032 /* Calculate temporary vectorial force */
1037 /* Update vectorial force */
1041 f[j_coord_offset+DIM*2+XX] -= tx;
1042 f[j_coord_offset+DIM*2+YY] -= ty;
1043 f[j_coord_offset+DIM*2+ZZ] -= tz;
1045 /**************************
1046 * CALCULATE INTERACTIONS *
1047 **************************/
1051 /* Calculate table index by multiplying r with table scale and truncate to integer */
1052 rt = r13*vftabscale;
1055 vfitab = 1*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 = -qq13*FF*vftabscale*rinv13;
1068 /* Calculate temporary vectorial force */
1073 /* Update vectorial force */
1077 f[j_coord_offset+DIM*3+XX] -= tx;
1078 f[j_coord_offset+DIM*3+YY] -= ty;
1079 f[j_coord_offset+DIM*3+ZZ] -= tz;
1081 /**************************
1082 * CALCULATE INTERACTIONS *
1083 **************************/
1087 /* Calculate table index by multiplying r with table scale and truncate to integer */
1088 rt = r21*vftabscale;
1091 vfitab = 1*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 = -qq21*FF*vftabscale*rinv21;
1104 /* Calculate temporary vectorial force */
1109 /* Update vectorial force */
1113 f[j_coord_offset+DIM*1+XX] -= tx;
1114 f[j_coord_offset+DIM*1+YY] -= ty;
1115 f[j_coord_offset+DIM*1+ZZ] -= tz;
1117 /**************************
1118 * CALCULATE INTERACTIONS *
1119 **************************/
1123 /* Calculate table index by multiplying r with table scale and truncate to integer */
1124 rt = r22*vftabscale;
1127 vfitab = 1*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 = -qq22*FF*vftabscale*rinv22;
1140 /* Calculate temporary vectorial force */
1145 /* Update vectorial force */
1149 f[j_coord_offset+DIM*2+XX] -= tx;
1150 f[j_coord_offset+DIM*2+YY] -= ty;
1151 f[j_coord_offset+DIM*2+ZZ] -= tz;
1153 /**************************
1154 * CALCULATE INTERACTIONS *
1155 **************************/
1159 /* Calculate table index by multiplying r with table scale and truncate to integer */
1160 rt = r23*vftabscale;
1163 vfitab = 1*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 = -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 */
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 = -qq31*FF*vftabscale*rinv31;
1212 /* Calculate temporary vectorial force */
1217 /* Update vectorial force */
1221 f[j_coord_offset+DIM*1+XX] -= tx;
1222 f[j_coord_offset+DIM*1+YY] -= ty;
1223 f[j_coord_offset+DIM*1+ZZ] -= tz;
1225 /**************************
1226 * CALCULATE INTERACTIONS *
1227 **************************/
1231 /* Calculate table index by multiplying r with table scale and truncate to integer */
1232 rt = r32*vftabscale;
1235 vfitab = 1*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 = -qq32*FF*vftabscale*rinv32;
1248 /* Calculate temporary vectorial force */
1253 /* Update vectorial force */
1257 f[j_coord_offset+DIM*2+XX] -= tx;
1258 f[j_coord_offset+DIM*2+YY] -= ty;
1259 f[j_coord_offset+DIM*2+ZZ] -= tz;
1261 /**************************
1262 * CALCULATE INTERACTIONS *
1263 **************************/
1267 /* Calculate table index by multiplying r with table scale and truncate to integer */
1268 rt = r33*vftabscale;
1271 vfitab = 1*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 = -qq33*FF*vftabscale*rinv33;
1284 /* Calculate temporary vectorial force */
1289 /* Update vectorial force */
1293 f[j_coord_offset+DIM*3+XX] -= tx;
1294 f[j_coord_offset+DIM*3+YY] -= ty;
1295 f[j_coord_offset+DIM*3+ZZ] -= tz;
1297 /* Inner loop uses 391 flops */
1299 /* End of innermost loop */
1302 f[i_coord_offset+DIM*0+XX] += fix0;
1303 f[i_coord_offset+DIM*0+YY] += fiy0;
1304 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1308 f[i_coord_offset+DIM*1+XX] += fix1;
1309 f[i_coord_offset+DIM*1+YY] += fiy1;
1310 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1314 f[i_coord_offset+DIM*2+XX] += fix2;
1315 f[i_coord_offset+DIM*2+YY] += fiy2;
1316 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1320 f[i_coord_offset+DIM*3+XX] += fix3;
1321 f[i_coord_offset+DIM*3+YY] += fiy3;
1322 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1326 fshift[i_shift_offset+XX] += tx;
1327 fshift[i_shift_offset+YY] += ty;
1328 fshift[i_shift_offset+ZZ] += tz;
1330 /* Increment number of inner iterations */
1331 inneriter += j_index_end - j_index_start;
1333 /* Outer loop uses 39 flops */
1336 /* Increment number of outer iterations */
1339 /* Update outer/inner flops */
1341 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*391);