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_ElecEw_VdwLJ_GeomW4W4_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwLJ_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 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
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 sh_ewald = fr->ic->sh_ewald;
110 ewtab = fr->ic->tabq_coul_FDV0;
111 ewtabscale = fr->ic->tabq_scale;
112 ewtabhalfspace = 0.5/ewtabscale;
114 /* Setup water-specific parameters */
115 inr = nlist->iinr[0];
116 iq1 = facel*charge[inr+1];
117 iq2 = facel*charge[inr+2];
118 iq3 = facel*charge[inr+3];
119 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
124 vdwjidx0 = 2*vdwtype[inr+0];
125 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
126 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
140 /* Start outer loop over neighborlists */
141 for(iidx=0; iidx<nri; iidx++)
143 /* Load shift vector for this list */
144 i_shift_offset = DIM*shiftidx[iidx];
145 shX = shiftvec[i_shift_offset+XX];
146 shY = shiftvec[i_shift_offset+YY];
147 shZ = shiftvec[i_shift_offset+ZZ];
149 /* Load limits for loop over neighbors */
150 j_index_start = jindex[iidx];
151 j_index_end = jindex[iidx+1];
153 /* Get outer coordinate index */
155 i_coord_offset = DIM*inr;
157 /* Load i particle coords and add shift vector */
158 ix0 = shX + x[i_coord_offset+DIM*0+XX];
159 iy0 = shY + x[i_coord_offset+DIM*0+YY];
160 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
161 ix1 = shX + x[i_coord_offset+DIM*1+XX];
162 iy1 = shY + x[i_coord_offset+DIM*1+YY];
163 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
164 ix2 = shX + x[i_coord_offset+DIM*2+XX];
165 iy2 = shY + x[i_coord_offset+DIM*2+YY];
166 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
167 ix3 = shX + x[i_coord_offset+DIM*3+XX];
168 iy3 = shY + x[i_coord_offset+DIM*3+YY];
169 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
184 /* Reset potential sums */
188 /* Start inner kernel loop */
189 for(jidx=j_index_start; jidx<j_index_end; jidx++)
191 /* Get j neighbor index, and coordinate index */
193 j_coord_offset = DIM*jnr;
195 /* load j atom coordinates */
196 jx0 = x[j_coord_offset+DIM*0+XX];
197 jy0 = x[j_coord_offset+DIM*0+YY];
198 jz0 = x[j_coord_offset+DIM*0+ZZ];
199 jx1 = x[j_coord_offset+DIM*1+XX];
200 jy1 = x[j_coord_offset+DIM*1+YY];
201 jz1 = x[j_coord_offset+DIM*1+ZZ];
202 jx2 = x[j_coord_offset+DIM*2+XX];
203 jy2 = x[j_coord_offset+DIM*2+YY];
204 jz2 = x[j_coord_offset+DIM*2+ZZ];
205 jx3 = x[j_coord_offset+DIM*3+XX];
206 jy3 = x[j_coord_offset+DIM*3+YY];
207 jz3 = x[j_coord_offset+DIM*3+ZZ];
209 /* Calculate displacement vector */
241 /* Calculate squared distance and things based on it */
242 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
243 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
244 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
245 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
246 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
247 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
248 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
249 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
250 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
251 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
253 rinv11 = gmx_invsqrt(rsq11);
254 rinv12 = gmx_invsqrt(rsq12);
255 rinv13 = gmx_invsqrt(rsq13);
256 rinv21 = gmx_invsqrt(rsq21);
257 rinv22 = gmx_invsqrt(rsq22);
258 rinv23 = gmx_invsqrt(rsq23);
259 rinv31 = gmx_invsqrt(rsq31);
260 rinv32 = gmx_invsqrt(rsq32);
261 rinv33 = gmx_invsqrt(rsq33);
263 rinvsq00 = 1.0/rsq00;
264 rinvsq11 = rinv11*rinv11;
265 rinvsq12 = rinv12*rinv12;
266 rinvsq13 = rinv13*rinv13;
267 rinvsq21 = rinv21*rinv21;
268 rinvsq22 = rinv22*rinv22;
269 rinvsq23 = rinv23*rinv23;
270 rinvsq31 = rinv31*rinv31;
271 rinvsq32 = rinv32*rinv32;
272 rinvsq33 = rinv33*rinv33;
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
278 /* LENNARD-JONES DISPERSION/REPULSION */
280 rinvsix = rinvsq00*rinvsq00*rinvsq00;
281 vvdw6 = c6_00*rinvsix;
282 vvdw12 = c12_00*rinvsix*rinvsix;
283 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
284 fvdw = (vvdw12-vvdw6)*rinvsq00;
286 /* Update potential sums from outer loop */
291 /* Calculate temporary vectorial force */
296 /* Update vectorial force */
300 f[j_coord_offset+DIM*0+XX] -= tx;
301 f[j_coord_offset+DIM*0+YY] -= ty;
302 f[j_coord_offset+DIM*0+ZZ] -= tz;
304 /**************************
305 * CALCULATE INTERACTIONS *
306 **************************/
310 /* EWALD ELECTROSTATICS */
312 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
313 ewrt = r11*ewtabscale;
317 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
318 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
319 felec = qq11*rinv11*(rinvsq11-felec);
321 /* Update potential sums from outer loop */
326 /* Calculate temporary vectorial force */
331 /* Update vectorial force */
335 f[j_coord_offset+DIM*1+XX] -= tx;
336 f[j_coord_offset+DIM*1+YY] -= ty;
337 f[j_coord_offset+DIM*1+ZZ] -= tz;
339 /**************************
340 * CALCULATE INTERACTIONS *
341 **************************/
345 /* EWALD ELECTROSTATICS */
347 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
348 ewrt = r12*ewtabscale;
352 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
353 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
354 felec = qq12*rinv12*(rinvsq12-felec);
356 /* Update potential sums from outer loop */
361 /* Calculate temporary vectorial force */
366 /* Update vectorial force */
370 f[j_coord_offset+DIM*2+XX] -= tx;
371 f[j_coord_offset+DIM*2+YY] -= ty;
372 f[j_coord_offset+DIM*2+ZZ] -= tz;
374 /**************************
375 * CALCULATE INTERACTIONS *
376 **************************/
380 /* EWALD ELECTROSTATICS */
382 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
383 ewrt = r13*ewtabscale;
387 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
388 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
389 felec = qq13*rinv13*(rinvsq13-felec);
391 /* Update potential sums from outer loop */
396 /* Calculate temporary vectorial force */
401 /* Update vectorial force */
405 f[j_coord_offset+DIM*3+XX] -= tx;
406 f[j_coord_offset+DIM*3+YY] -= ty;
407 f[j_coord_offset+DIM*3+ZZ] -= tz;
409 /**************************
410 * CALCULATE INTERACTIONS *
411 **************************/
415 /* EWALD ELECTROSTATICS */
417 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
418 ewrt = r21*ewtabscale;
422 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
423 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
424 felec = qq21*rinv21*(rinvsq21-felec);
426 /* Update potential sums from outer loop */
431 /* Calculate temporary vectorial force */
436 /* Update vectorial force */
440 f[j_coord_offset+DIM*1+XX] -= tx;
441 f[j_coord_offset+DIM*1+YY] -= ty;
442 f[j_coord_offset+DIM*1+ZZ] -= tz;
444 /**************************
445 * CALCULATE INTERACTIONS *
446 **************************/
450 /* EWALD ELECTROSTATICS */
452 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
453 ewrt = r22*ewtabscale;
457 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
458 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
459 felec = qq22*rinv22*(rinvsq22-felec);
461 /* Update potential sums from outer loop */
466 /* Calculate temporary vectorial force */
471 /* Update vectorial force */
475 f[j_coord_offset+DIM*2+XX] -= tx;
476 f[j_coord_offset+DIM*2+YY] -= ty;
477 f[j_coord_offset+DIM*2+ZZ] -= tz;
479 /**************************
480 * CALCULATE INTERACTIONS *
481 **************************/
485 /* EWALD ELECTROSTATICS */
487 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
488 ewrt = r23*ewtabscale;
492 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
493 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
494 felec = qq23*rinv23*(rinvsq23-felec);
496 /* Update potential sums from outer loop */
501 /* Calculate temporary vectorial force */
506 /* Update vectorial force */
510 f[j_coord_offset+DIM*3+XX] -= tx;
511 f[j_coord_offset+DIM*3+YY] -= ty;
512 f[j_coord_offset+DIM*3+ZZ] -= tz;
514 /**************************
515 * CALCULATE INTERACTIONS *
516 **************************/
520 /* EWALD ELECTROSTATICS */
522 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
523 ewrt = r31*ewtabscale;
527 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
528 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
529 felec = qq31*rinv31*(rinvsq31-felec);
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;
549 /**************************
550 * CALCULATE INTERACTIONS *
551 **************************/
555 /* EWALD ELECTROSTATICS */
557 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
558 ewrt = r32*ewtabscale;
562 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
563 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
564 felec = qq32*rinv32*(rinvsq32-felec);
566 /* Update potential sums from outer loop */
571 /* Calculate temporary vectorial force */
576 /* Update vectorial force */
580 f[j_coord_offset+DIM*2+XX] -= tx;
581 f[j_coord_offset+DIM*2+YY] -= ty;
582 f[j_coord_offset+DIM*2+ZZ] -= tz;
584 /**************************
585 * CALCULATE INTERACTIONS *
586 **************************/
590 /* EWALD ELECTROSTATICS */
592 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
593 ewrt = r33*ewtabscale;
597 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
598 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
599 felec = qq33*rinv33*(rinvsq33-felec);
601 /* Update potential sums from outer loop */
606 /* Calculate temporary vectorial force */
611 /* Update vectorial force */
615 f[j_coord_offset+DIM*3+XX] -= tx;
616 f[j_coord_offset+DIM*3+YY] -= ty;
617 f[j_coord_offset+DIM*3+ZZ] -= tz;
619 /* Inner loop uses 392 flops */
621 /* End of innermost loop */
624 f[i_coord_offset+DIM*0+XX] += fix0;
625 f[i_coord_offset+DIM*0+YY] += fiy0;
626 f[i_coord_offset+DIM*0+ZZ] += fiz0;
630 f[i_coord_offset+DIM*1+XX] += fix1;
631 f[i_coord_offset+DIM*1+YY] += fiy1;
632 f[i_coord_offset+DIM*1+ZZ] += fiz1;
636 f[i_coord_offset+DIM*2+XX] += fix2;
637 f[i_coord_offset+DIM*2+YY] += fiy2;
638 f[i_coord_offset+DIM*2+ZZ] += fiz2;
642 f[i_coord_offset+DIM*3+XX] += fix3;
643 f[i_coord_offset+DIM*3+YY] += fiy3;
644 f[i_coord_offset+DIM*3+ZZ] += fiz3;
648 fshift[i_shift_offset+XX] += tx;
649 fshift[i_shift_offset+YY] += ty;
650 fshift[i_shift_offset+ZZ] += tz;
653 /* Update potential energies */
654 kernel_data->energygrp_elec[ggid] += velecsum;
655 kernel_data->energygrp_vdw[ggid] += vvdwsum;
657 /* Increment number of inner iterations */
658 inneriter += j_index_end - j_index_start;
660 /* Outer loop uses 41 flops */
663 /* Increment number of outer iterations */
666 /* Update outer/inner flops */
668 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*392);
671 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW4W4_F_c
672 * Electrostatics interaction: Ewald
673 * VdW interaction: LennardJones
674 * Geometry: Water4-Water4
675 * Calculate force/pot: Force
678 nb_kernel_ElecEw_VdwLJ_GeomW4W4_F_c
679 (t_nblist * gmx_restrict nlist,
680 rvec * gmx_restrict xx,
681 rvec * gmx_restrict ff,
682 t_forcerec * gmx_restrict fr,
683 t_mdatoms * gmx_restrict mdatoms,
684 nb_kernel_data_t * gmx_restrict kernel_data,
685 t_nrnb * gmx_restrict nrnb)
687 int i_shift_offset,i_coord_offset,j_coord_offset;
688 int j_index_start,j_index_end;
689 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
690 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
691 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
692 real *shiftvec,*fshift,*x,*f;
694 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
696 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
698 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
700 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
702 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
704 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
706 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
708 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
709 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
710 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
711 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
712 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
713 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
714 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
715 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
716 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
717 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
718 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
719 real velec,felec,velecsum,facel,crf,krf,krf2;
722 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
726 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
734 jindex = nlist->jindex;
736 shiftidx = nlist->shift;
738 shiftvec = fr->shift_vec[0];
739 fshift = fr->fshift[0];
741 charge = mdatoms->chargeA;
742 nvdwtype = fr->ntype;
744 vdwtype = mdatoms->typeA;
746 sh_ewald = fr->ic->sh_ewald;
747 ewtab = fr->ic->tabq_coul_F;
748 ewtabscale = fr->ic->tabq_scale;
749 ewtabhalfspace = 0.5/ewtabscale;
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];
777 /* Start outer loop over neighborlists */
778 for(iidx=0; iidx<nri; iidx++)
780 /* Load shift vector for this list */
781 i_shift_offset = DIM*shiftidx[iidx];
782 shX = shiftvec[i_shift_offset+XX];
783 shY = shiftvec[i_shift_offset+YY];
784 shZ = shiftvec[i_shift_offset+ZZ];
786 /* Load limits for loop over neighbors */
787 j_index_start = jindex[iidx];
788 j_index_end = jindex[iidx+1];
790 /* Get outer coordinate index */
792 i_coord_offset = DIM*inr;
794 /* Load i particle coords and add shift vector */
795 ix0 = shX + x[i_coord_offset+DIM*0+XX];
796 iy0 = shY + x[i_coord_offset+DIM*0+YY];
797 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
798 ix1 = shX + x[i_coord_offset+DIM*1+XX];
799 iy1 = shY + x[i_coord_offset+DIM*1+YY];
800 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
801 ix2 = shX + x[i_coord_offset+DIM*2+XX];
802 iy2 = shY + x[i_coord_offset+DIM*2+YY];
803 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
804 ix3 = shX + x[i_coord_offset+DIM*3+XX];
805 iy3 = shY + x[i_coord_offset+DIM*3+YY];
806 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
821 /* Start inner kernel loop */
822 for(jidx=j_index_start; jidx<j_index_end; jidx++)
824 /* Get j neighbor index, and coordinate index */
826 j_coord_offset = DIM*jnr;
828 /* load j atom coordinates */
829 jx0 = x[j_coord_offset+DIM*0+XX];
830 jy0 = x[j_coord_offset+DIM*0+YY];
831 jz0 = x[j_coord_offset+DIM*0+ZZ];
832 jx1 = x[j_coord_offset+DIM*1+XX];
833 jy1 = x[j_coord_offset+DIM*1+YY];
834 jz1 = x[j_coord_offset+DIM*1+ZZ];
835 jx2 = x[j_coord_offset+DIM*2+XX];
836 jy2 = x[j_coord_offset+DIM*2+YY];
837 jz2 = x[j_coord_offset+DIM*2+ZZ];
838 jx3 = x[j_coord_offset+DIM*3+XX];
839 jy3 = x[j_coord_offset+DIM*3+YY];
840 jz3 = x[j_coord_offset+DIM*3+ZZ];
842 /* Calculate displacement vector */
874 /* Calculate squared distance and things based on it */
875 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
876 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
877 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
878 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
879 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
880 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
881 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
882 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
883 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
884 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
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 rinvsq00 = 1.0/rsq00;
897 rinvsq11 = rinv11*rinv11;
898 rinvsq12 = rinv12*rinv12;
899 rinvsq13 = rinv13*rinv13;
900 rinvsq21 = rinv21*rinv21;
901 rinvsq22 = rinv22*rinv22;
902 rinvsq23 = rinv23*rinv23;
903 rinvsq31 = rinv31*rinv31;
904 rinvsq32 = rinv32*rinv32;
905 rinvsq33 = rinv33*rinv33;
907 /**************************
908 * CALCULATE INTERACTIONS *
909 **************************/
911 /* LENNARD-JONES DISPERSION/REPULSION */
913 rinvsix = rinvsq00*rinvsq00*rinvsq00;
914 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
918 /* Calculate temporary vectorial force */
923 /* Update vectorial force */
927 f[j_coord_offset+DIM*0+XX] -= tx;
928 f[j_coord_offset+DIM*0+YY] -= ty;
929 f[j_coord_offset+DIM*0+ZZ] -= tz;
931 /**************************
932 * CALCULATE INTERACTIONS *
933 **************************/
937 /* EWALD ELECTROSTATICS */
939 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
940 ewrt = r11*ewtabscale;
943 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
944 felec = qq11*rinv11*(rinvsq11-felec);
948 /* Calculate temporary vectorial force */
953 /* Update vectorial force */
957 f[j_coord_offset+DIM*1+XX] -= tx;
958 f[j_coord_offset+DIM*1+YY] -= ty;
959 f[j_coord_offset+DIM*1+ZZ] -= tz;
961 /**************************
962 * CALCULATE INTERACTIONS *
963 **************************/
967 /* EWALD ELECTROSTATICS */
969 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
970 ewrt = r12*ewtabscale;
973 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
974 felec = qq12*rinv12*(rinvsq12-felec);
978 /* Calculate temporary vectorial force */
983 /* Update vectorial force */
987 f[j_coord_offset+DIM*2+XX] -= tx;
988 f[j_coord_offset+DIM*2+YY] -= ty;
989 f[j_coord_offset+DIM*2+ZZ] -= tz;
991 /**************************
992 * CALCULATE INTERACTIONS *
993 **************************/
997 /* EWALD ELECTROSTATICS */
999 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1000 ewrt = r13*ewtabscale;
1002 eweps = ewrt-ewitab;
1003 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1004 felec = qq13*rinv13*(rinvsq13-felec);
1008 /* Calculate temporary vectorial force */
1013 /* Update vectorial force */
1017 f[j_coord_offset+DIM*3+XX] -= tx;
1018 f[j_coord_offset+DIM*3+YY] -= ty;
1019 f[j_coord_offset+DIM*3+ZZ] -= tz;
1021 /**************************
1022 * CALCULATE INTERACTIONS *
1023 **************************/
1027 /* EWALD ELECTROSTATICS */
1029 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1030 ewrt = r21*ewtabscale;
1032 eweps = ewrt-ewitab;
1033 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1034 felec = qq21*rinv21*(rinvsq21-felec);
1038 /* Calculate temporary vectorial force */
1043 /* Update vectorial force */
1047 f[j_coord_offset+DIM*1+XX] -= tx;
1048 f[j_coord_offset+DIM*1+YY] -= ty;
1049 f[j_coord_offset+DIM*1+ZZ] -= tz;
1051 /**************************
1052 * CALCULATE INTERACTIONS *
1053 **************************/
1057 /* EWALD ELECTROSTATICS */
1059 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1060 ewrt = r22*ewtabscale;
1062 eweps = ewrt-ewitab;
1063 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1064 felec = qq22*rinv22*(rinvsq22-felec);
1068 /* Calculate temporary vectorial force */
1073 /* Update vectorial force */
1077 f[j_coord_offset+DIM*2+XX] -= tx;
1078 f[j_coord_offset+DIM*2+YY] -= ty;
1079 f[j_coord_offset+DIM*2+ZZ] -= tz;
1081 /**************************
1082 * CALCULATE INTERACTIONS *
1083 **************************/
1087 /* EWALD ELECTROSTATICS */
1089 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1090 ewrt = r23*ewtabscale;
1092 eweps = ewrt-ewitab;
1093 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1094 felec = qq23*rinv23*(rinvsq23-felec);
1098 /* Calculate temporary vectorial force */
1103 /* Update vectorial force */
1107 f[j_coord_offset+DIM*3+XX] -= tx;
1108 f[j_coord_offset+DIM*3+YY] -= ty;
1109 f[j_coord_offset+DIM*3+ZZ] -= tz;
1111 /**************************
1112 * CALCULATE INTERACTIONS *
1113 **************************/
1117 /* EWALD ELECTROSTATICS */
1119 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1120 ewrt = r31*ewtabscale;
1122 eweps = ewrt-ewitab;
1123 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1124 felec = qq31*rinv31*(rinvsq31-felec);
1128 /* Calculate temporary vectorial force */
1133 /* Update vectorial force */
1137 f[j_coord_offset+DIM*1+XX] -= tx;
1138 f[j_coord_offset+DIM*1+YY] -= ty;
1139 f[j_coord_offset+DIM*1+ZZ] -= tz;
1141 /**************************
1142 * CALCULATE INTERACTIONS *
1143 **************************/
1147 /* EWALD ELECTROSTATICS */
1149 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1150 ewrt = r32*ewtabscale;
1152 eweps = ewrt-ewitab;
1153 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1154 felec = qq32*rinv32*(rinvsq32-felec);
1158 /* Calculate temporary vectorial force */
1163 /* Update vectorial force */
1167 f[j_coord_offset+DIM*2+XX] -= tx;
1168 f[j_coord_offset+DIM*2+YY] -= ty;
1169 f[j_coord_offset+DIM*2+ZZ] -= tz;
1171 /**************************
1172 * CALCULATE INTERACTIONS *
1173 **************************/
1177 /* EWALD ELECTROSTATICS */
1179 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1180 ewrt = r33*ewtabscale;
1182 eweps = ewrt-ewitab;
1183 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1184 felec = qq33*rinv33*(rinvsq33-felec);
1188 /* Calculate temporary vectorial force */
1193 /* Update vectorial force */
1197 f[j_coord_offset+DIM*3+XX] -= tx;
1198 f[j_coord_offset+DIM*3+YY] -= ty;
1199 f[j_coord_offset+DIM*3+ZZ] -= tz;
1201 /* Inner loop uses 324 flops */
1203 /* End of innermost loop */
1206 f[i_coord_offset+DIM*0+XX] += fix0;
1207 f[i_coord_offset+DIM*0+YY] += fiy0;
1208 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1212 f[i_coord_offset+DIM*1+XX] += fix1;
1213 f[i_coord_offset+DIM*1+YY] += fiy1;
1214 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1218 f[i_coord_offset+DIM*2+XX] += fix2;
1219 f[i_coord_offset+DIM*2+YY] += fiy2;
1220 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1224 f[i_coord_offset+DIM*3+XX] += fix3;
1225 f[i_coord_offset+DIM*3+YY] += fiy3;
1226 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1230 fshift[i_shift_offset+XX] += tx;
1231 fshift[i_shift_offset+YY] += ty;
1232 fshift[i_shift_offset+ZZ] += tz;
1234 /* Increment number of inner iterations */
1235 inneriter += j_index_end - j_index_start;
1237 /* Outer loop uses 39 flops */
1240 /* Increment number of outer iterations */
1243 /* Update outer/inner flops */
1245 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*324);