2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW4W4_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_VdwCSTab_GeomW4W4_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
65 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
67 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
69 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
71 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
72 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
73 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
74 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
75 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
76 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
77 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
78 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
79 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
80 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
81 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
82 real velec,felec,velecsum,facel,crf,krf,krf2;
85 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
89 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
97 jindex = nlist->jindex;
99 shiftidx = nlist->shift;
101 shiftvec = fr->shift_vec[0];
102 fshift = fr->fshift[0];
104 charge = mdatoms->chargeA;
108 nvdwtype = fr->ntype;
110 vdwtype = mdatoms->typeA;
112 vftab = kernel_data->table_vdw->data;
113 vftabscale = kernel_data->table_vdw->scale;
115 /* Setup water-specific parameters */
116 inr = nlist->iinr[0];
117 iq1 = facel*charge[inr+1];
118 iq2 = facel*charge[inr+2];
119 iq3 = facel*charge[inr+3];
120 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
125 vdwjidx0 = 2*vdwtype[inr+0];
126 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
127 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
141 /* Start outer loop over neighborlists */
142 for(iidx=0; iidx<nri; iidx++)
144 /* Load shift vector for this list */
145 i_shift_offset = DIM*shiftidx[iidx];
146 shX = shiftvec[i_shift_offset+XX];
147 shY = shiftvec[i_shift_offset+YY];
148 shZ = shiftvec[i_shift_offset+ZZ];
150 /* Load limits for loop over neighbors */
151 j_index_start = jindex[iidx];
152 j_index_end = jindex[iidx+1];
154 /* Get outer coordinate index */
156 i_coord_offset = DIM*inr;
158 /* Load i particle coords and add shift vector */
159 ix0 = shX + x[i_coord_offset+DIM*0+XX];
160 iy0 = shY + x[i_coord_offset+DIM*0+YY];
161 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
162 ix1 = shX + x[i_coord_offset+DIM*1+XX];
163 iy1 = shY + x[i_coord_offset+DIM*1+YY];
164 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
165 ix2 = shX + x[i_coord_offset+DIM*2+XX];
166 iy2 = shY + x[i_coord_offset+DIM*2+YY];
167 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
168 ix3 = shX + x[i_coord_offset+DIM*3+XX];
169 iy3 = shY + x[i_coord_offset+DIM*3+YY];
170 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
185 /* Reset potential sums */
189 /* Start inner kernel loop */
190 for(jidx=j_index_start; jidx<j_index_end; jidx++)
192 /* Get j neighbor index, and coordinate index */
194 j_coord_offset = DIM*jnr;
196 /* load j atom coordinates */
197 jx0 = x[j_coord_offset+DIM*0+XX];
198 jy0 = x[j_coord_offset+DIM*0+YY];
199 jz0 = x[j_coord_offset+DIM*0+ZZ];
200 jx1 = x[j_coord_offset+DIM*1+XX];
201 jy1 = x[j_coord_offset+DIM*1+YY];
202 jz1 = x[j_coord_offset+DIM*1+ZZ];
203 jx2 = x[j_coord_offset+DIM*2+XX];
204 jy2 = x[j_coord_offset+DIM*2+YY];
205 jz2 = x[j_coord_offset+DIM*2+ZZ];
206 jx3 = x[j_coord_offset+DIM*3+XX];
207 jy3 = x[j_coord_offset+DIM*3+YY];
208 jz3 = x[j_coord_offset+DIM*3+ZZ];
210 /* Calculate displacement vector */
242 /* Calculate squared distance and things based on it */
243 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
244 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
245 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
246 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
247 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
248 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
249 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
250 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
251 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
252 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
254 rinv00 = gmx_invsqrt(rsq00);
255 rinv11 = gmx_invsqrt(rsq11);
256 rinv12 = gmx_invsqrt(rsq12);
257 rinv13 = gmx_invsqrt(rsq13);
258 rinv21 = gmx_invsqrt(rsq21);
259 rinv22 = gmx_invsqrt(rsq22);
260 rinv23 = gmx_invsqrt(rsq23);
261 rinv31 = gmx_invsqrt(rsq31);
262 rinv32 = gmx_invsqrt(rsq32);
263 rinv33 = gmx_invsqrt(rsq33);
265 rinvsq11 = rinv11*rinv11;
266 rinvsq12 = rinv12*rinv12;
267 rinvsq13 = rinv13*rinv13;
268 rinvsq21 = rinv21*rinv21;
269 rinvsq22 = rinv22*rinv22;
270 rinvsq23 = rinv23*rinv23;
271 rinvsq31 = rinv31*rinv31;
272 rinvsq32 = rinv32*rinv32;
273 rinvsq33 = rinv33*rinv33;
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
281 /* Calculate table index by multiplying r with table scale and truncate to integer */
287 /* CUBIC SPLINE TABLE DISPERSION */
291 Geps = vfeps*vftab[vfitab+2];
292 Heps2 = vfeps*vfeps*vftab[vfitab+3];
296 FF = Fp+Geps+2.0*Heps2;
299 /* CUBIC SPLINE TABLE REPULSION */
302 Geps = vfeps*vftab[vfitab+6];
303 Heps2 = vfeps*vfeps*vftab[vfitab+7];
307 FF = Fp+Geps+2.0*Heps2;
310 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
312 /* Update potential sums from outer loop */
317 /* Calculate temporary vectorial force */
322 /* Update vectorial force */
326 f[j_coord_offset+DIM*0+XX] -= tx;
327 f[j_coord_offset+DIM*0+YY] -= ty;
328 f[j_coord_offset+DIM*0+ZZ] -= tz;
330 /**************************
331 * CALCULATE INTERACTIONS *
332 **************************/
334 /* REACTION-FIELD ELECTROSTATICS */
335 velec = qq11*(rinv11+krf*rsq11-crf);
336 felec = qq11*(rinv11*rinvsq11-krf2);
338 /* Update potential sums from outer loop */
343 /* Calculate temporary vectorial force */
348 /* Update vectorial force */
352 f[j_coord_offset+DIM*1+XX] -= tx;
353 f[j_coord_offset+DIM*1+YY] -= ty;
354 f[j_coord_offset+DIM*1+ZZ] -= tz;
356 /**************************
357 * CALCULATE INTERACTIONS *
358 **************************/
360 /* REACTION-FIELD ELECTROSTATICS */
361 velec = qq12*(rinv12+krf*rsq12-crf);
362 felec = qq12*(rinv12*rinvsq12-krf2);
364 /* Update potential sums from outer loop */
369 /* Calculate temporary vectorial force */
374 /* Update vectorial force */
378 f[j_coord_offset+DIM*2+XX] -= tx;
379 f[j_coord_offset+DIM*2+YY] -= ty;
380 f[j_coord_offset+DIM*2+ZZ] -= tz;
382 /**************************
383 * CALCULATE INTERACTIONS *
384 **************************/
386 /* REACTION-FIELD ELECTROSTATICS */
387 velec = qq13*(rinv13+krf*rsq13-crf);
388 felec = qq13*(rinv13*rinvsq13-krf2);
390 /* Update potential sums from outer loop */
395 /* Calculate temporary vectorial force */
400 /* Update vectorial force */
404 f[j_coord_offset+DIM*3+XX] -= tx;
405 f[j_coord_offset+DIM*3+YY] -= ty;
406 f[j_coord_offset+DIM*3+ZZ] -= tz;
408 /**************************
409 * CALCULATE INTERACTIONS *
410 **************************/
412 /* REACTION-FIELD ELECTROSTATICS */
413 velec = qq21*(rinv21+krf*rsq21-crf);
414 felec = qq21*(rinv21*rinvsq21-krf2);
416 /* Update potential sums from outer loop */
421 /* Calculate temporary vectorial force */
426 /* Update vectorial force */
430 f[j_coord_offset+DIM*1+XX] -= tx;
431 f[j_coord_offset+DIM*1+YY] -= ty;
432 f[j_coord_offset+DIM*1+ZZ] -= tz;
434 /**************************
435 * CALCULATE INTERACTIONS *
436 **************************/
438 /* REACTION-FIELD ELECTROSTATICS */
439 velec = qq22*(rinv22+krf*rsq22-crf);
440 felec = qq22*(rinv22*rinvsq22-krf2);
442 /* Update potential sums from outer loop */
447 /* Calculate temporary vectorial force */
452 /* Update vectorial force */
456 f[j_coord_offset+DIM*2+XX] -= tx;
457 f[j_coord_offset+DIM*2+YY] -= ty;
458 f[j_coord_offset+DIM*2+ZZ] -= tz;
460 /**************************
461 * CALCULATE INTERACTIONS *
462 **************************/
464 /* REACTION-FIELD ELECTROSTATICS */
465 velec = qq23*(rinv23+krf*rsq23-crf);
466 felec = qq23*(rinv23*rinvsq23-krf2);
468 /* Update potential sums from outer loop */
473 /* Calculate temporary vectorial force */
478 /* Update vectorial force */
482 f[j_coord_offset+DIM*3+XX] -= tx;
483 f[j_coord_offset+DIM*3+YY] -= ty;
484 f[j_coord_offset+DIM*3+ZZ] -= tz;
486 /**************************
487 * CALCULATE INTERACTIONS *
488 **************************/
490 /* REACTION-FIELD ELECTROSTATICS */
491 velec = qq31*(rinv31+krf*rsq31-crf);
492 felec = qq31*(rinv31*rinvsq31-krf2);
494 /* Update potential sums from outer loop */
499 /* Calculate temporary vectorial force */
504 /* Update vectorial force */
508 f[j_coord_offset+DIM*1+XX] -= tx;
509 f[j_coord_offset+DIM*1+YY] -= ty;
510 f[j_coord_offset+DIM*1+ZZ] -= tz;
512 /**************************
513 * CALCULATE INTERACTIONS *
514 **************************/
516 /* REACTION-FIELD ELECTROSTATICS */
517 velec = qq32*(rinv32+krf*rsq32-crf);
518 felec = qq32*(rinv32*rinvsq32-krf2);
520 /* Update potential sums from outer loop */
525 /* Calculate temporary vectorial force */
530 /* Update vectorial force */
534 f[j_coord_offset+DIM*2+XX] -= tx;
535 f[j_coord_offset+DIM*2+YY] -= ty;
536 f[j_coord_offset+DIM*2+ZZ] -= tz;
538 /**************************
539 * CALCULATE INTERACTIONS *
540 **************************/
542 /* REACTION-FIELD ELECTROSTATICS */
543 velec = qq33*(rinv33+krf*rsq33-crf);
544 felec = qq33*(rinv33*rinvsq33-krf2);
546 /* Update potential sums from outer loop */
551 /* Calculate temporary vectorial force */
556 /* Update vectorial force */
560 f[j_coord_offset+DIM*3+XX] -= tx;
561 f[j_coord_offset+DIM*3+YY] -= ty;
562 f[j_coord_offset+DIM*3+ZZ] -= tz;
564 /* Inner loop uses 334 flops */
566 /* End of innermost loop */
569 f[i_coord_offset+DIM*0+XX] += fix0;
570 f[i_coord_offset+DIM*0+YY] += fiy0;
571 f[i_coord_offset+DIM*0+ZZ] += fiz0;
575 f[i_coord_offset+DIM*1+XX] += fix1;
576 f[i_coord_offset+DIM*1+YY] += fiy1;
577 f[i_coord_offset+DIM*1+ZZ] += fiz1;
581 f[i_coord_offset+DIM*2+XX] += fix2;
582 f[i_coord_offset+DIM*2+YY] += fiy2;
583 f[i_coord_offset+DIM*2+ZZ] += fiz2;
587 f[i_coord_offset+DIM*3+XX] += fix3;
588 f[i_coord_offset+DIM*3+YY] += fiy3;
589 f[i_coord_offset+DIM*3+ZZ] += fiz3;
593 fshift[i_shift_offset+XX] += tx;
594 fshift[i_shift_offset+YY] += ty;
595 fshift[i_shift_offset+ZZ] += tz;
598 /* Update potential energies */
599 kernel_data->energygrp_elec[ggid] += velecsum;
600 kernel_data->energygrp_vdw[ggid] += vvdwsum;
602 /* Increment number of inner iterations */
603 inneriter += j_index_end - j_index_start;
605 /* Outer loop uses 41 flops */
608 /* Increment number of outer iterations */
611 /* Update outer/inner flops */
613 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*334);
616 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_c
617 * Electrostatics interaction: ReactionField
618 * VdW interaction: CubicSplineTable
619 * Geometry: Water4-Water4
620 * Calculate force/pot: Force
623 nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_c
624 (t_nblist * gmx_restrict nlist,
625 rvec * gmx_restrict xx,
626 rvec * gmx_restrict ff,
627 t_forcerec * gmx_restrict fr,
628 t_mdatoms * gmx_restrict mdatoms,
629 nb_kernel_data_t * gmx_restrict kernel_data,
630 t_nrnb * gmx_restrict nrnb)
632 int i_shift_offset,i_coord_offset,j_coord_offset;
633 int j_index_start,j_index_end;
634 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
635 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
636 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
637 real *shiftvec,*fshift,*x,*f;
639 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
641 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
643 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
645 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
647 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
649 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
651 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
653 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
654 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
655 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
656 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
657 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
658 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
659 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
660 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
661 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
662 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
663 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
664 real velec,felec,velecsum,facel,crf,krf,krf2;
667 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
671 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
679 jindex = nlist->jindex;
681 shiftidx = nlist->shift;
683 shiftvec = fr->shift_vec[0];
684 fshift = fr->fshift[0];
686 charge = mdatoms->chargeA;
690 nvdwtype = fr->ntype;
692 vdwtype = mdatoms->typeA;
694 vftab = kernel_data->table_vdw->data;
695 vftabscale = kernel_data->table_vdw->scale;
697 /* Setup water-specific parameters */
698 inr = nlist->iinr[0];
699 iq1 = facel*charge[inr+1];
700 iq2 = facel*charge[inr+2];
701 iq3 = facel*charge[inr+3];
702 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
707 vdwjidx0 = 2*vdwtype[inr+0];
708 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
709 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
723 /* Start outer loop over neighborlists */
724 for(iidx=0; iidx<nri; iidx++)
726 /* Load shift vector for this list */
727 i_shift_offset = DIM*shiftidx[iidx];
728 shX = shiftvec[i_shift_offset+XX];
729 shY = shiftvec[i_shift_offset+YY];
730 shZ = shiftvec[i_shift_offset+ZZ];
732 /* Load limits for loop over neighbors */
733 j_index_start = jindex[iidx];
734 j_index_end = jindex[iidx+1];
736 /* Get outer coordinate index */
738 i_coord_offset = DIM*inr;
740 /* Load i particle coords and add shift vector */
741 ix0 = shX + x[i_coord_offset+DIM*0+XX];
742 iy0 = shY + x[i_coord_offset+DIM*0+YY];
743 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
744 ix1 = shX + x[i_coord_offset+DIM*1+XX];
745 iy1 = shY + x[i_coord_offset+DIM*1+YY];
746 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
747 ix2 = shX + x[i_coord_offset+DIM*2+XX];
748 iy2 = shY + x[i_coord_offset+DIM*2+YY];
749 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
750 ix3 = shX + x[i_coord_offset+DIM*3+XX];
751 iy3 = shY + x[i_coord_offset+DIM*3+YY];
752 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
767 /* Start inner kernel loop */
768 for(jidx=j_index_start; jidx<j_index_end; jidx++)
770 /* Get j neighbor index, and coordinate index */
772 j_coord_offset = DIM*jnr;
774 /* load j atom coordinates */
775 jx0 = x[j_coord_offset+DIM*0+XX];
776 jy0 = x[j_coord_offset+DIM*0+YY];
777 jz0 = x[j_coord_offset+DIM*0+ZZ];
778 jx1 = x[j_coord_offset+DIM*1+XX];
779 jy1 = x[j_coord_offset+DIM*1+YY];
780 jz1 = x[j_coord_offset+DIM*1+ZZ];
781 jx2 = x[j_coord_offset+DIM*2+XX];
782 jy2 = x[j_coord_offset+DIM*2+YY];
783 jz2 = x[j_coord_offset+DIM*2+ZZ];
784 jx3 = x[j_coord_offset+DIM*3+XX];
785 jy3 = x[j_coord_offset+DIM*3+YY];
786 jz3 = x[j_coord_offset+DIM*3+ZZ];
788 /* Calculate displacement vector */
820 /* Calculate squared distance and things based on it */
821 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
822 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
823 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
824 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
825 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
826 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
827 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
828 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
829 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
830 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
832 rinv00 = gmx_invsqrt(rsq00);
833 rinv11 = gmx_invsqrt(rsq11);
834 rinv12 = gmx_invsqrt(rsq12);
835 rinv13 = gmx_invsqrt(rsq13);
836 rinv21 = gmx_invsqrt(rsq21);
837 rinv22 = gmx_invsqrt(rsq22);
838 rinv23 = gmx_invsqrt(rsq23);
839 rinv31 = gmx_invsqrt(rsq31);
840 rinv32 = gmx_invsqrt(rsq32);
841 rinv33 = gmx_invsqrt(rsq33);
843 rinvsq11 = rinv11*rinv11;
844 rinvsq12 = rinv12*rinv12;
845 rinvsq13 = rinv13*rinv13;
846 rinvsq21 = rinv21*rinv21;
847 rinvsq22 = rinv22*rinv22;
848 rinvsq23 = rinv23*rinv23;
849 rinvsq31 = rinv31*rinv31;
850 rinvsq32 = rinv32*rinv32;
851 rinvsq33 = rinv33*rinv33;
853 /**************************
854 * CALCULATE INTERACTIONS *
855 **************************/
859 /* Calculate table index by multiplying r with table scale and truncate to integer */
865 /* CUBIC SPLINE TABLE DISPERSION */
869 Geps = vfeps*vftab[vfitab+2];
870 Heps2 = vfeps*vfeps*vftab[vfitab+3];
872 FF = Fp+Geps+2.0*Heps2;
875 /* CUBIC SPLINE TABLE REPULSION */
878 Geps = vfeps*vftab[vfitab+6];
879 Heps2 = vfeps*vfeps*vftab[vfitab+7];
881 FF = Fp+Geps+2.0*Heps2;
883 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
887 /* Calculate temporary vectorial force */
892 /* Update vectorial force */
896 f[j_coord_offset+DIM*0+XX] -= tx;
897 f[j_coord_offset+DIM*0+YY] -= ty;
898 f[j_coord_offset+DIM*0+ZZ] -= tz;
900 /**************************
901 * CALCULATE INTERACTIONS *
902 **************************/
904 /* REACTION-FIELD ELECTROSTATICS */
905 felec = qq11*(rinv11*rinvsq11-krf2);
909 /* Calculate temporary vectorial force */
914 /* Update vectorial force */
918 f[j_coord_offset+DIM*1+XX] -= tx;
919 f[j_coord_offset+DIM*1+YY] -= ty;
920 f[j_coord_offset+DIM*1+ZZ] -= tz;
922 /**************************
923 * CALCULATE INTERACTIONS *
924 **************************/
926 /* REACTION-FIELD ELECTROSTATICS */
927 felec = qq12*(rinv12*rinvsq12-krf2);
931 /* Calculate temporary vectorial force */
936 /* Update vectorial force */
940 f[j_coord_offset+DIM*2+XX] -= tx;
941 f[j_coord_offset+DIM*2+YY] -= ty;
942 f[j_coord_offset+DIM*2+ZZ] -= tz;
944 /**************************
945 * CALCULATE INTERACTIONS *
946 **************************/
948 /* REACTION-FIELD ELECTROSTATICS */
949 felec = qq13*(rinv13*rinvsq13-krf2);
953 /* Calculate temporary vectorial force */
958 /* Update vectorial force */
962 f[j_coord_offset+DIM*3+XX] -= tx;
963 f[j_coord_offset+DIM*3+YY] -= ty;
964 f[j_coord_offset+DIM*3+ZZ] -= tz;
966 /**************************
967 * CALCULATE INTERACTIONS *
968 **************************/
970 /* REACTION-FIELD ELECTROSTATICS */
971 felec = qq21*(rinv21*rinvsq21-krf2);
975 /* Calculate temporary vectorial force */
980 /* Update vectorial force */
984 f[j_coord_offset+DIM*1+XX] -= tx;
985 f[j_coord_offset+DIM*1+YY] -= ty;
986 f[j_coord_offset+DIM*1+ZZ] -= tz;
988 /**************************
989 * CALCULATE INTERACTIONS *
990 **************************/
992 /* REACTION-FIELD ELECTROSTATICS */
993 felec = qq22*(rinv22*rinvsq22-krf2);
997 /* Calculate temporary vectorial force */
1002 /* Update vectorial force */
1006 f[j_coord_offset+DIM*2+XX] -= tx;
1007 f[j_coord_offset+DIM*2+YY] -= ty;
1008 f[j_coord_offset+DIM*2+ZZ] -= tz;
1010 /**************************
1011 * CALCULATE INTERACTIONS *
1012 **************************/
1014 /* REACTION-FIELD ELECTROSTATICS */
1015 felec = qq23*(rinv23*rinvsq23-krf2);
1019 /* Calculate temporary vectorial force */
1024 /* Update vectorial force */
1028 f[j_coord_offset+DIM*3+XX] -= tx;
1029 f[j_coord_offset+DIM*3+YY] -= ty;
1030 f[j_coord_offset+DIM*3+ZZ] -= tz;
1032 /**************************
1033 * CALCULATE INTERACTIONS *
1034 **************************/
1036 /* REACTION-FIELD ELECTROSTATICS */
1037 felec = qq31*(rinv31*rinvsq31-krf2);
1041 /* Calculate temporary vectorial force */
1046 /* Update vectorial force */
1050 f[j_coord_offset+DIM*1+XX] -= tx;
1051 f[j_coord_offset+DIM*1+YY] -= ty;
1052 f[j_coord_offset+DIM*1+ZZ] -= tz;
1054 /**************************
1055 * CALCULATE INTERACTIONS *
1056 **************************/
1058 /* REACTION-FIELD ELECTROSTATICS */
1059 felec = qq32*(rinv32*rinvsq32-krf2);
1063 /* Calculate temporary vectorial force */
1068 /* Update vectorial force */
1072 f[j_coord_offset+DIM*2+XX] -= tx;
1073 f[j_coord_offset+DIM*2+YY] -= ty;
1074 f[j_coord_offset+DIM*2+ZZ] -= tz;
1076 /**************************
1077 * CALCULATE INTERACTIONS *
1078 **************************/
1080 /* REACTION-FIELD ELECTROSTATICS */
1081 felec = qq33*(rinv33*rinvsq33-krf2);
1085 /* Calculate temporary vectorial force */
1090 /* Update vectorial force */
1094 f[j_coord_offset+DIM*3+XX] -= tx;
1095 f[j_coord_offset+DIM*3+YY] -= ty;
1096 f[j_coord_offset+DIM*3+ZZ] -= tz;
1098 /* Inner loop uses 281 flops */
1100 /* End of innermost loop */
1103 f[i_coord_offset+DIM*0+XX] += fix0;
1104 f[i_coord_offset+DIM*0+YY] += fiy0;
1105 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1109 f[i_coord_offset+DIM*1+XX] += fix1;
1110 f[i_coord_offset+DIM*1+YY] += fiy1;
1111 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1115 f[i_coord_offset+DIM*2+XX] += fix2;
1116 f[i_coord_offset+DIM*2+YY] += fiy2;
1117 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1121 f[i_coord_offset+DIM*3+XX] += fix3;
1122 f[i_coord_offset+DIM*3+YY] += fiy3;
1123 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1127 fshift[i_shift_offset+XX] += tx;
1128 fshift[i_shift_offset+YY] += ty;
1129 fshift[i_shift_offset+ZZ] += tz;
1131 /* Increment number of inner iterations */
1132 inneriter += j_index_end - j_index_start;
1134 /* Outer loop uses 39 flops */
1137 /* Increment number of outer iterations */
1140 /* Update outer/inner flops */
1142 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*281);