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 **************************/
288 /* Calculate table index by multiplying r with table scale and truncate to integer */
294 /* CUBIC SPLINE TABLE DISPERSION */
298 Geps = vfeps*vftab[vfitab+2];
299 Heps2 = vfeps*vfeps*vftab[vfitab+3];
303 FF = Fp+Geps+2.0*Heps2;
306 /* CUBIC SPLINE TABLE REPULSION */
309 Geps = vfeps*vftab[vfitab+6];
310 Heps2 = vfeps*vfeps*vftab[vfitab+7];
314 FF = Fp+Geps+2.0*Heps2;
317 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
319 /* Update potential sums from outer loop */
324 /* Calculate temporary vectorial force */
329 /* Update vectorial force */
333 f[j_coord_offset+DIM*0+XX] -= tx;
334 f[j_coord_offset+DIM*0+YY] -= ty;
335 f[j_coord_offset+DIM*0+ZZ] -= tz;
339 /**************************
340 * CALCULATE INTERACTIONS *
341 **************************/
346 /* REACTION-FIELD ELECTROSTATICS */
347 velec = qq11*(rinv11+krf*rsq11-crf);
348 felec = qq11*(rinv11*rinvsq11-krf2);
350 /* Update potential sums from outer loop */
355 /* Calculate temporary vectorial force */
360 /* Update vectorial force */
364 f[j_coord_offset+DIM*1+XX] -= tx;
365 f[j_coord_offset+DIM*1+YY] -= ty;
366 f[j_coord_offset+DIM*1+ZZ] -= tz;
370 /**************************
371 * CALCULATE INTERACTIONS *
372 **************************/
377 /* REACTION-FIELD ELECTROSTATICS */
378 velec = qq12*(rinv12+krf*rsq12-crf);
379 felec = qq12*(rinv12*rinvsq12-krf2);
381 /* Update potential sums from outer loop */
386 /* Calculate temporary vectorial force */
391 /* Update vectorial force */
395 f[j_coord_offset+DIM*2+XX] -= tx;
396 f[j_coord_offset+DIM*2+YY] -= ty;
397 f[j_coord_offset+DIM*2+ZZ] -= tz;
401 /**************************
402 * CALCULATE INTERACTIONS *
403 **************************/
408 /* REACTION-FIELD ELECTROSTATICS */
409 velec = qq13*(rinv13+krf*rsq13-crf);
410 felec = qq13*(rinv13*rinvsq13-krf2);
412 /* Update potential sums from outer loop */
417 /* Calculate temporary vectorial force */
422 /* Update vectorial force */
426 f[j_coord_offset+DIM*3+XX] -= tx;
427 f[j_coord_offset+DIM*3+YY] -= ty;
428 f[j_coord_offset+DIM*3+ZZ] -= tz;
432 /**************************
433 * CALCULATE INTERACTIONS *
434 **************************/
439 /* REACTION-FIELD ELECTROSTATICS */
440 velec = qq21*(rinv21+krf*rsq21-crf);
441 felec = qq21*(rinv21*rinvsq21-krf2);
443 /* Update potential sums from outer loop */
448 /* Calculate temporary vectorial force */
453 /* Update vectorial force */
457 f[j_coord_offset+DIM*1+XX] -= tx;
458 f[j_coord_offset+DIM*1+YY] -= ty;
459 f[j_coord_offset+DIM*1+ZZ] -= tz;
463 /**************************
464 * CALCULATE INTERACTIONS *
465 **************************/
470 /* REACTION-FIELD ELECTROSTATICS */
471 velec = qq22*(rinv22+krf*rsq22-crf);
472 felec = qq22*(rinv22*rinvsq22-krf2);
474 /* Update potential sums from outer loop */
479 /* Calculate temporary vectorial force */
484 /* Update vectorial force */
488 f[j_coord_offset+DIM*2+XX] -= tx;
489 f[j_coord_offset+DIM*2+YY] -= ty;
490 f[j_coord_offset+DIM*2+ZZ] -= tz;
494 /**************************
495 * CALCULATE INTERACTIONS *
496 **************************/
501 /* REACTION-FIELD ELECTROSTATICS */
502 velec = qq23*(rinv23+krf*rsq23-crf);
503 felec = qq23*(rinv23*rinvsq23-krf2);
505 /* Update potential sums from outer loop */
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*3+XX] -= tx;
520 f[j_coord_offset+DIM*3+YY] -= ty;
521 f[j_coord_offset+DIM*3+ZZ] -= tz;
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
532 /* REACTION-FIELD ELECTROSTATICS */
533 velec = qq31*(rinv31+krf*rsq31-crf);
534 felec = qq31*(rinv31*rinvsq31-krf2);
536 /* Update potential sums from outer loop */
541 /* Calculate temporary vectorial force */
546 /* Update vectorial force */
550 f[j_coord_offset+DIM*1+XX] -= tx;
551 f[j_coord_offset+DIM*1+YY] -= ty;
552 f[j_coord_offset+DIM*1+ZZ] -= tz;
556 /**************************
557 * CALCULATE INTERACTIONS *
558 **************************/
563 /* REACTION-FIELD ELECTROSTATICS */
564 velec = qq32*(rinv32+krf*rsq32-crf);
565 felec = qq32*(rinv32*rinvsq32-krf2);
567 /* Update potential sums from outer loop */
572 /* Calculate temporary vectorial force */
577 /* Update vectorial force */
581 f[j_coord_offset+DIM*2+XX] -= tx;
582 f[j_coord_offset+DIM*2+YY] -= ty;
583 f[j_coord_offset+DIM*2+ZZ] -= tz;
587 /**************************
588 * CALCULATE INTERACTIONS *
589 **************************/
594 /* REACTION-FIELD ELECTROSTATICS */
595 velec = qq33*(rinv33+krf*rsq33-crf);
596 felec = qq33*(rinv33*rinvsq33-krf2);
598 /* Update potential sums from outer loop */
603 /* Calculate temporary vectorial force */
608 /* Update vectorial force */
612 f[j_coord_offset+DIM*3+XX] -= tx;
613 f[j_coord_offset+DIM*3+YY] -= ty;
614 f[j_coord_offset+DIM*3+ZZ] -= tz;
618 /* Inner loop uses 334 flops */
620 /* End of innermost loop */
623 f[i_coord_offset+DIM*0+XX] += fix0;
624 f[i_coord_offset+DIM*0+YY] += fiy0;
625 f[i_coord_offset+DIM*0+ZZ] += fiz0;
629 f[i_coord_offset+DIM*1+XX] += fix1;
630 f[i_coord_offset+DIM*1+YY] += fiy1;
631 f[i_coord_offset+DIM*1+ZZ] += fiz1;
635 f[i_coord_offset+DIM*2+XX] += fix2;
636 f[i_coord_offset+DIM*2+YY] += fiy2;
637 f[i_coord_offset+DIM*2+ZZ] += fiz2;
641 f[i_coord_offset+DIM*3+XX] += fix3;
642 f[i_coord_offset+DIM*3+YY] += fiy3;
643 f[i_coord_offset+DIM*3+ZZ] += fiz3;
647 fshift[i_shift_offset+XX] += tx;
648 fshift[i_shift_offset+YY] += ty;
649 fshift[i_shift_offset+ZZ] += tz;
652 /* Update potential energies */
653 kernel_data->energygrp_elec[ggid] += velecsum;
654 kernel_data->energygrp_vdw[ggid] += vvdwsum;
656 /* Increment number of inner iterations */
657 inneriter += j_index_end - j_index_start;
659 /* Outer loop uses 41 flops */
662 /* Increment number of outer iterations */
665 /* Update outer/inner flops */
667 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*334);
670 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_c
671 * Electrostatics interaction: ReactionField
672 * VdW interaction: CubicSplineTable
673 * Geometry: Water4-Water4
674 * Calculate force/pot: Force
677 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_c
678 (t_nblist * gmx_restrict nlist,
679 rvec * gmx_restrict xx,
680 rvec * gmx_restrict ff,
681 t_forcerec * gmx_restrict fr,
682 t_mdatoms * gmx_restrict mdatoms,
683 nb_kernel_data_t * gmx_restrict kernel_data,
684 t_nrnb * gmx_restrict nrnb)
686 int i_shift_offset,i_coord_offset,j_coord_offset;
687 int j_index_start,j_index_end;
688 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
689 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
690 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
691 real *shiftvec,*fshift,*x,*f;
693 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
695 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
697 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
699 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
701 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
703 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
705 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
707 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
708 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
709 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
710 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
711 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
712 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
713 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
714 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
715 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
716 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
717 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
718 real velec,felec,velecsum,facel,crf,krf,krf2;
721 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
725 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
733 jindex = nlist->jindex;
735 shiftidx = nlist->shift;
737 shiftvec = fr->shift_vec[0];
738 fshift = fr->fshift[0];
740 charge = mdatoms->chargeA;
744 nvdwtype = fr->ntype;
746 vdwtype = mdatoms->typeA;
748 vftab = kernel_data->table_vdw->data;
749 vftabscale = kernel_data->table_vdw->scale;
751 /* Setup water-specific parameters */
752 inr = nlist->iinr[0];
753 iq1 = facel*charge[inr+1];
754 iq2 = facel*charge[inr+2];
755 iq3 = facel*charge[inr+3];
756 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
761 vdwjidx0 = 2*vdwtype[inr+0];
762 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
763 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
774 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
775 rcutoff = fr->rcoulomb;
776 rcutoff2 = rcutoff*rcutoff;
781 /* Start outer loop over neighborlists */
782 for(iidx=0; iidx<nri; iidx++)
784 /* Load shift vector for this list */
785 i_shift_offset = DIM*shiftidx[iidx];
786 shX = shiftvec[i_shift_offset+XX];
787 shY = shiftvec[i_shift_offset+YY];
788 shZ = shiftvec[i_shift_offset+ZZ];
790 /* Load limits for loop over neighbors */
791 j_index_start = jindex[iidx];
792 j_index_end = jindex[iidx+1];
794 /* Get outer coordinate index */
796 i_coord_offset = DIM*inr;
798 /* Load i particle coords and add shift vector */
799 ix0 = shX + x[i_coord_offset+DIM*0+XX];
800 iy0 = shY + x[i_coord_offset+DIM*0+YY];
801 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
802 ix1 = shX + x[i_coord_offset+DIM*1+XX];
803 iy1 = shY + x[i_coord_offset+DIM*1+YY];
804 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
805 ix2 = shX + x[i_coord_offset+DIM*2+XX];
806 iy2 = shY + x[i_coord_offset+DIM*2+YY];
807 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
808 ix3 = shX + x[i_coord_offset+DIM*3+XX];
809 iy3 = shY + x[i_coord_offset+DIM*3+YY];
810 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
825 /* Start inner kernel loop */
826 for(jidx=j_index_start; jidx<j_index_end; jidx++)
828 /* Get j neighbor index, and coordinate index */
830 j_coord_offset = DIM*jnr;
832 /* load j atom coordinates */
833 jx0 = x[j_coord_offset+DIM*0+XX];
834 jy0 = x[j_coord_offset+DIM*0+YY];
835 jz0 = x[j_coord_offset+DIM*0+ZZ];
836 jx1 = x[j_coord_offset+DIM*1+XX];
837 jy1 = x[j_coord_offset+DIM*1+YY];
838 jz1 = x[j_coord_offset+DIM*1+ZZ];
839 jx2 = x[j_coord_offset+DIM*2+XX];
840 jy2 = x[j_coord_offset+DIM*2+YY];
841 jz2 = x[j_coord_offset+DIM*2+ZZ];
842 jx3 = x[j_coord_offset+DIM*3+XX];
843 jy3 = x[j_coord_offset+DIM*3+YY];
844 jz3 = x[j_coord_offset+DIM*3+ZZ];
846 /* Calculate displacement vector */
878 /* Calculate squared distance and things based on it */
879 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
880 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
881 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
882 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
883 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
884 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
885 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
886 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
887 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
888 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
890 rinv00 = gmx_invsqrt(rsq00);
891 rinv11 = gmx_invsqrt(rsq11);
892 rinv12 = gmx_invsqrt(rsq12);
893 rinv13 = gmx_invsqrt(rsq13);
894 rinv21 = gmx_invsqrt(rsq21);
895 rinv22 = gmx_invsqrt(rsq22);
896 rinv23 = gmx_invsqrt(rsq23);
897 rinv31 = gmx_invsqrt(rsq31);
898 rinv32 = gmx_invsqrt(rsq32);
899 rinv33 = gmx_invsqrt(rsq33);
901 rinvsq11 = rinv11*rinv11;
902 rinvsq12 = rinv12*rinv12;
903 rinvsq13 = rinv13*rinv13;
904 rinvsq21 = rinv21*rinv21;
905 rinvsq22 = rinv22*rinv22;
906 rinvsq23 = rinv23*rinv23;
907 rinvsq31 = rinv31*rinv31;
908 rinvsq32 = rinv32*rinv32;
909 rinvsq33 = rinv33*rinv33;
911 /**************************
912 * CALCULATE INTERACTIONS *
913 **************************/
920 /* Calculate table index by multiplying r with table scale and truncate to integer */
926 /* CUBIC SPLINE TABLE DISPERSION */
929 Geps = vfeps*vftab[vfitab+2];
930 Heps2 = vfeps*vfeps*vftab[vfitab+3];
932 FF = Fp+Geps+2.0*Heps2;
935 /* CUBIC SPLINE TABLE REPULSION */
937 Geps = vfeps*vftab[vfitab+6];
938 Heps2 = vfeps*vfeps*vftab[vfitab+7];
940 FF = Fp+Geps+2.0*Heps2;
942 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
946 /* Calculate temporary vectorial force */
951 /* Update vectorial force */
955 f[j_coord_offset+DIM*0+XX] -= tx;
956 f[j_coord_offset+DIM*0+YY] -= ty;
957 f[j_coord_offset+DIM*0+ZZ] -= tz;
961 /**************************
962 * CALCULATE INTERACTIONS *
963 **************************/
968 /* REACTION-FIELD ELECTROSTATICS */
969 felec = qq11*(rinv11*rinvsq11-krf2);
973 /* Calculate temporary vectorial force */
978 /* Update vectorial force */
982 f[j_coord_offset+DIM*1+XX] -= tx;
983 f[j_coord_offset+DIM*1+YY] -= ty;
984 f[j_coord_offset+DIM*1+ZZ] -= tz;
988 /**************************
989 * CALCULATE INTERACTIONS *
990 **************************/
995 /* REACTION-FIELD ELECTROSTATICS */
996 felec = qq12*(rinv12*rinvsq12-krf2);
1000 /* Calculate temporary vectorial force */
1005 /* Update vectorial force */
1009 f[j_coord_offset+DIM*2+XX] -= tx;
1010 f[j_coord_offset+DIM*2+YY] -= ty;
1011 f[j_coord_offset+DIM*2+ZZ] -= tz;
1015 /**************************
1016 * CALCULATE INTERACTIONS *
1017 **************************/
1022 /* REACTION-FIELD ELECTROSTATICS */
1023 felec = qq13*(rinv13*rinvsq13-krf2);
1027 /* Calculate temporary vectorial force */
1032 /* Update vectorial force */
1036 f[j_coord_offset+DIM*3+XX] -= tx;
1037 f[j_coord_offset+DIM*3+YY] -= ty;
1038 f[j_coord_offset+DIM*3+ZZ] -= tz;
1042 /**************************
1043 * CALCULATE INTERACTIONS *
1044 **************************/
1049 /* REACTION-FIELD ELECTROSTATICS */
1050 felec = qq21*(rinv21*rinvsq21-krf2);
1054 /* Calculate temporary vectorial force */
1059 /* Update vectorial force */
1063 f[j_coord_offset+DIM*1+XX] -= tx;
1064 f[j_coord_offset+DIM*1+YY] -= ty;
1065 f[j_coord_offset+DIM*1+ZZ] -= tz;
1069 /**************************
1070 * CALCULATE INTERACTIONS *
1071 **************************/
1076 /* REACTION-FIELD ELECTROSTATICS */
1077 felec = qq22*(rinv22*rinvsq22-krf2);
1081 /* Calculate temporary vectorial force */
1086 /* Update vectorial force */
1090 f[j_coord_offset+DIM*2+XX] -= tx;
1091 f[j_coord_offset+DIM*2+YY] -= ty;
1092 f[j_coord_offset+DIM*2+ZZ] -= tz;
1096 /**************************
1097 * CALCULATE INTERACTIONS *
1098 **************************/
1103 /* REACTION-FIELD ELECTROSTATICS */
1104 felec = qq23*(rinv23*rinvsq23-krf2);
1108 /* Calculate temporary vectorial force */
1113 /* Update vectorial force */
1117 f[j_coord_offset+DIM*3+XX] -= tx;
1118 f[j_coord_offset+DIM*3+YY] -= ty;
1119 f[j_coord_offset+DIM*3+ZZ] -= tz;
1123 /**************************
1124 * CALCULATE INTERACTIONS *
1125 **************************/
1130 /* REACTION-FIELD ELECTROSTATICS */
1131 felec = qq31*(rinv31*rinvsq31-krf2);
1135 /* Calculate temporary vectorial force */
1140 /* Update vectorial force */
1144 f[j_coord_offset+DIM*1+XX] -= tx;
1145 f[j_coord_offset+DIM*1+YY] -= ty;
1146 f[j_coord_offset+DIM*1+ZZ] -= tz;
1150 /**************************
1151 * CALCULATE INTERACTIONS *
1152 **************************/
1157 /* REACTION-FIELD ELECTROSTATICS */
1158 felec = qq32*(rinv32*rinvsq32-krf2);
1162 /* Calculate temporary vectorial force */
1167 /* Update vectorial force */
1171 f[j_coord_offset+DIM*2+XX] -= tx;
1172 f[j_coord_offset+DIM*2+YY] -= ty;
1173 f[j_coord_offset+DIM*2+ZZ] -= tz;
1177 /**************************
1178 * CALCULATE INTERACTIONS *
1179 **************************/
1184 /* REACTION-FIELD ELECTROSTATICS */
1185 felec = qq33*(rinv33*rinvsq33-krf2);
1189 /* Calculate temporary vectorial force */
1194 /* Update vectorial force */
1198 f[j_coord_offset+DIM*3+XX] -= tx;
1199 f[j_coord_offset+DIM*3+YY] -= ty;
1200 f[j_coord_offset+DIM*3+ZZ] -= tz;
1204 /* Inner loop uses 281 flops */
1206 /* End of innermost loop */
1209 f[i_coord_offset+DIM*0+XX] += fix0;
1210 f[i_coord_offset+DIM*0+YY] += fiy0;
1211 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1215 f[i_coord_offset+DIM*1+XX] += fix1;
1216 f[i_coord_offset+DIM*1+YY] += fiy1;
1217 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1221 f[i_coord_offset+DIM*2+XX] += fix2;
1222 f[i_coord_offset+DIM*2+YY] += fiy2;
1223 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1227 f[i_coord_offset+DIM*3+XX] += fix3;
1228 f[i_coord_offset+DIM*3+YY] += fiy3;
1229 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1233 fshift[i_shift_offset+XX] += tx;
1234 fshift[i_shift_offset+YY] += ty;
1235 fshift[i_shift_offset+ZZ] += tz;
1237 /* Increment number of inner iterations */
1238 inneriter += j_index_end - j_index_start;
1240 /* Outer loop uses 39 flops */
1243 /* Increment number of outer iterations */
1246 /* Update outer/inner flops */
1248 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*281);