2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LJEwald
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
106 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
109 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
117 jindex = nlist->jindex;
119 shiftidx = nlist->shift;
121 shiftvec = fr->shift_vec[0];
122 fshift = fr->fshift[0];
124 charge = mdatoms->chargeA;
125 nvdwtype = fr->ntype;
127 vdwtype = mdatoms->typeA;
128 vdwgridparam = fr->ljpme_c6grid;
129 ewclj = fr->ewaldcoeff_lj;
130 sh_lj_ewald = fr->ic->sh_lj_ewald;
131 ewclj2 = ewclj*ewclj;
132 ewclj6 = ewclj2*ewclj2*ewclj2;
134 sh_ewald = fr->ic->sh_ewald;
135 ewtab = fr->ic->tabq_coul_FDV0;
136 ewtabscale = fr->ic->tabq_scale;
137 ewtabhalfspace = 0.5/ewtabscale;
139 /* Setup water-specific parameters */
140 inr = nlist->iinr[0];
141 iq0 = facel*charge[inr+0];
142 iq1 = facel*charge[inr+1];
143 iq2 = facel*charge[inr+2];
144 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
149 vdwjidx0 = 2*vdwtype[inr+0];
151 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
152 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
153 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
163 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
164 rcutoff = fr->rcoulomb;
165 rcutoff2 = rcutoff*rcutoff;
167 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
173 /* Start outer loop over neighborlists */
174 for(iidx=0; iidx<nri; iidx++)
176 /* Load shift vector for this list */
177 i_shift_offset = DIM*shiftidx[iidx];
178 shX = shiftvec[i_shift_offset+XX];
179 shY = shiftvec[i_shift_offset+YY];
180 shZ = shiftvec[i_shift_offset+ZZ];
182 /* Load limits for loop over neighbors */
183 j_index_start = jindex[iidx];
184 j_index_end = jindex[iidx+1];
186 /* Get outer coordinate index */
188 i_coord_offset = DIM*inr;
190 /* Load i particle coords and add shift vector */
191 ix0 = shX + x[i_coord_offset+DIM*0+XX];
192 iy0 = shY + x[i_coord_offset+DIM*0+YY];
193 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
194 ix1 = shX + x[i_coord_offset+DIM*1+XX];
195 iy1 = shY + x[i_coord_offset+DIM*1+YY];
196 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
197 ix2 = shX + x[i_coord_offset+DIM*2+XX];
198 iy2 = shY + x[i_coord_offset+DIM*2+YY];
199 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
211 /* Reset potential sums */
215 /* Start inner kernel loop */
216 for(jidx=j_index_start; jidx<j_index_end; jidx++)
218 /* Get j neighbor index, and coordinate index */
220 j_coord_offset = DIM*jnr;
222 /* load j atom coordinates */
223 jx0 = x[j_coord_offset+DIM*0+XX];
224 jy0 = x[j_coord_offset+DIM*0+YY];
225 jz0 = x[j_coord_offset+DIM*0+ZZ];
226 jx1 = x[j_coord_offset+DIM*1+XX];
227 jy1 = x[j_coord_offset+DIM*1+YY];
228 jz1 = x[j_coord_offset+DIM*1+ZZ];
229 jx2 = x[j_coord_offset+DIM*2+XX];
230 jy2 = x[j_coord_offset+DIM*2+YY];
231 jz2 = x[j_coord_offset+DIM*2+ZZ];
233 /* Calculate displacement vector */
262 /* Calculate squared distance and things based on it */
263 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
264 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
265 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
266 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
267 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
268 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
269 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
270 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
271 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
273 rinv00 = gmx_invsqrt(rsq00);
274 rinv01 = gmx_invsqrt(rsq01);
275 rinv02 = gmx_invsqrt(rsq02);
276 rinv10 = gmx_invsqrt(rsq10);
277 rinv11 = gmx_invsqrt(rsq11);
278 rinv12 = gmx_invsqrt(rsq12);
279 rinv20 = gmx_invsqrt(rsq20);
280 rinv21 = gmx_invsqrt(rsq21);
281 rinv22 = gmx_invsqrt(rsq22);
283 rinvsq00 = rinv00*rinv00;
284 rinvsq01 = rinv01*rinv01;
285 rinvsq02 = rinv02*rinv02;
286 rinvsq10 = rinv10*rinv10;
287 rinvsq11 = rinv11*rinv11;
288 rinvsq12 = rinv12*rinv12;
289 rinvsq20 = rinv20*rinv20;
290 rinvsq21 = rinv21*rinv21;
291 rinvsq22 = rinv22*rinv22;
293 /**************************
294 * CALCULATE INTERACTIONS *
295 **************************/
302 /* EWALD ELECTROSTATICS */
304 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
305 ewrt = r00*ewtabscale;
309 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
310 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
311 felec = qq00*rinv00*(rinvsq00-felec);
313 rinvsix = rinvsq00*rinvsq00*rinvsq00;
314 ewcljrsq = ewclj2*rsq00;
315 exponent = exp(-ewcljrsq);
316 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
317 vvdw6 = (c6_00-c6grid_00*(1.0-poly))*rinvsix;
318 vvdw12 = c12_00*rinvsix*rinvsix;
319 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6 - c6grid_00*sh_lj_ewald)*(1.0/6.0);
320 fvdw = (vvdw12 - vvdw6 - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
322 /* Update potential sums from outer loop */
328 /* Calculate temporary vectorial force */
333 /* Update vectorial force */
337 f[j_coord_offset+DIM*0+XX] -= tx;
338 f[j_coord_offset+DIM*0+YY] -= ty;
339 f[j_coord_offset+DIM*0+ZZ] -= tz;
343 /**************************
344 * CALCULATE INTERACTIONS *
345 **************************/
352 /* EWALD ELECTROSTATICS */
354 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
355 ewrt = r01*ewtabscale;
359 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
360 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
361 felec = qq01*rinv01*(rinvsq01-felec);
363 /* Update potential sums from outer loop */
368 /* Calculate temporary vectorial force */
373 /* Update vectorial force */
377 f[j_coord_offset+DIM*1+XX] -= tx;
378 f[j_coord_offset+DIM*1+YY] -= ty;
379 f[j_coord_offset+DIM*1+ZZ] -= tz;
383 /**************************
384 * CALCULATE INTERACTIONS *
385 **************************/
392 /* EWALD ELECTROSTATICS */
394 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
395 ewrt = r02*ewtabscale;
399 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
400 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
401 felec = qq02*rinv02*(rinvsq02-felec);
403 /* Update potential sums from outer loop */
408 /* Calculate temporary vectorial force */
413 /* Update vectorial force */
417 f[j_coord_offset+DIM*2+XX] -= tx;
418 f[j_coord_offset+DIM*2+YY] -= ty;
419 f[j_coord_offset+DIM*2+ZZ] -= tz;
423 /**************************
424 * CALCULATE INTERACTIONS *
425 **************************/
432 /* EWALD ELECTROSTATICS */
434 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
435 ewrt = r10*ewtabscale;
439 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
440 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
441 felec = qq10*rinv10*(rinvsq10-felec);
443 /* Update potential sums from outer loop */
448 /* Calculate temporary vectorial force */
453 /* Update vectorial force */
457 f[j_coord_offset+DIM*0+XX] -= tx;
458 f[j_coord_offset+DIM*0+YY] -= ty;
459 f[j_coord_offset+DIM*0+ZZ] -= tz;
463 /**************************
464 * CALCULATE INTERACTIONS *
465 **************************/
472 /* EWALD ELECTROSTATICS */
474 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
475 ewrt = r11*ewtabscale;
479 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
480 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
481 felec = qq11*rinv11*(rinvsq11-felec);
483 /* Update potential sums from outer loop */
488 /* Calculate temporary vectorial force */
493 /* Update vectorial force */
497 f[j_coord_offset+DIM*1+XX] -= tx;
498 f[j_coord_offset+DIM*1+YY] -= ty;
499 f[j_coord_offset+DIM*1+ZZ] -= tz;
503 /**************************
504 * CALCULATE INTERACTIONS *
505 **************************/
512 /* EWALD ELECTROSTATICS */
514 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
515 ewrt = r12*ewtabscale;
519 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
520 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
521 felec = qq12*rinv12*(rinvsq12-felec);
523 /* Update potential sums from outer loop */
528 /* Calculate temporary vectorial force */
533 /* Update vectorial force */
537 f[j_coord_offset+DIM*2+XX] -= tx;
538 f[j_coord_offset+DIM*2+YY] -= ty;
539 f[j_coord_offset+DIM*2+ZZ] -= tz;
543 /**************************
544 * CALCULATE INTERACTIONS *
545 **************************/
552 /* EWALD ELECTROSTATICS */
554 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
555 ewrt = r20*ewtabscale;
559 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
560 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
561 felec = qq20*rinv20*(rinvsq20-felec);
563 /* Update potential sums from outer loop */
568 /* Calculate temporary vectorial force */
573 /* Update vectorial force */
577 f[j_coord_offset+DIM*0+XX] -= tx;
578 f[j_coord_offset+DIM*0+YY] -= ty;
579 f[j_coord_offset+DIM*0+ZZ] -= tz;
583 /**************************
584 * CALCULATE INTERACTIONS *
585 **************************/
592 /* EWALD ELECTROSTATICS */
594 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
595 ewrt = r21*ewtabscale;
599 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
600 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
601 felec = qq21*rinv21*(rinvsq21-felec);
603 /* Update potential sums from outer loop */
608 /* Calculate temporary vectorial force */
613 /* Update vectorial force */
617 f[j_coord_offset+DIM*1+XX] -= tx;
618 f[j_coord_offset+DIM*1+YY] -= ty;
619 f[j_coord_offset+DIM*1+ZZ] -= tz;
623 /**************************
624 * CALCULATE INTERACTIONS *
625 **************************/
632 /* EWALD ELECTROSTATICS */
634 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
635 ewrt = r22*ewtabscale;
639 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
640 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
641 felec = qq22*rinv22*(rinvsq22-felec);
643 /* Update potential sums from outer loop */
648 /* Calculate temporary vectorial force */
653 /* Update vectorial force */
657 f[j_coord_offset+DIM*2+XX] -= tx;
658 f[j_coord_offset+DIM*2+YY] -= ty;
659 f[j_coord_offset+DIM*2+ZZ] -= tz;
663 /* Inner loop uses 401 flops */
665 /* End of innermost loop */
668 f[i_coord_offset+DIM*0+XX] += fix0;
669 f[i_coord_offset+DIM*0+YY] += fiy0;
670 f[i_coord_offset+DIM*0+ZZ] += fiz0;
674 f[i_coord_offset+DIM*1+XX] += fix1;
675 f[i_coord_offset+DIM*1+YY] += fiy1;
676 f[i_coord_offset+DIM*1+ZZ] += fiz1;
680 f[i_coord_offset+DIM*2+XX] += fix2;
681 f[i_coord_offset+DIM*2+YY] += fiy2;
682 f[i_coord_offset+DIM*2+ZZ] += fiz2;
686 fshift[i_shift_offset+XX] += tx;
687 fshift[i_shift_offset+YY] += ty;
688 fshift[i_shift_offset+ZZ] += tz;
691 /* Update potential energies */
692 kernel_data->energygrp_elec[ggid] += velecsum;
693 kernel_data->energygrp_vdw[ggid] += vvdwsum;
695 /* Increment number of inner iterations */
696 inneriter += j_index_end - j_index_start;
698 /* Outer loop uses 32 flops */
701 /* Increment number of outer iterations */
704 /* Update outer/inner flops */
706 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*401);
709 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomW3W3_F_c
710 * Electrostatics interaction: Ewald
711 * VdW interaction: LJEwald
712 * Geometry: Water3-Water3
713 * Calculate force/pot: Force
716 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW3W3_F_c
717 (t_nblist * gmx_restrict nlist,
718 rvec * gmx_restrict xx,
719 rvec * gmx_restrict ff,
720 t_forcerec * gmx_restrict fr,
721 t_mdatoms * gmx_restrict mdatoms,
722 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
723 t_nrnb * gmx_restrict nrnb)
725 int i_shift_offset,i_coord_offset,j_coord_offset;
726 int j_index_start,j_index_end;
727 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
728 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
729 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
730 real *shiftvec,*fshift,*x,*f;
732 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
734 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
736 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
738 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
740 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
742 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
743 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
744 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
745 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
746 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
747 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
748 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
749 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
750 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
751 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
752 real velec,felec,velecsum,facel,crf,krf,krf2;
755 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
767 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
770 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
778 jindex = nlist->jindex;
780 shiftidx = nlist->shift;
782 shiftvec = fr->shift_vec[0];
783 fshift = fr->fshift[0];
785 charge = mdatoms->chargeA;
786 nvdwtype = fr->ntype;
788 vdwtype = mdatoms->typeA;
789 vdwgridparam = fr->ljpme_c6grid;
790 ewclj = fr->ewaldcoeff_lj;
791 sh_lj_ewald = fr->ic->sh_lj_ewald;
792 ewclj2 = ewclj*ewclj;
793 ewclj6 = ewclj2*ewclj2*ewclj2;
795 sh_ewald = fr->ic->sh_ewald;
796 ewtab = fr->ic->tabq_coul_F;
797 ewtabscale = fr->ic->tabq_scale;
798 ewtabhalfspace = 0.5/ewtabscale;
800 /* Setup water-specific parameters */
801 inr = nlist->iinr[0];
802 iq0 = facel*charge[inr+0];
803 iq1 = facel*charge[inr+1];
804 iq2 = facel*charge[inr+2];
805 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
810 vdwjidx0 = 2*vdwtype[inr+0];
812 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
813 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
814 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
824 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
825 rcutoff = fr->rcoulomb;
826 rcutoff2 = rcutoff*rcutoff;
828 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
834 /* Start outer loop over neighborlists */
835 for(iidx=0; iidx<nri; iidx++)
837 /* Load shift vector for this list */
838 i_shift_offset = DIM*shiftidx[iidx];
839 shX = shiftvec[i_shift_offset+XX];
840 shY = shiftvec[i_shift_offset+YY];
841 shZ = shiftvec[i_shift_offset+ZZ];
843 /* Load limits for loop over neighbors */
844 j_index_start = jindex[iidx];
845 j_index_end = jindex[iidx+1];
847 /* Get outer coordinate index */
849 i_coord_offset = DIM*inr;
851 /* Load i particle coords and add shift vector */
852 ix0 = shX + x[i_coord_offset+DIM*0+XX];
853 iy0 = shY + x[i_coord_offset+DIM*0+YY];
854 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
855 ix1 = shX + x[i_coord_offset+DIM*1+XX];
856 iy1 = shY + x[i_coord_offset+DIM*1+YY];
857 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
858 ix2 = shX + x[i_coord_offset+DIM*2+XX];
859 iy2 = shY + x[i_coord_offset+DIM*2+YY];
860 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
872 /* Start inner kernel loop */
873 for(jidx=j_index_start; jidx<j_index_end; jidx++)
875 /* Get j neighbor index, and coordinate index */
877 j_coord_offset = DIM*jnr;
879 /* load j atom coordinates */
880 jx0 = x[j_coord_offset+DIM*0+XX];
881 jy0 = x[j_coord_offset+DIM*0+YY];
882 jz0 = x[j_coord_offset+DIM*0+ZZ];
883 jx1 = x[j_coord_offset+DIM*1+XX];
884 jy1 = x[j_coord_offset+DIM*1+YY];
885 jz1 = x[j_coord_offset+DIM*1+ZZ];
886 jx2 = x[j_coord_offset+DIM*2+XX];
887 jy2 = x[j_coord_offset+DIM*2+YY];
888 jz2 = x[j_coord_offset+DIM*2+ZZ];
890 /* Calculate displacement vector */
919 /* Calculate squared distance and things based on it */
920 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
921 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
922 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
923 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
924 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
925 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
926 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
927 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
928 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
930 rinv00 = gmx_invsqrt(rsq00);
931 rinv01 = gmx_invsqrt(rsq01);
932 rinv02 = gmx_invsqrt(rsq02);
933 rinv10 = gmx_invsqrt(rsq10);
934 rinv11 = gmx_invsqrt(rsq11);
935 rinv12 = gmx_invsqrt(rsq12);
936 rinv20 = gmx_invsqrt(rsq20);
937 rinv21 = gmx_invsqrt(rsq21);
938 rinv22 = gmx_invsqrt(rsq22);
940 rinvsq00 = rinv00*rinv00;
941 rinvsq01 = rinv01*rinv01;
942 rinvsq02 = rinv02*rinv02;
943 rinvsq10 = rinv10*rinv10;
944 rinvsq11 = rinv11*rinv11;
945 rinvsq12 = rinv12*rinv12;
946 rinvsq20 = rinv20*rinv20;
947 rinvsq21 = rinv21*rinv21;
948 rinvsq22 = rinv22*rinv22;
950 /**************************
951 * CALCULATE INTERACTIONS *
952 **************************/
959 /* EWALD ELECTROSTATICS */
961 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
962 ewrt = r00*ewtabscale;
965 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
966 felec = qq00*rinv00*(rinvsq00-felec);
968 rinvsix = rinvsq00*rinvsq00*rinvsq00;
969 ewcljrsq = ewclj2*rsq00;
970 exponent = exp(-ewcljrsq);
971 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
972 fvdw = (((c12_00*rinvsix - c6_00 + c6grid_00*(1.0-poly))*rinvsix) - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
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;
991 /**************************
992 * CALCULATE INTERACTIONS *
993 **************************/
1000 /* EWALD ELECTROSTATICS */
1002 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1003 ewrt = r01*ewtabscale;
1005 eweps = ewrt-ewitab;
1006 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1007 felec = qq01*rinv01*(rinvsq01-felec);
1011 /* Calculate temporary vectorial force */
1016 /* Update vectorial force */
1020 f[j_coord_offset+DIM*1+XX] -= tx;
1021 f[j_coord_offset+DIM*1+YY] -= ty;
1022 f[j_coord_offset+DIM*1+ZZ] -= tz;
1026 /**************************
1027 * CALCULATE INTERACTIONS *
1028 **************************/
1035 /* EWALD ELECTROSTATICS */
1037 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1038 ewrt = r02*ewtabscale;
1040 eweps = ewrt-ewitab;
1041 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1042 felec = qq02*rinv02*(rinvsq02-felec);
1046 /* Calculate temporary vectorial force */
1051 /* Update vectorial force */
1055 f[j_coord_offset+DIM*2+XX] -= tx;
1056 f[j_coord_offset+DIM*2+YY] -= ty;
1057 f[j_coord_offset+DIM*2+ZZ] -= tz;
1061 /**************************
1062 * CALCULATE INTERACTIONS *
1063 **************************/
1070 /* EWALD ELECTROSTATICS */
1072 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1073 ewrt = r10*ewtabscale;
1075 eweps = ewrt-ewitab;
1076 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1077 felec = qq10*rinv10*(rinvsq10-felec);
1081 /* Calculate temporary vectorial force */
1086 /* Update vectorial force */
1090 f[j_coord_offset+DIM*0+XX] -= tx;
1091 f[j_coord_offset+DIM*0+YY] -= ty;
1092 f[j_coord_offset+DIM*0+ZZ] -= tz;
1096 /**************************
1097 * CALCULATE INTERACTIONS *
1098 **************************/
1105 /* EWALD ELECTROSTATICS */
1107 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1108 ewrt = r11*ewtabscale;
1110 eweps = ewrt-ewitab;
1111 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1112 felec = qq11*rinv11*(rinvsq11-felec);
1116 /* Calculate temporary vectorial force */
1121 /* Update vectorial force */
1125 f[j_coord_offset+DIM*1+XX] -= tx;
1126 f[j_coord_offset+DIM*1+YY] -= ty;
1127 f[j_coord_offset+DIM*1+ZZ] -= tz;
1131 /**************************
1132 * CALCULATE INTERACTIONS *
1133 **************************/
1140 /* EWALD ELECTROSTATICS */
1142 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1143 ewrt = r12*ewtabscale;
1145 eweps = ewrt-ewitab;
1146 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1147 felec = qq12*rinv12*(rinvsq12-felec);
1151 /* Calculate temporary vectorial force */
1156 /* Update vectorial force */
1160 f[j_coord_offset+DIM*2+XX] -= tx;
1161 f[j_coord_offset+DIM*2+YY] -= ty;
1162 f[j_coord_offset+DIM*2+ZZ] -= tz;
1166 /**************************
1167 * CALCULATE INTERACTIONS *
1168 **************************/
1175 /* EWALD ELECTROSTATICS */
1177 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1178 ewrt = r20*ewtabscale;
1180 eweps = ewrt-ewitab;
1181 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1182 felec = qq20*rinv20*(rinvsq20-felec);
1186 /* Calculate temporary vectorial force */
1191 /* Update vectorial force */
1195 f[j_coord_offset+DIM*0+XX] -= tx;
1196 f[j_coord_offset+DIM*0+YY] -= ty;
1197 f[j_coord_offset+DIM*0+ZZ] -= tz;
1201 /**************************
1202 * CALCULATE INTERACTIONS *
1203 **************************/
1210 /* EWALD ELECTROSTATICS */
1212 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1213 ewrt = r21*ewtabscale;
1215 eweps = ewrt-ewitab;
1216 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1217 felec = qq21*rinv21*(rinvsq21-felec);
1221 /* Calculate temporary vectorial force */
1226 /* Update vectorial force */
1230 f[j_coord_offset+DIM*1+XX] -= tx;
1231 f[j_coord_offset+DIM*1+YY] -= ty;
1232 f[j_coord_offset+DIM*1+ZZ] -= tz;
1236 /**************************
1237 * CALCULATE INTERACTIONS *
1238 **************************/
1245 /* EWALD ELECTROSTATICS */
1247 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1248 ewrt = r22*ewtabscale;
1250 eweps = ewrt-ewitab;
1251 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1252 felec = qq22*rinv22*(rinvsq22-felec);
1256 /* Calculate temporary vectorial force */
1261 /* Update vectorial force */
1265 f[j_coord_offset+DIM*2+XX] -= tx;
1266 f[j_coord_offset+DIM*2+YY] -= ty;
1267 f[j_coord_offset+DIM*2+ZZ] -= tz;
1271 /* Inner loop uses 318 flops */
1273 /* End of innermost loop */
1276 f[i_coord_offset+DIM*0+XX] += fix0;
1277 f[i_coord_offset+DIM*0+YY] += fiy0;
1278 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1282 f[i_coord_offset+DIM*1+XX] += fix1;
1283 f[i_coord_offset+DIM*1+YY] += fiy1;
1284 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1288 f[i_coord_offset+DIM*2+XX] += fix2;
1289 f[i_coord_offset+DIM*2+YY] += fiy2;
1290 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1294 fshift[i_shift_offset+XX] += tx;
1295 fshift[i_shift_offset+YY] += ty;
1296 fshift[i_shift_offset+ZZ] += tz;
1298 /* Increment number of inner iterations */
1299 inneriter += j_index_end - j_index_start;
1301 /* Outer loop uses 30 flops */
1304 /* Increment number of outer iterations */
1307 /* Update outer/inner flops */
1309 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*318);