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_ElecCoul_VdwCSTab_GeomW4W4_VF_c
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
85 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
87 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
88 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
89 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
90 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
91 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
92 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
93 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
94 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
95 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
96 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
97 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
98 real velec,felec,velecsum,facel,crf,krf,krf2;
101 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
105 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
113 jindex = nlist->jindex;
115 shiftidx = nlist->shift;
117 shiftvec = fr->shift_vec[0];
118 fshift = fr->fshift[0];
120 charge = mdatoms->chargeA;
121 nvdwtype = fr->ntype;
123 vdwtype = mdatoms->typeA;
125 vftab = kernel_data->table_vdw->data;
126 vftabscale = kernel_data->table_vdw->scale;
128 /* Setup water-specific parameters */
129 inr = nlist->iinr[0];
130 iq1 = facel*charge[inr+1];
131 iq2 = facel*charge[inr+2];
132 iq3 = facel*charge[inr+3];
133 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
138 vdwjidx0 = 2*vdwtype[inr+0];
139 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
140 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
154 /* Start outer loop over neighborlists */
155 for(iidx=0; iidx<nri; iidx++)
157 /* Load shift vector for this list */
158 i_shift_offset = DIM*shiftidx[iidx];
159 shX = shiftvec[i_shift_offset+XX];
160 shY = shiftvec[i_shift_offset+YY];
161 shZ = shiftvec[i_shift_offset+ZZ];
163 /* Load limits for loop over neighbors */
164 j_index_start = jindex[iidx];
165 j_index_end = jindex[iidx+1];
167 /* Get outer coordinate index */
169 i_coord_offset = DIM*inr;
171 /* Load i particle coords and add shift vector */
172 ix0 = shX + x[i_coord_offset+DIM*0+XX];
173 iy0 = shY + x[i_coord_offset+DIM*0+YY];
174 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
175 ix1 = shX + x[i_coord_offset+DIM*1+XX];
176 iy1 = shY + x[i_coord_offset+DIM*1+YY];
177 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
178 ix2 = shX + x[i_coord_offset+DIM*2+XX];
179 iy2 = shY + x[i_coord_offset+DIM*2+YY];
180 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
181 ix3 = shX + x[i_coord_offset+DIM*3+XX];
182 iy3 = shY + x[i_coord_offset+DIM*3+YY];
183 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
198 /* Reset potential sums */
202 /* Start inner kernel loop */
203 for(jidx=j_index_start; jidx<j_index_end; jidx++)
205 /* Get j neighbor index, and coordinate index */
207 j_coord_offset = DIM*jnr;
209 /* load j atom coordinates */
210 jx0 = x[j_coord_offset+DIM*0+XX];
211 jy0 = x[j_coord_offset+DIM*0+YY];
212 jz0 = x[j_coord_offset+DIM*0+ZZ];
213 jx1 = x[j_coord_offset+DIM*1+XX];
214 jy1 = x[j_coord_offset+DIM*1+YY];
215 jz1 = x[j_coord_offset+DIM*1+ZZ];
216 jx2 = x[j_coord_offset+DIM*2+XX];
217 jy2 = x[j_coord_offset+DIM*2+YY];
218 jz2 = x[j_coord_offset+DIM*2+ZZ];
219 jx3 = x[j_coord_offset+DIM*3+XX];
220 jy3 = x[j_coord_offset+DIM*3+YY];
221 jz3 = x[j_coord_offset+DIM*3+ZZ];
223 /* Calculate displacement vector */
255 /* Calculate squared distance and things based on it */
256 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
257 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
258 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
259 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
260 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
261 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
262 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
263 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
264 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
265 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
267 rinv00 = gmx_invsqrt(rsq00);
268 rinv11 = gmx_invsqrt(rsq11);
269 rinv12 = gmx_invsqrt(rsq12);
270 rinv13 = gmx_invsqrt(rsq13);
271 rinv21 = gmx_invsqrt(rsq21);
272 rinv22 = gmx_invsqrt(rsq22);
273 rinv23 = gmx_invsqrt(rsq23);
274 rinv31 = gmx_invsqrt(rsq31);
275 rinv32 = gmx_invsqrt(rsq32);
276 rinv33 = gmx_invsqrt(rsq33);
278 rinvsq11 = rinv11*rinv11;
279 rinvsq12 = rinv12*rinv12;
280 rinvsq13 = rinv13*rinv13;
281 rinvsq21 = rinv21*rinv21;
282 rinvsq22 = rinv22*rinv22;
283 rinvsq23 = rinv23*rinv23;
284 rinvsq31 = rinv31*rinv31;
285 rinvsq32 = rinv32*rinv32;
286 rinvsq33 = rinv33*rinv33;
288 /**************************
289 * CALCULATE INTERACTIONS *
290 **************************/
294 /* Calculate table index by multiplying r with table scale and truncate to integer */
300 /* CUBIC SPLINE TABLE DISPERSION */
304 Geps = vfeps*vftab[vfitab+2];
305 Heps2 = vfeps*vfeps*vftab[vfitab+3];
309 FF = Fp+Geps+2.0*Heps2;
312 /* CUBIC SPLINE TABLE REPULSION */
315 Geps = vfeps*vftab[vfitab+6];
316 Heps2 = vfeps*vfeps*vftab[vfitab+7];
320 FF = Fp+Geps+2.0*Heps2;
323 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
325 /* Update potential sums from outer loop */
330 /* Calculate temporary vectorial force */
335 /* Update vectorial force */
339 f[j_coord_offset+DIM*0+XX] -= tx;
340 f[j_coord_offset+DIM*0+YY] -= ty;
341 f[j_coord_offset+DIM*0+ZZ] -= tz;
343 /**************************
344 * CALCULATE INTERACTIONS *
345 **************************/
347 /* COULOMB ELECTROSTATICS */
349 felec = velec*rinvsq11;
351 /* Update potential sums from outer loop */
356 /* Calculate temporary vectorial force */
361 /* Update vectorial force */
365 f[j_coord_offset+DIM*1+XX] -= tx;
366 f[j_coord_offset+DIM*1+YY] -= ty;
367 f[j_coord_offset+DIM*1+ZZ] -= tz;
369 /**************************
370 * CALCULATE INTERACTIONS *
371 **************************/
373 /* COULOMB ELECTROSTATICS */
375 felec = velec*rinvsq12;
377 /* Update potential sums from outer loop */
382 /* Calculate temporary vectorial force */
387 /* Update vectorial force */
391 f[j_coord_offset+DIM*2+XX] -= tx;
392 f[j_coord_offset+DIM*2+YY] -= ty;
393 f[j_coord_offset+DIM*2+ZZ] -= tz;
395 /**************************
396 * CALCULATE INTERACTIONS *
397 **************************/
399 /* COULOMB ELECTROSTATICS */
401 felec = velec*rinvsq13;
403 /* Update potential sums from outer loop */
408 /* Calculate temporary vectorial force */
413 /* Update vectorial force */
417 f[j_coord_offset+DIM*3+XX] -= tx;
418 f[j_coord_offset+DIM*3+YY] -= ty;
419 f[j_coord_offset+DIM*3+ZZ] -= tz;
421 /**************************
422 * CALCULATE INTERACTIONS *
423 **************************/
425 /* COULOMB ELECTROSTATICS */
427 felec = velec*rinvsq21;
429 /* Update potential sums from outer loop */
434 /* Calculate temporary vectorial force */
439 /* Update vectorial force */
443 f[j_coord_offset+DIM*1+XX] -= tx;
444 f[j_coord_offset+DIM*1+YY] -= ty;
445 f[j_coord_offset+DIM*1+ZZ] -= tz;
447 /**************************
448 * CALCULATE INTERACTIONS *
449 **************************/
451 /* COULOMB ELECTROSTATICS */
453 felec = velec*rinvsq22;
455 /* Update potential sums from outer loop */
460 /* Calculate temporary vectorial force */
465 /* Update vectorial force */
469 f[j_coord_offset+DIM*2+XX] -= tx;
470 f[j_coord_offset+DIM*2+YY] -= ty;
471 f[j_coord_offset+DIM*2+ZZ] -= tz;
473 /**************************
474 * CALCULATE INTERACTIONS *
475 **************************/
477 /* COULOMB ELECTROSTATICS */
479 felec = velec*rinvsq23;
481 /* Update potential sums from outer loop */
486 /* Calculate temporary vectorial force */
491 /* Update vectorial force */
495 f[j_coord_offset+DIM*3+XX] -= tx;
496 f[j_coord_offset+DIM*3+YY] -= ty;
497 f[j_coord_offset+DIM*3+ZZ] -= tz;
499 /**************************
500 * CALCULATE INTERACTIONS *
501 **************************/
503 /* COULOMB ELECTROSTATICS */
505 felec = velec*rinvsq31;
507 /* Update potential sums from outer loop */
512 /* Calculate temporary vectorial force */
517 /* Update vectorial force */
521 f[j_coord_offset+DIM*1+XX] -= tx;
522 f[j_coord_offset+DIM*1+YY] -= ty;
523 f[j_coord_offset+DIM*1+ZZ] -= tz;
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
529 /* COULOMB ELECTROSTATICS */
531 felec = velec*rinvsq32;
533 /* Update potential sums from outer loop */
538 /* Calculate temporary vectorial force */
543 /* Update vectorial force */
547 f[j_coord_offset+DIM*2+XX] -= tx;
548 f[j_coord_offset+DIM*2+YY] -= ty;
549 f[j_coord_offset+DIM*2+ZZ] -= tz;
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
555 /* COULOMB ELECTROSTATICS */
557 felec = velec*rinvsq33;
559 /* Update potential sums from outer loop */
564 /* Calculate temporary vectorial force */
569 /* Update vectorial force */
573 f[j_coord_offset+DIM*3+XX] -= tx;
574 f[j_coord_offset+DIM*3+YY] -= ty;
575 f[j_coord_offset+DIM*3+ZZ] -= tz;
577 /* Inner loop uses 298 flops */
579 /* End of innermost loop */
582 f[i_coord_offset+DIM*0+XX] += fix0;
583 f[i_coord_offset+DIM*0+YY] += fiy0;
584 f[i_coord_offset+DIM*0+ZZ] += fiz0;
588 f[i_coord_offset+DIM*1+XX] += fix1;
589 f[i_coord_offset+DIM*1+YY] += fiy1;
590 f[i_coord_offset+DIM*1+ZZ] += fiz1;
594 f[i_coord_offset+DIM*2+XX] += fix2;
595 f[i_coord_offset+DIM*2+YY] += fiy2;
596 f[i_coord_offset+DIM*2+ZZ] += fiz2;
600 f[i_coord_offset+DIM*3+XX] += fix3;
601 f[i_coord_offset+DIM*3+YY] += fiy3;
602 f[i_coord_offset+DIM*3+ZZ] += fiz3;
606 fshift[i_shift_offset+XX] += tx;
607 fshift[i_shift_offset+YY] += ty;
608 fshift[i_shift_offset+ZZ] += tz;
611 /* Update potential energies */
612 kernel_data->energygrp_elec[ggid] += velecsum;
613 kernel_data->energygrp_vdw[ggid] += vvdwsum;
615 /* Increment number of inner iterations */
616 inneriter += j_index_end - j_index_start;
618 /* Outer loop uses 41 flops */
621 /* Increment number of outer iterations */
624 /* Update outer/inner flops */
626 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*298);
629 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_F_c
630 * Electrostatics interaction: Coulomb
631 * VdW interaction: CubicSplineTable
632 * Geometry: Water4-Water4
633 * Calculate force/pot: Force
636 nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_F_c
637 (t_nblist * gmx_restrict nlist,
638 rvec * gmx_restrict xx,
639 rvec * gmx_restrict ff,
640 t_forcerec * gmx_restrict fr,
641 t_mdatoms * gmx_restrict mdatoms,
642 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
643 t_nrnb * gmx_restrict nrnb)
645 int i_shift_offset,i_coord_offset,j_coord_offset;
646 int j_index_start,j_index_end;
647 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
648 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
649 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
650 real *shiftvec,*fshift,*x,*f;
652 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
654 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
656 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
658 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
660 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
662 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
664 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
666 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
667 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
668 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
669 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
670 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
671 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
672 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
673 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
674 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
675 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
676 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
677 real velec,felec,velecsum,facel,crf,krf,krf2;
680 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
684 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
692 jindex = nlist->jindex;
694 shiftidx = nlist->shift;
696 shiftvec = fr->shift_vec[0];
697 fshift = fr->fshift[0];
699 charge = mdatoms->chargeA;
700 nvdwtype = fr->ntype;
702 vdwtype = mdatoms->typeA;
704 vftab = kernel_data->table_vdw->data;
705 vftabscale = kernel_data->table_vdw->scale;
707 /* Setup water-specific parameters */
708 inr = nlist->iinr[0];
709 iq1 = facel*charge[inr+1];
710 iq2 = facel*charge[inr+2];
711 iq3 = facel*charge[inr+3];
712 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
717 vdwjidx0 = 2*vdwtype[inr+0];
718 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
719 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
733 /* Start outer loop over neighborlists */
734 for(iidx=0; iidx<nri; iidx++)
736 /* Load shift vector for this list */
737 i_shift_offset = DIM*shiftidx[iidx];
738 shX = shiftvec[i_shift_offset+XX];
739 shY = shiftvec[i_shift_offset+YY];
740 shZ = shiftvec[i_shift_offset+ZZ];
742 /* Load limits for loop over neighbors */
743 j_index_start = jindex[iidx];
744 j_index_end = jindex[iidx+1];
746 /* Get outer coordinate index */
748 i_coord_offset = DIM*inr;
750 /* Load i particle coords and add shift vector */
751 ix0 = shX + x[i_coord_offset+DIM*0+XX];
752 iy0 = shY + x[i_coord_offset+DIM*0+YY];
753 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
754 ix1 = shX + x[i_coord_offset+DIM*1+XX];
755 iy1 = shY + x[i_coord_offset+DIM*1+YY];
756 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
757 ix2 = shX + x[i_coord_offset+DIM*2+XX];
758 iy2 = shY + x[i_coord_offset+DIM*2+YY];
759 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
760 ix3 = shX + x[i_coord_offset+DIM*3+XX];
761 iy3 = shY + x[i_coord_offset+DIM*3+YY];
762 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
777 /* Start inner kernel loop */
778 for(jidx=j_index_start; jidx<j_index_end; jidx++)
780 /* Get j neighbor index, and coordinate index */
782 j_coord_offset = DIM*jnr;
784 /* load j atom coordinates */
785 jx0 = x[j_coord_offset+DIM*0+XX];
786 jy0 = x[j_coord_offset+DIM*0+YY];
787 jz0 = x[j_coord_offset+DIM*0+ZZ];
788 jx1 = x[j_coord_offset+DIM*1+XX];
789 jy1 = x[j_coord_offset+DIM*1+YY];
790 jz1 = x[j_coord_offset+DIM*1+ZZ];
791 jx2 = x[j_coord_offset+DIM*2+XX];
792 jy2 = x[j_coord_offset+DIM*2+YY];
793 jz2 = x[j_coord_offset+DIM*2+ZZ];
794 jx3 = x[j_coord_offset+DIM*3+XX];
795 jy3 = x[j_coord_offset+DIM*3+YY];
796 jz3 = x[j_coord_offset+DIM*3+ZZ];
798 /* Calculate displacement vector */
830 /* Calculate squared distance and things based on it */
831 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
832 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
833 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
834 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
835 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
836 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
837 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
838 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
839 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
840 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
842 rinv00 = gmx_invsqrt(rsq00);
843 rinv11 = gmx_invsqrt(rsq11);
844 rinv12 = gmx_invsqrt(rsq12);
845 rinv13 = gmx_invsqrt(rsq13);
846 rinv21 = gmx_invsqrt(rsq21);
847 rinv22 = gmx_invsqrt(rsq22);
848 rinv23 = gmx_invsqrt(rsq23);
849 rinv31 = gmx_invsqrt(rsq31);
850 rinv32 = gmx_invsqrt(rsq32);
851 rinv33 = gmx_invsqrt(rsq33);
853 rinvsq11 = rinv11*rinv11;
854 rinvsq12 = rinv12*rinv12;
855 rinvsq13 = rinv13*rinv13;
856 rinvsq21 = rinv21*rinv21;
857 rinvsq22 = rinv22*rinv22;
858 rinvsq23 = rinv23*rinv23;
859 rinvsq31 = rinv31*rinv31;
860 rinvsq32 = rinv32*rinv32;
861 rinvsq33 = rinv33*rinv33;
863 /**************************
864 * CALCULATE INTERACTIONS *
865 **************************/
869 /* Calculate table index by multiplying r with table scale and truncate to integer */
875 /* CUBIC SPLINE TABLE DISPERSION */
878 Geps = vfeps*vftab[vfitab+2];
879 Heps2 = vfeps*vfeps*vftab[vfitab+3];
881 FF = Fp+Geps+2.0*Heps2;
884 /* CUBIC SPLINE TABLE REPULSION */
886 Geps = vfeps*vftab[vfitab+6];
887 Heps2 = vfeps*vfeps*vftab[vfitab+7];
889 FF = Fp+Geps+2.0*Heps2;
891 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
895 /* Calculate temporary vectorial force */
900 /* Update vectorial force */
904 f[j_coord_offset+DIM*0+XX] -= tx;
905 f[j_coord_offset+DIM*0+YY] -= ty;
906 f[j_coord_offset+DIM*0+ZZ] -= tz;
908 /**************************
909 * CALCULATE INTERACTIONS *
910 **************************/
912 /* COULOMB ELECTROSTATICS */
914 felec = velec*rinvsq11;
918 /* Calculate temporary vectorial force */
923 /* Update vectorial force */
927 f[j_coord_offset+DIM*1+XX] -= tx;
928 f[j_coord_offset+DIM*1+YY] -= ty;
929 f[j_coord_offset+DIM*1+ZZ] -= tz;
931 /**************************
932 * CALCULATE INTERACTIONS *
933 **************************/
935 /* COULOMB ELECTROSTATICS */
937 felec = velec*rinvsq12;
941 /* Calculate temporary vectorial force */
946 /* Update vectorial force */
950 f[j_coord_offset+DIM*2+XX] -= tx;
951 f[j_coord_offset+DIM*2+YY] -= ty;
952 f[j_coord_offset+DIM*2+ZZ] -= tz;
954 /**************************
955 * CALCULATE INTERACTIONS *
956 **************************/
958 /* COULOMB ELECTROSTATICS */
960 felec = velec*rinvsq13;
964 /* Calculate temporary vectorial force */
969 /* Update vectorial force */
973 f[j_coord_offset+DIM*3+XX] -= tx;
974 f[j_coord_offset+DIM*3+YY] -= ty;
975 f[j_coord_offset+DIM*3+ZZ] -= tz;
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
981 /* COULOMB ELECTROSTATICS */
983 felec = velec*rinvsq21;
987 /* Calculate temporary vectorial force */
992 /* Update vectorial force */
996 f[j_coord_offset+DIM*1+XX] -= tx;
997 f[j_coord_offset+DIM*1+YY] -= ty;
998 f[j_coord_offset+DIM*1+ZZ] -= tz;
1000 /**************************
1001 * CALCULATE INTERACTIONS *
1002 **************************/
1004 /* COULOMB ELECTROSTATICS */
1005 velec = qq22*rinv22;
1006 felec = velec*rinvsq22;
1010 /* Calculate temporary vectorial force */
1015 /* Update vectorial force */
1019 f[j_coord_offset+DIM*2+XX] -= tx;
1020 f[j_coord_offset+DIM*2+YY] -= ty;
1021 f[j_coord_offset+DIM*2+ZZ] -= tz;
1023 /**************************
1024 * CALCULATE INTERACTIONS *
1025 **************************/
1027 /* COULOMB ELECTROSTATICS */
1028 velec = qq23*rinv23;
1029 felec = velec*rinvsq23;
1033 /* Calculate temporary vectorial force */
1038 /* Update vectorial force */
1042 f[j_coord_offset+DIM*3+XX] -= tx;
1043 f[j_coord_offset+DIM*3+YY] -= ty;
1044 f[j_coord_offset+DIM*3+ZZ] -= tz;
1046 /**************************
1047 * CALCULATE INTERACTIONS *
1048 **************************/
1050 /* COULOMB ELECTROSTATICS */
1051 velec = qq31*rinv31;
1052 felec = velec*rinvsq31;
1056 /* Calculate temporary vectorial force */
1061 /* Update vectorial force */
1065 f[j_coord_offset+DIM*1+XX] -= tx;
1066 f[j_coord_offset+DIM*1+YY] -= ty;
1067 f[j_coord_offset+DIM*1+ZZ] -= tz;
1069 /**************************
1070 * CALCULATE INTERACTIONS *
1071 **************************/
1073 /* COULOMB ELECTROSTATICS */
1074 velec = qq32*rinv32;
1075 felec = velec*rinvsq32;
1079 /* Calculate temporary vectorial force */
1084 /* Update vectorial force */
1088 f[j_coord_offset+DIM*2+XX] -= tx;
1089 f[j_coord_offset+DIM*2+YY] -= ty;
1090 f[j_coord_offset+DIM*2+ZZ] -= tz;
1092 /**************************
1093 * CALCULATE INTERACTIONS *
1094 **************************/
1096 /* COULOMB ELECTROSTATICS */
1097 velec = qq33*rinv33;
1098 felec = velec*rinvsq33;
1102 /* Calculate temporary vectorial force */
1107 /* Update vectorial force */
1111 f[j_coord_offset+DIM*3+XX] -= tx;
1112 f[j_coord_offset+DIM*3+YY] -= ty;
1113 f[j_coord_offset+DIM*3+ZZ] -= tz;
1115 /* Inner loop uses 281 flops */
1117 /* End of innermost loop */
1120 f[i_coord_offset+DIM*0+XX] += fix0;
1121 f[i_coord_offset+DIM*0+YY] += fiy0;
1122 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1126 f[i_coord_offset+DIM*1+XX] += fix1;
1127 f[i_coord_offset+DIM*1+YY] += fiy1;
1128 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1132 f[i_coord_offset+DIM*2+XX] += fix2;
1133 f[i_coord_offset+DIM*2+YY] += fiy2;
1134 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1138 f[i_coord_offset+DIM*3+XX] += fix3;
1139 f[i_coord_offset+DIM*3+YY] += fiy3;
1140 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1144 fshift[i_shift_offset+XX] += tx;
1145 fshift[i_shift_offset+YY] += ty;
1146 fshift[i_shift_offset+ZZ] += tz;
1148 /* Increment number of inner iterations */
1149 inneriter += j_index_end - j_index_start;
1151 /* Outer loop uses 39 flops */
1154 /* Increment number of outer iterations */
1157 /* Update outer/inner flops */
1159 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*281);