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_ElecRFCut_VdwCSTab_GeomW4W4_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_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];
138 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
139 rcutoff = fr->rcoulomb;
140 rcutoff2 = rcutoff*rcutoff;
145 /* Start outer loop over neighborlists */
146 for(iidx=0; iidx<nri; iidx++)
148 /* Load shift vector for this list */
149 i_shift_offset = DIM*shiftidx[iidx];
150 shX = shiftvec[i_shift_offset+XX];
151 shY = shiftvec[i_shift_offset+YY];
152 shZ = shiftvec[i_shift_offset+ZZ];
154 /* Load limits for loop over neighbors */
155 j_index_start = jindex[iidx];
156 j_index_end = jindex[iidx+1];
158 /* Get outer coordinate index */
160 i_coord_offset = DIM*inr;
162 /* Load i particle coords and add shift vector */
163 ix0 = shX + x[i_coord_offset+DIM*0+XX];
164 iy0 = shY + x[i_coord_offset+DIM*0+YY];
165 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
166 ix1 = shX + x[i_coord_offset+DIM*1+XX];
167 iy1 = shY + x[i_coord_offset+DIM*1+YY];
168 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
169 ix2 = shX + x[i_coord_offset+DIM*2+XX];
170 iy2 = shY + x[i_coord_offset+DIM*2+YY];
171 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
172 ix3 = shX + x[i_coord_offset+DIM*3+XX];
173 iy3 = shY + x[i_coord_offset+DIM*3+YY];
174 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
189 /* Reset potential sums */
193 /* Start inner kernel loop */
194 for(jidx=j_index_start; jidx<j_index_end; jidx++)
196 /* Get j neighbor index, and coordinate index */
198 j_coord_offset = DIM*jnr;
200 /* load j atom coordinates */
201 jx0 = x[j_coord_offset+DIM*0+XX];
202 jy0 = x[j_coord_offset+DIM*0+YY];
203 jz0 = x[j_coord_offset+DIM*0+ZZ];
204 jx1 = x[j_coord_offset+DIM*1+XX];
205 jy1 = x[j_coord_offset+DIM*1+YY];
206 jz1 = x[j_coord_offset+DIM*1+ZZ];
207 jx2 = x[j_coord_offset+DIM*2+XX];
208 jy2 = x[j_coord_offset+DIM*2+YY];
209 jz2 = x[j_coord_offset+DIM*2+ZZ];
210 jx3 = x[j_coord_offset+DIM*3+XX];
211 jy3 = x[j_coord_offset+DIM*3+YY];
212 jz3 = x[j_coord_offset+DIM*3+ZZ];
214 /* Calculate displacement vector */
246 /* Calculate squared distance and things based on it */
247 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
248 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
249 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
250 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
251 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
252 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
253 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
254 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
255 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
256 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
258 rinv00 = gmx_invsqrt(rsq00);
259 rinv11 = gmx_invsqrt(rsq11);
260 rinv12 = gmx_invsqrt(rsq12);
261 rinv13 = gmx_invsqrt(rsq13);
262 rinv21 = gmx_invsqrt(rsq21);
263 rinv22 = gmx_invsqrt(rsq22);
264 rinv23 = gmx_invsqrt(rsq23);
265 rinv31 = gmx_invsqrt(rsq31);
266 rinv32 = gmx_invsqrt(rsq32);
267 rinv33 = gmx_invsqrt(rsq33);
269 rinvsq11 = rinv11*rinv11;
270 rinvsq12 = rinv12*rinv12;
271 rinvsq13 = rinv13*rinv13;
272 rinvsq21 = rinv21*rinv21;
273 rinvsq22 = rinv22*rinv22;
274 rinvsq23 = rinv23*rinv23;
275 rinvsq31 = rinv31*rinv31;
276 rinvsq32 = rinv32*rinv32;
277 rinvsq33 = rinv33*rinv33;
279 /**************************
280 * CALCULATE INTERACTIONS *
281 **************************/
285 /* Calculate table index by multiplying r with table scale and truncate to integer */
291 /* CUBIC SPLINE TABLE DISPERSION */
295 Geps = vfeps*vftab[vfitab+2];
296 Heps2 = vfeps*vfeps*vftab[vfitab+3];
300 FF = Fp+Geps+2.0*Heps2;
303 /* CUBIC SPLINE TABLE REPULSION */
306 Geps = vfeps*vftab[vfitab+6];
307 Heps2 = vfeps*vfeps*vftab[vfitab+7];
311 FF = Fp+Geps+2.0*Heps2;
314 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
316 /* Update potential sums from outer loop */
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*0+XX] -= tx;
331 f[j_coord_offset+DIM*0+YY] -= ty;
332 f[j_coord_offset+DIM*0+ZZ] -= tz;
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
341 /* REACTION-FIELD ELECTROSTATICS */
342 velec = qq11*(rinv11+krf*rsq11-crf);
343 felec = qq11*(rinv11*rinvsq11-krf2);
345 /* Update potential sums from outer loop */
350 /* Calculate temporary vectorial force */
355 /* Update vectorial force */
359 f[j_coord_offset+DIM*1+XX] -= tx;
360 f[j_coord_offset+DIM*1+YY] -= ty;
361 f[j_coord_offset+DIM*1+ZZ] -= tz;
365 /**************************
366 * CALCULATE INTERACTIONS *
367 **************************/
372 /* REACTION-FIELD ELECTROSTATICS */
373 velec = qq12*(rinv12+krf*rsq12-crf);
374 felec = qq12*(rinv12*rinvsq12-krf2);
376 /* Update potential sums from outer loop */
381 /* Calculate temporary vectorial force */
386 /* Update vectorial force */
390 f[j_coord_offset+DIM*2+XX] -= tx;
391 f[j_coord_offset+DIM*2+YY] -= ty;
392 f[j_coord_offset+DIM*2+ZZ] -= tz;
396 /**************************
397 * CALCULATE INTERACTIONS *
398 **************************/
403 /* REACTION-FIELD ELECTROSTATICS */
404 velec = qq13*(rinv13+krf*rsq13-crf);
405 felec = qq13*(rinv13*rinvsq13-krf2);
407 /* Update potential sums from outer loop */
412 /* Calculate temporary vectorial force */
417 /* Update vectorial force */
421 f[j_coord_offset+DIM*3+XX] -= tx;
422 f[j_coord_offset+DIM*3+YY] -= ty;
423 f[j_coord_offset+DIM*3+ZZ] -= tz;
427 /**************************
428 * CALCULATE INTERACTIONS *
429 **************************/
434 /* REACTION-FIELD ELECTROSTATICS */
435 velec = qq21*(rinv21+krf*rsq21-crf);
436 felec = qq21*(rinv21*rinvsq21-krf2);
438 /* Update potential sums from outer loop */
443 /* Calculate temporary vectorial force */
448 /* Update vectorial force */
452 f[j_coord_offset+DIM*1+XX] -= tx;
453 f[j_coord_offset+DIM*1+YY] -= ty;
454 f[j_coord_offset+DIM*1+ZZ] -= tz;
458 /**************************
459 * CALCULATE INTERACTIONS *
460 **************************/
465 /* REACTION-FIELD ELECTROSTATICS */
466 velec = qq22*(rinv22+krf*rsq22-crf);
467 felec = qq22*(rinv22*rinvsq22-krf2);
469 /* Update potential sums from outer loop */
474 /* Calculate temporary vectorial force */
479 /* Update vectorial force */
483 f[j_coord_offset+DIM*2+XX] -= tx;
484 f[j_coord_offset+DIM*2+YY] -= ty;
485 f[j_coord_offset+DIM*2+ZZ] -= tz;
489 /**************************
490 * CALCULATE INTERACTIONS *
491 **************************/
496 /* REACTION-FIELD ELECTROSTATICS */
497 velec = qq23*(rinv23+krf*rsq23-crf);
498 felec = qq23*(rinv23*rinvsq23-krf2);
500 /* Update potential sums from outer loop */
505 /* Calculate temporary vectorial force */
510 /* Update vectorial force */
514 f[j_coord_offset+DIM*3+XX] -= tx;
515 f[j_coord_offset+DIM*3+YY] -= ty;
516 f[j_coord_offset+DIM*3+ZZ] -= tz;
520 /**************************
521 * CALCULATE INTERACTIONS *
522 **************************/
527 /* REACTION-FIELD ELECTROSTATICS */
528 velec = qq31*(rinv31+krf*rsq31-crf);
529 felec = qq31*(rinv31*rinvsq31-krf2);
531 /* Update potential sums from outer loop */
536 /* Calculate temporary vectorial force */
541 /* Update vectorial force */
545 f[j_coord_offset+DIM*1+XX] -= tx;
546 f[j_coord_offset+DIM*1+YY] -= ty;
547 f[j_coord_offset+DIM*1+ZZ] -= tz;
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
558 /* REACTION-FIELD ELECTROSTATICS */
559 velec = qq32*(rinv32+krf*rsq32-crf);
560 felec = qq32*(rinv32*rinvsq32-krf2);
562 /* Update potential sums from outer loop */
567 /* Calculate temporary vectorial force */
572 /* Update vectorial force */
576 f[j_coord_offset+DIM*2+XX] -= tx;
577 f[j_coord_offset+DIM*2+YY] -= ty;
578 f[j_coord_offset+DIM*2+ZZ] -= tz;
582 /**************************
583 * CALCULATE INTERACTIONS *
584 **************************/
589 /* REACTION-FIELD ELECTROSTATICS */
590 velec = qq33*(rinv33+krf*rsq33-crf);
591 felec = qq33*(rinv33*rinvsq33-krf2);
593 /* Update potential sums from outer loop */
598 /* Calculate temporary vectorial force */
603 /* Update vectorial force */
607 f[j_coord_offset+DIM*3+XX] -= tx;
608 f[j_coord_offset+DIM*3+YY] -= ty;
609 f[j_coord_offset+DIM*3+ZZ] -= tz;
613 /* Inner loop uses 334 flops */
615 /* End of innermost loop */
618 f[i_coord_offset+DIM*0+XX] += fix0;
619 f[i_coord_offset+DIM*0+YY] += fiy0;
620 f[i_coord_offset+DIM*0+ZZ] += fiz0;
624 f[i_coord_offset+DIM*1+XX] += fix1;
625 f[i_coord_offset+DIM*1+YY] += fiy1;
626 f[i_coord_offset+DIM*1+ZZ] += fiz1;
630 f[i_coord_offset+DIM*2+XX] += fix2;
631 f[i_coord_offset+DIM*2+YY] += fiy2;
632 f[i_coord_offset+DIM*2+ZZ] += fiz2;
636 f[i_coord_offset+DIM*3+XX] += fix3;
637 f[i_coord_offset+DIM*3+YY] += fiy3;
638 f[i_coord_offset+DIM*3+ZZ] += fiz3;
642 fshift[i_shift_offset+XX] += tx;
643 fshift[i_shift_offset+YY] += ty;
644 fshift[i_shift_offset+ZZ] += tz;
647 /* Update potential energies */
648 kernel_data->energygrp_elec[ggid] += velecsum;
649 kernel_data->energygrp_vdw[ggid] += vvdwsum;
651 /* Increment number of inner iterations */
652 inneriter += j_index_end - j_index_start;
654 /* Outer loop uses 41 flops */
657 /* Increment number of outer iterations */
660 /* Update outer/inner flops */
662 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*334);
665 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_c
666 * Electrostatics interaction: ReactionField
667 * VdW interaction: CubicSplineTable
668 * Geometry: Water4-Water4
669 * Calculate force/pot: Force
672 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_c
673 (t_nblist * gmx_restrict nlist,
674 rvec * gmx_restrict xx,
675 rvec * gmx_restrict ff,
676 t_forcerec * gmx_restrict fr,
677 t_mdatoms * gmx_restrict mdatoms,
678 nb_kernel_data_t * gmx_restrict kernel_data,
679 t_nrnb * gmx_restrict nrnb)
681 int i_shift_offset,i_coord_offset,j_coord_offset;
682 int j_index_start,j_index_end;
683 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
684 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
685 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
686 real *shiftvec,*fshift,*x,*f;
688 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
690 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
692 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
694 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
696 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
698 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
700 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
702 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
703 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
704 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
705 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
706 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
707 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
708 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
709 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
710 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
711 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
712 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
713 real velec,felec,velecsum,facel,crf,krf,krf2;
716 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
720 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
728 jindex = nlist->jindex;
730 shiftidx = nlist->shift;
732 shiftvec = fr->shift_vec[0];
733 fshift = fr->fshift[0];
735 charge = mdatoms->chargeA;
739 nvdwtype = fr->ntype;
741 vdwtype = mdatoms->typeA;
743 vftab = kernel_data->table_vdw->data;
744 vftabscale = kernel_data->table_vdw->scale;
746 /* Setup water-specific parameters */
747 inr = nlist->iinr[0];
748 iq1 = facel*charge[inr+1];
749 iq2 = facel*charge[inr+2];
750 iq3 = facel*charge[inr+3];
751 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
756 vdwjidx0 = 2*vdwtype[inr+0];
757 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
758 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
769 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
770 rcutoff = fr->rcoulomb;
771 rcutoff2 = rcutoff*rcutoff;
776 /* Start outer loop over neighborlists */
777 for(iidx=0; iidx<nri; iidx++)
779 /* Load shift vector for this list */
780 i_shift_offset = DIM*shiftidx[iidx];
781 shX = shiftvec[i_shift_offset+XX];
782 shY = shiftvec[i_shift_offset+YY];
783 shZ = shiftvec[i_shift_offset+ZZ];
785 /* Load limits for loop over neighbors */
786 j_index_start = jindex[iidx];
787 j_index_end = jindex[iidx+1];
789 /* Get outer coordinate index */
791 i_coord_offset = DIM*inr;
793 /* Load i particle coords and add shift vector */
794 ix0 = shX + x[i_coord_offset+DIM*0+XX];
795 iy0 = shY + x[i_coord_offset+DIM*0+YY];
796 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
797 ix1 = shX + x[i_coord_offset+DIM*1+XX];
798 iy1 = shY + x[i_coord_offset+DIM*1+YY];
799 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
800 ix2 = shX + x[i_coord_offset+DIM*2+XX];
801 iy2 = shY + x[i_coord_offset+DIM*2+YY];
802 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
803 ix3 = shX + x[i_coord_offset+DIM*3+XX];
804 iy3 = shY + x[i_coord_offset+DIM*3+YY];
805 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
820 /* Start inner kernel loop */
821 for(jidx=j_index_start; jidx<j_index_end; jidx++)
823 /* Get j neighbor index, and coordinate index */
825 j_coord_offset = DIM*jnr;
827 /* load j atom coordinates */
828 jx0 = x[j_coord_offset+DIM*0+XX];
829 jy0 = x[j_coord_offset+DIM*0+YY];
830 jz0 = x[j_coord_offset+DIM*0+ZZ];
831 jx1 = x[j_coord_offset+DIM*1+XX];
832 jy1 = x[j_coord_offset+DIM*1+YY];
833 jz1 = x[j_coord_offset+DIM*1+ZZ];
834 jx2 = x[j_coord_offset+DIM*2+XX];
835 jy2 = x[j_coord_offset+DIM*2+YY];
836 jz2 = x[j_coord_offset+DIM*2+ZZ];
837 jx3 = x[j_coord_offset+DIM*3+XX];
838 jy3 = x[j_coord_offset+DIM*3+YY];
839 jz3 = x[j_coord_offset+DIM*3+ZZ];
841 /* Calculate displacement vector */
873 /* Calculate squared distance and things based on it */
874 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
875 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
876 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
877 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
878 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
879 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
880 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
881 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
882 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
883 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
885 rinv00 = gmx_invsqrt(rsq00);
886 rinv11 = gmx_invsqrt(rsq11);
887 rinv12 = gmx_invsqrt(rsq12);
888 rinv13 = gmx_invsqrt(rsq13);
889 rinv21 = gmx_invsqrt(rsq21);
890 rinv22 = gmx_invsqrt(rsq22);
891 rinv23 = gmx_invsqrt(rsq23);
892 rinv31 = gmx_invsqrt(rsq31);
893 rinv32 = gmx_invsqrt(rsq32);
894 rinv33 = gmx_invsqrt(rsq33);
896 rinvsq11 = rinv11*rinv11;
897 rinvsq12 = rinv12*rinv12;
898 rinvsq13 = rinv13*rinv13;
899 rinvsq21 = rinv21*rinv21;
900 rinvsq22 = rinv22*rinv22;
901 rinvsq23 = rinv23*rinv23;
902 rinvsq31 = rinv31*rinv31;
903 rinvsq32 = rinv32*rinv32;
904 rinvsq33 = rinv33*rinv33;
906 /**************************
907 * CALCULATE INTERACTIONS *
908 **************************/
912 /* Calculate table index by multiplying r with table scale and truncate to integer */
918 /* CUBIC SPLINE TABLE DISPERSION */
922 Geps = vfeps*vftab[vfitab+2];
923 Heps2 = vfeps*vfeps*vftab[vfitab+3];
925 FF = Fp+Geps+2.0*Heps2;
928 /* CUBIC SPLINE TABLE REPULSION */
931 Geps = vfeps*vftab[vfitab+6];
932 Heps2 = vfeps*vfeps*vftab[vfitab+7];
934 FF = Fp+Geps+2.0*Heps2;
936 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
940 /* Calculate temporary vectorial force */
945 /* Update vectorial force */
949 f[j_coord_offset+DIM*0+XX] -= tx;
950 f[j_coord_offset+DIM*0+YY] -= ty;
951 f[j_coord_offset+DIM*0+ZZ] -= tz;
953 /**************************
954 * CALCULATE INTERACTIONS *
955 **************************/
960 /* REACTION-FIELD ELECTROSTATICS */
961 felec = qq11*(rinv11*rinvsq11-krf2);
965 /* Calculate temporary vectorial force */
970 /* Update vectorial force */
974 f[j_coord_offset+DIM*1+XX] -= tx;
975 f[j_coord_offset+DIM*1+YY] -= ty;
976 f[j_coord_offset+DIM*1+ZZ] -= tz;
980 /**************************
981 * CALCULATE INTERACTIONS *
982 **************************/
987 /* REACTION-FIELD ELECTROSTATICS */
988 felec = qq12*(rinv12*rinvsq12-krf2);
992 /* Calculate temporary vectorial force */
997 /* Update vectorial force */
1001 f[j_coord_offset+DIM*2+XX] -= tx;
1002 f[j_coord_offset+DIM*2+YY] -= ty;
1003 f[j_coord_offset+DIM*2+ZZ] -= tz;
1007 /**************************
1008 * CALCULATE INTERACTIONS *
1009 **************************/
1014 /* REACTION-FIELD ELECTROSTATICS */
1015 felec = qq13*(rinv13*rinvsq13-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;
1034 /**************************
1035 * CALCULATE INTERACTIONS *
1036 **************************/
1041 /* REACTION-FIELD ELECTROSTATICS */
1042 felec = qq21*(rinv21*rinvsq21-krf2);
1046 /* Calculate temporary vectorial force */
1051 /* Update vectorial force */
1055 f[j_coord_offset+DIM*1+XX] -= tx;
1056 f[j_coord_offset+DIM*1+YY] -= ty;
1057 f[j_coord_offset+DIM*1+ZZ] -= tz;
1061 /**************************
1062 * CALCULATE INTERACTIONS *
1063 **************************/
1068 /* REACTION-FIELD ELECTROSTATICS */
1069 felec = qq22*(rinv22*rinvsq22-krf2);
1073 /* Calculate temporary vectorial force */
1078 /* Update vectorial force */
1082 f[j_coord_offset+DIM*2+XX] -= tx;
1083 f[j_coord_offset+DIM*2+YY] -= ty;
1084 f[j_coord_offset+DIM*2+ZZ] -= tz;
1088 /**************************
1089 * CALCULATE INTERACTIONS *
1090 **************************/
1095 /* REACTION-FIELD ELECTROSTATICS */
1096 felec = qq23*(rinv23*rinvsq23-krf2);
1100 /* Calculate temporary vectorial force */
1105 /* Update vectorial force */
1109 f[j_coord_offset+DIM*3+XX] -= tx;
1110 f[j_coord_offset+DIM*3+YY] -= ty;
1111 f[j_coord_offset+DIM*3+ZZ] -= tz;
1115 /**************************
1116 * CALCULATE INTERACTIONS *
1117 **************************/
1122 /* REACTION-FIELD ELECTROSTATICS */
1123 felec = qq31*(rinv31*rinvsq31-krf2);
1127 /* Calculate temporary vectorial force */
1132 /* Update vectorial force */
1136 f[j_coord_offset+DIM*1+XX] -= tx;
1137 f[j_coord_offset+DIM*1+YY] -= ty;
1138 f[j_coord_offset+DIM*1+ZZ] -= tz;
1142 /**************************
1143 * CALCULATE INTERACTIONS *
1144 **************************/
1149 /* REACTION-FIELD ELECTROSTATICS */
1150 felec = qq32*(rinv32*rinvsq32-krf2);
1154 /* Calculate temporary vectorial force */
1159 /* Update vectorial force */
1163 f[j_coord_offset+DIM*2+XX] -= tx;
1164 f[j_coord_offset+DIM*2+YY] -= ty;
1165 f[j_coord_offset+DIM*2+ZZ] -= tz;
1169 /**************************
1170 * CALCULATE INTERACTIONS *
1171 **************************/
1176 /* REACTION-FIELD ELECTROSTATICS */
1177 felec = qq33*(rinv33*rinvsq33-krf2);
1181 /* Calculate temporary vectorial force */
1186 /* Update vectorial force */
1190 f[j_coord_offset+DIM*3+XX] -= tx;
1191 f[j_coord_offset+DIM*3+YY] -= ty;
1192 f[j_coord_offset+DIM*3+ZZ] -= tz;
1196 /* Inner loop uses 281 flops */
1198 /* End of innermost loop */
1201 f[i_coord_offset+DIM*0+XX] += fix0;
1202 f[i_coord_offset+DIM*0+YY] += fiy0;
1203 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1207 f[i_coord_offset+DIM*1+XX] += fix1;
1208 f[i_coord_offset+DIM*1+YY] += fiy1;
1209 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1213 f[i_coord_offset+DIM*2+XX] += fix2;
1214 f[i_coord_offset+DIM*2+YY] += fiy2;
1215 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1219 f[i_coord_offset+DIM*3+XX] += fix3;
1220 f[i_coord_offset+DIM*3+YY] += fiy3;
1221 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1225 fshift[i_shift_offset+XX] += tx;
1226 fshift[i_shift_offset+YY] += ty;
1227 fshift[i_shift_offset+ZZ] += tz;
1229 /* Increment number of inner iterations */
1230 inneriter += j_index_end - j_index_start;
1232 /* Outer loop uses 39 flops */
1235 /* Increment number of outer iterations */
1238 /* Update outer/inner flops */
1240 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*281);