2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3W3_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwBham_GeomW3W3_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
100 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
108 jindex = nlist->jindex;
110 shiftidx = nlist->shift;
112 shiftvec = fr->shift_vec[0];
113 fshift = fr->fshift[0];
115 charge = mdatoms->chargeA;
116 nvdwtype = fr->ntype;
118 vdwtype = mdatoms->typeA;
120 vftab = kernel_data->table_elec->data;
121 vftabscale = kernel_data->table_elec->scale;
123 /* Setup water-specific parameters */
124 inr = nlist->iinr[0];
125 iq0 = facel*charge[inr+0];
126 iq1 = facel*charge[inr+1];
127 iq2 = facel*charge[inr+2];
128 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
133 vdwjidx0 = 3*vdwtype[inr+0];
135 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
136 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
137 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
150 /* Start outer loop over neighborlists */
151 for(iidx=0; iidx<nri; iidx++)
153 /* Load shift vector for this list */
154 i_shift_offset = DIM*shiftidx[iidx];
155 shX = shiftvec[i_shift_offset+XX];
156 shY = shiftvec[i_shift_offset+YY];
157 shZ = shiftvec[i_shift_offset+ZZ];
159 /* Load limits for loop over neighbors */
160 j_index_start = jindex[iidx];
161 j_index_end = jindex[iidx+1];
163 /* Get outer coordinate index */
165 i_coord_offset = DIM*inr;
167 /* Load i particle coords and add shift vector */
168 ix0 = shX + x[i_coord_offset+DIM*0+XX];
169 iy0 = shY + x[i_coord_offset+DIM*0+YY];
170 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
171 ix1 = shX + x[i_coord_offset+DIM*1+XX];
172 iy1 = shY + x[i_coord_offset+DIM*1+YY];
173 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
174 ix2 = shX + x[i_coord_offset+DIM*2+XX];
175 iy2 = shY + x[i_coord_offset+DIM*2+YY];
176 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
188 /* Reset potential sums */
192 /* Start inner kernel loop */
193 for(jidx=j_index_start; jidx<j_index_end; jidx++)
195 /* Get j neighbor index, and coordinate index */
197 j_coord_offset = DIM*jnr;
199 /* load j atom coordinates */
200 jx0 = x[j_coord_offset+DIM*0+XX];
201 jy0 = x[j_coord_offset+DIM*0+YY];
202 jz0 = x[j_coord_offset+DIM*0+ZZ];
203 jx1 = x[j_coord_offset+DIM*1+XX];
204 jy1 = x[j_coord_offset+DIM*1+YY];
205 jz1 = x[j_coord_offset+DIM*1+ZZ];
206 jx2 = x[j_coord_offset+DIM*2+XX];
207 jy2 = x[j_coord_offset+DIM*2+YY];
208 jz2 = x[j_coord_offset+DIM*2+ZZ];
210 /* Calculate displacement vector */
239 /* Calculate squared distance and things based on it */
240 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
241 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
242 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
243 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
244 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
245 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
246 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
247 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
248 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
250 rinv00 = gmx_invsqrt(rsq00);
251 rinv01 = gmx_invsqrt(rsq01);
252 rinv02 = gmx_invsqrt(rsq02);
253 rinv10 = gmx_invsqrt(rsq10);
254 rinv11 = gmx_invsqrt(rsq11);
255 rinv12 = gmx_invsqrt(rsq12);
256 rinv20 = gmx_invsqrt(rsq20);
257 rinv21 = gmx_invsqrt(rsq21);
258 rinv22 = gmx_invsqrt(rsq22);
260 rinvsq00 = rinv00*rinv00;
262 /**************************
263 * CALCULATE INTERACTIONS *
264 **************************/
268 /* Calculate table index by multiplying r with table scale and truncate to integer */
274 /* CUBIC SPLINE TABLE ELECTROSTATICS */
277 Geps = vfeps*vftab[vfitab+2];
278 Heps2 = vfeps*vfeps*vftab[vfitab+3];
282 FF = Fp+Geps+2.0*Heps2;
283 felec = -qq00*FF*vftabscale*rinv00;
285 /* BUCKINGHAM DISPERSION/REPULSION */
286 rinvsix = rinvsq00*rinvsq00*rinvsq00;
287 vvdw6 = c6_00*rinvsix;
289 vvdwexp = cexp1_00*exp(-br);
290 vvdw = vvdwexp - vvdw6*(1.0/6.0);
291 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
293 /* Update potential sums from outer loop */
299 /* Calculate temporary vectorial force */
304 /* Update vectorial force */
308 f[j_coord_offset+DIM*0+XX] -= tx;
309 f[j_coord_offset+DIM*0+YY] -= ty;
310 f[j_coord_offset+DIM*0+ZZ] -= tz;
312 /**************************
313 * CALCULATE INTERACTIONS *
314 **************************/
318 /* Calculate table index by multiplying r with table scale and truncate to integer */
324 /* CUBIC SPLINE TABLE ELECTROSTATICS */
327 Geps = vfeps*vftab[vfitab+2];
328 Heps2 = vfeps*vfeps*vftab[vfitab+3];
332 FF = Fp+Geps+2.0*Heps2;
333 felec = -qq01*FF*vftabscale*rinv01;
335 /* Update potential sums from outer loop */
340 /* Calculate temporary vectorial force */
345 /* Update vectorial force */
349 f[j_coord_offset+DIM*1+XX] -= tx;
350 f[j_coord_offset+DIM*1+YY] -= ty;
351 f[j_coord_offset+DIM*1+ZZ] -= tz;
353 /**************************
354 * CALCULATE INTERACTIONS *
355 **************************/
359 /* Calculate table index by multiplying r with table scale and truncate to integer */
365 /* CUBIC SPLINE TABLE ELECTROSTATICS */
368 Geps = vfeps*vftab[vfitab+2];
369 Heps2 = vfeps*vfeps*vftab[vfitab+3];
373 FF = Fp+Geps+2.0*Heps2;
374 felec = -qq02*FF*vftabscale*rinv02;
376 /* Update potential sums from outer loop */
381 /* Calculate temporary vectorial force */
386 /* Update vectorial force */
390 f[j_coord_offset+DIM*2+XX] -= tx;
391 f[j_coord_offset+DIM*2+YY] -= ty;
392 f[j_coord_offset+DIM*2+ZZ] -= tz;
394 /**************************
395 * CALCULATE INTERACTIONS *
396 **************************/
400 /* Calculate table index by multiplying r with table scale and truncate to integer */
406 /* CUBIC SPLINE TABLE ELECTROSTATICS */
409 Geps = vfeps*vftab[vfitab+2];
410 Heps2 = vfeps*vfeps*vftab[vfitab+3];
414 FF = Fp+Geps+2.0*Heps2;
415 felec = -qq10*FF*vftabscale*rinv10;
417 /* Update potential sums from outer loop */
422 /* Calculate temporary vectorial force */
427 /* Update vectorial force */
431 f[j_coord_offset+DIM*0+XX] -= tx;
432 f[j_coord_offset+DIM*0+YY] -= ty;
433 f[j_coord_offset+DIM*0+ZZ] -= tz;
435 /**************************
436 * CALCULATE INTERACTIONS *
437 **************************/
441 /* Calculate table index by multiplying r with table scale and truncate to integer */
447 /* CUBIC SPLINE TABLE ELECTROSTATICS */
450 Geps = vfeps*vftab[vfitab+2];
451 Heps2 = vfeps*vfeps*vftab[vfitab+3];
455 FF = Fp+Geps+2.0*Heps2;
456 felec = -qq11*FF*vftabscale*rinv11;
458 /* Update potential sums from outer loop */
463 /* Calculate temporary vectorial force */
468 /* Update vectorial force */
472 f[j_coord_offset+DIM*1+XX] -= tx;
473 f[j_coord_offset+DIM*1+YY] -= ty;
474 f[j_coord_offset+DIM*1+ZZ] -= tz;
476 /**************************
477 * CALCULATE INTERACTIONS *
478 **************************/
482 /* Calculate table index by multiplying r with table scale and truncate to integer */
488 /* CUBIC SPLINE TABLE ELECTROSTATICS */
491 Geps = vfeps*vftab[vfitab+2];
492 Heps2 = vfeps*vfeps*vftab[vfitab+3];
496 FF = Fp+Geps+2.0*Heps2;
497 felec = -qq12*FF*vftabscale*rinv12;
499 /* Update potential sums from outer loop */
504 /* Calculate temporary vectorial force */
509 /* Update vectorial force */
513 f[j_coord_offset+DIM*2+XX] -= tx;
514 f[j_coord_offset+DIM*2+YY] -= ty;
515 f[j_coord_offset+DIM*2+ZZ] -= tz;
517 /**************************
518 * CALCULATE INTERACTIONS *
519 **************************/
523 /* Calculate table index by multiplying r with table scale and truncate to integer */
529 /* CUBIC SPLINE TABLE ELECTROSTATICS */
532 Geps = vfeps*vftab[vfitab+2];
533 Heps2 = vfeps*vfeps*vftab[vfitab+3];
537 FF = Fp+Geps+2.0*Heps2;
538 felec = -qq20*FF*vftabscale*rinv20;
540 /* Update potential sums from outer loop */
545 /* Calculate temporary vectorial force */
550 /* Update vectorial force */
554 f[j_coord_offset+DIM*0+XX] -= tx;
555 f[j_coord_offset+DIM*0+YY] -= ty;
556 f[j_coord_offset+DIM*0+ZZ] -= tz;
558 /**************************
559 * CALCULATE INTERACTIONS *
560 **************************/
564 /* Calculate table index by multiplying r with table scale and truncate to integer */
570 /* CUBIC SPLINE TABLE ELECTROSTATICS */
573 Geps = vfeps*vftab[vfitab+2];
574 Heps2 = vfeps*vfeps*vftab[vfitab+3];
578 FF = Fp+Geps+2.0*Heps2;
579 felec = -qq21*FF*vftabscale*rinv21;
581 /* Update potential sums from outer loop */
586 /* Calculate temporary vectorial force */
591 /* Update vectorial force */
595 f[j_coord_offset+DIM*1+XX] -= tx;
596 f[j_coord_offset+DIM*1+YY] -= ty;
597 f[j_coord_offset+DIM*1+ZZ] -= tz;
599 /**************************
600 * CALCULATE INTERACTIONS *
601 **************************/
605 /* Calculate table index by multiplying r with table scale and truncate to integer */
611 /* CUBIC SPLINE TABLE ELECTROSTATICS */
614 Geps = vfeps*vftab[vfitab+2];
615 Heps2 = vfeps*vfeps*vftab[vfitab+3];
619 FF = Fp+Geps+2.0*Heps2;
620 felec = -qq22*FF*vftabscale*rinv22;
622 /* Update potential sums from outer loop */
627 /* Calculate temporary vectorial force */
632 /* Update vectorial force */
636 f[j_coord_offset+DIM*2+XX] -= tx;
637 f[j_coord_offset+DIM*2+YY] -= ty;
638 f[j_coord_offset+DIM*2+ZZ] -= tz;
640 /* Inner loop uses 408 flops */
642 /* End of innermost loop */
645 f[i_coord_offset+DIM*0+XX] += fix0;
646 f[i_coord_offset+DIM*0+YY] += fiy0;
647 f[i_coord_offset+DIM*0+ZZ] += fiz0;
651 f[i_coord_offset+DIM*1+XX] += fix1;
652 f[i_coord_offset+DIM*1+YY] += fiy1;
653 f[i_coord_offset+DIM*1+ZZ] += fiz1;
657 f[i_coord_offset+DIM*2+XX] += fix2;
658 f[i_coord_offset+DIM*2+YY] += fiy2;
659 f[i_coord_offset+DIM*2+ZZ] += fiz2;
663 fshift[i_shift_offset+XX] += tx;
664 fshift[i_shift_offset+YY] += ty;
665 fshift[i_shift_offset+ZZ] += tz;
668 /* Update potential energies */
669 kernel_data->energygrp_elec[ggid] += velecsum;
670 kernel_data->energygrp_vdw[ggid] += vvdwsum;
672 /* Increment number of inner iterations */
673 inneriter += j_index_end - j_index_start;
675 /* Outer loop uses 32 flops */
678 /* Increment number of outer iterations */
681 /* Update outer/inner flops */
683 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*408);
686 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3W3_F_c
687 * Electrostatics interaction: CubicSplineTable
688 * VdW interaction: Buckingham
689 * Geometry: Water3-Water3
690 * Calculate force/pot: Force
693 nb_kernel_ElecCSTab_VdwBham_GeomW3W3_F_c
694 (t_nblist * gmx_restrict nlist,
695 rvec * gmx_restrict xx,
696 rvec * gmx_restrict ff,
697 t_forcerec * gmx_restrict fr,
698 t_mdatoms * gmx_restrict mdatoms,
699 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
700 t_nrnb * gmx_restrict nrnb)
702 int i_shift_offset,i_coord_offset,j_coord_offset;
703 int j_index_start,j_index_end;
704 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
705 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
706 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
707 real *shiftvec,*fshift,*x,*f;
709 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
711 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
713 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
715 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
717 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
719 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
720 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
721 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
722 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
723 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
724 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
725 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
726 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
727 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
728 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
729 real velec,felec,velecsum,facel,crf,krf,krf2;
732 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
736 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
744 jindex = nlist->jindex;
746 shiftidx = nlist->shift;
748 shiftvec = fr->shift_vec[0];
749 fshift = fr->fshift[0];
751 charge = mdatoms->chargeA;
752 nvdwtype = fr->ntype;
754 vdwtype = mdatoms->typeA;
756 vftab = kernel_data->table_elec->data;
757 vftabscale = kernel_data->table_elec->scale;
759 /* Setup water-specific parameters */
760 inr = nlist->iinr[0];
761 iq0 = facel*charge[inr+0];
762 iq1 = facel*charge[inr+1];
763 iq2 = facel*charge[inr+2];
764 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
769 vdwjidx0 = 3*vdwtype[inr+0];
771 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
772 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
773 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
786 /* Start outer loop over neighborlists */
787 for(iidx=0; iidx<nri; iidx++)
789 /* Load shift vector for this list */
790 i_shift_offset = DIM*shiftidx[iidx];
791 shX = shiftvec[i_shift_offset+XX];
792 shY = shiftvec[i_shift_offset+YY];
793 shZ = shiftvec[i_shift_offset+ZZ];
795 /* Load limits for loop over neighbors */
796 j_index_start = jindex[iidx];
797 j_index_end = jindex[iidx+1];
799 /* Get outer coordinate index */
801 i_coord_offset = DIM*inr;
803 /* Load i particle coords and add shift vector */
804 ix0 = shX + x[i_coord_offset+DIM*0+XX];
805 iy0 = shY + x[i_coord_offset+DIM*0+YY];
806 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
807 ix1 = shX + x[i_coord_offset+DIM*1+XX];
808 iy1 = shY + x[i_coord_offset+DIM*1+YY];
809 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
810 ix2 = shX + x[i_coord_offset+DIM*2+XX];
811 iy2 = shY + x[i_coord_offset+DIM*2+YY];
812 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
824 /* Start inner kernel loop */
825 for(jidx=j_index_start; jidx<j_index_end; jidx++)
827 /* Get j neighbor index, and coordinate index */
829 j_coord_offset = DIM*jnr;
831 /* load j atom coordinates */
832 jx0 = x[j_coord_offset+DIM*0+XX];
833 jy0 = x[j_coord_offset+DIM*0+YY];
834 jz0 = x[j_coord_offset+DIM*0+ZZ];
835 jx1 = x[j_coord_offset+DIM*1+XX];
836 jy1 = x[j_coord_offset+DIM*1+YY];
837 jz1 = x[j_coord_offset+DIM*1+ZZ];
838 jx2 = x[j_coord_offset+DIM*2+XX];
839 jy2 = x[j_coord_offset+DIM*2+YY];
840 jz2 = x[j_coord_offset+DIM*2+ZZ];
842 /* Calculate displacement vector */
871 /* Calculate squared distance and things based on it */
872 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
873 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
874 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
875 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
876 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
877 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
878 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
879 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
880 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
882 rinv00 = gmx_invsqrt(rsq00);
883 rinv01 = gmx_invsqrt(rsq01);
884 rinv02 = gmx_invsqrt(rsq02);
885 rinv10 = gmx_invsqrt(rsq10);
886 rinv11 = gmx_invsqrt(rsq11);
887 rinv12 = gmx_invsqrt(rsq12);
888 rinv20 = gmx_invsqrt(rsq20);
889 rinv21 = gmx_invsqrt(rsq21);
890 rinv22 = gmx_invsqrt(rsq22);
892 rinvsq00 = rinv00*rinv00;
894 /**************************
895 * CALCULATE INTERACTIONS *
896 **************************/
900 /* Calculate table index by multiplying r with table scale and truncate to integer */
906 /* CUBIC SPLINE TABLE ELECTROSTATICS */
908 Geps = vfeps*vftab[vfitab+2];
909 Heps2 = vfeps*vfeps*vftab[vfitab+3];
911 FF = Fp+Geps+2.0*Heps2;
912 felec = -qq00*FF*vftabscale*rinv00;
914 /* BUCKINGHAM DISPERSION/REPULSION */
915 rinvsix = rinvsq00*rinvsq00*rinvsq00;
916 vvdw6 = c6_00*rinvsix;
918 vvdwexp = cexp1_00*exp(-br);
919 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
923 /* Calculate temporary vectorial force */
928 /* Update vectorial force */
932 f[j_coord_offset+DIM*0+XX] -= tx;
933 f[j_coord_offset+DIM*0+YY] -= ty;
934 f[j_coord_offset+DIM*0+ZZ] -= tz;
936 /**************************
937 * CALCULATE INTERACTIONS *
938 **************************/
942 /* Calculate table index by multiplying r with table scale and truncate to integer */
948 /* CUBIC SPLINE TABLE ELECTROSTATICS */
950 Geps = vfeps*vftab[vfitab+2];
951 Heps2 = vfeps*vfeps*vftab[vfitab+3];
953 FF = Fp+Geps+2.0*Heps2;
954 felec = -qq01*FF*vftabscale*rinv01;
958 /* Calculate temporary vectorial force */
963 /* Update vectorial force */
967 f[j_coord_offset+DIM*1+XX] -= tx;
968 f[j_coord_offset+DIM*1+YY] -= ty;
969 f[j_coord_offset+DIM*1+ZZ] -= tz;
971 /**************************
972 * CALCULATE INTERACTIONS *
973 **************************/
977 /* Calculate table index by multiplying r with table scale and truncate to integer */
983 /* CUBIC SPLINE TABLE ELECTROSTATICS */
985 Geps = vfeps*vftab[vfitab+2];
986 Heps2 = vfeps*vfeps*vftab[vfitab+3];
988 FF = Fp+Geps+2.0*Heps2;
989 felec = -qq02*FF*vftabscale*rinv02;
993 /* Calculate temporary vectorial force */
998 /* Update vectorial force */
1002 f[j_coord_offset+DIM*2+XX] -= tx;
1003 f[j_coord_offset+DIM*2+YY] -= ty;
1004 f[j_coord_offset+DIM*2+ZZ] -= tz;
1006 /**************************
1007 * CALCULATE INTERACTIONS *
1008 **************************/
1012 /* Calculate table index by multiplying r with table scale and truncate to integer */
1013 rt = r10*vftabscale;
1016 vfitab = 1*4*vfitab;
1018 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1019 F = vftab[vfitab+1];
1020 Geps = vfeps*vftab[vfitab+2];
1021 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1023 FF = Fp+Geps+2.0*Heps2;
1024 felec = -qq10*FF*vftabscale*rinv10;
1028 /* Calculate temporary vectorial force */
1033 /* Update vectorial force */
1037 f[j_coord_offset+DIM*0+XX] -= tx;
1038 f[j_coord_offset+DIM*0+YY] -= ty;
1039 f[j_coord_offset+DIM*0+ZZ] -= tz;
1041 /**************************
1042 * CALCULATE INTERACTIONS *
1043 **************************/
1047 /* Calculate table index by multiplying r with table scale and truncate to integer */
1048 rt = r11*vftabscale;
1051 vfitab = 1*4*vfitab;
1053 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1054 F = vftab[vfitab+1];
1055 Geps = vfeps*vftab[vfitab+2];
1056 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1058 FF = Fp+Geps+2.0*Heps2;
1059 felec = -qq11*FF*vftabscale*rinv11;
1063 /* Calculate temporary vectorial force */
1068 /* Update vectorial force */
1072 f[j_coord_offset+DIM*1+XX] -= tx;
1073 f[j_coord_offset+DIM*1+YY] -= ty;
1074 f[j_coord_offset+DIM*1+ZZ] -= tz;
1076 /**************************
1077 * CALCULATE INTERACTIONS *
1078 **************************/
1082 /* Calculate table index by multiplying r with table scale and truncate to integer */
1083 rt = r12*vftabscale;
1086 vfitab = 1*4*vfitab;
1088 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1089 F = vftab[vfitab+1];
1090 Geps = vfeps*vftab[vfitab+2];
1091 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1093 FF = Fp+Geps+2.0*Heps2;
1094 felec = -qq12*FF*vftabscale*rinv12;
1098 /* Calculate temporary vectorial force */
1103 /* Update vectorial force */
1107 f[j_coord_offset+DIM*2+XX] -= tx;
1108 f[j_coord_offset+DIM*2+YY] -= ty;
1109 f[j_coord_offset+DIM*2+ZZ] -= tz;
1111 /**************************
1112 * CALCULATE INTERACTIONS *
1113 **************************/
1117 /* Calculate table index by multiplying r with table scale and truncate to integer */
1118 rt = r20*vftabscale;
1121 vfitab = 1*4*vfitab;
1123 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1124 F = vftab[vfitab+1];
1125 Geps = vfeps*vftab[vfitab+2];
1126 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1128 FF = Fp+Geps+2.0*Heps2;
1129 felec = -qq20*FF*vftabscale*rinv20;
1133 /* Calculate temporary vectorial force */
1138 /* Update vectorial force */
1142 f[j_coord_offset+DIM*0+XX] -= tx;
1143 f[j_coord_offset+DIM*0+YY] -= ty;
1144 f[j_coord_offset+DIM*0+ZZ] -= tz;
1146 /**************************
1147 * CALCULATE INTERACTIONS *
1148 **************************/
1152 /* Calculate table index by multiplying r with table scale and truncate to integer */
1153 rt = r21*vftabscale;
1156 vfitab = 1*4*vfitab;
1158 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1159 F = vftab[vfitab+1];
1160 Geps = vfeps*vftab[vfitab+2];
1161 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1163 FF = Fp+Geps+2.0*Heps2;
1164 felec = -qq21*FF*vftabscale*rinv21;
1168 /* Calculate temporary vectorial force */
1173 /* Update vectorial force */
1177 f[j_coord_offset+DIM*1+XX] -= tx;
1178 f[j_coord_offset+DIM*1+YY] -= ty;
1179 f[j_coord_offset+DIM*1+ZZ] -= tz;
1181 /**************************
1182 * CALCULATE INTERACTIONS *
1183 **************************/
1187 /* Calculate table index by multiplying r with table scale and truncate to integer */
1188 rt = r22*vftabscale;
1191 vfitab = 1*4*vfitab;
1193 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1194 F = vftab[vfitab+1];
1195 Geps = vfeps*vftab[vfitab+2];
1196 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1198 FF = Fp+Geps+2.0*Heps2;
1199 felec = -qq22*FF*vftabscale*rinv22;
1203 /* Calculate temporary vectorial force */
1208 /* Update vectorial force */
1212 f[j_coord_offset+DIM*2+XX] -= tx;
1213 f[j_coord_offset+DIM*2+YY] -= ty;
1214 f[j_coord_offset+DIM*2+ZZ] -= tz;
1216 /* Inner loop uses 369 flops */
1218 /* End of innermost loop */
1221 f[i_coord_offset+DIM*0+XX] += fix0;
1222 f[i_coord_offset+DIM*0+YY] += fiy0;
1223 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1227 f[i_coord_offset+DIM*1+XX] += fix1;
1228 f[i_coord_offset+DIM*1+YY] += fiy1;
1229 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1233 f[i_coord_offset+DIM*2+XX] += fix2;
1234 f[i_coord_offset+DIM*2+YY] += fiy2;
1235 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1239 fshift[i_shift_offset+XX] += tx;
1240 fshift[i_shift_offset+YY] += ty;
1241 fshift[i_shift_offset+ZZ] += tz;
1243 /* Increment number of inner iterations */
1244 inneriter += j_index_end - j_index_start;
1246 /* Outer loop uses 30 flops */
1249 /* Increment number of outer iterations */
1252 /* Update outer/inner flops */
1254 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*369);