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_ElecEwSh_VdwLJSh_GeomW4W4_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_VdwLJSh_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];
137 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
138 rcutoff = fr->rcoulomb;
139 rcutoff2 = rcutoff*rcutoff;
141 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
147 /* Start outer loop over neighborlists */
148 for(iidx=0; iidx<nri; iidx++)
150 /* Load shift vector for this list */
151 i_shift_offset = DIM*shiftidx[iidx];
152 shX = shiftvec[i_shift_offset+XX];
153 shY = shiftvec[i_shift_offset+YY];
154 shZ = shiftvec[i_shift_offset+ZZ];
156 /* Load limits for loop over neighbors */
157 j_index_start = jindex[iidx];
158 j_index_end = jindex[iidx+1];
160 /* Get outer coordinate index */
162 i_coord_offset = DIM*inr;
164 /* Load i particle coords and add shift vector */
165 ix0 = shX + x[i_coord_offset+DIM*0+XX];
166 iy0 = shY + x[i_coord_offset+DIM*0+YY];
167 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
168 ix1 = shX + x[i_coord_offset+DIM*1+XX];
169 iy1 = shY + x[i_coord_offset+DIM*1+YY];
170 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
171 ix2 = shX + x[i_coord_offset+DIM*2+XX];
172 iy2 = shY + x[i_coord_offset+DIM*2+YY];
173 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
174 ix3 = shX + x[i_coord_offset+DIM*3+XX];
175 iy3 = shY + x[i_coord_offset+DIM*3+YY];
176 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
191 /* Reset potential sums */
195 /* Start inner kernel loop */
196 for(jidx=j_index_start; jidx<j_index_end; jidx++)
198 /* Get j neighbor index, and coordinate index */
200 j_coord_offset = DIM*jnr;
202 /* load j atom coordinates */
203 jx0 = x[j_coord_offset+DIM*0+XX];
204 jy0 = x[j_coord_offset+DIM*0+YY];
205 jz0 = x[j_coord_offset+DIM*0+ZZ];
206 jx1 = x[j_coord_offset+DIM*1+XX];
207 jy1 = x[j_coord_offset+DIM*1+YY];
208 jz1 = x[j_coord_offset+DIM*1+ZZ];
209 jx2 = x[j_coord_offset+DIM*2+XX];
210 jy2 = x[j_coord_offset+DIM*2+YY];
211 jz2 = x[j_coord_offset+DIM*2+ZZ];
212 jx3 = x[j_coord_offset+DIM*3+XX];
213 jy3 = x[j_coord_offset+DIM*3+YY];
214 jz3 = x[j_coord_offset+DIM*3+ZZ];
216 /* Calculate displacement vector */
248 /* Calculate squared distance and things based on it */
249 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
250 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
251 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
252 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
253 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
254 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
255 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
256 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
257 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
258 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
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 rinvsq00 = 1.0/rsq00;
271 rinvsq11 = rinv11*rinv11;
272 rinvsq12 = rinv12*rinv12;
273 rinvsq13 = rinv13*rinv13;
274 rinvsq21 = rinv21*rinv21;
275 rinvsq22 = rinv22*rinv22;
276 rinvsq23 = rinv23*rinv23;
277 rinvsq31 = rinv31*rinv31;
278 rinvsq32 = rinv32*rinv32;
279 rinvsq33 = rinv33*rinv33;
281 /**************************
282 * CALCULATE INTERACTIONS *
283 **************************/
288 /* LENNARD-JONES DISPERSION/REPULSION */
290 rinvsix = rinvsq00*rinvsq00*rinvsq00;
291 vvdw6 = c6_00*rinvsix;
292 vvdw12 = c12_00*rinvsix*rinvsix;
293 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
294 fvdw = (vvdw12-vvdw6)*rinvsq00;
296 /* Update potential sums from outer loop */
301 /* Calculate temporary vectorial force */
306 /* Update vectorial force */
310 f[j_coord_offset+DIM*0+XX] -= tx;
311 f[j_coord_offset+DIM*0+YY] -= ty;
312 f[j_coord_offset+DIM*0+ZZ] -= tz;
316 /**************************
317 * CALCULATE INTERACTIONS *
318 **************************/
325 /* EWALD ELECTROSTATICS */
327 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
328 ewrt = r11*ewtabscale;
332 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
333 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
334 felec = qq11*rinv11*(rinvsq11-felec);
336 /* Update potential sums from outer loop */
341 /* Calculate temporary vectorial force */
346 /* Update vectorial force */
350 f[j_coord_offset+DIM*1+XX] -= tx;
351 f[j_coord_offset+DIM*1+YY] -= ty;
352 f[j_coord_offset+DIM*1+ZZ] -= tz;
356 /**************************
357 * CALCULATE INTERACTIONS *
358 **************************/
365 /* EWALD ELECTROSTATICS */
367 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
368 ewrt = r12*ewtabscale;
372 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
373 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
374 felec = qq12*rinv12*(rinvsq12-felec);
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 **************************/
405 /* EWALD ELECTROSTATICS */
407 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
408 ewrt = r13*ewtabscale;
412 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
413 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
414 felec = qq13*rinv13*(rinvsq13-felec);
416 /* Update potential sums from outer loop */
421 /* Calculate temporary vectorial force */
426 /* Update vectorial force */
430 f[j_coord_offset+DIM*3+XX] -= tx;
431 f[j_coord_offset+DIM*3+YY] -= ty;
432 f[j_coord_offset+DIM*3+ZZ] -= tz;
436 /**************************
437 * CALCULATE INTERACTIONS *
438 **************************/
445 /* EWALD ELECTROSTATICS */
447 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
448 ewrt = r21*ewtabscale;
452 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
453 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
454 felec = qq21*rinv21*(rinvsq21-felec);
456 /* Update potential sums from outer loop */
461 /* Calculate temporary vectorial force */
466 /* Update vectorial force */
470 f[j_coord_offset+DIM*1+XX] -= tx;
471 f[j_coord_offset+DIM*1+YY] -= ty;
472 f[j_coord_offset+DIM*1+ZZ] -= tz;
476 /**************************
477 * CALCULATE INTERACTIONS *
478 **************************/
485 /* EWALD ELECTROSTATICS */
487 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
488 ewrt = r22*ewtabscale;
492 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
493 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
494 felec = qq22*rinv22*(rinvsq22-felec);
496 /* Update potential sums from outer loop */
501 /* Calculate temporary vectorial force */
506 /* Update vectorial force */
510 f[j_coord_offset+DIM*2+XX] -= tx;
511 f[j_coord_offset+DIM*2+YY] -= ty;
512 f[j_coord_offset+DIM*2+ZZ] -= tz;
516 /**************************
517 * CALCULATE INTERACTIONS *
518 **************************/
525 /* EWALD ELECTROSTATICS */
527 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
528 ewrt = r23*ewtabscale;
532 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
533 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
534 felec = qq23*rinv23*(rinvsq23-felec);
536 /* Update potential sums from outer loop */
541 /* Calculate temporary vectorial force */
546 /* Update vectorial force */
550 f[j_coord_offset+DIM*3+XX] -= tx;
551 f[j_coord_offset+DIM*3+YY] -= ty;
552 f[j_coord_offset+DIM*3+ZZ] -= tz;
556 /**************************
557 * CALCULATE INTERACTIONS *
558 **************************/
565 /* EWALD ELECTROSTATICS */
567 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
568 ewrt = r31*ewtabscale;
572 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
573 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
574 felec = qq31*rinv31*(rinvsq31-felec);
576 /* Update potential sums from outer loop */
581 /* Calculate temporary vectorial force */
586 /* Update vectorial force */
590 f[j_coord_offset+DIM*1+XX] -= tx;
591 f[j_coord_offset+DIM*1+YY] -= ty;
592 f[j_coord_offset+DIM*1+ZZ] -= tz;
596 /**************************
597 * CALCULATE INTERACTIONS *
598 **************************/
605 /* EWALD ELECTROSTATICS */
607 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
608 ewrt = r32*ewtabscale;
612 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
613 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
614 felec = qq32*rinv32*(rinvsq32-felec);
616 /* Update potential sums from outer loop */
621 /* Calculate temporary vectorial force */
626 /* Update vectorial force */
630 f[j_coord_offset+DIM*2+XX] -= tx;
631 f[j_coord_offset+DIM*2+YY] -= ty;
632 f[j_coord_offset+DIM*2+ZZ] -= tz;
636 /**************************
637 * CALCULATE INTERACTIONS *
638 **************************/
645 /* EWALD ELECTROSTATICS */
647 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
648 ewrt = r33*ewtabscale;
652 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
653 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
654 felec = qq33*rinv33*(rinvsq33-felec);
656 /* Update potential sums from outer loop */
661 /* Calculate temporary vectorial force */
666 /* Update vectorial force */
670 f[j_coord_offset+DIM*3+XX] -= tx;
671 f[j_coord_offset+DIM*3+YY] -= ty;
672 f[j_coord_offset+DIM*3+ZZ] -= tz;
676 /* Inner loop uses 406 flops */
678 /* End of innermost loop */
681 f[i_coord_offset+DIM*0+XX] += fix0;
682 f[i_coord_offset+DIM*0+YY] += fiy0;
683 f[i_coord_offset+DIM*0+ZZ] += fiz0;
687 f[i_coord_offset+DIM*1+XX] += fix1;
688 f[i_coord_offset+DIM*1+YY] += fiy1;
689 f[i_coord_offset+DIM*1+ZZ] += fiz1;
693 f[i_coord_offset+DIM*2+XX] += fix2;
694 f[i_coord_offset+DIM*2+YY] += fiy2;
695 f[i_coord_offset+DIM*2+ZZ] += fiz2;
699 f[i_coord_offset+DIM*3+XX] += fix3;
700 f[i_coord_offset+DIM*3+YY] += fiy3;
701 f[i_coord_offset+DIM*3+ZZ] += fiz3;
705 fshift[i_shift_offset+XX] += tx;
706 fshift[i_shift_offset+YY] += ty;
707 fshift[i_shift_offset+ZZ] += tz;
710 /* Update potential energies */
711 kernel_data->energygrp_elec[ggid] += velecsum;
712 kernel_data->energygrp_vdw[ggid] += vvdwsum;
714 /* Increment number of inner iterations */
715 inneriter += j_index_end - j_index_start;
717 /* Outer loop uses 41 flops */
720 /* Increment number of outer iterations */
723 /* Update outer/inner flops */
725 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*406);
728 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_c
729 * Electrostatics interaction: Ewald
730 * VdW interaction: LennardJones
731 * Geometry: Water4-Water4
732 * Calculate force/pot: Force
735 nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_c
736 (t_nblist * gmx_restrict nlist,
737 rvec * gmx_restrict xx,
738 rvec * gmx_restrict ff,
739 t_forcerec * gmx_restrict fr,
740 t_mdatoms * gmx_restrict mdatoms,
741 nb_kernel_data_t * gmx_restrict kernel_data,
742 t_nrnb * gmx_restrict nrnb)
744 int i_shift_offset,i_coord_offset,j_coord_offset;
745 int j_index_start,j_index_end;
746 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
747 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
748 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
749 real *shiftvec,*fshift,*x,*f;
751 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
753 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
755 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
757 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
759 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
761 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
763 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
765 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
766 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
767 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
768 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
769 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
770 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
771 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
772 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
773 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
774 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
775 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
776 real velec,felec,velecsum,facel,crf,krf,krf2;
779 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
783 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
791 jindex = nlist->jindex;
793 shiftidx = nlist->shift;
795 shiftvec = fr->shift_vec[0];
796 fshift = fr->fshift[0];
798 charge = mdatoms->chargeA;
799 nvdwtype = fr->ntype;
801 vdwtype = mdatoms->typeA;
803 sh_ewald = fr->ic->sh_ewald;
804 ewtab = fr->ic->tabq_coul_F;
805 ewtabscale = fr->ic->tabq_scale;
806 ewtabhalfspace = 0.5/ewtabscale;
808 /* Setup water-specific parameters */
809 inr = nlist->iinr[0];
810 iq1 = facel*charge[inr+1];
811 iq2 = facel*charge[inr+2];
812 iq3 = facel*charge[inr+3];
813 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
818 vdwjidx0 = 2*vdwtype[inr+0];
819 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
820 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
831 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
832 rcutoff = fr->rcoulomb;
833 rcutoff2 = rcutoff*rcutoff;
835 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
841 /* Start outer loop over neighborlists */
842 for(iidx=0; iidx<nri; iidx++)
844 /* Load shift vector for this list */
845 i_shift_offset = DIM*shiftidx[iidx];
846 shX = shiftvec[i_shift_offset+XX];
847 shY = shiftvec[i_shift_offset+YY];
848 shZ = shiftvec[i_shift_offset+ZZ];
850 /* Load limits for loop over neighbors */
851 j_index_start = jindex[iidx];
852 j_index_end = jindex[iidx+1];
854 /* Get outer coordinate index */
856 i_coord_offset = DIM*inr;
858 /* Load i particle coords and add shift vector */
859 ix0 = shX + x[i_coord_offset+DIM*0+XX];
860 iy0 = shY + x[i_coord_offset+DIM*0+YY];
861 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
862 ix1 = shX + x[i_coord_offset+DIM*1+XX];
863 iy1 = shY + x[i_coord_offset+DIM*1+YY];
864 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
865 ix2 = shX + x[i_coord_offset+DIM*2+XX];
866 iy2 = shY + x[i_coord_offset+DIM*2+YY];
867 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
868 ix3 = shX + x[i_coord_offset+DIM*3+XX];
869 iy3 = shY + x[i_coord_offset+DIM*3+YY];
870 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
885 /* Start inner kernel loop */
886 for(jidx=j_index_start; jidx<j_index_end; jidx++)
888 /* Get j neighbor index, and coordinate index */
890 j_coord_offset = DIM*jnr;
892 /* load j atom coordinates */
893 jx0 = x[j_coord_offset+DIM*0+XX];
894 jy0 = x[j_coord_offset+DIM*0+YY];
895 jz0 = x[j_coord_offset+DIM*0+ZZ];
896 jx1 = x[j_coord_offset+DIM*1+XX];
897 jy1 = x[j_coord_offset+DIM*1+YY];
898 jz1 = x[j_coord_offset+DIM*1+ZZ];
899 jx2 = x[j_coord_offset+DIM*2+XX];
900 jy2 = x[j_coord_offset+DIM*2+YY];
901 jz2 = x[j_coord_offset+DIM*2+ZZ];
902 jx3 = x[j_coord_offset+DIM*3+XX];
903 jy3 = x[j_coord_offset+DIM*3+YY];
904 jz3 = x[j_coord_offset+DIM*3+ZZ];
906 /* Calculate displacement vector */
938 /* Calculate squared distance and things based on it */
939 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
940 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
941 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
942 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
943 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
944 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
945 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
946 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
947 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
948 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
950 rinv11 = gmx_invsqrt(rsq11);
951 rinv12 = gmx_invsqrt(rsq12);
952 rinv13 = gmx_invsqrt(rsq13);
953 rinv21 = gmx_invsqrt(rsq21);
954 rinv22 = gmx_invsqrt(rsq22);
955 rinv23 = gmx_invsqrt(rsq23);
956 rinv31 = gmx_invsqrt(rsq31);
957 rinv32 = gmx_invsqrt(rsq32);
958 rinv33 = gmx_invsqrt(rsq33);
960 rinvsq00 = 1.0/rsq00;
961 rinvsq11 = rinv11*rinv11;
962 rinvsq12 = rinv12*rinv12;
963 rinvsq13 = rinv13*rinv13;
964 rinvsq21 = rinv21*rinv21;
965 rinvsq22 = rinv22*rinv22;
966 rinvsq23 = rinv23*rinv23;
967 rinvsq31 = rinv31*rinv31;
968 rinvsq32 = rinv32*rinv32;
969 rinvsq33 = rinv33*rinv33;
971 /**************************
972 * CALCULATE INTERACTIONS *
973 **************************/
978 /* LENNARD-JONES DISPERSION/REPULSION */
980 rinvsix = rinvsq00*rinvsq00*rinvsq00;
981 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
985 /* Calculate temporary vectorial force */
990 /* Update vectorial force */
994 f[j_coord_offset+DIM*0+XX] -= tx;
995 f[j_coord_offset+DIM*0+YY] -= ty;
996 f[j_coord_offset+DIM*0+ZZ] -= tz;
1000 /**************************
1001 * CALCULATE INTERACTIONS *
1002 **************************/
1009 /* EWALD ELECTROSTATICS */
1011 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1012 ewrt = r11*ewtabscale;
1014 eweps = ewrt-ewitab;
1015 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1016 felec = qq11*rinv11*(rinvsq11-felec);
1020 /* Calculate temporary vectorial force */
1025 /* Update vectorial force */
1029 f[j_coord_offset+DIM*1+XX] -= tx;
1030 f[j_coord_offset+DIM*1+YY] -= ty;
1031 f[j_coord_offset+DIM*1+ZZ] -= tz;
1035 /**************************
1036 * CALCULATE INTERACTIONS *
1037 **************************/
1044 /* EWALD ELECTROSTATICS */
1046 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1047 ewrt = r12*ewtabscale;
1049 eweps = ewrt-ewitab;
1050 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1051 felec = qq12*rinv12*(rinvsq12-felec);
1055 /* Calculate temporary vectorial force */
1060 /* Update vectorial force */
1064 f[j_coord_offset+DIM*2+XX] -= tx;
1065 f[j_coord_offset+DIM*2+YY] -= ty;
1066 f[j_coord_offset+DIM*2+ZZ] -= tz;
1070 /**************************
1071 * CALCULATE INTERACTIONS *
1072 **************************/
1079 /* EWALD ELECTROSTATICS */
1081 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1082 ewrt = r13*ewtabscale;
1084 eweps = ewrt-ewitab;
1085 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1086 felec = qq13*rinv13*(rinvsq13-felec);
1090 /* Calculate temporary vectorial force */
1095 /* Update vectorial force */
1099 f[j_coord_offset+DIM*3+XX] -= tx;
1100 f[j_coord_offset+DIM*3+YY] -= ty;
1101 f[j_coord_offset+DIM*3+ZZ] -= tz;
1105 /**************************
1106 * CALCULATE INTERACTIONS *
1107 **************************/
1114 /* EWALD ELECTROSTATICS */
1116 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1117 ewrt = r21*ewtabscale;
1119 eweps = ewrt-ewitab;
1120 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1121 felec = qq21*rinv21*(rinvsq21-felec);
1125 /* Calculate temporary vectorial force */
1130 /* Update vectorial force */
1134 f[j_coord_offset+DIM*1+XX] -= tx;
1135 f[j_coord_offset+DIM*1+YY] -= ty;
1136 f[j_coord_offset+DIM*1+ZZ] -= tz;
1140 /**************************
1141 * CALCULATE INTERACTIONS *
1142 **************************/
1149 /* EWALD ELECTROSTATICS */
1151 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1152 ewrt = r22*ewtabscale;
1154 eweps = ewrt-ewitab;
1155 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1156 felec = qq22*rinv22*(rinvsq22-felec);
1160 /* Calculate temporary vectorial force */
1165 /* Update vectorial force */
1169 f[j_coord_offset+DIM*2+XX] -= tx;
1170 f[j_coord_offset+DIM*2+YY] -= ty;
1171 f[j_coord_offset+DIM*2+ZZ] -= tz;
1175 /**************************
1176 * CALCULATE INTERACTIONS *
1177 **************************/
1184 /* EWALD ELECTROSTATICS */
1186 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1187 ewrt = r23*ewtabscale;
1189 eweps = ewrt-ewitab;
1190 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1191 felec = qq23*rinv23*(rinvsq23-felec);
1195 /* Calculate temporary vectorial force */
1200 /* Update vectorial force */
1204 f[j_coord_offset+DIM*3+XX] -= tx;
1205 f[j_coord_offset+DIM*3+YY] -= ty;
1206 f[j_coord_offset+DIM*3+ZZ] -= tz;
1210 /**************************
1211 * CALCULATE INTERACTIONS *
1212 **************************/
1219 /* EWALD ELECTROSTATICS */
1221 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1222 ewrt = r31*ewtabscale;
1224 eweps = ewrt-ewitab;
1225 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1226 felec = qq31*rinv31*(rinvsq31-felec);
1230 /* Calculate temporary vectorial force */
1235 /* Update vectorial force */
1239 f[j_coord_offset+DIM*1+XX] -= tx;
1240 f[j_coord_offset+DIM*1+YY] -= ty;
1241 f[j_coord_offset+DIM*1+ZZ] -= tz;
1245 /**************************
1246 * CALCULATE INTERACTIONS *
1247 **************************/
1254 /* EWALD ELECTROSTATICS */
1256 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1257 ewrt = r32*ewtabscale;
1259 eweps = ewrt-ewitab;
1260 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1261 felec = qq32*rinv32*(rinvsq32-felec);
1265 /* Calculate temporary vectorial force */
1270 /* Update vectorial force */
1274 f[j_coord_offset+DIM*2+XX] -= tx;
1275 f[j_coord_offset+DIM*2+YY] -= ty;
1276 f[j_coord_offset+DIM*2+ZZ] -= tz;
1280 /**************************
1281 * CALCULATE INTERACTIONS *
1282 **************************/
1289 /* EWALD ELECTROSTATICS */
1291 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1292 ewrt = r33*ewtabscale;
1294 eweps = ewrt-ewitab;
1295 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1296 felec = qq33*rinv33*(rinvsq33-felec);
1300 /* Calculate temporary vectorial force */
1305 /* Update vectorial force */
1309 f[j_coord_offset+DIM*3+XX] -= tx;
1310 f[j_coord_offset+DIM*3+YY] -= ty;
1311 f[j_coord_offset+DIM*3+ZZ] -= tz;
1315 /* Inner loop uses 324 flops */
1317 /* End of innermost loop */
1320 f[i_coord_offset+DIM*0+XX] += fix0;
1321 f[i_coord_offset+DIM*0+YY] += fiy0;
1322 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1326 f[i_coord_offset+DIM*1+XX] += fix1;
1327 f[i_coord_offset+DIM*1+YY] += fiy1;
1328 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1332 f[i_coord_offset+DIM*2+XX] += fix2;
1333 f[i_coord_offset+DIM*2+YY] += fiy2;
1334 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1338 f[i_coord_offset+DIM*3+XX] += fix3;
1339 f[i_coord_offset+DIM*3+YY] += fiy3;
1340 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1344 fshift[i_shift_offset+XX] += tx;
1345 fshift[i_shift_offset+YY] += ty;
1346 fshift[i_shift_offset+ZZ] += tz;
1348 /* Increment number of inner iterations */
1349 inneriter += j_index_end - j_index_start;
1351 /* Outer loop uses 39 flops */
1354 /* Increment number of outer iterations */
1357 /* Update outer/inner flops */
1359 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*324);