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 "types/simple.h"
46 #include "gromacs/math/vec.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3W3_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_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];
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];
190 /* Reset potential sums */
194 /* Start inner kernel loop */
195 for(jidx=j_index_start; jidx<j_index_end; jidx++)
197 /* Get j neighbor index, and coordinate index */
199 j_coord_offset = DIM*jnr;
201 /* load j atom coordinates */
202 jx0 = x[j_coord_offset+DIM*0+XX];
203 jy0 = x[j_coord_offset+DIM*0+YY];
204 jz0 = x[j_coord_offset+DIM*0+ZZ];
205 jx1 = x[j_coord_offset+DIM*1+XX];
206 jy1 = x[j_coord_offset+DIM*1+YY];
207 jz1 = x[j_coord_offset+DIM*1+ZZ];
208 jx2 = x[j_coord_offset+DIM*2+XX];
209 jy2 = x[j_coord_offset+DIM*2+YY];
210 jz2 = x[j_coord_offset+DIM*2+ZZ];
212 /* Calculate displacement vector */
241 /* Calculate squared distance and things based on it */
242 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
243 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
244 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
245 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
246 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
247 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
248 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
249 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
250 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
252 rinv00 = gmx_invsqrt(rsq00);
253 rinv01 = gmx_invsqrt(rsq01);
254 rinv02 = gmx_invsqrt(rsq02);
255 rinv10 = gmx_invsqrt(rsq10);
256 rinv11 = gmx_invsqrt(rsq11);
257 rinv12 = gmx_invsqrt(rsq12);
258 rinv20 = gmx_invsqrt(rsq20);
259 rinv21 = gmx_invsqrt(rsq21);
260 rinv22 = gmx_invsqrt(rsq22);
262 rinvsq00 = rinv00*rinv00;
263 rinvsq01 = rinv01*rinv01;
264 rinvsq02 = rinv02*rinv02;
265 rinvsq10 = rinv10*rinv10;
266 rinvsq11 = rinv11*rinv11;
267 rinvsq12 = rinv12*rinv12;
268 rinvsq20 = rinv20*rinv20;
269 rinvsq21 = rinv21*rinv21;
270 rinvsq22 = rinv22*rinv22;
272 /**************************
273 * CALCULATE INTERACTIONS *
274 **************************/
278 /* Calculate table index by multiplying r with table scale and truncate to integer */
284 /* REACTION-FIELD ELECTROSTATICS */
285 velec = qq00*(rinv00+krf*rsq00-crf);
286 felec = qq00*(rinv00*rinvsq00-krf2);
288 /* CUBIC SPLINE TABLE DISPERSION */
292 Geps = vfeps*vftab[vfitab+2];
293 Heps2 = vfeps*vfeps*vftab[vfitab+3];
297 FF = Fp+Geps+2.0*Heps2;
300 /* CUBIC SPLINE TABLE REPULSION */
303 Geps = vfeps*vftab[vfitab+6];
304 Heps2 = vfeps*vfeps*vftab[vfitab+7];
308 FF = Fp+Geps+2.0*Heps2;
311 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
313 /* Update potential sums from outer loop */
319 /* Calculate temporary vectorial force */
324 /* Update vectorial force */
328 f[j_coord_offset+DIM*0+XX] -= tx;
329 f[j_coord_offset+DIM*0+YY] -= ty;
330 f[j_coord_offset+DIM*0+ZZ] -= tz;
332 /**************************
333 * CALCULATE INTERACTIONS *
334 **************************/
336 /* REACTION-FIELD ELECTROSTATICS */
337 velec = qq01*(rinv01+krf*rsq01-crf);
338 felec = qq01*(rinv01*rinvsq01-krf2);
340 /* Update potential sums from outer loop */
345 /* Calculate temporary vectorial force */
350 /* Update vectorial force */
354 f[j_coord_offset+DIM*1+XX] -= tx;
355 f[j_coord_offset+DIM*1+YY] -= ty;
356 f[j_coord_offset+DIM*1+ZZ] -= tz;
358 /**************************
359 * CALCULATE INTERACTIONS *
360 **************************/
362 /* REACTION-FIELD ELECTROSTATICS */
363 velec = qq02*(rinv02+krf*rsq02-crf);
364 felec = qq02*(rinv02*rinvsq02-krf2);
366 /* Update potential sums from outer loop */
371 /* Calculate temporary vectorial force */
376 /* Update vectorial force */
380 f[j_coord_offset+DIM*2+XX] -= tx;
381 f[j_coord_offset+DIM*2+YY] -= ty;
382 f[j_coord_offset+DIM*2+ZZ] -= tz;
384 /**************************
385 * CALCULATE INTERACTIONS *
386 **************************/
388 /* REACTION-FIELD ELECTROSTATICS */
389 velec = qq10*(rinv10+krf*rsq10-crf);
390 felec = qq10*(rinv10*rinvsq10-krf2);
392 /* Update potential sums from outer loop */
397 /* Calculate temporary vectorial force */
402 /* Update vectorial force */
406 f[j_coord_offset+DIM*0+XX] -= tx;
407 f[j_coord_offset+DIM*0+YY] -= ty;
408 f[j_coord_offset+DIM*0+ZZ] -= tz;
410 /**************************
411 * CALCULATE INTERACTIONS *
412 **************************/
414 /* REACTION-FIELD ELECTROSTATICS */
415 velec = qq11*(rinv11+krf*rsq11-crf);
416 felec = qq11*(rinv11*rinvsq11-krf2);
418 /* Update potential sums from outer loop */
423 /* Calculate temporary vectorial force */
428 /* Update vectorial force */
432 f[j_coord_offset+DIM*1+XX] -= tx;
433 f[j_coord_offset+DIM*1+YY] -= ty;
434 f[j_coord_offset+DIM*1+ZZ] -= tz;
436 /**************************
437 * CALCULATE INTERACTIONS *
438 **************************/
440 /* REACTION-FIELD ELECTROSTATICS */
441 velec = qq12*(rinv12+krf*rsq12-crf);
442 felec = qq12*(rinv12*rinvsq12-krf2);
444 /* Update potential sums from outer loop */
449 /* Calculate temporary vectorial force */
454 /* Update vectorial force */
458 f[j_coord_offset+DIM*2+XX] -= tx;
459 f[j_coord_offset+DIM*2+YY] -= ty;
460 f[j_coord_offset+DIM*2+ZZ] -= tz;
462 /**************************
463 * CALCULATE INTERACTIONS *
464 **************************/
466 /* REACTION-FIELD ELECTROSTATICS */
467 velec = qq20*(rinv20+krf*rsq20-crf);
468 felec = qq20*(rinv20*rinvsq20-krf2);
470 /* Update potential sums from outer loop */
475 /* Calculate temporary vectorial force */
480 /* Update vectorial force */
484 f[j_coord_offset+DIM*0+XX] -= tx;
485 f[j_coord_offset+DIM*0+YY] -= ty;
486 f[j_coord_offset+DIM*0+ZZ] -= tz;
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
492 /* REACTION-FIELD ELECTROSTATICS */
493 velec = qq21*(rinv21+krf*rsq21-crf);
494 felec = qq21*(rinv21*rinvsq21-krf2);
496 /* Update potential sums from outer loop */
501 /* Calculate temporary vectorial force */
506 /* Update vectorial force */
510 f[j_coord_offset+DIM*1+XX] -= tx;
511 f[j_coord_offset+DIM*1+YY] -= ty;
512 f[j_coord_offset+DIM*1+ZZ] -= tz;
514 /**************************
515 * CALCULATE INTERACTIONS *
516 **************************/
518 /* REACTION-FIELD ELECTROSTATICS */
519 velec = qq22*(rinv22+krf*rsq22-crf);
520 felec = qq22*(rinv22*rinvsq22-krf2);
522 /* Update potential sums from outer loop */
527 /* Calculate temporary vectorial force */
532 /* Update vectorial force */
536 f[j_coord_offset+DIM*2+XX] -= tx;
537 f[j_coord_offset+DIM*2+YY] -= ty;
538 f[j_coord_offset+DIM*2+ZZ] -= tz;
540 /* Inner loop uses 313 flops */
542 /* End of innermost loop */
545 f[i_coord_offset+DIM*0+XX] += fix0;
546 f[i_coord_offset+DIM*0+YY] += fiy0;
547 f[i_coord_offset+DIM*0+ZZ] += fiz0;
551 f[i_coord_offset+DIM*1+XX] += fix1;
552 f[i_coord_offset+DIM*1+YY] += fiy1;
553 f[i_coord_offset+DIM*1+ZZ] += fiz1;
557 f[i_coord_offset+DIM*2+XX] += fix2;
558 f[i_coord_offset+DIM*2+YY] += fiy2;
559 f[i_coord_offset+DIM*2+ZZ] += fiz2;
563 fshift[i_shift_offset+XX] += tx;
564 fshift[i_shift_offset+YY] += ty;
565 fshift[i_shift_offset+ZZ] += tz;
568 /* Update potential energies */
569 kernel_data->energygrp_elec[ggid] += velecsum;
570 kernel_data->energygrp_vdw[ggid] += vvdwsum;
572 /* Increment number of inner iterations */
573 inneriter += j_index_end - j_index_start;
575 /* Outer loop uses 32 flops */
578 /* Increment number of outer iterations */
581 /* Update outer/inner flops */
583 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*313);
586 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3W3_F_c
587 * Electrostatics interaction: ReactionField
588 * VdW interaction: CubicSplineTable
589 * Geometry: Water3-Water3
590 * Calculate force/pot: Force
593 nb_kernel_ElecRF_VdwCSTab_GeomW3W3_F_c
594 (t_nblist * gmx_restrict nlist,
595 rvec * gmx_restrict xx,
596 rvec * gmx_restrict ff,
597 t_forcerec * gmx_restrict fr,
598 t_mdatoms * gmx_restrict mdatoms,
599 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
600 t_nrnb * gmx_restrict nrnb)
602 int i_shift_offset,i_coord_offset,j_coord_offset;
603 int j_index_start,j_index_end;
604 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
605 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
606 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
607 real *shiftvec,*fshift,*x,*f;
609 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
611 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
613 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
615 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
617 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
619 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
620 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
621 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
622 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
623 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
624 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
625 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
626 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
627 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
628 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
629 real velec,felec,velecsum,facel,crf,krf,krf2;
632 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
636 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
644 jindex = nlist->jindex;
646 shiftidx = nlist->shift;
648 shiftvec = fr->shift_vec[0];
649 fshift = fr->fshift[0];
651 charge = mdatoms->chargeA;
655 nvdwtype = fr->ntype;
657 vdwtype = mdatoms->typeA;
659 vftab = kernel_data->table_vdw->data;
660 vftabscale = kernel_data->table_vdw->scale;
662 /* Setup water-specific parameters */
663 inr = nlist->iinr[0];
664 iq0 = facel*charge[inr+0];
665 iq1 = facel*charge[inr+1];
666 iq2 = facel*charge[inr+2];
667 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
672 vdwjidx0 = 2*vdwtype[inr+0];
674 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
675 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
688 /* Start outer loop over neighborlists */
689 for(iidx=0; iidx<nri; iidx++)
691 /* Load shift vector for this list */
692 i_shift_offset = DIM*shiftidx[iidx];
693 shX = shiftvec[i_shift_offset+XX];
694 shY = shiftvec[i_shift_offset+YY];
695 shZ = shiftvec[i_shift_offset+ZZ];
697 /* Load limits for loop over neighbors */
698 j_index_start = jindex[iidx];
699 j_index_end = jindex[iidx+1];
701 /* Get outer coordinate index */
703 i_coord_offset = DIM*inr;
705 /* Load i particle coords and add shift vector */
706 ix0 = shX + x[i_coord_offset+DIM*0+XX];
707 iy0 = shY + x[i_coord_offset+DIM*0+YY];
708 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
709 ix1 = shX + x[i_coord_offset+DIM*1+XX];
710 iy1 = shY + x[i_coord_offset+DIM*1+YY];
711 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
712 ix2 = shX + x[i_coord_offset+DIM*2+XX];
713 iy2 = shY + x[i_coord_offset+DIM*2+YY];
714 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
726 /* Start inner kernel loop */
727 for(jidx=j_index_start; jidx<j_index_end; jidx++)
729 /* Get j neighbor index, and coordinate index */
731 j_coord_offset = DIM*jnr;
733 /* load j atom coordinates */
734 jx0 = x[j_coord_offset+DIM*0+XX];
735 jy0 = x[j_coord_offset+DIM*0+YY];
736 jz0 = x[j_coord_offset+DIM*0+ZZ];
737 jx1 = x[j_coord_offset+DIM*1+XX];
738 jy1 = x[j_coord_offset+DIM*1+YY];
739 jz1 = x[j_coord_offset+DIM*1+ZZ];
740 jx2 = x[j_coord_offset+DIM*2+XX];
741 jy2 = x[j_coord_offset+DIM*2+YY];
742 jz2 = x[j_coord_offset+DIM*2+ZZ];
744 /* Calculate displacement vector */
773 /* Calculate squared distance and things based on it */
774 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
775 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
776 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
777 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
778 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
779 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
780 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
781 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
782 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
784 rinv00 = gmx_invsqrt(rsq00);
785 rinv01 = gmx_invsqrt(rsq01);
786 rinv02 = gmx_invsqrt(rsq02);
787 rinv10 = gmx_invsqrt(rsq10);
788 rinv11 = gmx_invsqrt(rsq11);
789 rinv12 = gmx_invsqrt(rsq12);
790 rinv20 = gmx_invsqrt(rsq20);
791 rinv21 = gmx_invsqrt(rsq21);
792 rinv22 = gmx_invsqrt(rsq22);
794 rinvsq00 = rinv00*rinv00;
795 rinvsq01 = rinv01*rinv01;
796 rinvsq02 = rinv02*rinv02;
797 rinvsq10 = rinv10*rinv10;
798 rinvsq11 = rinv11*rinv11;
799 rinvsq12 = rinv12*rinv12;
800 rinvsq20 = rinv20*rinv20;
801 rinvsq21 = rinv21*rinv21;
802 rinvsq22 = rinv22*rinv22;
804 /**************************
805 * CALCULATE INTERACTIONS *
806 **************************/
810 /* Calculate table index by multiplying r with table scale and truncate to integer */
816 /* REACTION-FIELD ELECTROSTATICS */
817 felec = qq00*(rinv00*rinvsq00-krf2);
819 /* CUBIC SPLINE TABLE DISPERSION */
822 Geps = vfeps*vftab[vfitab+2];
823 Heps2 = vfeps*vfeps*vftab[vfitab+3];
825 FF = Fp+Geps+2.0*Heps2;
828 /* CUBIC SPLINE TABLE REPULSION */
830 Geps = vfeps*vftab[vfitab+6];
831 Heps2 = vfeps*vfeps*vftab[vfitab+7];
833 FF = Fp+Geps+2.0*Heps2;
835 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
839 /* Calculate temporary vectorial force */
844 /* Update vectorial force */
848 f[j_coord_offset+DIM*0+XX] -= tx;
849 f[j_coord_offset+DIM*0+YY] -= ty;
850 f[j_coord_offset+DIM*0+ZZ] -= tz;
852 /**************************
853 * CALCULATE INTERACTIONS *
854 **************************/
856 /* REACTION-FIELD ELECTROSTATICS */
857 felec = qq01*(rinv01*rinvsq01-krf2);
861 /* Calculate temporary vectorial force */
866 /* Update vectorial force */
870 f[j_coord_offset+DIM*1+XX] -= tx;
871 f[j_coord_offset+DIM*1+YY] -= ty;
872 f[j_coord_offset+DIM*1+ZZ] -= tz;
874 /**************************
875 * CALCULATE INTERACTIONS *
876 **************************/
878 /* REACTION-FIELD ELECTROSTATICS */
879 felec = qq02*(rinv02*rinvsq02-krf2);
883 /* Calculate temporary vectorial force */
888 /* Update vectorial force */
892 f[j_coord_offset+DIM*2+XX] -= tx;
893 f[j_coord_offset+DIM*2+YY] -= ty;
894 f[j_coord_offset+DIM*2+ZZ] -= tz;
896 /**************************
897 * CALCULATE INTERACTIONS *
898 **************************/
900 /* REACTION-FIELD ELECTROSTATICS */
901 felec = qq10*(rinv10*rinvsq10-krf2);
905 /* Calculate temporary vectorial force */
910 /* Update vectorial force */
914 f[j_coord_offset+DIM*0+XX] -= tx;
915 f[j_coord_offset+DIM*0+YY] -= ty;
916 f[j_coord_offset+DIM*0+ZZ] -= tz;
918 /**************************
919 * CALCULATE INTERACTIONS *
920 **************************/
922 /* REACTION-FIELD ELECTROSTATICS */
923 felec = qq11*(rinv11*rinvsq11-krf2);
927 /* Calculate temporary vectorial force */
932 /* Update vectorial force */
936 f[j_coord_offset+DIM*1+XX] -= tx;
937 f[j_coord_offset+DIM*1+YY] -= ty;
938 f[j_coord_offset+DIM*1+ZZ] -= tz;
940 /**************************
941 * CALCULATE INTERACTIONS *
942 **************************/
944 /* REACTION-FIELD ELECTROSTATICS */
945 felec = qq12*(rinv12*rinvsq12-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;
962 /**************************
963 * CALCULATE INTERACTIONS *
964 **************************/
966 /* REACTION-FIELD ELECTROSTATICS */
967 felec = qq20*(rinv20*rinvsq20-krf2);
971 /* Calculate temporary vectorial force */
976 /* Update vectorial force */
980 f[j_coord_offset+DIM*0+XX] -= tx;
981 f[j_coord_offset+DIM*0+YY] -= ty;
982 f[j_coord_offset+DIM*0+ZZ] -= tz;
984 /**************************
985 * CALCULATE INTERACTIONS *
986 **************************/
988 /* REACTION-FIELD ELECTROSTATICS */
989 felec = qq21*(rinv21*rinvsq21-krf2);
993 /* Calculate temporary vectorial force */
998 /* Update vectorial force */
1002 f[j_coord_offset+DIM*1+XX] -= tx;
1003 f[j_coord_offset+DIM*1+YY] -= ty;
1004 f[j_coord_offset+DIM*1+ZZ] -= tz;
1006 /**************************
1007 * CALCULATE INTERACTIONS *
1008 **************************/
1010 /* REACTION-FIELD ELECTROSTATICS */
1011 felec = qq22*(rinv22*rinvsq22-krf2);
1015 /* Calculate temporary vectorial force */
1020 /* Update vectorial force */
1024 f[j_coord_offset+DIM*2+XX] -= tx;
1025 f[j_coord_offset+DIM*2+YY] -= ty;
1026 f[j_coord_offset+DIM*2+ZZ] -= tz;
1028 /* Inner loop uses 260 flops */
1030 /* End of innermost loop */
1033 f[i_coord_offset+DIM*0+XX] += fix0;
1034 f[i_coord_offset+DIM*0+YY] += fiy0;
1035 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1039 f[i_coord_offset+DIM*1+XX] += fix1;
1040 f[i_coord_offset+DIM*1+YY] += fiy1;
1041 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1045 f[i_coord_offset+DIM*2+XX] += fix2;
1046 f[i_coord_offset+DIM*2+YY] += fiy2;
1047 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1051 fshift[i_shift_offset+XX] += tx;
1052 fshift[i_shift_offset+YY] += ty;
1053 fshift[i_shift_offset+ZZ] += tz;
1055 /* Increment number of inner iterations */
1056 inneriter += j_index_end - j_index_start;
1058 /* Outer loop uses 30 flops */
1061 /* Increment number of outer iterations */
1064 /* Update outer/inner flops */
1066 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*260);