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_ElecRFCut_VdwCSTab_GeomW3W3_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
100 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
108 jindex = nlist->jindex;
110 shiftidx = nlist->shift;
112 shiftvec = fr->shift_vec[0];
113 fshift = fr->fshift[0];
115 charge = mdatoms->chargeA;
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 iq0 = facel*charge[inr+0];
129 iq1 = facel*charge[inr+1];
130 iq2 = facel*charge[inr+2];
131 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
136 vdwjidx0 = 2*vdwtype[inr+0];
138 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
139 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
149 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
150 rcutoff = fr->rcoulomb;
151 rcutoff2 = rcutoff*rcutoff;
156 /* Start outer loop over neighborlists */
157 for(iidx=0; iidx<nri; iidx++)
159 /* Load shift vector for this list */
160 i_shift_offset = DIM*shiftidx[iidx];
161 shX = shiftvec[i_shift_offset+XX];
162 shY = shiftvec[i_shift_offset+YY];
163 shZ = shiftvec[i_shift_offset+ZZ];
165 /* Load limits for loop over neighbors */
166 j_index_start = jindex[iidx];
167 j_index_end = jindex[iidx+1];
169 /* Get outer coordinate index */
171 i_coord_offset = DIM*inr;
173 /* Load i particle coords and add shift vector */
174 ix0 = shX + x[i_coord_offset+DIM*0+XX];
175 iy0 = shY + x[i_coord_offset+DIM*0+YY];
176 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
177 ix1 = shX + x[i_coord_offset+DIM*1+XX];
178 iy1 = shY + x[i_coord_offset+DIM*1+YY];
179 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
180 ix2 = shX + x[i_coord_offset+DIM*2+XX];
181 iy2 = shY + x[i_coord_offset+DIM*2+YY];
182 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
194 /* Reset potential sums */
198 /* Start inner kernel loop */
199 for(jidx=j_index_start; jidx<j_index_end; jidx++)
201 /* Get j neighbor index, and coordinate index */
203 j_coord_offset = DIM*jnr;
205 /* load j atom coordinates */
206 jx0 = x[j_coord_offset+DIM*0+XX];
207 jy0 = x[j_coord_offset+DIM*0+YY];
208 jz0 = x[j_coord_offset+DIM*0+ZZ];
209 jx1 = x[j_coord_offset+DIM*1+XX];
210 jy1 = x[j_coord_offset+DIM*1+YY];
211 jz1 = x[j_coord_offset+DIM*1+ZZ];
212 jx2 = x[j_coord_offset+DIM*2+XX];
213 jy2 = x[j_coord_offset+DIM*2+YY];
214 jz2 = x[j_coord_offset+DIM*2+ZZ];
216 /* Calculate displacement vector */
245 /* Calculate squared distance and things based on it */
246 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
247 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
248 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
249 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
250 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
251 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
252 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
253 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
254 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
256 rinv00 = gmx_invsqrt(rsq00);
257 rinv01 = gmx_invsqrt(rsq01);
258 rinv02 = gmx_invsqrt(rsq02);
259 rinv10 = gmx_invsqrt(rsq10);
260 rinv11 = gmx_invsqrt(rsq11);
261 rinv12 = gmx_invsqrt(rsq12);
262 rinv20 = gmx_invsqrt(rsq20);
263 rinv21 = gmx_invsqrt(rsq21);
264 rinv22 = gmx_invsqrt(rsq22);
266 rinvsq00 = rinv00*rinv00;
267 rinvsq01 = rinv01*rinv01;
268 rinvsq02 = rinv02*rinv02;
269 rinvsq10 = rinv10*rinv10;
270 rinvsq11 = rinv11*rinv11;
271 rinvsq12 = rinv12*rinv12;
272 rinvsq20 = rinv20*rinv20;
273 rinvsq21 = rinv21*rinv21;
274 rinvsq22 = rinv22*rinv22;
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
285 /* Calculate table index by multiplying r with table scale and truncate to integer */
291 /* REACTION-FIELD ELECTROSTATICS */
292 velec = qq00*(rinv00+krf*rsq00-crf);
293 felec = qq00*(rinv00*rinvsq00-krf2);
295 /* CUBIC SPLINE TABLE DISPERSION */
299 Geps = vfeps*vftab[vfitab+2];
300 Heps2 = vfeps*vfeps*vftab[vfitab+3];
304 FF = Fp+Geps+2.0*Heps2;
307 /* CUBIC SPLINE TABLE REPULSION */
310 Geps = vfeps*vftab[vfitab+6];
311 Heps2 = vfeps*vfeps*vftab[vfitab+7];
315 FF = Fp+Geps+2.0*Heps2;
318 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
320 /* Update potential sums from outer loop */
326 /* Calculate temporary vectorial force */
331 /* Update vectorial force */
335 f[j_coord_offset+DIM*0+XX] -= tx;
336 f[j_coord_offset+DIM*0+YY] -= ty;
337 f[j_coord_offset+DIM*0+ZZ] -= tz;
341 /**************************
342 * CALCULATE INTERACTIONS *
343 **************************/
348 /* REACTION-FIELD ELECTROSTATICS */
349 velec = qq01*(rinv01+krf*rsq01-crf);
350 felec = qq01*(rinv01*rinvsq01-krf2);
352 /* Update potential sums from outer loop */
357 /* Calculate temporary vectorial force */
362 /* Update vectorial force */
366 f[j_coord_offset+DIM*1+XX] -= tx;
367 f[j_coord_offset+DIM*1+YY] -= ty;
368 f[j_coord_offset+DIM*1+ZZ] -= tz;
372 /**************************
373 * CALCULATE INTERACTIONS *
374 **************************/
379 /* REACTION-FIELD ELECTROSTATICS */
380 velec = qq02*(rinv02+krf*rsq02-crf);
381 felec = qq02*(rinv02*rinvsq02-krf2);
383 /* Update potential sums from outer loop */
388 /* Calculate temporary vectorial force */
393 /* Update vectorial force */
397 f[j_coord_offset+DIM*2+XX] -= tx;
398 f[j_coord_offset+DIM*2+YY] -= ty;
399 f[j_coord_offset+DIM*2+ZZ] -= tz;
403 /**************************
404 * CALCULATE INTERACTIONS *
405 **************************/
410 /* REACTION-FIELD ELECTROSTATICS */
411 velec = qq10*(rinv10+krf*rsq10-crf);
412 felec = qq10*(rinv10*rinvsq10-krf2);
414 /* Update potential sums from outer loop */
419 /* Calculate temporary vectorial force */
424 /* Update vectorial force */
428 f[j_coord_offset+DIM*0+XX] -= tx;
429 f[j_coord_offset+DIM*0+YY] -= ty;
430 f[j_coord_offset+DIM*0+ZZ] -= tz;
434 /**************************
435 * CALCULATE INTERACTIONS *
436 **************************/
441 /* REACTION-FIELD ELECTROSTATICS */
442 velec = qq11*(rinv11+krf*rsq11-crf);
443 felec = qq11*(rinv11*rinvsq11-krf2);
445 /* Update potential sums from outer loop */
450 /* Calculate temporary vectorial force */
455 /* Update vectorial force */
459 f[j_coord_offset+DIM*1+XX] -= tx;
460 f[j_coord_offset+DIM*1+YY] -= ty;
461 f[j_coord_offset+DIM*1+ZZ] -= tz;
465 /**************************
466 * CALCULATE INTERACTIONS *
467 **************************/
472 /* REACTION-FIELD ELECTROSTATICS */
473 velec = qq12*(rinv12+krf*rsq12-crf);
474 felec = qq12*(rinv12*rinvsq12-krf2);
476 /* Update potential sums from outer loop */
481 /* Calculate temporary vectorial force */
486 /* Update vectorial force */
490 f[j_coord_offset+DIM*2+XX] -= tx;
491 f[j_coord_offset+DIM*2+YY] -= ty;
492 f[j_coord_offset+DIM*2+ZZ] -= tz;
496 /**************************
497 * CALCULATE INTERACTIONS *
498 **************************/
503 /* REACTION-FIELD ELECTROSTATICS */
504 velec = qq20*(rinv20+krf*rsq20-crf);
505 felec = qq20*(rinv20*rinvsq20-krf2);
507 /* Update potential sums from outer loop */
512 /* Calculate temporary vectorial force */
517 /* Update vectorial force */
521 f[j_coord_offset+DIM*0+XX] -= tx;
522 f[j_coord_offset+DIM*0+YY] -= ty;
523 f[j_coord_offset+DIM*0+ZZ] -= tz;
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
534 /* REACTION-FIELD ELECTROSTATICS */
535 velec = qq21*(rinv21+krf*rsq21-crf);
536 felec = qq21*(rinv21*rinvsq21-krf2);
538 /* Update potential sums from outer loop */
543 /* Calculate temporary vectorial force */
548 /* Update vectorial force */
552 f[j_coord_offset+DIM*1+XX] -= tx;
553 f[j_coord_offset+DIM*1+YY] -= ty;
554 f[j_coord_offset+DIM*1+ZZ] -= tz;
558 /**************************
559 * CALCULATE INTERACTIONS *
560 **************************/
565 /* REACTION-FIELD ELECTROSTATICS */
566 velec = qq22*(rinv22+krf*rsq22-crf);
567 felec = qq22*(rinv22*rinvsq22-krf2);
569 /* Update potential sums from outer loop */
574 /* Calculate temporary vectorial force */
579 /* Update vectorial force */
583 f[j_coord_offset+DIM*2+XX] -= tx;
584 f[j_coord_offset+DIM*2+YY] -= ty;
585 f[j_coord_offset+DIM*2+ZZ] -= tz;
589 /* Inner loop uses 313 flops */
591 /* End of innermost loop */
594 f[i_coord_offset+DIM*0+XX] += fix0;
595 f[i_coord_offset+DIM*0+YY] += fiy0;
596 f[i_coord_offset+DIM*0+ZZ] += fiz0;
600 f[i_coord_offset+DIM*1+XX] += fix1;
601 f[i_coord_offset+DIM*1+YY] += fiy1;
602 f[i_coord_offset+DIM*1+ZZ] += fiz1;
606 f[i_coord_offset+DIM*2+XX] += fix2;
607 f[i_coord_offset+DIM*2+YY] += fiy2;
608 f[i_coord_offset+DIM*2+ZZ] += fiz2;
612 fshift[i_shift_offset+XX] += tx;
613 fshift[i_shift_offset+YY] += ty;
614 fshift[i_shift_offset+ZZ] += tz;
617 /* Update potential energies */
618 kernel_data->energygrp_elec[ggid] += velecsum;
619 kernel_data->energygrp_vdw[ggid] += vvdwsum;
621 /* Increment number of inner iterations */
622 inneriter += j_index_end - j_index_start;
624 /* Outer loop uses 32 flops */
627 /* Increment number of outer iterations */
630 /* Update outer/inner flops */
632 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*313);
635 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_F_c
636 * Electrostatics interaction: ReactionField
637 * VdW interaction: CubicSplineTable
638 * Geometry: Water3-Water3
639 * Calculate force/pot: Force
642 nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_F_c
643 (t_nblist * gmx_restrict nlist,
644 rvec * gmx_restrict xx,
645 rvec * gmx_restrict ff,
646 t_forcerec * gmx_restrict fr,
647 t_mdatoms * gmx_restrict mdatoms,
648 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
649 t_nrnb * gmx_restrict nrnb)
651 int i_shift_offset,i_coord_offset,j_coord_offset;
652 int j_index_start,j_index_end;
653 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
654 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
655 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
656 real *shiftvec,*fshift,*x,*f;
658 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
660 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
662 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
664 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
666 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
668 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
669 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
670 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
671 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
672 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
673 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
674 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
675 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
676 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
677 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
678 real velec,felec,velecsum,facel,crf,krf,krf2;
681 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
685 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
693 jindex = nlist->jindex;
695 shiftidx = nlist->shift;
697 shiftvec = fr->shift_vec[0];
698 fshift = fr->fshift[0];
700 charge = mdatoms->chargeA;
704 nvdwtype = fr->ntype;
706 vdwtype = mdatoms->typeA;
708 vftab = kernel_data->table_vdw->data;
709 vftabscale = kernel_data->table_vdw->scale;
711 /* Setup water-specific parameters */
712 inr = nlist->iinr[0];
713 iq0 = facel*charge[inr+0];
714 iq1 = facel*charge[inr+1];
715 iq2 = facel*charge[inr+2];
716 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
721 vdwjidx0 = 2*vdwtype[inr+0];
723 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
724 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
734 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
735 rcutoff = fr->rcoulomb;
736 rcutoff2 = rcutoff*rcutoff;
741 /* Start outer loop over neighborlists */
742 for(iidx=0; iidx<nri; iidx++)
744 /* Load shift vector for this list */
745 i_shift_offset = DIM*shiftidx[iidx];
746 shX = shiftvec[i_shift_offset+XX];
747 shY = shiftvec[i_shift_offset+YY];
748 shZ = shiftvec[i_shift_offset+ZZ];
750 /* Load limits for loop over neighbors */
751 j_index_start = jindex[iidx];
752 j_index_end = jindex[iidx+1];
754 /* Get outer coordinate index */
756 i_coord_offset = DIM*inr;
758 /* Load i particle coords and add shift vector */
759 ix0 = shX + x[i_coord_offset+DIM*0+XX];
760 iy0 = shY + x[i_coord_offset+DIM*0+YY];
761 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
762 ix1 = shX + x[i_coord_offset+DIM*1+XX];
763 iy1 = shY + x[i_coord_offset+DIM*1+YY];
764 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
765 ix2 = shX + x[i_coord_offset+DIM*2+XX];
766 iy2 = shY + x[i_coord_offset+DIM*2+YY];
767 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
779 /* Start inner kernel loop */
780 for(jidx=j_index_start; jidx<j_index_end; jidx++)
782 /* Get j neighbor index, and coordinate index */
784 j_coord_offset = DIM*jnr;
786 /* load j atom coordinates */
787 jx0 = x[j_coord_offset+DIM*0+XX];
788 jy0 = x[j_coord_offset+DIM*0+YY];
789 jz0 = x[j_coord_offset+DIM*0+ZZ];
790 jx1 = x[j_coord_offset+DIM*1+XX];
791 jy1 = x[j_coord_offset+DIM*1+YY];
792 jz1 = x[j_coord_offset+DIM*1+ZZ];
793 jx2 = x[j_coord_offset+DIM*2+XX];
794 jy2 = x[j_coord_offset+DIM*2+YY];
795 jz2 = x[j_coord_offset+DIM*2+ZZ];
797 /* Calculate displacement vector */
826 /* Calculate squared distance and things based on it */
827 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
828 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
829 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
830 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
831 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
832 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
833 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
834 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
835 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
837 rinv00 = gmx_invsqrt(rsq00);
838 rinv01 = gmx_invsqrt(rsq01);
839 rinv02 = gmx_invsqrt(rsq02);
840 rinv10 = gmx_invsqrt(rsq10);
841 rinv11 = gmx_invsqrt(rsq11);
842 rinv12 = gmx_invsqrt(rsq12);
843 rinv20 = gmx_invsqrt(rsq20);
844 rinv21 = gmx_invsqrt(rsq21);
845 rinv22 = gmx_invsqrt(rsq22);
847 rinvsq00 = rinv00*rinv00;
848 rinvsq01 = rinv01*rinv01;
849 rinvsq02 = rinv02*rinv02;
850 rinvsq10 = rinv10*rinv10;
851 rinvsq11 = rinv11*rinv11;
852 rinvsq12 = rinv12*rinv12;
853 rinvsq20 = rinv20*rinv20;
854 rinvsq21 = rinv21*rinv21;
855 rinvsq22 = rinv22*rinv22;
857 /**************************
858 * CALCULATE INTERACTIONS *
859 **************************/
866 /* Calculate table index by multiplying r with table scale and truncate to integer */
872 /* REACTION-FIELD ELECTROSTATICS */
873 felec = qq00*(rinv00*rinvsq00-krf2);
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;
910 /**************************
911 * CALCULATE INTERACTIONS *
912 **************************/
917 /* REACTION-FIELD ELECTROSTATICS */
918 felec = qq01*(rinv01*rinvsq01-krf2);
922 /* Calculate temporary vectorial force */
927 /* Update vectorial force */
931 f[j_coord_offset+DIM*1+XX] -= tx;
932 f[j_coord_offset+DIM*1+YY] -= ty;
933 f[j_coord_offset+DIM*1+ZZ] -= tz;
937 /**************************
938 * CALCULATE INTERACTIONS *
939 **************************/
944 /* REACTION-FIELD ELECTROSTATICS */
945 felec = qq02*(rinv02*rinvsq02-krf2);
949 /* Calculate temporary vectorial force */
954 /* Update vectorial force */
958 f[j_coord_offset+DIM*2+XX] -= tx;
959 f[j_coord_offset+DIM*2+YY] -= ty;
960 f[j_coord_offset+DIM*2+ZZ] -= tz;
964 /**************************
965 * CALCULATE INTERACTIONS *
966 **************************/
971 /* REACTION-FIELD ELECTROSTATICS */
972 felec = qq10*(rinv10*rinvsq10-krf2);
976 /* Calculate temporary vectorial force */
981 /* Update vectorial force */
985 f[j_coord_offset+DIM*0+XX] -= tx;
986 f[j_coord_offset+DIM*0+YY] -= ty;
987 f[j_coord_offset+DIM*0+ZZ] -= tz;
991 /**************************
992 * CALCULATE INTERACTIONS *
993 **************************/
998 /* REACTION-FIELD ELECTROSTATICS */
999 felec = qq11*(rinv11*rinvsq11-krf2);
1003 /* Calculate temporary vectorial force */
1008 /* Update vectorial force */
1012 f[j_coord_offset+DIM*1+XX] -= tx;
1013 f[j_coord_offset+DIM*1+YY] -= ty;
1014 f[j_coord_offset+DIM*1+ZZ] -= tz;
1018 /**************************
1019 * CALCULATE INTERACTIONS *
1020 **************************/
1025 /* REACTION-FIELD ELECTROSTATICS */
1026 felec = qq12*(rinv12*rinvsq12-krf2);
1030 /* Calculate temporary vectorial force */
1035 /* Update vectorial force */
1039 f[j_coord_offset+DIM*2+XX] -= tx;
1040 f[j_coord_offset+DIM*2+YY] -= ty;
1041 f[j_coord_offset+DIM*2+ZZ] -= tz;
1045 /**************************
1046 * CALCULATE INTERACTIONS *
1047 **************************/
1052 /* REACTION-FIELD ELECTROSTATICS */
1053 felec = qq20*(rinv20*rinvsq20-krf2);
1057 /* Calculate temporary vectorial force */
1062 /* Update vectorial force */
1066 f[j_coord_offset+DIM*0+XX] -= tx;
1067 f[j_coord_offset+DIM*0+YY] -= ty;
1068 f[j_coord_offset+DIM*0+ZZ] -= tz;
1072 /**************************
1073 * CALCULATE INTERACTIONS *
1074 **************************/
1079 /* REACTION-FIELD ELECTROSTATICS */
1080 felec = qq21*(rinv21*rinvsq21-krf2);
1084 /* Calculate temporary vectorial force */
1089 /* Update vectorial force */
1093 f[j_coord_offset+DIM*1+XX] -= tx;
1094 f[j_coord_offset+DIM*1+YY] -= ty;
1095 f[j_coord_offset+DIM*1+ZZ] -= tz;
1099 /**************************
1100 * CALCULATE INTERACTIONS *
1101 **************************/
1106 /* REACTION-FIELD ELECTROSTATICS */
1107 felec = qq22*(rinv22*rinvsq22-krf2);
1111 /* Calculate temporary vectorial force */
1116 /* Update vectorial force */
1120 f[j_coord_offset+DIM*2+XX] -= tx;
1121 f[j_coord_offset+DIM*2+YY] -= ty;
1122 f[j_coord_offset+DIM*2+ZZ] -= tz;
1126 /* Inner loop uses 260 flops */
1128 /* End of innermost loop */
1131 f[i_coord_offset+DIM*0+XX] += fix0;
1132 f[i_coord_offset+DIM*0+YY] += fiy0;
1133 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1137 f[i_coord_offset+DIM*1+XX] += fix1;
1138 f[i_coord_offset+DIM*1+YY] += fiy1;
1139 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1143 f[i_coord_offset+DIM*2+XX] += fix2;
1144 f[i_coord_offset+DIM*2+YY] += fiy2;
1145 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1149 fshift[i_shift_offset+XX] += tx;
1150 fshift[i_shift_offset+YY] += ty;
1151 fshift[i_shift_offset+ZZ] += tz;
1153 /* Increment number of inner iterations */
1154 inneriter += j_index_end - j_index_start;
1156 /* Outer loop uses 30 flops */
1159 /* Increment number of outer iterations */
1162 /* Update outer/inner flops */
1164 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*260);