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_ElecRFCut_VdwCSTab_GeomW3W3_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwCSTab_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;
117 nvdwtype = fr->ntype;
119 vdwtype = mdatoms->typeA;
121 vftab = kernel_data->table_vdw->data;
122 vftabscale = kernel_data->table_vdw->scale;
124 /* Setup water-specific parameters */
125 inr = nlist->iinr[0];
126 iq0 = facel*charge[inr+0];
127 iq1 = facel*charge[inr+1];
128 iq2 = facel*charge[inr+2];
129 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
134 vdwjidx0 = 2*vdwtype[inr+0];
136 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
137 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
147 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
148 rcutoff = fr->rcoulomb;
149 rcutoff2 = rcutoff*rcutoff;
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];
192 /* Reset potential sums */
196 /* Start inner kernel loop */
197 for(jidx=j_index_start; jidx<j_index_end; jidx++)
199 /* Get j neighbor index, and coordinate index */
201 j_coord_offset = DIM*jnr;
203 /* load j atom coordinates */
204 jx0 = x[j_coord_offset+DIM*0+XX];
205 jy0 = x[j_coord_offset+DIM*0+YY];
206 jz0 = x[j_coord_offset+DIM*0+ZZ];
207 jx1 = x[j_coord_offset+DIM*1+XX];
208 jy1 = x[j_coord_offset+DIM*1+YY];
209 jz1 = x[j_coord_offset+DIM*1+ZZ];
210 jx2 = x[j_coord_offset+DIM*2+XX];
211 jy2 = x[j_coord_offset+DIM*2+YY];
212 jz2 = x[j_coord_offset+DIM*2+ZZ];
214 /* Calculate displacement vector */
243 /* Calculate squared distance and things based on it */
244 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
245 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
246 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
247 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
248 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
249 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
250 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
251 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
252 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
254 rinv00 = gmx_invsqrt(rsq00);
255 rinv01 = gmx_invsqrt(rsq01);
256 rinv02 = gmx_invsqrt(rsq02);
257 rinv10 = gmx_invsqrt(rsq10);
258 rinv11 = gmx_invsqrt(rsq11);
259 rinv12 = gmx_invsqrt(rsq12);
260 rinv20 = gmx_invsqrt(rsq20);
261 rinv21 = gmx_invsqrt(rsq21);
262 rinv22 = gmx_invsqrt(rsq22);
264 rinvsq00 = rinv00*rinv00;
265 rinvsq01 = rinv01*rinv01;
266 rinvsq02 = rinv02*rinv02;
267 rinvsq10 = rinv10*rinv10;
268 rinvsq11 = rinv11*rinv11;
269 rinvsq12 = rinv12*rinv12;
270 rinvsq20 = rinv20*rinv20;
271 rinvsq21 = rinv21*rinv21;
272 rinvsq22 = rinv22*rinv22;
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
283 /* Calculate table index by multiplying r with table scale and truncate to integer */
289 /* REACTION-FIELD ELECTROSTATICS */
290 velec = qq00*(rinv00+krf*rsq00-crf);
291 felec = qq00*(rinv00*rinvsq00-krf2);
293 /* CUBIC SPLINE TABLE DISPERSION */
297 Geps = vfeps*vftab[vfitab+2];
298 Heps2 = vfeps*vfeps*vftab[vfitab+3];
302 FF = Fp+Geps+2.0*Heps2;
305 /* CUBIC SPLINE TABLE REPULSION */
308 Geps = vfeps*vftab[vfitab+6];
309 Heps2 = vfeps*vfeps*vftab[vfitab+7];
313 FF = Fp+Geps+2.0*Heps2;
316 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
318 /* Update potential sums from outer loop */
324 /* Calculate temporary vectorial force */
329 /* Update vectorial force */
333 f[j_coord_offset+DIM*0+XX] -= tx;
334 f[j_coord_offset+DIM*0+YY] -= ty;
335 f[j_coord_offset+DIM*0+ZZ] -= tz;
339 /**************************
340 * CALCULATE INTERACTIONS *
341 **************************/
346 /* REACTION-FIELD ELECTROSTATICS */
347 velec = qq01*(rinv01+krf*rsq01-crf);
348 felec = qq01*(rinv01*rinvsq01-krf2);
350 /* Update potential sums from outer loop */
355 /* Calculate temporary vectorial force */
360 /* Update vectorial force */
364 f[j_coord_offset+DIM*1+XX] -= tx;
365 f[j_coord_offset+DIM*1+YY] -= ty;
366 f[j_coord_offset+DIM*1+ZZ] -= tz;
370 /**************************
371 * CALCULATE INTERACTIONS *
372 **************************/
377 /* REACTION-FIELD ELECTROSTATICS */
378 velec = qq02*(rinv02+krf*rsq02-crf);
379 felec = qq02*(rinv02*rinvsq02-krf2);
381 /* Update potential sums from outer loop */
386 /* Calculate temporary vectorial force */
391 /* Update vectorial force */
395 f[j_coord_offset+DIM*2+XX] -= tx;
396 f[j_coord_offset+DIM*2+YY] -= ty;
397 f[j_coord_offset+DIM*2+ZZ] -= tz;
401 /**************************
402 * CALCULATE INTERACTIONS *
403 **************************/
408 /* REACTION-FIELD ELECTROSTATICS */
409 velec = qq10*(rinv10+krf*rsq10-crf);
410 felec = qq10*(rinv10*rinvsq10-krf2);
412 /* Update potential sums from outer loop */
417 /* Calculate temporary vectorial force */
422 /* Update vectorial force */
426 f[j_coord_offset+DIM*0+XX] -= tx;
427 f[j_coord_offset+DIM*0+YY] -= ty;
428 f[j_coord_offset+DIM*0+ZZ] -= tz;
432 /**************************
433 * CALCULATE INTERACTIONS *
434 **************************/
439 /* REACTION-FIELD ELECTROSTATICS */
440 velec = qq11*(rinv11+krf*rsq11-crf);
441 felec = qq11*(rinv11*rinvsq11-krf2);
443 /* Update potential sums from outer loop */
448 /* Calculate temporary vectorial force */
453 /* Update vectorial force */
457 f[j_coord_offset+DIM*1+XX] -= tx;
458 f[j_coord_offset+DIM*1+YY] -= ty;
459 f[j_coord_offset+DIM*1+ZZ] -= tz;
463 /**************************
464 * CALCULATE INTERACTIONS *
465 **************************/
470 /* REACTION-FIELD ELECTROSTATICS */
471 velec = qq12*(rinv12+krf*rsq12-crf);
472 felec = qq12*(rinv12*rinvsq12-krf2);
474 /* Update potential sums from outer loop */
479 /* Calculate temporary vectorial force */
484 /* Update vectorial force */
488 f[j_coord_offset+DIM*2+XX] -= tx;
489 f[j_coord_offset+DIM*2+YY] -= ty;
490 f[j_coord_offset+DIM*2+ZZ] -= tz;
494 /**************************
495 * CALCULATE INTERACTIONS *
496 **************************/
501 /* REACTION-FIELD ELECTROSTATICS */
502 velec = qq20*(rinv20+krf*rsq20-crf);
503 felec = qq20*(rinv20*rinvsq20-krf2);
505 /* Update potential sums from outer loop */
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*0+XX] -= tx;
520 f[j_coord_offset+DIM*0+YY] -= ty;
521 f[j_coord_offset+DIM*0+ZZ] -= tz;
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
532 /* REACTION-FIELD ELECTROSTATICS */
533 velec = qq21*(rinv21+krf*rsq21-crf);
534 felec = qq21*(rinv21*rinvsq21-krf2);
536 /* Update potential sums from outer loop */
541 /* Calculate temporary vectorial force */
546 /* Update vectorial force */
550 f[j_coord_offset+DIM*1+XX] -= tx;
551 f[j_coord_offset+DIM*1+YY] -= ty;
552 f[j_coord_offset+DIM*1+ZZ] -= tz;
556 /**************************
557 * CALCULATE INTERACTIONS *
558 **************************/
563 /* REACTION-FIELD ELECTROSTATICS */
564 velec = qq22*(rinv22+krf*rsq22-crf);
565 felec = qq22*(rinv22*rinvsq22-krf2);
567 /* Update potential sums from outer loop */
572 /* Calculate temporary vectorial force */
577 /* Update vectorial force */
581 f[j_coord_offset+DIM*2+XX] -= tx;
582 f[j_coord_offset+DIM*2+YY] -= ty;
583 f[j_coord_offset+DIM*2+ZZ] -= tz;
587 /* Inner loop uses 313 flops */
589 /* End of innermost loop */
592 f[i_coord_offset+DIM*0+XX] += fix0;
593 f[i_coord_offset+DIM*0+YY] += fiy0;
594 f[i_coord_offset+DIM*0+ZZ] += fiz0;
598 f[i_coord_offset+DIM*1+XX] += fix1;
599 f[i_coord_offset+DIM*1+YY] += fiy1;
600 f[i_coord_offset+DIM*1+ZZ] += fiz1;
604 f[i_coord_offset+DIM*2+XX] += fix2;
605 f[i_coord_offset+DIM*2+YY] += fiy2;
606 f[i_coord_offset+DIM*2+ZZ] += fiz2;
610 fshift[i_shift_offset+XX] += tx;
611 fshift[i_shift_offset+YY] += ty;
612 fshift[i_shift_offset+ZZ] += tz;
615 /* Update potential energies */
616 kernel_data->energygrp_elec[ggid] += velecsum;
617 kernel_data->energygrp_vdw[ggid] += vvdwsum;
619 /* Increment number of inner iterations */
620 inneriter += j_index_end - j_index_start;
622 /* Outer loop uses 32 flops */
625 /* Increment number of outer iterations */
628 /* Update outer/inner flops */
630 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*313);
633 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_F_c
634 * Electrostatics interaction: ReactionField
635 * VdW interaction: CubicSplineTable
636 * Geometry: Water3-Water3
637 * Calculate force/pot: Force
640 nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_F_c
641 (t_nblist * gmx_restrict nlist,
642 rvec * gmx_restrict xx,
643 rvec * gmx_restrict ff,
644 t_forcerec * gmx_restrict fr,
645 t_mdatoms * gmx_restrict mdatoms,
646 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
647 t_nrnb * gmx_restrict nrnb)
649 int i_shift_offset,i_coord_offset,j_coord_offset;
650 int j_index_start,j_index_end;
651 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
652 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
653 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
654 real *shiftvec,*fshift,*x,*f;
656 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
658 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
660 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
662 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
664 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
666 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
667 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
668 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
669 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
670 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
671 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
672 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
673 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
674 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
675 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
676 real velec,felec,velecsum,facel,crf,krf,krf2;
679 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
683 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
691 jindex = nlist->jindex;
693 shiftidx = nlist->shift;
695 shiftvec = fr->shift_vec[0];
696 fshift = fr->fshift[0];
698 charge = mdatoms->chargeA;
702 nvdwtype = fr->ntype;
704 vdwtype = mdatoms->typeA;
706 vftab = kernel_data->table_vdw->data;
707 vftabscale = kernel_data->table_vdw->scale;
709 /* Setup water-specific parameters */
710 inr = nlist->iinr[0];
711 iq0 = facel*charge[inr+0];
712 iq1 = facel*charge[inr+1];
713 iq2 = facel*charge[inr+2];
714 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
719 vdwjidx0 = 2*vdwtype[inr+0];
721 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
722 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
732 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
733 rcutoff = fr->rcoulomb;
734 rcutoff2 = rcutoff*rcutoff;
739 /* Start outer loop over neighborlists */
740 for(iidx=0; iidx<nri; iidx++)
742 /* Load shift vector for this list */
743 i_shift_offset = DIM*shiftidx[iidx];
744 shX = shiftvec[i_shift_offset+XX];
745 shY = shiftvec[i_shift_offset+YY];
746 shZ = shiftvec[i_shift_offset+ZZ];
748 /* Load limits for loop over neighbors */
749 j_index_start = jindex[iidx];
750 j_index_end = jindex[iidx+1];
752 /* Get outer coordinate index */
754 i_coord_offset = DIM*inr;
756 /* Load i particle coords and add shift vector */
757 ix0 = shX + x[i_coord_offset+DIM*0+XX];
758 iy0 = shY + x[i_coord_offset+DIM*0+YY];
759 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
760 ix1 = shX + x[i_coord_offset+DIM*1+XX];
761 iy1 = shY + x[i_coord_offset+DIM*1+YY];
762 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
763 ix2 = shX + x[i_coord_offset+DIM*2+XX];
764 iy2 = shY + x[i_coord_offset+DIM*2+YY];
765 iz2 = shZ + x[i_coord_offset+DIM*2+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];
795 /* Calculate displacement vector */
824 /* Calculate squared distance and things based on it */
825 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
826 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
827 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
828 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
829 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
830 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
831 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
832 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
833 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
835 rinv00 = gmx_invsqrt(rsq00);
836 rinv01 = gmx_invsqrt(rsq01);
837 rinv02 = gmx_invsqrt(rsq02);
838 rinv10 = gmx_invsqrt(rsq10);
839 rinv11 = gmx_invsqrt(rsq11);
840 rinv12 = gmx_invsqrt(rsq12);
841 rinv20 = gmx_invsqrt(rsq20);
842 rinv21 = gmx_invsqrt(rsq21);
843 rinv22 = gmx_invsqrt(rsq22);
845 rinvsq00 = rinv00*rinv00;
846 rinvsq01 = rinv01*rinv01;
847 rinvsq02 = rinv02*rinv02;
848 rinvsq10 = rinv10*rinv10;
849 rinvsq11 = rinv11*rinv11;
850 rinvsq12 = rinv12*rinv12;
851 rinvsq20 = rinv20*rinv20;
852 rinvsq21 = rinv21*rinv21;
853 rinvsq22 = rinv22*rinv22;
855 /**************************
856 * CALCULATE INTERACTIONS *
857 **************************/
864 /* Calculate table index by multiplying r with table scale and truncate to integer */
870 /* REACTION-FIELD ELECTROSTATICS */
871 felec = qq00*(rinv00*rinvsq00-krf2);
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;
908 /**************************
909 * CALCULATE INTERACTIONS *
910 **************************/
915 /* REACTION-FIELD ELECTROSTATICS */
916 felec = qq01*(rinv01*rinvsq01-krf2);
920 /* Calculate temporary vectorial force */
925 /* Update vectorial force */
929 f[j_coord_offset+DIM*1+XX] -= tx;
930 f[j_coord_offset+DIM*1+YY] -= ty;
931 f[j_coord_offset+DIM*1+ZZ] -= tz;
935 /**************************
936 * CALCULATE INTERACTIONS *
937 **************************/
942 /* REACTION-FIELD ELECTROSTATICS */
943 felec = qq02*(rinv02*rinvsq02-krf2);
947 /* Calculate temporary vectorial force */
952 /* Update vectorial force */
956 f[j_coord_offset+DIM*2+XX] -= tx;
957 f[j_coord_offset+DIM*2+YY] -= ty;
958 f[j_coord_offset+DIM*2+ZZ] -= tz;
962 /**************************
963 * CALCULATE INTERACTIONS *
964 **************************/
969 /* REACTION-FIELD ELECTROSTATICS */
970 felec = qq10*(rinv10*rinvsq10-krf2);
974 /* Calculate temporary vectorial force */
979 /* Update vectorial force */
983 f[j_coord_offset+DIM*0+XX] -= tx;
984 f[j_coord_offset+DIM*0+YY] -= ty;
985 f[j_coord_offset+DIM*0+ZZ] -= tz;
989 /**************************
990 * CALCULATE INTERACTIONS *
991 **************************/
996 /* REACTION-FIELD ELECTROSTATICS */
997 felec = qq11*(rinv11*rinvsq11-krf2);
1001 /* Calculate temporary vectorial force */
1006 /* Update vectorial force */
1010 f[j_coord_offset+DIM*1+XX] -= tx;
1011 f[j_coord_offset+DIM*1+YY] -= ty;
1012 f[j_coord_offset+DIM*1+ZZ] -= tz;
1016 /**************************
1017 * CALCULATE INTERACTIONS *
1018 **************************/
1023 /* REACTION-FIELD ELECTROSTATICS */
1024 felec = qq12*(rinv12*rinvsq12-krf2);
1028 /* Calculate temporary vectorial force */
1033 /* Update vectorial force */
1037 f[j_coord_offset+DIM*2+XX] -= tx;
1038 f[j_coord_offset+DIM*2+YY] -= ty;
1039 f[j_coord_offset+DIM*2+ZZ] -= tz;
1043 /**************************
1044 * CALCULATE INTERACTIONS *
1045 **************************/
1050 /* REACTION-FIELD ELECTROSTATICS */
1051 felec = qq20*(rinv20*rinvsq20-krf2);
1055 /* Calculate temporary vectorial force */
1060 /* Update vectorial force */
1064 f[j_coord_offset+DIM*0+XX] -= tx;
1065 f[j_coord_offset+DIM*0+YY] -= ty;
1066 f[j_coord_offset+DIM*0+ZZ] -= tz;
1070 /**************************
1071 * CALCULATE INTERACTIONS *
1072 **************************/
1077 /* REACTION-FIELD ELECTROSTATICS */
1078 felec = qq21*(rinv21*rinvsq21-krf2);
1082 /* Calculate temporary vectorial force */
1087 /* Update vectorial force */
1091 f[j_coord_offset+DIM*1+XX] -= tx;
1092 f[j_coord_offset+DIM*1+YY] -= ty;
1093 f[j_coord_offset+DIM*1+ZZ] -= tz;
1097 /**************************
1098 * CALCULATE INTERACTIONS *
1099 **************************/
1104 /* REACTION-FIELD ELECTROSTATICS */
1105 felec = qq22*(rinv22*rinvsq22-krf2);
1109 /* Calculate temporary vectorial force */
1114 /* Update vectorial force */
1118 f[j_coord_offset+DIM*2+XX] -= tx;
1119 f[j_coord_offset+DIM*2+YY] -= ty;
1120 f[j_coord_offset+DIM*2+ZZ] -= tz;
1124 /* Inner loop uses 260 flops */
1126 /* End of innermost loop */
1129 f[i_coord_offset+DIM*0+XX] += fix0;
1130 f[i_coord_offset+DIM*0+YY] += fiy0;
1131 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1135 f[i_coord_offset+DIM*1+XX] += fix1;
1136 f[i_coord_offset+DIM*1+YY] += fiy1;
1137 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1141 f[i_coord_offset+DIM*2+XX] += fix2;
1142 f[i_coord_offset+DIM*2+YY] += fiy2;
1143 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1147 fshift[i_shift_offset+XX] += tx;
1148 fshift[i_shift_offset+YY] += ty;
1149 fshift[i_shift_offset+ZZ] += tz;
1151 /* Increment number of inner iterations */
1152 inneriter += j_index_end - j_index_start;
1154 /* Outer loop uses 30 flops */
1157 /* Increment number of outer iterations */
1160 /* Update outer/inner flops */
1162 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*260);