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_ElecCoul_VdwCSTab_GeomW4W4_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_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;
105 nvdwtype = fr->ntype;
107 vdwtype = mdatoms->typeA;
109 vftab = kernel_data->table_vdw->data;
110 vftabscale = kernel_data->table_vdw->scale;
112 /* Setup water-specific parameters */
113 inr = nlist->iinr[0];
114 iq1 = facel*charge[inr+1];
115 iq2 = facel*charge[inr+2];
116 iq3 = facel*charge[inr+3];
117 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
122 vdwjidx0 = 2*vdwtype[inr+0];
123 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
124 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
138 /* Start outer loop over neighborlists */
139 for(iidx=0; iidx<nri; iidx++)
141 /* Load shift vector for this list */
142 i_shift_offset = DIM*shiftidx[iidx];
143 shX = shiftvec[i_shift_offset+XX];
144 shY = shiftvec[i_shift_offset+YY];
145 shZ = shiftvec[i_shift_offset+ZZ];
147 /* Load limits for loop over neighbors */
148 j_index_start = jindex[iidx];
149 j_index_end = jindex[iidx+1];
151 /* Get outer coordinate index */
153 i_coord_offset = DIM*inr;
155 /* Load i particle coords and add shift vector */
156 ix0 = shX + x[i_coord_offset+DIM*0+XX];
157 iy0 = shY + x[i_coord_offset+DIM*0+YY];
158 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
159 ix1 = shX + x[i_coord_offset+DIM*1+XX];
160 iy1 = shY + x[i_coord_offset+DIM*1+YY];
161 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
162 ix2 = shX + x[i_coord_offset+DIM*2+XX];
163 iy2 = shY + x[i_coord_offset+DIM*2+YY];
164 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
165 ix3 = shX + x[i_coord_offset+DIM*3+XX];
166 iy3 = shY + x[i_coord_offset+DIM*3+YY];
167 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
182 /* Reset potential sums */
186 /* Start inner kernel loop */
187 for(jidx=j_index_start; jidx<j_index_end; jidx++)
189 /* Get j neighbor index, and coordinate index */
191 j_coord_offset = DIM*jnr;
193 /* load j atom coordinates */
194 jx0 = x[j_coord_offset+DIM*0+XX];
195 jy0 = x[j_coord_offset+DIM*0+YY];
196 jz0 = x[j_coord_offset+DIM*0+ZZ];
197 jx1 = x[j_coord_offset+DIM*1+XX];
198 jy1 = x[j_coord_offset+DIM*1+YY];
199 jz1 = x[j_coord_offset+DIM*1+ZZ];
200 jx2 = x[j_coord_offset+DIM*2+XX];
201 jy2 = x[j_coord_offset+DIM*2+YY];
202 jz2 = x[j_coord_offset+DIM*2+ZZ];
203 jx3 = x[j_coord_offset+DIM*3+XX];
204 jy3 = x[j_coord_offset+DIM*3+YY];
205 jz3 = x[j_coord_offset+DIM*3+ZZ];
207 /* Calculate displacement vector */
239 /* Calculate squared distance and things based on it */
240 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
241 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
242 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
243 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
244 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
245 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
246 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
247 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
248 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
249 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
251 rinv00 = gmx_invsqrt(rsq00);
252 rinv11 = gmx_invsqrt(rsq11);
253 rinv12 = gmx_invsqrt(rsq12);
254 rinv13 = gmx_invsqrt(rsq13);
255 rinv21 = gmx_invsqrt(rsq21);
256 rinv22 = gmx_invsqrt(rsq22);
257 rinv23 = gmx_invsqrt(rsq23);
258 rinv31 = gmx_invsqrt(rsq31);
259 rinv32 = gmx_invsqrt(rsq32);
260 rinv33 = gmx_invsqrt(rsq33);
262 rinvsq11 = rinv11*rinv11;
263 rinvsq12 = rinv12*rinv12;
264 rinvsq13 = rinv13*rinv13;
265 rinvsq21 = rinv21*rinv21;
266 rinvsq22 = rinv22*rinv22;
267 rinvsq23 = rinv23*rinv23;
268 rinvsq31 = rinv31*rinv31;
269 rinvsq32 = rinv32*rinv32;
270 rinvsq33 = rinv33*rinv33;
272 /**************************
273 * CALCULATE INTERACTIONS *
274 **************************/
278 /* Calculate table index by multiplying r with table scale and truncate to integer */
284 /* CUBIC SPLINE TABLE DISPERSION */
288 Geps = vfeps*vftab[vfitab+2];
289 Heps2 = vfeps*vfeps*vftab[vfitab+3];
293 FF = Fp+Geps+2.0*Heps2;
296 /* CUBIC SPLINE TABLE REPULSION */
299 Geps = vfeps*vftab[vfitab+6];
300 Heps2 = vfeps*vfeps*vftab[vfitab+7];
304 FF = Fp+Geps+2.0*Heps2;
307 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
309 /* Update potential sums from outer loop */
314 /* Calculate temporary vectorial force */
319 /* Update vectorial force */
323 f[j_coord_offset+DIM*0+XX] -= tx;
324 f[j_coord_offset+DIM*0+YY] -= ty;
325 f[j_coord_offset+DIM*0+ZZ] -= tz;
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
331 /* COULOMB ELECTROSTATICS */
333 felec = velec*rinvsq11;
335 /* Update potential sums from outer loop */
340 /* Calculate temporary vectorial force */
345 /* Update vectorial force */
349 f[j_coord_offset+DIM*1+XX] -= tx;
350 f[j_coord_offset+DIM*1+YY] -= ty;
351 f[j_coord_offset+DIM*1+ZZ] -= tz;
353 /**************************
354 * CALCULATE INTERACTIONS *
355 **************************/
357 /* COULOMB ELECTROSTATICS */
359 felec = velec*rinvsq12;
361 /* Update potential sums from outer loop */
366 /* Calculate temporary vectorial force */
371 /* Update vectorial force */
375 f[j_coord_offset+DIM*2+XX] -= tx;
376 f[j_coord_offset+DIM*2+YY] -= ty;
377 f[j_coord_offset+DIM*2+ZZ] -= tz;
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
383 /* COULOMB ELECTROSTATICS */
385 felec = velec*rinvsq13;
387 /* Update potential sums from outer loop */
392 /* Calculate temporary vectorial force */
397 /* Update vectorial force */
401 f[j_coord_offset+DIM*3+XX] -= tx;
402 f[j_coord_offset+DIM*3+YY] -= ty;
403 f[j_coord_offset+DIM*3+ZZ] -= tz;
405 /**************************
406 * CALCULATE INTERACTIONS *
407 **************************/
409 /* COULOMB ELECTROSTATICS */
411 felec = velec*rinvsq21;
413 /* Update potential sums from outer loop */
418 /* Calculate temporary vectorial force */
423 /* Update vectorial force */
427 f[j_coord_offset+DIM*1+XX] -= tx;
428 f[j_coord_offset+DIM*1+YY] -= ty;
429 f[j_coord_offset+DIM*1+ZZ] -= tz;
431 /**************************
432 * CALCULATE INTERACTIONS *
433 **************************/
435 /* COULOMB ELECTROSTATICS */
437 felec = velec*rinvsq22;
439 /* Update potential sums from outer loop */
444 /* Calculate temporary vectorial force */
449 /* Update vectorial force */
453 f[j_coord_offset+DIM*2+XX] -= tx;
454 f[j_coord_offset+DIM*2+YY] -= ty;
455 f[j_coord_offset+DIM*2+ZZ] -= tz;
457 /**************************
458 * CALCULATE INTERACTIONS *
459 **************************/
461 /* COULOMB ELECTROSTATICS */
463 felec = velec*rinvsq23;
465 /* Update potential sums from outer loop */
470 /* Calculate temporary vectorial force */
475 /* Update vectorial force */
479 f[j_coord_offset+DIM*3+XX] -= tx;
480 f[j_coord_offset+DIM*3+YY] -= ty;
481 f[j_coord_offset+DIM*3+ZZ] -= tz;
483 /**************************
484 * CALCULATE INTERACTIONS *
485 **************************/
487 /* COULOMB ELECTROSTATICS */
489 felec = velec*rinvsq31;
491 /* Update potential sums from outer loop */
496 /* Calculate temporary vectorial force */
501 /* Update vectorial force */
505 f[j_coord_offset+DIM*1+XX] -= tx;
506 f[j_coord_offset+DIM*1+YY] -= ty;
507 f[j_coord_offset+DIM*1+ZZ] -= tz;
509 /**************************
510 * CALCULATE INTERACTIONS *
511 **************************/
513 /* COULOMB ELECTROSTATICS */
515 felec = velec*rinvsq32;
517 /* Update potential sums from outer loop */
522 /* Calculate temporary vectorial force */
527 /* Update vectorial force */
531 f[j_coord_offset+DIM*2+XX] -= tx;
532 f[j_coord_offset+DIM*2+YY] -= ty;
533 f[j_coord_offset+DIM*2+ZZ] -= tz;
535 /**************************
536 * CALCULATE INTERACTIONS *
537 **************************/
539 /* COULOMB ELECTROSTATICS */
541 felec = velec*rinvsq33;
543 /* Update potential sums from outer loop */
548 /* Calculate temporary vectorial force */
553 /* Update vectorial force */
557 f[j_coord_offset+DIM*3+XX] -= tx;
558 f[j_coord_offset+DIM*3+YY] -= ty;
559 f[j_coord_offset+DIM*3+ZZ] -= tz;
561 /* Inner loop uses 298 flops */
563 /* End of innermost loop */
566 f[i_coord_offset+DIM*0+XX] += fix0;
567 f[i_coord_offset+DIM*0+YY] += fiy0;
568 f[i_coord_offset+DIM*0+ZZ] += fiz0;
572 f[i_coord_offset+DIM*1+XX] += fix1;
573 f[i_coord_offset+DIM*1+YY] += fiy1;
574 f[i_coord_offset+DIM*1+ZZ] += fiz1;
578 f[i_coord_offset+DIM*2+XX] += fix2;
579 f[i_coord_offset+DIM*2+YY] += fiy2;
580 f[i_coord_offset+DIM*2+ZZ] += fiz2;
584 f[i_coord_offset+DIM*3+XX] += fix3;
585 f[i_coord_offset+DIM*3+YY] += fiy3;
586 f[i_coord_offset+DIM*3+ZZ] += fiz3;
590 fshift[i_shift_offset+XX] += tx;
591 fshift[i_shift_offset+YY] += ty;
592 fshift[i_shift_offset+ZZ] += tz;
595 /* Update potential energies */
596 kernel_data->energygrp_elec[ggid] += velecsum;
597 kernel_data->energygrp_vdw[ggid] += vvdwsum;
599 /* Increment number of inner iterations */
600 inneriter += j_index_end - j_index_start;
602 /* Outer loop uses 41 flops */
605 /* Increment number of outer iterations */
608 /* Update outer/inner flops */
610 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*298);
613 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_F_c
614 * Electrostatics interaction: Coulomb
615 * VdW interaction: CubicSplineTable
616 * Geometry: Water4-Water4
617 * Calculate force/pot: Force
620 nb_kernel_ElecCoul_VdwCSTab_GeomW4W4_F_c
621 (t_nblist * gmx_restrict nlist,
622 rvec * gmx_restrict xx,
623 rvec * gmx_restrict ff,
624 t_forcerec * gmx_restrict fr,
625 t_mdatoms * gmx_restrict mdatoms,
626 nb_kernel_data_t * gmx_restrict kernel_data,
627 t_nrnb * gmx_restrict nrnb)
629 int i_shift_offset,i_coord_offset,j_coord_offset;
630 int j_index_start,j_index_end;
631 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
632 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
633 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
634 real *shiftvec,*fshift,*x,*f;
636 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
638 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
640 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
642 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
644 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
646 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
648 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
650 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
651 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
652 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
653 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
654 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
655 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
656 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
657 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
658 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
659 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
660 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
661 real velec,felec,velecsum,facel,crf,krf,krf2;
664 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
668 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
676 jindex = nlist->jindex;
678 shiftidx = nlist->shift;
680 shiftvec = fr->shift_vec[0];
681 fshift = fr->fshift[0];
683 charge = mdatoms->chargeA;
684 nvdwtype = fr->ntype;
686 vdwtype = mdatoms->typeA;
688 vftab = kernel_data->table_vdw->data;
689 vftabscale = kernel_data->table_vdw->scale;
691 /* Setup water-specific parameters */
692 inr = nlist->iinr[0];
693 iq1 = facel*charge[inr+1];
694 iq2 = facel*charge[inr+2];
695 iq3 = facel*charge[inr+3];
696 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
701 vdwjidx0 = 2*vdwtype[inr+0];
702 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
703 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
717 /* Start outer loop over neighborlists */
718 for(iidx=0; iidx<nri; iidx++)
720 /* Load shift vector for this list */
721 i_shift_offset = DIM*shiftidx[iidx];
722 shX = shiftvec[i_shift_offset+XX];
723 shY = shiftvec[i_shift_offset+YY];
724 shZ = shiftvec[i_shift_offset+ZZ];
726 /* Load limits for loop over neighbors */
727 j_index_start = jindex[iidx];
728 j_index_end = jindex[iidx+1];
730 /* Get outer coordinate index */
732 i_coord_offset = DIM*inr;
734 /* Load i particle coords and add shift vector */
735 ix0 = shX + x[i_coord_offset+DIM*0+XX];
736 iy0 = shY + x[i_coord_offset+DIM*0+YY];
737 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
738 ix1 = shX + x[i_coord_offset+DIM*1+XX];
739 iy1 = shY + x[i_coord_offset+DIM*1+YY];
740 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
741 ix2 = shX + x[i_coord_offset+DIM*2+XX];
742 iy2 = shY + x[i_coord_offset+DIM*2+YY];
743 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
744 ix3 = shX + x[i_coord_offset+DIM*3+XX];
745 iy3 = shY + x[i_coord_offset+DIM*3+YY];
746 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
761 /* Start inner kernel loop */
762 for(jidx=j_index_start; jidx<j_index_end; jidx++)
764 /* Get j neighbor index, and coordinate index */
766 j_coord_offset = DIM*jnr;
768 /* load j atom coordinates */
769 jx0 = x[j_coord_offset+DIM*0+XX];
770 jy0 = x[j_coord_offset+DIM*0+YY];
771 jz0 = x[j_coord_offset+DIM*0+ZZ];
772 jx1 = x[j_coord_offset+DIM*1+XX];
773 jy1 = x[j_coord_offset+DIM*1+YY];
774 jz1 = x[j_coord_offset+DIM*1+ZZ];
775 jx2 = x[j_coord_offset+DIM*2+XX];
776 jy2 = x[j_coord_offset+DIM*2+YY];
777 jz2 = x[j_coord_offset+DIM*2+ZZ];
778 jx3 = x[j_coord_offset+DIM*3+XX];
779 jy3 = x[j_coord_offset+DIM*3+YY];
780 jz3 = x[j_coord_offset+DIM*3+ZZ];
782 /* Calculate displacement vector */
814 /* Calculate squared distance and things based on it */
815 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
816 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
817 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
818 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
819 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
820 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
821 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
822 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
823 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
824 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
826 rinv00 = gmx_invsqrt(rsq00);
827 rinv11 = gmx_invsqrt(rsq11);
828 rinv12 = gmx_invsqrt(rsq12);
829 rinv13 = gmx_invsqrt(rsq13);
830 rinv21 = gmx_invsqrt(rsq21);
831 rinv22 = gmx_invsqrt(rsq22);
832 rinv23 = gmx_invsqrt(rsq23);
833 rinv31 = gmx_invsqrt(rsq31);
834 rinv32 = gmx_invsqrt(rsq32);
835 rinv33 = gmx_invsqrt(rsq33);
837 rinvsq11 = rinv11*rinv11;
838 rinvsq12 = rinv12*rinv12;
839 rinvsq13 = rinv13*rinv13;
840 rinvsq21 = rinv21*rinv21;
841 rinvsq22 = rinv22*rinv22;
842 rinvsq23 = rinv23*rinv23;
843 rinvsq31 = rinv31*rinv31;
844 rinvsq32 = rinv32*rinv32;
845 rinvsq33 = rinv33*rinv33;
847 /**************************
848 * CALCULATE INTERACTIONS *
849 **************************/
853 /* Calculate table index by multiplying r with table scale and truncate to integer */
859 /* CUBIC SPLINE TABLE DISPERSION */
862 Geps = vfeps*vftab[vfitab+2];
863 Heps2 = vfeps*vfeps*vftab[vfitab+3];
865 FF = Fp+Geps+2.0*Heps2;
868 /* CUBIC SPLINE TABLE REPULSION */
870 Geps = vfeps*vftab[vfitab+6];
871 Heps2 = vfeps*vfeps*vftab[vfitab+7];
873 FF = Fp+Geps+2.0*Heps2;
875 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
879 /* Calculate temporary vectorial force */
884 /* Update vectorial force */
888 f[j_coord_offset+DIM*0+XX] -= tx;
889 f[j_coord_offset+DIM*0+YY] -= ty;
890 f[j_coord_offset+DIM*0+ZZ] -= tz;
892 /**************************
893 * CALCULATE INTERACTIONS *
894 **************************/
896 /* COULOMB ELECTROSTATICS */
898 felec = velec*rinvsq11;
902 /* Calculate temporary vectorial force */
907 /* Update vectorial force */
911 f[j_coord_offset+DIM*1+XX] -= tx;
912 f[j_coord_offset+DIM*1+YY] -= ty;
913 f[j_coord_offset+DIM*1+ZZ] -= tz;
915 /**************************
916 * CALCULATE INTERACTIONS *
917 **************************/
919 /* COULOMB ELECTROSTATICS */
921 felec = velec*rinvsq12;
925 /* Calculate temporary vectorial force */
930 /* Update vectorial force */
934 f[j_coord_offset+DIM*2+XX] -= tx;
935 f[j_coord_offset+DIM*2+YY] -= ty;
936 f[j_coord_offset+DIM*2+ZZ] -= tz;
938 /**************************
939 * CALCULATE INTERACTIONS *
940 **************************/
942 /* COULOMB ELECTROSTATICS */
944 felec = velec*rinvsq13;
948 /* Calculate temporary vectorial force */
953 /* Update vectorial force */
957 f[j_coord_offset+DIM*3+XX] -= tx;
958 f[j_coord_offset+DIM*3+YY] -= ty;
959 f[j_coord_offset+DIM*3+ZZ] -= tz;
961 /**************************
962 * CALCULATE INTERACTIONS *
963 **************************/
965 /* COULOMB ELECTROSTATICS */
967 felec = velec*rinvsq21;
971 /* Calculate temporary vectorial force */
976 /* Update vectorial force */
980 f[j_coord_offset+DIM*1+XX] -= tx;
981 f[j_coord_offset+DIM*1+YY] -= ty;
982 f[j_coord_offset+DIM*1+ZZ] -= tz;
984 /**************************
985 * CALCULATE INTERACTIONS *
986 **************************/
988 /* COULOMB ELECTROSTATICS */
990 felec = velec*rinvsq22;
994 /* Calculate temporary vectorial force */
999 /* Update vectorial force */
1003 f[j_coord_offset+DIM*2+XX] -= tx;
1004 f[j_coord_offset+DIM*2+YY] -= ty;
1005 f[j_coord_offset+DIM*2+ZZ] -= tz;
1007 /**************************
1008 * CALCULATE INTERACTIONS *
1009 **************************/
1011 /* COULOMB ELECTROSTATICS */
1012 velec = qq23*rinv23;
1013 felec = velec*rinvsq23;
1017 /* Calculate temporary vectorial force */
1022 /* Update vectorial force */
1026 f[j_coord_offset+DIM*3+XX] -= tx;
1027 f[j_coord_offset+DIM*3+YY] -= ty;
1028 f[j_coord_offset+DIM*3+ZZ] -= tz;
1030 /**************************
1031 * CALCULATE INTERACTIONS *
1032 **************************/
1034 /* COULOMB ELECTROSTATICS */
1035 velec = qq31*rinv31;
1036 felec = velec*rinvsq31;
1040 /* Calculate temporary vectorial force */
1045 /* Update vectorial force */
1049 f[j_coord_offset+DIM*1+XX] -= tx;
1050 f[j_coord_offset+DIM*1+YY] -= ty;
1051 f[j_coord_offset+DIM*1+ZZ] -= tz;
1053 /**************************
1054 * CALCULATE INTERACTIONS *
1055 **************************/
1057 /* COULOMB ELECTROSTATICS */
1058 velec = qq32*rinv32;
1059 felec = velec*rinvsq32;
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 /* COULOMB ELECTROSTATICS */
1081 velec = qq33*rinv33;
1082 felec = velec*rinvsq33;
1086 /* Calculate temporary vectorial force */
1091 /* Update vectorial force */
1095 f[j_coord_offset+DIM*3+XX] -= tx;
1096 f[j_coord_offset+DIM*3+YY] -= ty;
1097 f[j_coord_offset+DIM*3+ZZ] -= tz;
1099 /* Inner loop uses 281 flops */
1101 /* End of innermost loop */
1104 f[i_coord_offset+DIM*0+XX] += fix0;
1105 f[i_coord_offset+DIM*0+YY] += fiy0;
1106 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1110 f[i_coord_offset+DIM*1+XX] += fix1;
1111 f[i_coord_offset+DIM*1+YY] += fiy1;
1112 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1116 f[i_coord_offset+DIM*2+XX] += fix2;
1117 f[i_coord_offset+DIM*2+YY] += fiy2;
1118 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1122 f[i_coord_offset+DIM*3+XX] += fix3;
1123 f[i_coord_offset+DIM*3+YY] += fiy3;
1124 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1128 fshift[i_shift_offset+XX] += tx;
1129 fshift[i_shift_offset+YY] += ty;
1130 fshift[i_shift_offset+ZZ] += tz;
1132 /* Increment number of inner iterations */
1133 inneriter += j_index_end - j_index_start;
1135 /* Outer loop uses 39 flops */
1138 /* Increment number of outer iterations */
1141 /* Update outer/inner flops */
1143 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*281);