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_VdwCSTab_GeomW4W4_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_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;
92 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
100 jindex = nlist->jindex;
102 shiftidx = nlist->shift;
104 shiftvec = fr->shift_vec[0];
105 fshift = fr->fshift[0];
107 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 sh_ewald = fr->ic->sh_ewald;
116 ewtab = fr->ic->tabq_coul_FDV0;
117 ewtabscale = fr->ic->tabq_scale;
118 ewtabhalfspace = 0.5/ewtabscale;
120 /* Setup water-specific parameters */
121 inr = nlist->iinr[0];
122 iq1 = facel*charge[inr+1];
123 iq2 = facel*charge[inr+2];
124 iq3 = facel*charge[inr+3];
125 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
130 vdwjidx0 = 2*vdwtype[inr+0];
131 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
132 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
146 /* Start outer loop over neighborlists */
147 for(iidx=0; iidx<nri; iidx++)
149 /* Load shift vector for this list */
150 i_shift_offset = DIM*shiftidx[iidx];
151 shX = shiftvec[i_shift_offset+XX];
152 shY = shiftvec[i_shift_offset+YY];
153 shZ = shiftvec[i_shift_offset+ZZ];
155 /* Load limits for loop over neighbors */
156 j_index_start = jindex[iidx];
157 j_index_end = jindex[iidx+1];
159 /* Get outer coordinate index */
161 i_coord_offset = DIM*inr;
163 /* Load i particle coords and add shift vector */
164 ix0 = shX + x[i_coord_offset+DIM*0+XX];
165 iy0 = shY + x[i_coord_offset+DIM*0+YY];
166 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
167 ix1 = shX + x[i_coord_offset+DIM*1+XX];
168 iy1 = shY + x[i_coord_offset+DIM*1+YY];
169 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
170 ix2 = shX + x[i_coord_offset+DIM*2+XX];
171 iy2 = shY + x[i_coord_offset+DIM*2+YY];
172 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
173 ix3 = shX + x[i_coord_offset+DIM*3+XX];
174 iy3 = shY + x[i_coord_offset+DIM*3+YY];
175 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
190 /* Reset potential sums */
194 /* Start inner kernel loop */
195 for(jidx=j_index_start; jidx<j_index_end; jidx++)
197 /* Get j neighbor index, and coordinate index */
199 j_coord_offset = DIM*jnr;
201 /* load j atom coordinates */
202 jx0 = x[j_coord_offset+DIM*0+XX];
203 jy0 = x[j_coord_offset+DIM*0+YY];
204 jz0 = x[j_coord_offset+DIM*0+ZZ];
205 jx1 = x[j_coord_offset+DIM*1+XX];
206 jy1 = x[j_coord_offset+DIM*1+YY];
207 jz1 = x[j_coord_offset+DIM*1+ZZ];
208 jx2 = x[j_coord_offset+DIM*2+XX];
209 jy2 = x[j_coord_offset+DIM*2+YY];
210 jz2 = x[j_coord_offset+DIM*2+ZZ];
211 jx3 = x[j_coord_offset+DIM*3+XX];
212 jy3 = x[j_coord_offset+DIM*3+YY];
213 jz3 = x[j_coord_offset+DIM*3+ZZ];
215 /* Calculate displacement vector */
247 /* Calculate squared distance and things based on it */
248 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
249 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
250 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
251 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
252 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
253 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
254 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
255 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
256 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
257 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
259 rinv00 = gmx_invsqrt(rsq00);
260 rinv11 = gmx_invsqrt(rsq11);
261 rinv12 = gmx_invsqrt(rsq12);
262 rinv13 = gmx_invsqrt(rsq13);
263 rinv21 = gmx_invsqrt(rsq21);
264 rinv22 = gmx_invsqrt(rsq22);
265 rinv23 = gmx_invsqrt(rsq23);
266 rinv31 = gmx_invsqrt(rsq31);
267 rinv32 = gmx_invsqrt(rsq32);
268 rinv33 = gmx_invsqrt(rsq33);
270 rinvsq11 = rinv11*rinv11;
271 rinvsq12 = rinv12*rinv12;
272 rinvsq13 = rinv13*rinv13;
273 rinvsq21 = rinv21*rinv21;
274 rinvsq22 = rinv22*rinv22;
275 rinvsq23 = rinv23*rinv23;
276 rinvsq31 = rinv31*rinv31;
277 rinvsq32 = rinv32*rinv32;
278 rinvsq33 = rinv33*rinv33;
280 /**************************
281 * CALCULATE INTERACTIONS *
282 **************************/
286 /* Calculate table index by multiplying r with table scale and truncate to integer */
292 /* CUBIC SPLINE TABLE DISPERSION */
296 Geps = vfeps*vftab[vfitab+2];
297 Heps2 = vfeps*vfeps*vftab[vfitab+3];
301 FF = Fp+Geps+2.0*Heps2;
304 /* CUBIC SPLINE TABLE REPULSION */
307 Geps = vfeps*vftab[vfitab+6];
308 Heps2 = vfeps*vfeps*vftab[vfitab+7];
312 FF = Fp+Geps+2.0*Heps2;
315 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
317 /* Update potential sums from outer loop */
322 /* Calculate temporary vectorial force */
327 /* Update vectorial force */
331 f[j_coord_offset+DIM*0+XX] -= tx;
332 f[j_coord_offset+DIM*0+YY] -= ty;
333 f[j_coord_offset+DIM*0+ZZ] -= tz;
335 /**************************
336 * CALCULATE INTERACTIONS *
337 **************************/
341 /* EWALD ELECTROSTATICS */
343 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
344 ewrt = r11*ewtabscale;
348 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
349 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
350 felec = qq11*rinv11*(rinvsq11-felec);
352 /* Update potential sums from outer loop */
357 /* Calculate temporary vectorial force */
362 /* Update vectorial force */
366 f[j_coord_offset+DIM*1+XX] -= tx;
367 f[j_coord_offset+DIM*1+YY] -= ty;
368 f[j_coord_offset+DIM*1+ZZ] -= tz;
370 /**************************
371 * CALCULATE INTERACTIONS *
372 **************************/
376 /* EWALD ELECTROSTATICS */
378 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
379 ewrt = r12*ewtabscale;
383 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
384 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
385 felec = qq12*rinv12*(rinvsq12-felec);
387 /* Update potential sums from outer loop */
392 /* Calculate temporary vectorial force */
397 /* Update vectorial force */
401 f[j_coord_offset+DIM*2+XX] -= tx;
402 f[j_coord_offset+DIM*2+YY] -= ty;
403 f[j_coord_offset+DIM*2+ZZ] -= tz;
405 /**************************
406 * CALCULATE INTERACTIONS *
407 **************************/
411 /* EWALD ELECTROSTATICS */
413 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
414 ewrt = r13*ewtabscale;
418 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
419 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
420 felec = qq13*rinv13*(rinvsq13-felec);
422 /* Update potential sums from outer loop */
427 /* Calculate temporary vectorial force */
432 /* Update vectorial force */
436 f[j_coord_offset+DIM*3+XX] -= tx;
437 f[j_coord_offset+DIM*3+YY] -= ty;
438 f[j_coord_offset+DIM*3+ZZ] -= tz;
440 /**************************
441 * CALCULATE INTERACTIONS *
442 **************************/
446 /* EWALD ELECTROSTATICS */
448 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
449 ewrt = r21*ewtabscale;
453 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
454 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
455 felec = qq21*rinv21*(rinvsq21-felec);
457 /* Update potential sums from outer loop */
462 /* Calculate temporary vectorial force */
467 /* Update vectorial force */
471 f[j_coord_offset+DIM*1+XX] -= tx;
472 f[j_coord_offset+DIM*1+YY] -= ty;
473 f[j_coord_offset+DIM*1+ZZ] -= tz;
475 /**************************
476 * CALCULATE INTERACTIONS *
477 **************************/
481 /* EWALD ELECTROSTATICS */
483 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
484 ewrt = r22*ewtabscale;
488 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
489 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
490 felec = qq22*rinv22*(rinvsq22-felec);
492 /* Update potential sums from outer loop */
497 /* Calculate temporary vectorial force */
502 /* Update vectorial force */
506 f[j_coord_offset+DIM*2+XX] -= tx;
507 f[j_coord_offset+DIM*2+YY] -= ty;
508 f[j_coord_offset+DIM*2+ZZ] -= tz;
510 /**************************
511 * CALCULATE INTERACTIONS *
512 **************************/
516 /* EWALD ELECTROSTATICS */
518 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
519 ewrt = r23*ewtabscale;
523 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
524 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
525 felec = qq23*rinv23*(rinvsq23-felec);
527 /* Update potential sums from outer loop */
532 /* Calculate temporary vectorial force */
537 /* Update vectorial force */
541 f[j_coord_offset+DIM*3+XX] -= tx;
542 f[j_coord_offset+DIM*3+YY] -= ty;
543 f[j_coord_offset+DIM*3+ZZ] -= tz;
545 /**************************
546 * CALCULATE INTERACTIONS *
547 **************************/
551 /* EWALD ELECTROSTATICS */
553 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
554 ewrt = r31*ewtabscale;
558 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
559 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
560 felec = qq31*rinv31*(rinvsq31-felec);
562 /* Update potential sums from outer loop */
567 /* Calculate temporary vectorial force */
572 /* Update vectorial force */
576 f[j_coord_offset+DIM*1+XX] -= tx;
577 f[j_coord_offset+DIM*1+YY] -= ty;
578 f[j_coord_offset+DIM*1+ZZ] -= tz;
580 /**************************
581 * CALCULATE INTERACTIONS *
582 **************************/
586 /* EWALD ELECTROSTATICS */
588 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
589 ewrt = r32*ewtabscale;
593 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
594 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
595 felec = qq32*rinv32*(rinvsq32-felec);
597 /* Update potential sums from outer loop */
602 /* Calculate temporary vectorial force */
607 /* Update vectorial force */
611 f[j_coord_offset+DIM*2+XX] -= tx;
612 f[j_coord_offset+DIM*2+YY] -= ty;
613 f[j_coord_offset+DIM*2+ZZ] -= tz;
615 /**************************
616 * CALCULATE INTERACTIONS *
617 **************************/
621 /* EWALD ELECTROSTATICS */
623 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
624 ewrt = r33*ewtabscale;
628 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
629 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
630 felec = qq33*rinv33*(rinvsq33-felec);
632 /* Update potential sums from outer loop */
637 /* Calculate temporary vectorial force */
642 /* Update vectorial force */
646 f[j_coord_offset+DIM*3+XX] -= tx;
647 f[j_coord_offset+DIM*3+YY] -= ty;
648 f[j_coord_offset+DIM*3+ZZ] -= tz;
650 /* Inner loop uses 415 flops */
652 /* End of innermost loop */
655 f[i_coord_offset+DIM*0+XX] += fix0;
656 f[i_coord_offset+DIM*0+YY] += fiy0;
657 f[i_coord_offset+DIM*0+ZZ] += fiz0;
661 f[i_coord_offset+DIM*1+XX] += fix1;
662 f[i_coord_offset+DIM*1+YY] += fiy1;
663 f[i_coord_offset+DIM*1+ZZ] += fiz1;
667 f[i_coord_offset+DIM*2+XX] += fix2;
668 f[i_coord_offset+DIM*2+YY] += fiy2;
669 f[i_coord_offset+DIM*2+ZZ] += fiz2;
673 f[i_coord_offset+DIM*3+XX] += fix3;
674 f[i_coord_offset+DIM*3+YY] += fiy3;
675 f[i_coord_offset+DIM*3+ZZ] += fiz3;
679 fshift[i_shift_offset+XX] += tx;
680 fshift[i_shift_offset+YY] += ty;
681 fshift[i_shift_offset+ZZ] += tz;
684 /* Update potential energies */
685 kernel_data->energygrp_elec[ggid] += velecsum;
686 kernel_data->energygrp_vdw[ggid] += vvdwsum;
688 /* Increment number of inner iterations */
689 inneriter += j_index_end - j_index_start;
691 /* Outer loop uses 41 flops */
694 /* Increment number of outer iterations */
697 /* Update outer/inner flops */
699 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*415);
702 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW4W4_F_c
703 * Electrostatics interaction: Ewald
704 * VdW interaction: CubicSplineTable
705 * Geometry: Water4-Water4
706 * Calculate force/pot: Force
709 nb_kernel_ElecEw_VdwCSTab_GeomW4W4_F_c
710 (t_nblist * gmx_restrict nlist,
711 rvec * gmx_restrict xx,
712 rvec * gmx_restrict ff,
713 t_forcerec * gmx_restrict fr,
714 t_mdatoms * gmx_restrict mdatoms,
715 nb_kernel_data_t * gmx_restrict kernel_data,
716 t_nrnb * gmx_restrict nrnb)
718 int i_shift_offset,i_coord_offset,j_coord_offset;
719 int j_index_start,j_index_end;
720 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
721 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
722 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
723 real *shiftvec,*fshift,*x,*f;
725 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
727 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
729 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
731 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
733 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
735 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
737 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
739 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
740 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
741 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
742 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
743 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
744 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
745 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
746 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
747 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
748 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
749 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
750 real velec,felec,velecsum,facel,crf,krf,krf2;
753 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
757 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
760 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
768 jindex = nlist->jindex;
770 shiftidx = nlist->shift;
772 shiftvec = fr->shift_vec[0];
773 fshift = fr->fshift[0];
775 charge = mdatoms->chargeA;
776 nvdwtype = fr->ntype;
778 vdwtype = mdatoms->typeA;
780 vftab = kernel_data->table_vdw->data;
781 vftabscale = kernel_data->table_vdw->scale;
783 sh_ewald = fr->ic->sh_ewald;
784 ewtab = fr->ic->tabq_coul_F;
785 ewtabscale = fr->ic->tabq_scale;
786 ewtabhalfspace = 0.5/ewtabscale;
788 /* Setup water-specific parameters */
789 inr = nlist->iinr[0];
790 iq1 = facel*charge[inr+1];
791 iq2 = facel*charge[inr+2];
792 iq3 = facel*charge[inr+3];
793 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
798 vdwjidx0 = 2*vdwtype[inr+0];
799 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
800 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
814 /* Start outer loop over neighborlists */
815 for(iidx=0; iidx<nri; iidx++)
817 /* Load shift vector for this list */
818 i_shift_offset = DIM*shiftidx[iidx];
819 shX = shiftvec[i_shift_offset+XX];
820 shY = shiftvec[i_shift_offset+YY];
821 shZ = shiftvec[i_shift_offset+ZZ];
823 /* Load limits for loop over neighbors */
824 j_index_start = jindex[iidx];
825 j_index_end = jindex[iidx+1];
827 /* Get outer coordinate index */
829 i_coord_offset = DIM*inr;
831 /* Load i particle coords and add shift vector */
832 ix0 = shX + x[i_coord_offset+DIM*0+XX];
833 iy0 = shY + x[i_coord_offset+DIM*0+YY];
834 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
835 ix1 = shX + x[i_coord_offset+DIM*1+XX];
836 iy1 = shY + x[i_coord_offset+DIM*1+YY];
837 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
838 ix2 = shX + x[i_coord_offset+DIM*2+XX];
839 iy2 = shY + x[i_coord_offset+DIM*2+YY];
840 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
841 ix3 = shX + x[i_coord_offset+DIM*3+XX];
842 iy3 = shY + x[i_coord_offset+DIM*3+YY];
843 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
858 /* Start inner kernel loop */
859 for(jidx=j_index_start; jidx<j_index_end; jidx++)
861 /* Get j neighbor index, and coordinate index */
863 j_coord_offset = DIM*jnr;
865 /* load j atom coordinates */
866 jx0 = x[j_coord_offset+DIM*0+XX];
867 jy0 = x[j_coord_offset+DIM*0+YY];
868 jz0 = x[j_coord_offset+DIM*0+ZZ];
869 jx1 = x[j_coord_offset+DIM*1+XX];
870 jy1 = x[j_coord_offset+DIM*1+YY];
871 jz1 = x[j_coord_offset+DIM*1+ZZ];
872 jx2 = x[j_coord_offset+DIM*2+XX];
873 jy2 = x[j_coord_offset+DIM*2+YY];
874 jz2 = x[j_coord_offset+DIM*2+ZZ];
875 jx3 = x[j_coord_offset+DIM*3+XX];
876 jy3 = x[j_coord_offset+DIM*3+YY];
877 jz3 = x[j_coord_offset+DIM*3+ZZ];
879 /* Calculate displacement vector */
911 /* Calculate squared distance and things based on it */
912 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
913 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
914 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
915 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
916 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
917 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
918 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
919 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
920 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
921 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
923 rinv00 = gmx_invsqrt(rsq00);
924 rinv11 = gmx_invsqrt(rsq11);
925 rinv12 = gmx_invsqrt(rsq12);
926 rinv13 = gmx_invsqrt(rsq13);
927 rinv21 = gmx_invsqrt(rsq21);
928 rinv22 = gmx_invsqrt(rsq22);
929 rinv23 = gmx_invsqrt(rsq23);
930 rinv31 = gmx_invsqrt(rsq31);
931 rinv32 = gmx_invsqrt(rsq32);
932 rinv33 = gmx_invsqrt(rsq33);
934 rinvsq11 = rinv11*rinv11;
935 rinvsq12 = rinv12*rinv12;
936 rinvsq13 = rinv13*rinv13;
937 rinvsq21 = rinv21*rinv21;
938 rinvsq22 = rinv22*rinv22;
939 rinvsq23 = rinv23*rinv23;
940 rinvsq31 = rinv31*rinv31;
941 rinvsq32 = rinv32*rinv32;
942 rinvsq33 = rinv33*rinv33;
944 /**************************
945 * CALCULATE INTERACTIONS *
946 **************************/
950 /* Calculate table index by multiplying r with table scale and truncate to integer */
956 /* CUBIC SPLINE TABLE DISPERSION */
959 Geps = vfeps*vftab[vfitab+2];
960 Heps2 = vfeps*vfeps*vftab[vfitab+3];
962 FF = Fp+Geps+2.0*Heps2;
965 /* CUBIC SPLINE TABLE REPULSION */
967 Geps = vfeps*vftab[vfitab+6];
968 Heps2 = vfeps*vfeps*vftab[vfitab+7];
970 FF = Fp+Geps+2.0*Heps2;
972 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
976 /* Calculate temporary vectorial force */
981 /* Update vectorial force */
985 f[j_coord_offset+DIM*0+XX] -= tx;
986 f[j_coord_offset+DIM*0+YY] -= ty;
987 f[j_coord_offset+DIM*0+ZZ] -= tz;
989 /**************************
990 * CALCULATE INTERACTIONS *
991 **************************/
995 /* EWALD ELECTROSTATICS */
997 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
998 ewrt = r11*ewtabscale;
1000 eweps = ewrt-ewitab;
1001 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1002 felec = qq11*rinv11*(rinvsq11-felec);
1006 /* Calculate temporary vectorial force */
1011 /* Update vectorial force */
1015 f[j_coord_offset+DIM*1+XX] -= tx;
1016 f[j_coord_offset+DIM*1+YY] -= ty;
1017 f[j_coord_offset+DIM*1+ZZ] -= tz;
1019 /**************************
1020 * CALCULATE INTERACTIONS *
1021 **************************/
1025 /* EWALD ELECTROSTATICS */
1027 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1028 ewrt = r12*ewtabscale;
1030 eweps = ewrt-ewitab;
1031 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1032 felec = qq12*rinv12*(rinvsq12-felec);
1036 /* Calculate temporary vectorial force */
1041 /* Update vectorial force */
1045 f[j_coord_offset+DIM*2+XX] -= tx;
1046 f[j_coord_offset+DIM*2+YY] -= ty;
1047 f[j_coord_offset+DIM*2+ZZ] -= tz;
1049 /**************************
1050 * CALCULATE INTERACTIONS *
1051 **************************/
1055 /* EWALD ELECTROSTATICS */
1057 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1058 ewrt = r13*ewtabscale;
1060 eweps = ewrt-ewitab;
1061 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1062 felec = qq13*rinv13*(rinvsq13-felec);
1066 /* Calculate temporary vectorial force */
1071 /* Update vectorial force */
1075 f[j_coord_offset+DIM*3+XX] -= tx;
1076 f[j_coord_offset+DIM*3+YY] -= ty;
1077 f[j_coord_offset+DIM*3+ZZ] -= tz;
1079 /**************************
1080 * CALCULATE INTERACTIONS *
1081 **************************/
1085 /* EWALD ELECTROSTATICS */
1087 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1088 ewrt = r21*ewtabscale;
1090 eweps = ewrt-ewitab;
1091 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1092 felec = qq21*rinv21*(rinvsq21-felec);
1096 /* Calculate temporary vectorial force */
1101 /* Update vectorial force */
1105 f[j_coord_offset+DIM*1+XX] -= tx;
1106 f[j_coord_offset+DIM*1+YY] -= ty;
1107 f[j_coord_offset+DIM*1+ZZ] -= tz;
1109 /**************************
1110 * CALCULATE INTERACTIONS *
1111 **************************/
1115 /* EWALD ELECTROSTATICS */
1117 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1118 ewrt = r22*ewtabscale;
1120 eweps = ewrt-ewitab;
1121 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1122 felec = qq22*rinv22*(rinvsq22-felec);
1126 /* Calculate temporary vectorial force */
1131 /* Update vectorial force */
1135 f[j_coord_offset+DIM*2+XX] -= tx;
1136 f[j_coord_offset+DIM*2+YY] -= ty;
1137 f[j_coord_offset+DIM*2+ZZ] -= tz;
1139 /**************************
1140 * CALCULATE INTERACTIONS *
1141 **************************/
1145 /* EWALD ELECTROSTATICS */
1147 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1148 ewrt = r23*ewtabscale;
1150 eweps = ewrt-ewitab;
1151 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1152 felec = qq23*rinv23*(rinvsq23-felec);
1156 /* Calculate temporary vectorial force */
1161 /* Update vectorial force */
1165 f[j_coord_offset+DIM*3+XX] -= tx;
1166 f[j_coord_offset+DIM*3+YY] -= ty;
1167 f[j_coord_offset+DIM*3+ZZ] -= tz;
1169 /**************************
1170 * CALCULATE INTERACTIONS *
1171 **************************/
1175 /* EWALD ELECTROSTATICS */
1177 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1178 ewrt = r31*ewtabscale;
1180 eweps = ewrt-ewitab;
1181 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1182 felec = qq31*rinv31*(rinvsq31-felec);
1186 /* Calculate temporary vectorial force */
1191 /* Update vectorial force */
1195 f[j_coord_offset+DIM*1+XX] -= tx;
1196 f[j_coord_offset+DIM*1+YY] -= ty;
1197 f[j_coord_offset+DIM*1+ZZ] -= tz;
1199 /**************************
1200 * CALCULATE INTERACTIONS *
1201 **************************/
1205 /* EWALD ELECTROSTATICS */
1207 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1208 ewrt = r32*ewtabscale;
1210 eweps = ewrt-ewitab;
1211 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1212 felec = qq32*rinv32*(rinvsq32-felec);
1216 /* Calculate temporary vectorial force */
1221 /* Update vectorial force */
1225 f[j_coord_offset+DIM*2+XX] -= tx;
1226 f[j_coord_offset+DIM*2+YY] -= ty;
1227 f[j_coord_offset+DIM*2+ZZ] -= tz;
1229 /**************************
1230 * CALCULATE INTERACTIONS *
1231 **************************/
1235 /* EWALD ELECTROSTATICS */
1237 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1238 ewrt = r33*ewtabscale;
1240 eweps = ewrt-ewitab;
1241 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1242 felec = qq33*rinv33*(rinvsq33-felec);
1246 /* Calculate temporary vectorial force */
1251 /* Update vectorial force */
1255 f[j_coord_offset+DIM*3+XX] -= tx;
1256 f[j_coord_offset+DIM*3+YY] -= ty;
1257 f[j_coord_offset+DIM*3+ZZ] -= tz;
1259 /* Inner loop uses 344 flops */
1261 /* End of innermost loop */
1264 f[i_coord_offset+DIM*0+XX] += fix0;
1265 f[i_coord_offset+DIM*0+YY] += fiy0;
1266 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1270 f[i_coord_offset+DIM*1+XX] += fix1;
1271 f[i_coord_offset+DIM*1+YY] += fiy1;
1272 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1276 f[i_coord_offset+DIM*2+XX] += fix2;
1277 f[i_coord_offset+DIM*2+YY] += fiy2;
1278 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1282 f[i_coord_offset+DIM*3+XX] += fix3;
1283 f[i_coord_offset+DIM*3+YY] += fiy3;
1284 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1288 fshift[i_shift_offset+XX] += tx;
1289 fshift[i_shift_offset+YY] += ty;
1290 fshift[i_shift_offset+ZZ] += tz;
1292 /* Increment number of inner iterations */
1293 inneriter += j_index_end - j_index_start;
1295 /* Outer loop uses 39 flops */
1298 /* Increment number of outer iterations */
1301 /* Update outer/inner flops */
1303 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*344);