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 "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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;
85 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
86 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
87 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
88 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
89 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
90 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
91 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
92 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
93 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
94 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
95 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
96 real velec,felec,velecsum,facel,crf,krf,krf2;
99 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
103 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
118 charge = mdatoms->chargeA;
119 nvdwtype = fr->ntype;
121 vdwtype = mdatoms->typeA;
123 vftab = kernel_data->table_vdw->data;
124 vftabscale = kernel_data->table_vdw->scale;
126 /* Setup water-specific parameters */
127 inr = nlist->iinr[0];
128 iq1 = facel*charge[inr+1];
129 iq2 = facel*charge[inr+2];
130 iq3 = facel*charge[inr+3];
131 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
136 vdwjidx0 = 2*vdwtype[inr+0];
137 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
138 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
152 /* Start outer loop over neighborlists */
153 for(iidx=0; iidx<nri; iidx++)
155 /* Load shift vector for this list */
156 i_shift_offset = DIM*shiftidx[iidx];
157 shX = shiftvec[i_shift_offset+XX];
158 shY = shiftvec[i_shift_offset+YY];
159 shZ = shiftvec[i_shift_offset+ZZ];
161 /* Load limits for loop over neighbors */
162 j_index_start = jindex[iidx];
163 j_index_end = jindex[iidx+1];
165 /* Get outer coordinate index */
167 i_coord_offset = DIM*inr;
169 /* Load i particle coords and add shift vector */
170 ix0 = shX + x[i_coord_offset+DIM*0+XX];
171 iy0 = shY + x[i_coord_offset+DIM*0+YY];
172 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
173 ix1 = shX + x[i_coord_offset+DIM*1+XX];
174 iy1 = shY + x[i_coord_offset+DIM*1+YY];
175 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
176 ix2 = shX + x[i_coord_offset+DIM*2+XX];
177 iy2 = shY + x[i_coord_offset+DIM*2+YY];
178 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
179 ix3 = shX + x[i_coord_offset+DIM*3+XX];
180 iy3 = shY + x[i_coord_offset+DIM*3+YY];
181 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
196 /* Reset potential sums */
200 /* Start inner kernel loop */
201 for(jidx=j_index_start; jidx<j_index_end; jidx++)
203 /* Get j neighbor index, and coordinate index */
205 j_coord_offset = DIM*jnr;
207 /* load j atom coordinates */
208 jx0 = x[j_coord_offset+DIM*0+XX];
209 jy0 = x[j_coord_offset+DIM*0+YY];
210 jz0 = x[j_coord_offset+DIM*0+ZZ];
211 jx1 = x[j_coord_offset+DIM*1+XX];
212 jy1 = x[j_coord_offset+DIM*1+YY];
213 jz1 = x[j_coord_offset+DIM*1+ZZ];
214 jx2 = x[j_coord_offset+DIM*2+XX];
215 jy2 = x[j_coord_offset+DIM*2+YY];
216 jz2 = x[j_coord_offset+DIM*2+ZZ];
217 jx3 = x[j_coord_offset+DIM*3+XX];
218 jy3 = x[j_coord_offset+DIM*3+YY];
219 jz3 = x[j_coord_offset+DIM*3+ZZ];
221 /* Calculate displacement vector */
253 /* Calculate squared distance and things based on it */
254 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
255 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
256 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
257 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
258 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
259 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
260 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
261 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
262 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
263 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
265 rinv00 = gmx_invsqrt(rsq00);
266 rinv11 = gmx_invsqrt(rsq11);
267 rinv12 = gmx_invsqrt(rsq12);
268 rinv13 = gmx_invsqrt(rsq13);
269 rinv21 = gmx_invsqrt(rsq21);
270 rinv22 = gmx_invsqrt(rsq22);
271 rinv23 = gmx_invsqrt(rsq23);
272 rinv31 = gmx_invsqrt(rsq31);
273 rinv32 = gmx_invsqrt(rsq32);
274 rinv33 = gmx_invsqrt(rsq33);
276 rinvsq11 = rinv11*rinv11;
277 rinvsq12 = rinv12*rinv12;
278 rinvsq13 = rinv13*rinv13;
279 rinvsq21 = rinv21*rinv21;
280 rinvsq22 = rinv22*rinv22;
281 rinvsq23 = rinv23*rinv23;
282 rinvsq31 = rinv31*rinv31;
283 rinvsq32 = rinv32*rinv32;
284 rinvsq33 = rinv33*rinv33;
286 /**************************
287 * CALCULATE INTERACTIONS *
288 **************************/
292 /* Calculate table index by multiplying r with table scale and truncate to integer */
298 /* CUBIC SPLINE TABLE DISPERSION */
302 Geps = vfeps*vftab[vfitab+2];
303 Heps2 = vfeps*vfeps*vftab[vfitab+3];
307 FF = Fp+Geps+2.0*Heps2;
310 /* CUBIC SPLINE TABLE REPULSION */
313 Geps = vfeps*vftab[vfitab+6];
314 Heps2 = vfeps*vfeps*vftab[vfitab+7];
318 FF = Fp+Geps+2.0*Heps2;
321 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
323 /* Update potential sums from outer loop */
328 /* Calculate temporary vectorial force */
333 /* Update vectorial force */
337 f[j_coord_offset+DIM*0+XX] -= tx;
338 f[j_coord_offset+DIM*0+YY] -= ty;
339 f[j_coord_offset+DIM*0+ZZ] -= tz;
341 /**************************
342 * CALCULATE INTERACTIONS *
343 **************************/
345 /* COULOMB ELECTROSTATICS */
347 felec = velec*rinvsq11;
349 /* Update potential sums from outer loop */
354 /* Calculate temporary vectorial force */
359 /* Update vectorial force */
363 f[j_coord_offset+DIM*1+XX] -= tx;
364 f[j_coord_offset+DIM*1+YY] -= ty;
365 f[j_coord_offset+DIM*1+ZZ] -= tz;
367 /**************************
368 * CALCULATE INTERACTIONS *
369 **************************/
371 /* COULOMB ELECTROSTATICS */
373 felec = velec*rinvsq12;
375 /* Update potential sums from outer loop */
380 /* Calculate temporary vectorial force */
385 /* Update vectorial force */
389 f[j_coord_offset+DIM*2+XX] -= tx;
390 f[j_coord_offset+DIM*2+YY] -= ty;
391 f[j_coord_offset+DIM*2+ZZ] -= tz;
393 /**************************
394 * CALCULATE INTERACTIONS *
395 **************************/
397 /* COULOMB ELECTROSTATICS */
399 felec = velec*rinvsq13;
401 /* Update potential sums from outer loop */
406 /* Calculate temporary vectorial force */
411 /* Update vectorial force */
415 f[j_coord_offset+DIM*3+XX] -= tx;
416 f[j_coord_offset+DIM*3+YY] -= ty;
417 f[j_coord_offset+DIM*3+ZZ] -= tz;
419 /**************************
420 * CALCULATE INTERACTIONS *
421 **************************/
423 /* COULOMB ELECTROSTATICS */
425 felec = velec*rinvsq21;
427 /* Update potential sums from outer loop */
432 /* Calculate temporary vectorial force */
437 /* Update vectorial force */
441 f[j_coord_offset+DIM*1+XX] -= tx;
442 f[j_coord_offset+DIM*1+YY] -= ty;
443 f[j_coord_offset+DIM*1+ZZ] -= tz;
445 /**************************
446 * CALCULATE INTERACTIONS *
447 **************************/
449 /* COULOMB ELECTROSTATICS */
451 felec = velec*rinvsq22;
453 /* Update potential sums from outer loop */
458 /* Calculate temporary vectorial force */
463 /* Update vectorial force */
467 f[j_coord_offset+DIM*2+XX] -= tx;
468 f[j_coord_offset+DIM*2+YY] -= ty;
469 f[j_coord_offset+DIM*2+ZZ] -= tz;
471 /**************************
472 * CALCULATE INTERACTIONS *
473 **************************/
475 /* COULOMB ELECTROSTATICS */
477 felec = velec*rinvsq23;
479 /* Update potential sums from outer loop */
484 /* Calculate temporary vectorial force */
489 /* Update vectorial force */
493 f[j_coord_offset+DIM*3+XX] -= tx;
494 f[j_coord_offset+DIM*3+YY] -= ty;
495 f[j_coord_offset+DIM*3+ZZ] -= tz;
497 /**************************
498 * CALCULATE INTERACTIONS *
499 **************************/
501 /* COULOMB ELECTROSTATICS */
503 felec = velec*rinvsq31;
505 /* Update potential sums from outer loop */
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*1+XX] -= tx;
520 f[j_coord_offset+DIM*1+YY] -= ty;
521 f[j_coord_offset+DIM*1+ZZ] -= tz;
523 /**************************
524 * CALCULATE INTERACTIONS *
525 **************************/
527 /* COULOMB ELECTROSTATICS */
529 felec = velec*rinvsq32;
531 /* Update potential sums from outer loop */
536 /* Calculate temporary vectorial force */
541 /* Update vectorial force */
545 f[j_coord_offset+DIM*2+XX] -= tx;
546 f[j_coord_offset+DIM*2+YY] -= ty;
547 f[j_coord_offset+DIM*2+ZZ] -= tz;
549 /**************************
550 * CALCULATE INTERACTIONS *
551 **************************/
553 /* COULOMB ELECTROSTATICS */
555 felec = velec*rinvsq33;
557 /* Update potential sums from outer loop */
562 /* Calculate temporary vectorial force */
567 /* Update vectorial force */
571 f[j_coord_offset+DIM*3+XX] -= tx;
572 f[j_coord_offset+DIM*3+YY] -= ty;
573 f[j_coord_offset+DIM*3+ZZ] -= tz;
575 /* Inner loop uses 298 flops */
577 /* End of innermost loop */
580 f[i_coord_offset+DIM*0+XX] += fix0;
581 f[i_coord_offset+DIM*0+YY] += fiy0;
582 f[i_coord_offset+DIM*0+ZZ] += fiz0;
586 f[i_coord_offset+DIM*1+XX] += fix1;
587 f[i_coord_offset+DIM*1+YY] += fiy1;
588 f[i_coord_offset+DIM*1+ZZ] += fiz1;
592 f[i_coord_offset+DIM*2+XX] += fix2;
593 f[i_coord_offset+DIM*2+YY] += fiy2;
594 f[i_coord_offset+DIM*2+ZZ] += fiz2;
598 f[i_coord_offset+DIM*3+XX] += fix3;
599 f[i_coord_offset+DIM*3+YY] += fiy3;
600 f[i_coord_offset+DIM*3+ZZ] += fiz3;
604 fshift[i_shift_offset+XX] += tx;
605 fshift[i_shift_offset+YY] += ty;
606 fshift[i_shift_offset+ZZ] += tz;
609 /* Update potential energies */
610 kernel_data->energygrp_elec[ggid] += velecsum;
611 kernel_data->energygrp_vdw[ggid] += vvdwsum;
613 /* Increment number of inner iterations */
614 inneriter += j_index_end - j_index_start;
616 /* Outer loop uses 41 flops */
619 /* Increment number of outer iterations */
622 /* Update outer/inner flops */
624 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*298);
627 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_F_c
628 * Electrostatics interaction: Coulomb
629 * VdW interaction: CubicSplineTable
630 * Geometry: Water4-Water4
631 * Calculate force/pot: Force
634 nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_F_c
635 (t_nblist * gmx_restrict nlist,
636 rvec * gmx_restrict xx,
637 rvec * gmx_restrict ff,
638 t_forcerec * gmx_restrict fr,
639 t_mdatoms * gmx_restrict mdatoms,
640 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
641 t_nrnb * gmx_restrict nrnb)
643 int i_shift_offset,i_coord_offset,j_coord_offset;
644 int j_index_start,j_index_end;
645 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
646 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
647 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
648 real *shiftvec,*fshift,*x,*f;
650 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
652 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
654 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
656 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
658 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
660 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
662 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
664 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
665 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
666 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
667 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
668 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
669 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
670 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
671 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
672 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
673 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
674 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
675 real velec,felec,velecsum,facel,crf,krf,krf2;
678 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
682 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
690 jindex = nlist->jindex;
692 shiftidx = nlist->shift;
694 shiftvec = fr->shift_vec[0];
695 fshift = fr->fshift[0];
697 charge = mdatoms->chargeA;
698 nvdwtype = fr->ntype;
700 vdwtype = mdatoms->typeA;
702 vftab = kernel_data->table_vdw->data;
703 vftabscale = kernel_data->table_vdw->scale;
705 /* Setup water-specific parameters */
706 inr = nlist->iinr[0];
707 iq1 = facel*charge[inr+1];
708 iq2 = facel*charge[inr+2];
709 iq3 = facel*charge[inr+3];
710 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
715 vdwjidx0 = 2*vdwtype[inr+0];
716 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
717 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
731 /* Start outer loop over neighborlists */
732 for(iidx=0; iidx<nri; iidx++)
734 /* Load shift vector for this list */
735 i_shift_offset = DIM*shiftidx[iidx];
736 shX = shiftvec[i_shift_offset+XX];
737 shY = shiftvec[i_shift_offset+YY];
738 shZ = shiftvec[i_shift_offset+ZZ];
740 /* Load limits for loop over neighbors */
741 j_index_start = jindex[iidx];
742 j_index_end = jindex[iidx+1];
744 /* Get outer coordinate index */
746 i_coord_offset = DIM*inr;
748 /* Load i particle coords and add shift vector */
749 ix0 = shX + x[i_coord_offset+DIM*0+XX];
750 iy0 = shY + x[i_coord_offset+DIM*0+YY];
751 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
752 ix1 = shX + x[i_coord_offset+DIM*1+XX];
753 iy1 = shY + x[i_coord_offset+DIM*1+YY];
754 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
755 ix2 = shX + x[i_coord_offset+DIM*2+XX];
756 iy2 = shY + x[i_coord_offset+DIM*2+YY];
757 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
758 ix3 = shX + x[i_coord_offset+DIM*3+XX];
759 iy3 = shY + x[i_coord_offset+DIM*3+YY];
760 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
775 /* Start inner kernel loop */
776 for(jidx=j_index_start; jidx<j_index_end; jidx++)
778 /* Get j neighbor index, and coordinate index */
780 j_coord_offset = DIM*jnr;
782 /* load j atom coordinates */
783 jx0 = x[j_coord_offset+DIM*0+XX];
784 jy0 = x[j_coord_offset+DIM*0+YY];
785 jz0 = x[j_coord_offset+DIM*0+ZZ];
786 jx1 = x[j_coord_offset+DIM*1+XX];
787 jy1 = x[j_coord_offset+DIM*1+YY];
788 jz1 = x[j_coord_offset+DIM*1+ZZ];
789 jx2 = x[j_coord_offset+DIM*2+XX];
790 jy2 = x[j_coord_offset+DIM*2+YY];
791 jz2 = x[j_coord_offset+DIM*2+ZZ];
792 jx3 = x[j_coord_offset+DIM*3+XX];
793 jy3 = x[j_coord_offset+DIM*3+YY];
794 jz3 = x[j_coord_offset+DIM*3+ZZ];
796 /* Calculate displacement vector */
828 /* Calculate squared distance and things based on it */
829 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
830 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
831 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
832 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
833 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
834 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
835 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
836 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
837 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
838 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
840 rinv00 = gmx_invsqrt(rsq00);
841 rinv11 = gmx_invsqrt(rsq11);
842 rinv12 = gmx_invsqrt(rsq12);
843 rinv13 = gmx_invsqrt(rsq13);
844 rinv21 = gmx_invsqrt(rsq21);
845 rinv22 = gmx_invsqrt(rsq22);
846 rinv23 = gmx_invsqrt(rsq23);
847 rinv31 = gmx_invsqrt(rsq31);
848 rinv32 = gmx_invsqrt(rsq32);
849 rinv33 = gmx_invsqrt(rsq33);
851 rinvsq11 = rinv11*rinv11;
852 rinvsq12 = rinv12*rinv12;
853 rinvsq13 = rinv13*rinv13;
854 rinvsq21 = rinv21*rinv21;
855 rinvsq22 = rinv22*rinv22;
856 rinvsq23 = rinv23*rinv23;
857 rinvsq31 = rinv31*rinv31;
858 rinvsq32 = rinv32*rinv32;
859 rinvsq33 = rinv33*rinv33;
861 /**************************
862 * CALCULATE INTERACTIONS *
863 **************************/
867 /* Calculate table index by multiplying r with table scale and truncate to integer */
873 /* CUBIC SPLINE TABLE DISPERSION */
876 Geps = vfeps*vftab[vfitab+2];
877 Heps2 = vfeps*vfeps*vftab[vfitab+3];
879 FF = Fp+Geps+2.0*Heps2;
882 /* CUBIC SPLINE TABLE REPULSION */
884 Geps = vfeps*vftab[vfitab+6];
885 Heps2 = vfeps*vfeps*vftab[vfitab+7];
887 FF = Fp+Geps+2.0*Heps2;
889 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
893 /* Calculate temporary vectorial force */
898 /* Update vectorial force */
902 f[j_coord_offset+DIM*0+XX] -= tx;
903 f[j_coord_offset+DIM*0+YY] -= ty;
904 f[j_coord_offset+DIM*0+ZZ] -= tz;
906 /**************************
907 * CALCULATE INTERACTIONS *
908 **************************/
910 /* COULOMB ELECTROSTATICS */
912 felec = velec*rinvsq11;
916 /* Calculate temporary vectorial force */
921 /* Update vectorial force */
925 f[j_coord_offset+DIM*1+XX] -= tx;
926 f[j_coord_offset+DIM*1+YY] -= ty;
927 f[j_coord_offset+DIM*1+ZZ] -= tz;
929 /**************************
930 * CALCULATE INTERACTIONS *
931 **************************/
933 /* COULOMB ELECTROSTATICS */
935 felec = velec*rinvsq12;
939 /* Calculate temporary vectorial force */
944 /* Update vectorial force */
948 f[j_coord_offset+DIM*2+XX] -= tx;
949 f[j_coord_offset+DIM*2+YY] -= ty;
950 f[j_coord_offset+DIM*2+ZZ] -= tz;
952 /**************************
953 * CALCULATE INTERACTIONS *
954 **************************/
956 /* COULOMB ELECTROSTATICS */
958 felec = velec*rinvsq13;
962 /* Calculate temporary vectorial force */
967 /* Update vectorial force */
971 f[j_coord_offset+DIM*3+XX] -= tx;
972 f[j_coord_offset+DIM*3+YY] -= ty;
973 f[j_coord_offset+DIM*3+ZZ] -= tz;
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
979 /* COULOMB ELECTROSTATICS */
981 felec = velec*rinvsq21;
985 /* Calculate temporary vectorial force */
990 /* Update vectorial force */
994 f[j_coord_offset+DIM*1+XX] -= tx;
995 f[j_coord_offset+DIM*1+YY] -= ty;
996 f[j_coord_offset+DIM*1+ZZ] -= tz;
998 /**************************
999 * CALCULATE INTERACTIONS *
1000 **************************/
1002 /* COULOMB ELECTROSTATICS */
1003 velec = qq22*rinv22;
1004 felec = velec*rinvsq22;
1008 /* Calculate temporary vectorial force */
1013 /* Update vectorial force */
1017 f[j_coord_offset+DIM*2+XX] -= tx;
1018 f[j_coord_offset+DIM*2+YY] -= ty;
1019 f[j_coord_offset+DIM*2+ZZ] -= tz;
1021 /**************************
1022 * CALCULATE INTERACTIONS *
1023 **************************/
1025 /* COULOMB ELECTROSTATICS */
1026 velec = qq23*rinv23;
1027 felec = velec*rinvsq23;
1031 /* Calculate temporary vectorial force */
1036 /* Update vectorial force */
1040 f[j_coord_offset+DIM*3+XX] -= tx;
1041 f[j_coord_offset+DIM*3+YY] -= ty;
1042 f[j_coord_offset+DIM*3+ZZ] -= tz;
1044 /**************************
1045 * CALCULATE INTERACTIONS *
1046 **************************/
1048 /* COULOMB ELECTROSTATICS */
1049 velec = qq31*rinv31;
1050 felec = velec*rinvsq31;
1054 /* Calculate temporary vectorial force */
1059 /* Update vectorial force */
1063 f[j_coord_offset+DIM*1+XX] -= tx;
1064 f[j_coord_offset+DIM*1+YY] -= ty;
1065 f[j_coord_offset+DIM*1+ZZ] -= tz;
1067 /**************************
1068 * CALCULATE INTERACTIONS *
1069 **************************/
1071 /* COULOMB ELECTROSTATICS */
1072 velec = qq32*rinv32;
1073 felec = velec*rinvsq32;
1077 /* Calculate temporary vectorial force */
1082 /* Update vectorial force */
1086 f[j_coord_offset+DIM*2+XX] -= tx;
1087 f[j_coord_offset+DIM*2+YY] -= ty;
1088 f[j_coord_offset+DIM*2+ZZ] -= tz;
1090 /**************************
1091 * CALCULATE INTERACTIONS *
1092 **************************/
1094 /* COULOMB ELECTROSTATICS */
1095 velec = qq33*rinv33;
1096 felec = velec*rinvsq33;
1100 /* Calculate temporary vectorial force */
1105 /* Update vectorial force */
1109 f[j_coord_offset+DIM*3+XX] -= tx;
1110 f[j_coord_offset+DIM*3+YY] -= ty;
1111 f[j_coord_offset+DIM*3+ZZ] -= tz;
1113 /* Inner loop uses 281 flops */
1115 /* End of innermost loop */
1118 f[i_coord_offset+DIM*0+XX] += fix0;
1119 f[i_coord_offset+DIM*0+YY] += fiy0;
1120 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1124 f[i_coord_offset+DIM*1+XX] += fix1;
1125 f[i_coord_offset+DIM*1+YY] += fiy1;
1126 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1130 f[i_coord_offset+DIM*2+XX] += fix2;
1131 f[i_coord_offset+DIM*2+YY] += fiy2;
1132 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1136 f[i_coord_offset+DIM*3+XX] += fix3;
1137 f[i_coord_offset+DIM*3+YY] += fiy3;
1138 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1142 fshift[i_shift_offset+XX] += tx;
1143 fshift[i_shift_offset+YY] += ty;
1144 fshift[i_shift_offset+ZZ] += tz;
1146 /* Increment number of inner iterations */
1147 inneriter += j_index_end - j_index_start;
1149 /* Outer loop uses 39 flops */
1152 /* Increment number of outer iterations */
1155 /* Update outer/inner flops */
1157 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*281);