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_GeomW3W3_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Water3
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwLJ_GeomW3W3_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
65 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
67 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
68 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
69 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
70 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
71 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
72 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
73 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
74 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
75 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
76 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
77 real velec,felec,velecsum,facel,crf,krf,krf2;
80 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
84 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
92 jindex = nlist->jindex;
94 shiftidx = nlist->shift;
96 shiftvec = fr->shift_vec[0];
97 fshift = fr->fshift[0];
99 charge = mdatoms->chargeA;
100 nvdwtype = fr->ntype;
102 vdwtype = mdatoms->typeA;
104 vftab = kernel_data->table_elec->data;
105 vftabscale = kernel_data->table_elec->scale;
107 /* Setup water-specific parameters */
108 inr = nlist->iinr[0];
109 iq0 = facel*charge[inr+0];
110 iq1 = facel*charge[inr+1];
111 iq2 = facel*charge[inr+2];
112 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
117 vdwjidx0 = 2*vdwtype[inr+0];
119 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
120 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
133 /* Start outer loop over neighborlists */
134 for(iidx=0; iidx<nri; iidx++)
136 /* Load shift vector for this list */
137 i_shift_offset = DIM*shiftidx[iidx];
138 shX = shiftvec[i_shift_offset+XX];
139 shY = shiftvec[i_shift_offset+YY];
140 shZ = shiftvec[i_shift_offset+ZZ];
142 /* Load limits for loop over neighbors */
143 j_index_start = jindex[iidx];
144 j_index_end = jindex[iidx+1];
146 /* Get outer coordinate index */
148 i_coord_offset = DIM*inr;
150 /* Load i particle coords and add shift vector */
151 ix0 = shX + x[i_coord_offset+DIM*0+XX];
152 iy0 = shY + x[i_coord_offset+DIM*0+YY];
153 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
154 ix1 = shX + x[i_coord_offset+DIM*1+XX];
155 iy1 = shY + x[i_coord_offset+DIM*1+YY];
156 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
157 ix2 = shX + x[i_coord_offset+DIM*2+XX];
158 iy2 = shY + x[i_coord_offset+DIM*2+YY];
159 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
171 /* Reset potential sums */
175 /* Start inner kernel loop */
176 for(jidx=j_index_start; jidx<j_index_end; jidx++)
178 /* Get j neighbor index, and coordinate index */
180 j_coord_offset = DIM*jnr;
182 /* load j atom coordinates */
183 jx0 = x[j_coord_offset+DIM*0+XX];
184 jy0 = x[j_coord_offset+DIM*0+YY];
185 jz0 = x[j_coord_offset+DIM*0+ZZ];
186 jx1 = x[j_coord_offset+DIM*1+XX];
187 jy1 = x[j_coord_offset+DIM*1+YY];
188 jz1 = x[j_coord_offset+DIM*1+ZZ];
189 jx2 = x[j_coord_offset+DIM*2+XX];
190 jy2 = x[j_coord_offset+DIM*2+YY];
191 jz2 = x[j_coord_offset+DIM*2+ZZ];
193 /* Calculate displacement vector */
222 /* Calculate squared distance and things based on it */
223 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
224 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
225 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
226 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
227 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
228 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
229 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
230 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
231 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
233 rinv00 = gmx_invsqrt(rsq00);
234 rinv01 = gmx_invsqrt(rsq01);
235 rinv02 = gmx_invsqrt(rsq02);
236 rinv10 = gmx_invsqrt(rsq10);
237 rinv11 = gmx_invsqrt(rsq11);
238 rinv12 = gmx_invsqrt(rsq12);
239 rinv20 = gmx_invsqrt(rsq20);
240 rinv21 = gmx_invsqrt(rsq21);
241 rinv22 = gmx_invsqrt(rsq22);
243 rinvsq00 = rinv00*rinv00;
245 /**************************
246 * CALCULATE INTERACTIONS *
247 **************************/
251 /* Calculate table index by multiplying r with table scale and truncate to integer */
257 /* CUBIC SPLINE TABLE ELECTROSTATICS */
260 Geps = vfeps*vftab[vfitab+2];
261 Heps2 = vfeps*vfeps*vftab[vfitab+3];
265 FF = Fp+Geps+2.0*Heps2;
266 felec = -qq00*FF*vftabscale*rinv00;
268 /* LENNARD-JONES DISPERSION/REPULSION */
270 rinvsix = rinvsq00*rinvsq00*rinvsq00;
271 vvdw6 = c6_00*rinvsix;
272 vvdw12 = c12_00*rinvsix*rinvsix;
273 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
274 fvdw = (vvdw12-vvdw6)*rinvsq00;
276 /* Update potential sums from outer loop */
282 /* Calculate temporary vectorial force */
287 /* Update vectorial force */
291 f[j_coord_offset+DIM*0+XX] -= tx;
292 f[j_coord_offset+DIM*0+YY] -= ty;
293 f[j_coord_offset+DIM*0+ZZ] -= tz;
295 /**************************
296 * CALCULATE INTERACTIONS *
297 **************************/
301 /* Calculate table index by multiplying r with table scale and truncate to integer */
307 /* CUBIC SPLINE TABLE ELECTROSTATICS */
310 Geps = vfeps*vftab[vfitab+2];
311 Heps2 = vfeps*vfeps*vftab[vfitab+3];
315 FF = Fp+Geps+2.0*Heps2;
316 felec = -qq01*FF*vftabscale*rinv01;
318 /* Update potential sums from outer loop */
323 /* Calculate temporary vectorial force */
328 /* Update vectorial force */
332 f[j_coord_offset+DIM*1+XX] -= tx;
333 f[j_coord_offset+DIM*1+YY] -= ty;
334 f[j_coord_offset+DIM*1+ZZ] -= tz;
336 /**************************
337 * CALCULATE INTERACTIONS *
338 **************************/
342 /* Calculate table index by multiplying r with table scale and truncate to integer */
348 /* CUBIC SPLINE TABLE ELECTROSTATICS */
351 Geps = vfeps*vftab[vfitab+2];
352 Heps2 = vfeps*vfeps*vftab[vfitab+3];
356 FF = Fp+Geps+2.0*Heps2;
357 felec = -qq02*FF*vftabscale*rinv02;
359 /* Update potential sums from outer loop */
364 /* Calculate temporary vectorial force */
369 /* Update vectorial force */
373 f[j_coord_offset+DIM*2+XX] -= tx;
374 f[j_coord_offset+DIM*2+YY] -= ty;
375 f[j_coord_offset+DIM*2+ZZ] -= tz;
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
383 /* Calculate table index by multiplying r with table scale and truncate to integer */
389 /* CUBIC SPLINE TABLE ELECTROSTATICS */
392 Geps = vfeps*vftab[vfitab+2];
393 Heps2 = vfeps*vfeps*vftab[vfitab+3];
397 FF = Fp+Geps+2.0*Heps2;
398 felec = -qq10*FF*vftabscale*rinv10;
400 /* Update potential sums from outer loop */
405 /* Calculate temporary vectorial force */
410 /* Update vectorial force */
414 f[j_coord_offset+DIM*0+XX] -= tx;
415 f[j_coord_offset+DIM*0+YY] -= ty;
416 f[j_coord_offset+DIM*0+ZZ] -= tz;
418 /**************************
419 * CALCULATE INTERACTIONS *
420 **************************/
424 /* Calculate table index by multiplying r with table scale and truncate to integer */
430 /* CUBIC SPLINE TABLE ELECTROSTATICS */
433 Geps = vfeps*vftab[vfitab+2];
434 Heps2 = vfeps*vfeps*vftab[vfitab+3];
438 FF = Fp+Geps+2.0*Heps2;
439 felec = -qq11*FF*vftabscale*rinv11;
441 /* Update potential sums from outer loop */
446 /* Calculate temporary vectorial force */
451 /* Update vectorial force */
455 f[j_coord_offset+DIM*1+XX] -= tx;
456 f[j_coord_offset+DIM*1+YY] -= ty;
457 f[j_coord_offset+DIM*1+ZZ] -= tz;
459 /**************************
460 * CALCULATE INTERACTIONS *
461 **************************/
465 /* Calculate table index by multiplying r with table scale and truncate to integer */
471 /* CUBIC SPLINE TABLE ELECTROSTATICS */
474 Geps = vfeps*vftab[vfitab+2];
475 Heps2 = vfeps*vfeps*vftab[vfitab+3];
479 FF = Fp+Geps+2.0*Heps2;
480 felec = -qq12*FF*vftabscale*rinv12;
482 /* Update potential sums from outer loop */
487 /* Calculate temporary vectorial force */
492 /* Update vectorial force */
496 f[j_coord_offset+DIM*2+XX] -= tx;
497 f[j_coord_offset+DIM*2+YY] -= ty;
498 f[j_coord_offset+DIM*2+ZZ] -= tz;
500 /**************************
501 * CALCULATE INTERACTIONS *
502 **************************/
506 /* Calculate table index by multiplying r with table scale and truncate to integer */
512 /* CUBIC SPLINE TABLE ELECTROSTATICS */
515 Geps = vfeps*vftab[vfitab+2];
516 Heps2 = vfeps*vfeps*vftab[vfitab+3];
520 FF = Fp+Geps+2.0*Heps2;
521 felec = -qq20*FF*vftabscale*rinv20;
523 /* Update potential sums from outer loop */
528 /* Calculate temporary vectorial force */
533 /* Update vectorial force */
537 f[j_coord_offset+DIM*0+XX] -= tx;
538 f[j_coord_offset+DIM*0+YY] -= ty;
539 f[j_coord_offset+DIM*0+ZZ] -= tz;
541 /**************************
542 * CALCULATE INTERACTIONS *
543 **************************/
547 /* Calculate table index by multiplying r with table scale and truncate to integer */
553 /* CUBIC SPLINE TABLE ELECTROSTATICS */
556 Geps = vfeps*vftab[vfitab+2];
557 Heps2 = vfeps*vfeps*vftab[vfitab+3];
561 FF = Fp+Geps+2.0*Heps2;
562 felec = -qq21*FF*vftabscale*rinv21;
564 /* Update potential sums from outer loop */
569 /* Calculate temporary vectorial force */
574 /* Update vectorial force */
578 f[j_coord_offset+DIM*1+XX] -= tx;
579 f[j_coord_offset+DIM*1+YY] -= ty;
580 f[j_coord_offset+DIM*1+ZZ] -= tz;
582 /**************************
583 * CALCULATE INTERACTIONS *
584 **************************/
588 /* Calculate table index by multiplying r with table scale and truncate to integer */
594 /* CUBIC SPLINE TABLE ELECTROSTATICS */
597 Geps = vfeps*vftab[vfitab+2];
598 Heps2 = vfeps*vfeps*vftab[vfitab+3];
602 FF = Fp+Geps+2.0*Heps2;
603 felec = -qq22*FF*vftabscale*rinv22;
605 /* Update potential sums from outer loop */
610 /* Calculate temporary vectorial force */
615 /* Update vectorial force */
619 f[j_coord_offset+DIM*2+XX] -= tx;
620 f[j_coord_offset+DIM*2+YY] -= ty;
621 f[j_coord_offset+DIM*2+ZZ] -= tz;
623 /* Inner loop uses 382 flops */
625 /* End of innermost loop */
628 f[i_coord_offset+DIM*0+XX] += fix0;
629 f[i_coord_offset+DIM*0+YY] += fiy0;
630 f[i_coord_offset+DIM*0+ZZ] += fiz0;
634 f[i_coord_offset+DIM*1+XX] += fix1;
635 f[i_coord_offset+DIM*1+YY] += fiy1;
636 f[i_coord_offset+DIM*1+ZZ] += fiz1;
640 f[i_coord_offset+DIM*2+XX] += fix2;
641 f[i_coord_offset+DIM*2+YY] += fiy2;
642 f[i_coord_offset+DIM*2+ZZ] += fiz2;
646 fshift[i_shift_offset+XX] += tx;
647 fshift[i_shift_offset+YY] += ty;
648 fshift[i_shift_offset+ZZ] += tz;
651 /* Update potential energies */
652 kernel_data->energygrp_elec[ggid] += velecsum;
653 kernel_data->energygrp_vdw[ggid] += vvdwsum;
655 /* Increment number of inner iterations */
656 inneriter += j_index_end - j_index_start;
658 /* Outer loop uses 32 flops */
661 /* Increment number of outer iterations */
664 /* Update outer/inner flops */
666 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*382);
669 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW3W3_F_c
670 * Electrostatics interaction: CubicSplineTable
671 * VdW interaction: LennardJones
672 * Geometry: Water3-Water3
673 * Calculate force/pot: Force
676 nb_kernel_ElecCSTab_VdwLJ_GeomW3W3_F_c
677 (t_nblist * gmx_restrict nlist,
678 rvec * gmx_restrict xx,
679 rvec * gmx_restrict ff,
680 t_forcerec * gmx_restrict fr,
681 t_mdatoms * gmx_restrict mdatoms,
682 nb_kernel_data_t * gmx_restrict kernel_data,
683 t_nrnb * gmx_restrict nrnb)
685 int i_shift_offset,i_coord_offset,j_coord_offset;
686 int j_index_start,j_index_end;
687 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
688 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
689 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
690 real *shiftvec,*fshift,*x,*f;
692 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
694 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
696 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
698 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
700 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
702 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
703 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
704 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
705 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
706 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
707 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
708 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
709 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
710 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
711 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
712 real velec,felec,velecsum,facel,crf,krf,krf2;
715 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
719 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
727 jindex = nlist->jindex;
729 shiftidx = nlist->shift;
731 shiftvec = fr->shift_vec[0];
732 fshift = fr->fshift[0];
734 charge = mdatoms->chargeA;
735 nvdwtype = fr->ntype;
737 vdwtype = mdatoms->typeA;
739 vftab = kernel_data->table_elec->data;
740 vftabscale = kernel_data->table_elec->scale;
742 /* Setup water-specific parameters */
743 inr = nlist->iinr[0];
744 iq0 = facel*charge[inr+0];
745 iq1 = facel*charge[inr+1];
746 iq2 = facel*charge[inr+2];
747 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
752 vdwjidx0 = 2*vdwtype[inr+0];
754 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
755 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
768 /* Start outer loop over neighborlists */
769 for(iidx=0; iidx<nri; iidx++)
771 /* Load shift vector for this list */
772 i_shift_offset = DIM*shiftidx[iidx];
773 shX = shiftvec[i_shift_offset+XX];
774 shY = shiftvec[i_shift_offset+YY];
775 shZ = shiftvec[i_shift_offset+ZZ];
777 /* Load limits for loop over neighbors */
778 j_index_start = jindex[iidx];
779 j_index_end = jindex[iidx+1];
781 /* Get outer coordinate index */
783 i_coord_offset = DIM*inr;
785 /* Load i particle coords and add shift vector */
786 ix0 = shX + x[i_coord_offset+DIM*0+XX];
787 iy0 = shY + x[i_coord_offset+DIM*0+YY];
788 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
789 ix1 = shX + x[i_coord_offset+DIM*1+XX];
790 iy1 = shY + x[i_coord_offset+DIM*1+YY];
791 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
792 ix2 = shX + x[i_coord_offset+DIM*2+XX];
793 iy2 = shY + x[i_coord_offset+DIM*2+YY];
794 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
806 /* Start inner kernel loop */
807 for(jidx=j_index_start; jidx<j_index_end; jidx++)
809 /* Get j neighbor index, and coordinate index */
811 j_coord_offset = DIM*jnr;
813 /* load j atom coordinates */
814 jx0 = x[j_coord_offset+DIM*0+XX];
815 jy0 = x[j_coord_offset+DIM*0+YY];
816 jz0 = x[j_coord_offset+DIM*0+ZZ];
817 jx1 = x[j_coord_offset+DIM*1+XX];
818 jy1 = x[j_coord_offset+DIM*1+YY];
819 jz1 = x[j_coord_offset+DIM*1+ZZ];
820 jx2 = x[j_coord_offset+DIM*2+XX];
821 jy2 = x[j_coord_offset+DIM*2+YY];
822 jz2 = x[j_coord_offset+DIM*2+ZZ];
824 /* Calculate displacement vector */
853 /* Calculate squared distance and things based on it */
854 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
855 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
856 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
857 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
858 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
859 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
860 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
861 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
862 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
864 rinv00 = gmx_invsqrt(rsq00);
865 rinv01 = gmx_invsqrt(rsq01);
866 rinv02 = gmx_invsqrt(rsq02);
867 rinv10 = gmx_invsqrt(rsq10);
868 rinv11 = gmx_invsqrt(rsq11);
869 rinv12 = gmx_invsqrt(rsq12);
870 rinv20 = gmx_invsqrt(rsq20);
871 rinv21 = gmx_invsqrt(rsq21);
872 rinv22 = gmx_invsqrt(rsq22);
874 rinvsq00 = rinv00*rinv00;
876 /**************************
877 * CALCULATE INTERACTIONS *
878 **************************/
882 /* Calculate table index by multiplying r with table scale and truncate to integer */
888 /* CUBIC SPLINE TABLE ELECTROSTATICS */
891 Geps = vfeps*vftab[vfitab+2];
892 Heps2 = vfeps*vfeps*vftab[vfitab+3];
894 FF = Fp+Geps+2.0*Heps2;
895 felec = -qq00*FF*vftabscale*rinv00;
897 /* LENNARD-JONES DISPERSION/REPULSION */
899 rinvsix = rinvsq00*rinvsq00*rinvsq00;
900 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
904 /* Calculate temporary vectorial force */
909 /* Update vectorial force */
913 f[j_coord_offset+DIM*0+XX] -= tx;
914 f[j_coord_offset+DIM*0+YY] -= ty;
915 f[j_coord_offset+DIM*0+ZZ] -= tz;
917 /**************************
918 * CALCULATE INTERACTIONS *
919 **************************/
923 /* Calculate table index by multiplying r with table scale and truncate to integer */
929 /* CUBIC SPLINE TABLE ELECTROSTATICS */
932 Geps = vfeps*vftab[vfitab+2];
933 Heps2 = vfeps*vfeps*vftab[vfitab+3];
935 FF = Fp+Geps+2.0*Heps2;
936 felec = -qq01*FF*vftabscale*rinv01;
940 /* Calculate temporary vectorial force */
945 /* Update vectorial force */
949 f[j_coord_offset+DIM*1+XX] -= tx;
950 f[j_coord_offset+DIM*1+YY] -= ty;
951 f[j_coord_offset+DIM*1+ZZ] -= tz;
953 /**************************
954 * CALCULATE INTERACTIONS *
955 **************************/
959 /* Calculate table index by multiplying r with table scale and truncate to integer */
965 /* CUBIC SPLINE TABLE ELECTROSTATICS */
968 Geps = vfeps*vftab[vfitab+2];
969 Heps2 = vfeps*vfeps*vftab[vfitab+3];
971 FF = Fp+Geps+2.0*Heps2;
972 felec = -qq02*FF*vftabscale*rinv02;
976 /* Calculate temporary vectorial force */
981 /* Update vectorial force */
985 f[j_coord_offset+DIM*2+XX] -= tx;
986 f[j_coord_offset+DIM*2+YY] -= ty;
987 f[j_coord_offset+DIM*2+ZZ] -= tz;
989 /**************************
990 * CALCULATE INTERACTIONS *
991 **************************/
995 /* Calculate table index by multiplying r with table scale and truncate to integer */
1001 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1003 F = vftab[vfitab+1];
1004 Geps = vfeps*vftab[vfitab+2];
1005 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1007 FF = Fp+Geps+2.0*Heps2;
1008 felec = -qq10*FF*vftabscale*rinv10;
1012 /* Calculate temporary vectorial force */
1017 /* Update vectorial force */
1021 f[j_coord_offset+DIM*0+XX] -= tx;
1022 f[j_coord_offset+DIM*0+YY] -= ty;
1023 f[j_coord_offset+DIM*0+ZZ] -= tz;
1025 /**************************
1026 * CALCULATE INTERACTIONS *
1027 **************************/
1031 /* Calculate table index by multiplying r with table scale and truncate to integer */
1032 rt = r11*vftabscale;
1035 vfitab = 1*4*vfitab;
1037 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1039 F = vftab[vfitab+1];
1040 Geps = vfeps*vftab[vfitab+2];
1041 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1043 FF = Fp+Geps+2.0*Heps2;
1044 felec = -qq11*FF*vftabscale*rinv11;
1048 /* Calculate temporary vectorial force */
1053 /* Update vectorial force */
1057 f[j_coord_offset+DIM*1+XX] -= tx;
1058 f[j_coord_offset+DIM*1+YY] -= ty;
1059 f[j_coord_offset+DIM*1+ZZ] -= tz;
1061 /**************************
1062 * CALCULATE INTERACTIONS *
1063 **************************/
1067 /* Calculate table index by multiplying r with table scale and truncate to integer */
1068 rt = r12*vftabscale;
1071 vfitab = 1*4*vfitab;
1073 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1075 F = vftab[vfitab+1];
1076 Geps = vfeps*vftab[vfitab+2];
1077 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1079 FF = Fp+Geps+2.0*Heps2;
1080 felec = -qq12*FF*vftabscale*rinv12;
1084 /* Calculate temporary vectorial force */
1089 /* Update vectorial force */
1093 f[j_coord_offset+DIM*2+XX] -= tx;
1094 f[j_coord_offset+DIM*2+YY] -= ty;
1095 f[j_coord_offset+DIM*2+ZZ] -= tz;
1097 /**************************
1098 * CALCULATE INTERACTIONS *
1099 **************************/
1103 /* Calculate table index by multiplying r with table scale and truncate to integer */
1104 rt = r20*vftabscale;
1107 vfitab = 1*4*vfitab;
1109 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1111 F = vftab[vfitab+1];
1112 Geps = vfeps*vftab[vfitab+2];
1113 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1115 FF = Fp+Geps+2.0*Heps2;
1116 felec = -qq20*FF*vftabscale*rinv20;
1120 /* Calculate temporary vectorial force */
1125 /* Update vectorial force */
1129 f[j_coord_offset+DIM*0+XX] -= tx;
1130 f[j_coord_offset+DIM*0+YY] -= ty;
1131 f[j_coord_offset+DIM*0+ZZ] -= tz;
1133 /**************************
1134 * CALCULATE INTERACTIONS *
1135 **************************/
1139 /* Calculate table index by multiplying r with table scale and truncate to integer */
1140 rt = r21*vftabscale;
1143 vfitab = 1*4*vfitab;
1145 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1147 F = vftab[vfitab+1];
1148 Geps = vfeps*vftab[vfitab+2];
1149 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1151 FF = Fp+Geps+2.0*Heps2;
1152 felec = -qq21*FF*vftabscale*rinv21;
1156 /* Calculate temporary vectorial force */
1161 /* Update vectorial force */
1165 f[j_coord_offset+DIM*1+XX] -= tx;
1166 f[j_coord_offset+DIM*1+YY] -= ty;
1167 f[j_coord_offset+DIM*1+ZZ] -= tz;
1169 /**************************
1170 * CALCULATE INTERACTIONS *
1171 **************************/
1175 /* Calculate table index by multiplying r with table scale and truncate to integer */
1176 rt = r22*vftabscale;
1179 vfitab = 1*4*vfitab;
1181 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1183 F = vftab[vfitab+1];
1184 Geps = vfeps*vftab[vfitab+2];
1185 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1187 FF = Fp+Geps+2.0*Heps2;
1188 felec = -qq22*FF*vftabscale*rinv22;
1192 /* Calculate temporary vectorial force */
1197 /* Update vectorial force */
1201 f[j_coord_offset+DIM*2+XX] -= tx;
1202 f[j_coord_offset+DIM*2+YY] -= ty;
1203 f[j_coord_offset+DIM*2+ZZ] -= tz;
1205 /* Inner loop uses 341 flops */
1207 /* End of innermost loop */
1210 f[i_coord_offset+DIM*0+XX] += fix0;
1211 f[i_coord_offset+DIM*0+YY] += fiy0;
1212 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1216 f[i_coord_offset+DIM*1+XX] += fix1;
1217 f[i_coord_offset+DIM*1+YY] += fiy1;
1218 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1222 f[i_coord_offset+DIM*2+XX] += fix2;
1223 f[i_coord_offset+DIM*2+YY] += fiy2;
1224 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1228 fshift[i_shift_offset+XX] += tx;
1229 fshift[i_shift_offset+YY] += ty;
1230 fshift[i_shift_offset+ZZ] += tz;
1232 /* Increment number of inner iterations */
1233 inneriter += j_index_end - j_index_start;
1235 /* Outer loop uses 30 flops */
1238 /* Increment number of outer iterations */
1241 /* Update outer/inner flops */
1243 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*341);