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.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3W3_VF_c
49 * Electrostatics interaction: CubicSplineTable
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCSTab_VdwBham_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
98 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
106 jindex = nlist->jindex;
108 shiftidx = nlist->shift;
110 shiftvec = fr->shift_vec[0];
111 fshift = fr->fshift[0];
113 charge = mdatoms->chargeA;
114 nvdwtype = fr->ntype;
116 vdwtype = mdatoms->typeA;
118 vftab = kernel_data->table_elec->data;
119 vftabscale = kernel_data->table_elec->scale;
121 /* Setup water-specific parameters */
122 inr = nlist->iinr[0];
123 iq0 = facel*charge[inr+0];
124 iq1 = facel*charge[inr+1];
125 iq2 = facel*charge[inr+2];
126 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
131 vdwjidx0 = 3*vdwtype[inr+0];
133 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
134 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
135 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
148 /* Start outer loop over neighborlists */
149 for(iidx=0; iidx<nri; iidx++)
151 /* Load shift vector for this list */
152 i_shift_offset = DIM*shiftidx[iidx];
153 shX = shiftvec[i_shift_offset+XX];
154 shY = shiftvec[i_shift_offset+YY];
155 shZ = shiftvec[i_shift_offset+ZZ];
157 /* Load limits for loop over neighbors */
158 j_index_start = jindex[iidx];
159 j_index_end = jindex[iidx+1];
161 /* Get outer coordinate index */
163 i_coord_offset = DIM*inr;
165 /* Load i particle coords and add shift vector */
166 ix0 = shX + x[i_coord_offset+DIM*0+XX];
167 iy0 = shY + x[i_coord_offset+DIM*0+YY];
168 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
169 ix1 = shX + x[i_coord_offset+DIM*1+XX];
170 iy1 = shY + x[i_coord_offset+DIM*1+YY];
171 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
172 ix2 = shX + x[i_coord_offset+DIM*2+XX];
173 iy2 = shY + x[i_coord_offset+DIM*2+YY];
174 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
186 /* Reset potential sums */
190 /* Start inner kernel loop */
191 for(jidx=j_index_start; jidx<j_index_end; jidx++)
193 /* Get j neighbor index, and coordinate index */
195 j_coord_offset = DIM*jnr;
197 /* load j atom coordinates */
198 jx0 = x[j_coord_offset+DIM*0+XX];
199 jy0 = x[j_coord_offset+DIM*0+YY];
200 jz0 = x[j_coord_offset+DIM*0+ZZ];
201 jx1 = x[j_coord_offset+DIM*1+XX];
202 jy1 = x[j_coord_offset+DIM*1+YY];
203 jz1 = x[j_coord_offset+DIM*1+ZZ];
204 jx2 = x[j_coord_offset+DIM*2+XX];
205 jy2 = x[j_coord_offset+DIM*2+YY];
206 jz2 = x[j_coord_offset+DIM*2+ZZ];
208 /* Calculate displacement vector */
237 /* Calculate squared distance and things based on it */
238 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
239 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
240 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
241 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
242 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
243 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
244 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
245 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
246 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
248 rinv00 = gmx_invsqrt(rsq00);
249 rinv01 = gmx_invsqrt(rsq01);
250 rinv02 = gmx_invsqrt(rsq02);
251 rinv10 = gmx_invsqrt(rsq10);
252 rinv11 = gmx_invsqrt(rsq11);
253 rinv12 = gmx_invsqrt(rsq12);
254 rinv20 = gmx_invsqrt(rsq20);
255 rinv21 = gmx_invsqrt(rsq21);
256 rinv22 = gmx_invsqrt(rsq22);
258 rinvsq00 = rinv00*rinv00;
260 /**************************
261 * CALCULATE INTERACTIONS *
262 **************************/
266 /* Calculate table index by multiplying r with table scale and truncate to integer */
272 /* CUBIC SPLINE TABLE ELECTROSTATICS */
275 Geps = vfeps*vftab[vfitab+2];
276 Heps2 = vfeps*vfeps*vftab[vfitab+3];
280 FF = Fp+Geps+2.0*Heps2;
281 felec = -qq00*FF*vftabscale*rinv00;
283 /* BUCKINGHAM DISPERSION/REPULSION */
284 rinvsix = rinvsq00*rinvsq00*rinvsq00;
285 vvdw6 = c6_00*rinvsix;
287 vvdwexp = cexp1_00*exp(-br);
288 vvdw = vvdwexp - vvdw6*(1.0/6.0);
289 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
291 /* Update potential sums from outer loop */
297 /* Calculate temporary vectorial force */
302 /* Update vectorial force */
306 f[j_coord_offset+DIM*0+XX] -= tx;
307 f[j_coord_offset+DIM*0+YY] -= ty;
308 f[j_coord_offset+DIM*0+ZZ] -= tz;
310 /**************************
311 * CALCULATE INTERACTIONS *
312 **************************/
316 /* Calculate table index by multiplying r with table scale and truncate to integer */
322 /* CUBIC SPLINE TABLE ELECTROSTATICS */
325 Geps = vfeps*vftab[vfitab+2];
326 Heps2 = vfeps*vfeps*vftab[vfitab+3];
330 FF = Fp+Geps+2.0*Heps2;
331 felec = -qq01*FF*vftabscale*rinv01;
333 /* Update potential sums from outer loop */
338 /* Calculate temporary vectorial force */
343 /* Update vectorial force */
347 f[j_coord_offset+DIM*1+XX] -= tx;
348 f[j_coord_offset+DIM*1+YY] -= ty;
349 f[j_coord_offset+DIM*1+ZZ] -= tz;
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
357 /* Calculate table index by multiplying r with table scale and truncate to integer */
363 /* CUBIC SPLINE TABLE ELECTROSTATICS */
366 Geps = vfeps*vftab[vfitab+2];
367 Heps2 = vfeps*vfeps*vftab[vfitab+3];
371 FF = Fp+Geps+2.0*Heps2;
372 felec = -qq02*FF*vftabscale*rinv02;
374 /* Update potential sums from outer loop */
379 /* Calculate temporary vectorial force */
384 /* Update vectorial force */
388 f[j_coord_offset+DIM*2+XX] -= tx;
389 f[j_coord_offset+DIM*2+YY] -= ty;
390 f[j_coord_offset+DIM*2+ZZ] -= tz;
392 /**************************
393 * CALCULATE INTERACTIONS *
394 **************************/
398 /* Calculate table index by multiplying r with table scale and truncate to integer */
404 /* CUBIC SPLINE TABLE ELECTROSTATICS */
407 Geps = vfeps*vftab[vfitab+2];
408 Heps2 = vfeps*vfeps*vftab[vfitab+3];
412 FF = Fp+Geps+2.0*Heps2;
413 felec = -qq10*FF*vftabscale*rinv10;
415 /* Update potential sums from outer loop */
420 /* Calculate temporary vectorial force */
425 /* Update vectorial force */
429 f[j_coord_offset+DIM*0+XX] -= tx;
430 f[j_coord_offset+DIM*0+YY] -= ty;
431 f[j_coord_offset+DIM*0+ZZ] -= tz;
433 /**************************
434 * CALCULATE INTERACTIONS *
435 **************************/
439 /* Calculate table index by multiplying r with table scale and truncate to integer */
445 /* CUBIC SPLINE TABLE ELECTROSTATICS */
448 Geps = vfeps*vftab[vfitab+2];
449 Heps2 = vfeps*vfeps*vftab[vfitab+3];
453 FF = Fp+Geps+2.0*Heps2;
454 felec = -qq11*FF*vftabscale*rinv11;
456 /* Update potential sums from outer loop */
461 /* Calculate temporary vectorial force */
466 /* Update vectorial force */
470 f[j_coord_offset+DIM*1+XX] -= tx;
471 f[j_coord_offset+DIM*1+YY] -= ty;
472 f[j_coord_offset+DIM*1+ZZ] -= tz;
474 /**************************
475 * CALCULATE INTERACTIONS *
476 **************************/
480 /* Calculate table index by multiplying r with table scale and truncate to integer */
486 /* CUBIC SPLINE TABLE ELECTROSTATICS */
489 Geps = vfeps*vftab[vfitab+2];
490 Heps2 = vfeps*vfeps*vftab[vfitab+3];
494 FF = Fp+Geps+2.0*Heps2;
495 felec = -qq12*FF*vftabscale*rinv12;
497 /* Update potential sums from outer loop */
502 /* Calculate temporary vectorial force */
507 /* Update vectorial force */
511 f[j_coord_offset+DIM*2+XX] -= tx;
512 f[j_coord_offset+DIM*2+YY] -= ty;
513 f[j_coord_offset+DIM*2+ZZ] -= tz;
515 /**************************
516 * CALCULATE INTERACTIONS *
517 **************************/
521 /* Calculate table index by multiplying r with table scale and truncate to integer */
527 /* CUBIC SPLINE TABLE ELECTROSTATICS */
530 Geps = vfeps*vftab[vfitab+2];
531 Heps2 = vfeps*vfeps*vftab[vfitab+3];
535 FF = Fp+Geps+2.0*Heps2;
536 felec = -qq20*FF*vftabscale*rinv20;
538 /* Update potential sums from outer loop */
543 /* Calculate temporary vectorial force */
548 /* Update vectorial force */
552 f[j_coord_offset+DIM*0+XX] -= tx;
553 f[j_coord_offset+DIM*0+YY] -= ty;
554 f[j_coord_offset+DIM*0+ZZ] -= tz;
556 /**************************
557 * CALCULATE INTERACTIONS *
558 **************************/
562 /* Calculate table index by multiplying r with table scale and truncate to integer */
568 /* CUBIC SPLINE TABLE ELECTROSTATICS */
571 Geps = vfeps*vftab[vfitab+2];
572 Heps2 = vfeps*vfeps*vftab[vfitab+3];
576 FF = Fp+Geps+2.0*Heps2;
577 felec = -qq21*FF*vftabscale*rinv21;
579 /* Update potential sums from outer loop */
584 /* Calculate temporary vectorial force */
589 /* Update vectorial force */
593 f[j_coord_offset+DIM*1+XX] -= tx;
594 f[j_coord_offset+DIM*1+YY] -= ty;
595 f[j_coord_offset+DIM*1+ZZ] -= tz;
597 /**************************
598 * CALCULATE INTERACTIONS *
599 **************************/
603 /* Calculate table index by multiplying r with table scale and truncate to integer */
609 /* CUBIC SPLINE TABLE ELECTROSTATICS */
612 Geps = vfeps*vftab[vfitab+2];
613 Heps2 = vfeps*vfeps*vftab[vfitab+3];
617 FF = Fp+Geps+2.0*Heps2;
618 felec = -qq22*FF*vftabscale*rinv22;
620 /* Update potential sums from outer loop */
625 /* Calculate temporary vectorial force */
630 /* Update vectorial force */
634 f[j_coord_offset+DIM*2+XX] -= tx;
635 f[j_coord_offset+DIM*2+YY] -= ty;
636 f[j_coord_offset+DIM*2+ZZ] -= tz;
638 /* Inner loop uses 408 flops */
640 /* End of innermost loop */
643 f[i_coord_offset+DIM*0+XX] += fix0;
644 f[i_coord_offset+DIM*0+YY] += fiy0;
645 f[i_coord_offset+DIM*0+ZZ] += fiz0;
649 f[i_coord_offset+DIM*1+XX] += fix1;
650 f[i_coord_offset+DIM*1+YY] += fiy1;
651 f[i_coord_offset+DIM*1+ZZ] += fiz1;
655 f[i_coord_offset+DIM*2+XX] += fix2;
656 f[i_coord_offset+DIM*2+YY] += fiy2;
657 f[i_coord_offset+DIM*2+ZZ] += fiz2;
661 fshift[i_shift_offset+XX] += tx;
662 fshift[i_shift_offset+YY] += ty;
663 fshift[i_shift_offset+ZZ] += tz;
666 /* Update potential energies */
667 kernel_data->energygrp_elec[ggid] += velecsum;
668 kernel_data->energygrp_vdw[ggid] += vvdwsum;
670 /* Increment number of inner iterations */
671 inneriter += j_index_end - j_index_start;
673 /* Outer loop uses 32 flops */
676 /* Increment number of outer iterations */
679 /* Update outer/inner flops */
681 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*408);
684 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3W3_F_c
685 * Electrostatics interaction: CubicSplineTable
686 * VdW interaction: Buckingham
687 * Geometry: Water3-Water3
688 * Calculate force/pot: Force
691 nb_kernel_ElecCSTab_VdwBham_GeomW3W3_F_c
692 (t_nblist * gmx_restrict nlist,
693 rvec * gmx_restrict xx,
694 rvec * gmx_restrict ff,
695 t_forcerec * gmx_restrict fr,
696 t_mdatoms * gmx_restrict mdatoms,
697 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
698 t_nrnb * gmx_restrict nrnb)
700 int i_shift_offset,i_coord_offset,j_coord_offset;
701 int j_index_start,j_index_end;
702 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
703 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
704 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
705 real *shiftvec,*fshift,*x,*f;
707 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
709 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
711 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
713 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
715 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
717 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
718 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
719 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
720 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
721 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
722 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
723 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
724 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
725 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
726 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
727 real velec,felec,velecsum,facel,crf,krf,krf2;
730 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
734 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
742 jindex = nlist->jindex;
744 shiftidx = nlist->shift;
746 shiftvec = fr->shift_vec[0];
747 fshift = fr->fshift[0];
749 charge = mdatoms->chargeA;
750 nvdwtype = fr->ntype;
752 vdwtype = mdatoms->typeA;
754 vftab = kernel_data->table_elec->data;
755 vftabscale = kernel_data->table_elec->scale;
757 /* Setup water-specific parameters */
758 inr = nlist->iinr[0];
759 iq0 = facel*charge[inr+0];
760 iq1 = facel*charge[inr+1];
761 iq2 = facel*charge[inr+2];
762 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
767 vdwjidx0 = 3*vdwtype[inr+0];
769 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
770 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
771 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
784 /* Start outer loop over neighborlists */
785 for(iidx=0; iidx<nri; iidx++)
787 /* Load shift vector for this list */
788 i_shift_offset = DIM*shiftidx[iidx];
789 shX = shiftvec[i_shift_offset+XX];
790 shY = shiftvec[i_shift_offset+YY];
791 shZ = shiftvec[i_shift_offset+ZZ];
793 /* Load limits for loop over neighbors */
794 j_index_start = jindex[iidx];
795 j_index_end = jindex[iidx+1];
797 /* Get outer coordinate index */
799 i_coord_offset = DIM*inr;
801 /* Load i particle coords and add shift vector */
802 ix0 = shX + x[i_coord_offset+DIM*0+XX];
803 iy0 = shY + x[i_coord_offset+DIM*0+YY];
804 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
805 ix1 = shX + x[i_coord_offset+DIM*1+XX];
806 iy1 = shY + x[i_coord_offset+DIM*1+YY];
807 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
808 ix2 = shX + x[i_coord_offset+DIM*2+XX];
809 iy2 = shY + x[i_coord_offset+DIM*2+YY];
810 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
822 /* Start inner kernel loop */
823 for(jidx=j_index_start; jidx<j_index_end; jidx++)
825 /* Get j neighbor index, and coordinate index */
827 j_coord_offset = DIM*jnr;
829 /* load j atom coordinates */
830 jx0 = x[j_coord_offset+DIM*0+XX];
831 jy0 = x[j_coord_offset+DIM*0+YY];
832 jz0 = x[j_coord_offset+DIM*0+ZZ];
833 jx1 = x[j_coord_offset+DIM*1+XX];
834 jy1 = x[j_coord_offset+DIM*1+YY];
835 jz1 = x[j_coord_offset+DIM*1+ZZ];
836 jx2 = x[j_coord_offset+DIM*2+XX];
837 jy2 = x[j_coord_offset+DIM*2+YY];
838 jz2 = x[j_coord_offset+DIM*2+ZZ];
840 /* Calculate displacement vector */
869 /* Calculate squared distance and things based on it */
870 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
871 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
872 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
873 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
874 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
875 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
876 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
877 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
878 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
880 rinv00 = gmx_invsqrt(rsq00);
881 rinv01 = gmx_invsqrt(rsq01);
882 rinv02 = gmx_invsqrt(rsq02);
883 rinv10 = gmx_invsqrt(rsq10);
884 rinv11 = gmx_invsqrt(rsq11);
885 rinv12 = gmx_invsqrt(rsq12);
886 rinv20 = gmx_invsqrt(rsq20);
887 rinv21 = gmx_invsqrt(rsq21);
888 rinv22 = gmx_invsqrt(rsq22);
890 rinvsq00 = rinv00*rinv00;
892 /**************************
893 * CALCULATE INTERACTIONS *
894 **************************/
898 /* Calculate table index by multiplying r with table scale and truncate to integer */
904 /* CUBIC SPLINE TABLE ELECTROSTATICS */
906 Geps = vfeps*vftab[vfitab+2];
907 Heps2 = vfeps*vfeps*vftab[vfitab+3];
909 FF = Fp+Geps+2.0*Heps2;
910 felec = -qq00*FF*vftabscale*rinv00;
912 /* BUCKINGHAM DISPERSION/REPULSION */
913 rinvsix = rinvsq00*rinvsq00*rinvsq00;
914 vvdw6 = c6_00*rinvsix;
916 vvdwexp = cexp1_00*exp(-br);
917 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
921 /* Calculate temporary vectorial force */
926 /* Update vectorial force */
930 f[j_coord_offset+DIM*0+XX] -= tx;
931 f[j_coord_offset+DIM*0+YY] -= ty;
932 f[j_coord_offset+DIM*0+ZZ] -= tz;
934 /**************************
935 * CALCULATE INTERACTIONS *
936 **************************/
940 /* Calculate table index by multiplying r with table scale and truncate to integer */
946 /* CUBIC SPLINE TABLE ELECTROSTATICS */
948 Geps = vfeps*vftab[vfitab+2];
949 Heps2 = vfeps*vfeps*vftab[vfitab+3];
951 FF = Fp+Geps+2.0*Heps2;
952 felec = -qq01*FF*vftabscale*rinv01;
956 /* Calculate temporary vectorial force */
961 /* Update vectorial force */
965 f[j_coord_offset+DIM*1+XX] -= tx;
966 f[j_coord_offset+DIM*1+YY] -= ty;
967 f[j_coord_offset+DIM*1+ZZ] -= tz;
969 /**************************
970 * CALCULATE INTERACTIONS *
971 **************************/
975 /* Calculate table index by multiplying r with table scale and truncate to integer */
981 /* CUBIC SPLINE TABLE ELECTROSTATICS */
983 Geps = vfeps*vftab[vfitab+2];
984 Heps2 = vfeps*vfeps*vftab[vfitab+3];
986 FF = Fp+Geps+2.0*Heps2;
987 felec = -qq02*FF*vftabscale*rinv02;
991 /* Calculate temporary vectorial force */
996 /* Update vectorial force */
1000 f[j_coord_offset+DIM*2+XX] -= tx;
1001 f[j_coord_offset+DIM*2+YY] -= ty;
1002 f[j_coord_offset+DIM*2+ZZ] -= tz;
1004 /**************************
1005 * CALCULATE INTERACTIONS *
1006 **************************/
1010 /* Calculate table index by multiplying r with table scale and truncate to integer */
1011 rt = r10*vftabscale;
1014 vfitab = 1*4*vfitab;
1016 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1017 F = vftab[vfitab+1];
1018 Geps = vfeps*vftab[vfitab+2];
1019 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1021 FF = Fp+Geps+2.0*Heps2;
1022 felec = -qq10*FF*vftabscale*rinv10;
1026 /* Calculate temporary vectorial force */
1031 /* Update vectorial force */
1035 f[j_coord_offset+DIM*0+XX] -= tx;
1036 f[j_coord_offset+DIM*0+YY] -= ty;
1037 f[j_coord_offset+DIM*0+ZZ] -= tz;
1039 /**************************
1040 * CALCULATE INTERACTIONS *
1041 **************************/
1045 /* Calculate table index by multiplying r with table scale and truncate to integer */
1046 rt = r11*vftabscale;
1049 vfitab = 1*4*vfitab;
1051 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1052 F = vftab[vfitab+1];
1053 Geps = vfeps*vftab[vfitab+2];
1054 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1056 FF = Fp+Geps+2.0*Heps2;
1057 felec = -qq11*FF*vftabscale*rinv11;
1061 /* Calculate temporary vectorial force */
1066 /* Update vectorial force */
1070 f[j_coord_offset+DIM*1+XX] -= tx;
1071 f[j_coord_offset+DIM*1+YY] -= ty;
1072 f[j_coord_offset+DIM*1+ZZ] -= tz;
1074 /**************************
1075 * CALCULATE INTERACTIONS *
1076 **************************/
1080 /* Calculate table index by multiplying r with table scale and truncate to integer */
1081 rt = r12*vftabscale;
1084 vfitab = 1*4*vfitab;
1086 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1087 F = vftab[vfitab+1];
1088 Geps = vfeps*vftab[vfitab+2];
1089 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1091 FF = Fp+Geps+2.0*Heps2;
1092 felec = -qq12*FF*vftabscale*rinv12;
1096 /* Calculate temporary vectorial force */
1101 /* Update vectorial force */
1105 f[j_coord_offset+DIM*2+XX] -= tx;
1106 f[j_coord_offset+DIM*2+YY] -= ty;
1107 f[j_coord_offset+DIM*2+ZZ] -= tz;
1109 /**************************
1110 * CALCULATE INTERACTIONS *
1111 **************************/
1115 /* Calculate table index by multiplying r with table scale and truncate to integer */
1116 rt = r20*vftabscale;
1119 vfitab = 1*4*vfitab;
1121 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1122 F = vftab[vfitab+1];
1123 Geps = vfeps*vftab[vfitab+2];
1124 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1126 FF = Fp+Geps+2.0*Heps2;
1127 felec = -qq20*FF*vftabscale*rinv20;
1131 /* Calculate temporary vectorial force */
1136 /* Update vectorial force */
1140 f[j_coord_offset+DIM*0+XX] -= tx;
1141 f[j_coord_offset+DIM*0+YY] -= ty;
1142 f[j_coord_offset+DIM*0+ZZ] -= tz;
1144 /**************************
1145 * CALCULATE INTERACTIONS *
1146 **************************/
1150 /* Calculate table index by multiplying r with table scale and truncate to integer */
1151 rt = r21*vftabscale;
1154 vfitab = 1*4*vfitab;
1156 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1157 F = vftab[vfitab+1];
1158 Geps = vfeps*vftab[vfitab+2];
1159 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1161 FF = Fp+Geps+2.0*Heps2;
1162 felec = -qq21*FF*vftabscale*rinv21;
1166 /* Calculate temporary vectorial force */
1171 /* Update vectorial force */
1175 f[j_coord_offset+DIM*1+XX] -= tx;
1176 f[j_coord_offset+DIM*1+YY] -= ty;
1177 f[j_coord_offset+DIM*1+ZZ] -= tz;
1179 /**************************
1180 * CALCULATE INTERACTIONS *
1181 **************************/
1185 /* Calculate table index by multiplying r with table scale and truncate to integer */
1186 rt = r22*vftabscale;
1189 vfitab = 1*4*vfitab;
1191 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1192 F = vftab[vfitab+1];
1193 Geps = vfeps*vftab[vfitab+2];
1194 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1196 FF = Fp+Geps+2.0*Heps2;
1197 felec = -qq22*FF*vftabscale*rinv22;
1201 /* Calculate temporary vectorial force */
1206 /* Update vectorial force */
1210 f[j_coord_offset+DIM*2+XX] -= tx;
1211 f[j_coord_offset+DIM*2+YY] -= ty;
1212 f[j_coord_offset+DIM*2+ZZ] -= tz;
1214 /* Inner loop uses 369 flops */
1216 /* End of innermost loop */
1219 f[i_coord_offset+DIM*0+XX] += fix0;
1220 f[i_coord_offset+DIM*0+YY] += fiy0;
1221 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1225 f[i_coord_offset+DIM*1+XX] += fix1;
1226 f[i_coord_offset+DIM*1+YY] += fiy1;
1227 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1231 f[i_coord_offset+DIM*2+XX] += fix2;
1232 f[i_coord_offset+DIM*2+YY] += fiy2;
1233 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1237 fshift[i_shift_offset+XX] += tx;
1238 fshift[i_shift_offset+YY] += ty;
1239 fshift[i_shift_offset+ZZ] += tz;
1241 /* Increment number of inner iterations */
1242 inneriter += j_index_end - j_index_start;
1244 /* Outer loop uses 30 flops */
1247 /* Increment number of outer iterations */
1250 /* Update outer/inner flops */
1252 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*369);