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.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomW3W3_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LJEwald
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW3W3_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
108 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
111 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
119 jindex = nlist->jindex;
121 shiftidx = nlist->shift;
123 shiftvec = fr->shift_vec[0];
124 fshift = fr->fshift[0];
126 charge = mdatoms->chargeA;
127 nvdwtype = fr->ntype;
129 vdwtype = mdatoms->typeA;
130 vdwgridparam = fr->ljpme_c6grid;
131 ewclj = fr->ewaldcoeff_lj;
132 sh_lj_ewald = fr->ic->sh_lj_ewald;
133 ewclj2 = ewclj*ewclj;
134 ewclj6 = ewclj2*ewclj2*ewclj2;
136 sh_ewald = fr->ic->sh_ewald;
137 ewtab = fr->ic->tabq_coul_FDV0;
138 ewtabscale = fr->ic->tabq_scale;
139 ewtabhalfspace = 0.5/ewtabscale;
141 /* Setup water-specific parameters */
142 inr = nlist->iinr[0];
143 iq0 = facel*charge[inr+0];
144 iq1 = facel*charge[inr+1];
145 iq2 = facel*charge[inr+2];
146 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
151 vdwjidx0 = 2*vdwtype[inr+0];
153 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
154 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
155 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
165 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
166 rcutoff = fr->rcoulomb;
167 rcutoff2 = rcutoff*rcutoff;
169 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
175 /* Start outer loop over neighborlists */
176 for(iidx=0; iidx<nri; iidx++)
178 /* Load shift vector for this list */
179 i_shift_offset = DIM*shiftidx[iidx];
180 shX = shiftvec[i_shift_offset+XX];
181 shY = shiftvec[i_shift_offset+YY];
182 shZ = shiftvec[i_shift_offset+ZZ];
184 /* Load limits for loop over neighbors */
185 j_index_start = jindex[iidx];
186 j_index_end = jindex[iidx+1];
188 /* Get outer coordinate index */
190 i_coord_offset = DIM*inr;
192 /* Load i particle coords and add shift vector */
193 ix0 = shX + x[i_coord_offset+DIM*0+XX];
194 iy0 = shY + x[i_coord_offset+DIM*0+YY];
195 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
196 ix1 = shX + x[i_coord_offset+DIM*1+XX];
197 iy1 = shY + x[i_coord_offset+DIM*1+YY];
198 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
199 ix2 = shX + x[i_coord_offset+DIM*2+XX];
200 iy2 = shY + x[i_coord_offset+DIM*2+YY];
201 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
213 /* Reset potential sums */
217 /* Start inner kernel loop */
218 for(jidx=j_index_start; jidx<j_index_end; jidx++)
220 /* Get j neighbor index, and coordinate index */
222 j_coord_offset = DIM*jnr;
224 /* load j atom coordinates */
225 jx0 = x[j_coord_offset+DIM*0+XX];
226 jy0 = x[j_coord_offset+DIM*0+YY];
227 jz0 = x[j_coord_offset+DIM*0+ZZ];
228 jx1 = x[j_coord_offset+DIM*1+XX];
229 jy1 = x[j_coord_offset+DIM*1+YY];
230 jz1 = x[j_coord_offset+DIM*1+ZZ];
231 jx2 = x[j_coord_offset+DIM*2+XX];
232 jy2 = x[j_coord_offset+DIM*2+YY];
233 jz2 = x[j_coord_offset+DIM*2+ZZ];
235 /* Calculate displacement vector */
264 /* Calculate squared distance and things based on it */
265 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
266 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
267 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
268 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
269 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
270 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
271 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
272 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
273 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
275 rinv00 = gmx_invsqrt(rsq00);
276 rinv01 = gmx_invsqrt(rsq01);
277 rinv02 = gmx_invsqrt(rsq02);
278 rinv10 = gmx_invsqrt(rsq10);
279 rinv11 = gmx_invsqrt(rsq11);
280 rinv12 = gmx_invsqrt(rsq12);
281 rinv20 = gmx_invsqrt(rsq20);
282 rinv21 = gmx_invsqrt(rsq21);
283 rinv22 = gmx_invsqrt(rsq22);
285 rinvsq00 = rinv00*rinv00;
286 rinvsq01 = rinv01*rinv01;
287 rinvsq02 = rinv02*rinv02;
288 rinvsq10 = rinv10*rinv10;
289 rinvsq11 = rinv11*rinv11;
290 rinvsq12 = rinv12*rinv12;
291 rinvsq20 = rinv20*rinv20;
292 rinvsq21 = rinv21*rinv21;
293 rinvsq22 = rinv22*rinv22;
295 /**************************
296 * CALCULATE INTERACTIONS *
297 **************************/
304 /* EWALD ELECTROSTATICS */
306 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
307 ewrt = r00*ewtabscale;
311 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
312 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
313 felec = qq00*rinv00*(rinvsq00-felec);
315 rinvsix = rinvsq00*rinvsq00*rinvsq00;
316 ewcljrsq = ewclj2*rsq00;
317 exponent = exp(-ewcljrsq);
318 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
319 vvdw6 = (c6_00-c6grid_00*(1.0-poly))*rinvsix;
320 vvdw12 = c12_00*rinvsix*rinvsix;
321 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);
322 fvdw = (vvdw12 - vvdw6 - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
324 /* Update potential sums from outer loop */
330 /* Calculate temporary vectorial force */
335 /* Update vectorial force */
339 f[j_coord_offset+DIM*0+XX] -= tx;
340 f[j_coord_offset+DIM*0+YY] -= ty;
341 f[j_coord_offset+DIM*0+ZZ] -= tz;
345 /**************************
346 * CALCULATE INTERACTIONS *
347 **************************/
354 /* EWALD ELECTROSTATICS */
356 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
357 ewrt = r01*ewtabscale;
361 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
362 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
363 felec = qq01*rinv01*(rinvsq01-felec);
365 /* Update potential sums from outer loop */
370 /* Calculate temporary vectorial force */
375 /* Update vectorial force */
379 f[j_coord_offset+DIM*1+XX] -= tx;
380 f[j_coord_offset+DIM*1+YY] -= ty;
381 f[j_coord_offset+DIM*1+ZZ] -= tz;
385 /**************************
386 * CALCULATE INTERACTIONS *
387 **************************/
394 /* EWALD ELECTROSTATICS */
396 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
397 ewrt = r02*ewtabscale;
401 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
402 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
403 felec = qq02*rinv02*(rinvsq02-felec);
405 /* Update potential sums from outer loop */
410 /* Calculate temporary vectorial force */
415 /* Update vectorial force */
419 f[j_coord_offset+DIM*2+XX] -= tx;
420 f[j_coord_offset+DIM*2+YY] -= ty;
421 f[j_coord_offset+DIM*2+ZZ] -= tz;
425 /**************************
426 * CALCULATE INTERACTIONS *
427 **************************/
434 /* EWALD ELECTROSTATICS */
436 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
437 ewrt = r10*ewtabscale;
441 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
442 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
443 felec = qq10*rinv10*(rinvsq10-felec);
445 /* Update potential sums from outer loop */
450 /* Calculate temporary vectorial force */
455 /* Update vectorial force */
459 f[j_coord_offset+DIM*0+XX] -= tx;
460 f[j_coord_offset+DIM*0+YY] -= ty;
461 f[j_coord_offset+DIM*0+ZZ] -= tz;
465 /**************************
466 * CALCULATE INTERACTIONS *
467 **************************/
474 /* EWALD ELECTROSTATICS */
476 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
477 ewrt = r11*ewtabscale;
481 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
482 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
483 felec = qq11*rinv11*(rinvsq11-felec);
485 /* Update potential sums from outer loop */
490 /* Calculate temporary vectorial force */
495 /* Update vectorial force */
499 f[j_coord_offset+DIM*1+XX] -= tx;
500 f[j_coord_offset+DIM*1+YY] -= ty;
501 f[j_coord_offset+DIM*1+ZZ] -= tz;
505 /**************************
506 * CALCULATE INTERACTIONS *
507 **************************/
514 /* EWALD ELECTROSTATICS */
516 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
517 ewrt = r12*ewtabscale;
521 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
522 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
523 felec = qq12*rinv12*(rinvsq12-felec);
525 /* Update potential sums from outer loop */
530 /* Calculate temporary vectorial force */
535 /* Update vectorial force */
539 f[j_coord_offset+DIM*2+XX] -= tx;
540 f[j_coord_offset+DIM*2+YY] -= ty;
541 f[j_coord_offset+DIM*2+ZZ] -= tz;
545 /**************************
546 * CALCULATE INTERACTIONS *
547 **************************/
554 /* EWALD ELECTROSTATICS */
556 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
557 ewrt = r20*ewtabscale;
561 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
562 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
563 felec = qq20*rinv20*(rinvsq20-felec);
565 /* Update potential sums from outer loop */
570 /* Calculate temporary vectorial force */
575 /* Update vectorial force */
579 f[j_coord_offset+DIM*0+XX] -= tx;
580 f[j_coord_offset+DIM*0+YY] -= ty;
581 f[j_coord_offset+DIM*0+ZZ] -= tz;
585 /**************************
586 * CALCULATE INTERACTIONS *
587 **************************/
594 /* EWALD ELECTROSTATICS */
596 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
597 ewrt = r21*ewtabscale;
601 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
602 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
603 felec = qq21*rinv21*(rinvsq21-felec);
605 /* Update potential sums from outer loop */
610 /* Calculate temporary vectorial force */
615 /* Update vectorial force */
619 f[j_coord_offset+DIM*1+XX] -= tx;
620 f[j_coord_offset+DIM*1+YY] -= ty;
621 f[j_coord_offset+DIM*1+ZZ] -= tz;
625 /**************************
626 * CALCULATE INTERACTIONS *
627 **************************/
634 /* EWALD ELECTROSTATICS */
636 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
637 ewrt = r22*ewtabscale;
641 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
642 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
643 felec = qq22*rinv22*(rinvsq22-felec);
645 /* Update potential sums from outer loop */
650 /* Calculate temporary vectorial force */
655 /* Update vectorial force */
659 f[j_coord_offset+DIM*2+XX] -= tx;
660 f[j_coord_offset+DIM*2+YY] -= ty;
661 f[j_coord_offset+DIM*2+ZZ] -= tz;
665 /* Inner loop uses 401 flops */
667 /* End of innermost loop */
670 f[i_coord_offset+DIM*0+XX] += fix0;
671 f[i_coord_offset+DIM*0+YY] += fiy0;
672 f[i_coord_offset+DIM*0+ZZ] += fiz0;
676 f[i_coord_offset+DIM*1+XX] += fix1;
677 f[i_coord_offset+DIM*1+YY] += fiy1;
678 f[i_coord_offset+DIM*1+ZZ] += fiz1;
682 f[i_coord_offset+DIM*2+XX] += fix2;
683 f[i_coord_offset+DIM*2+YY] += fiy2;
684 f[i_coord_offset+DIM*2+ZZ] += fiz2;
688 fshift[i_shift_offset+XX] += tx;
689 fshift[i_shift_offset+YY] += ty;
690 fshift[i_shift_offset+ZZ] += tz;
693 /* Update potential energies */
694 kernel_data->energygrp_elec[ggid] += velecsum;
695 kernel_data->energygrp_vdw[ggid] += vvdwsum;
697 /* Increment number of inner iterations */
698 inneriter += j_index_end - j_index_start;
700 /* Outer loop uses 32 flops */
703 /* Increment number of outer iterations */
706 /* Update outer/inner flops */
708 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*401);
711 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomW3W3_F_c
712 * Electrostatics interaction: Ewald
713 * VdW interaction: LJEwald
714 * Geometry: Water3-Water3
715 * Calculate force/pot: Force
718 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW3W3_F_c
719 (t_nblist * gmx_restrict nlist,
720 rvec * gmx_restrict xx,
721 rvec * gmx_restrict ff,
722 t_forcerec * gmx_restrict fr,
723 t_mdatoms * gmx_restrict mdatoms,
724 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
725 t_nrnb * gmx_restrict nrnb)
727 int i_shift_offset,i_coord_offset,j_coord_offset;
728 int j_index_start,j_index_end;
729 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
730 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
731 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
732 real *shiftvec,*fshift,*x,*f;
734 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
736 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
738 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
740 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
742 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
744 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
745 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
746 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
747 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
748 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
749 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
750 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
751 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
752 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
753 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
754 real velec,felec,velecsum,facel,crf,krf,krf2;
757 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
769 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
772 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
780 jindex = nlist->jindex;
782 shiftidx = nlist->shift;
784 shiftvec = fr->shift_vec[0];
785 fshift = fr->fshift[0];
787 charge = mdatoms->chargeA;
788 nvdwtype = fr->ntype;
790 vdwtype = mdatoms->typeA;
791 vdwgridparam = fr->ljpme_c6grid;
792 ewclj = fr->ewaldcoeff_lj;
793 sh_lj_ewald = fr->ic->sh_lj_ewald;
794 ewclj2 = ewclj*ewclj;
795 ewclj6 = ewclj2*ewclj2*ewclj2;
797 sh_ewald = fr->ic->sh_ewald;
798 ewtab = fr->ic->tabq_coul_F;
799 ewtabscale = fr->ic->tabq_scale;
800 ewtabhalfspace = 0.5/ewtabscale;
802 /* Setup water-specific parameters */
803 inr = nlist->iinr[0];
804 iq0 = facel*charge[inr+0];
805 iq1 = facel*charge[inr+1];
806 iq2 = facel*charge[inr+2];
807 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
812 vdwjidx0 = 2*vdwtype[inr+0];
814 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
815 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
816 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
826 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
827 rcutoff = fr->rcoulomb;
828 rcutoff2 = rcutoff*rcutoff;
830 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
836 /* Start outer loop over neighborlists */
837 for(iidx=0; iidx<nri; iidx++)
839 /* Load shift vector for this list */
840 i_shift_offset = DIM*shiftidx[iidx];
841 shX = shiftvec[i_shift_offset+XX];
842 shY = shiftvec[i_shift_offset+YY];
843 shZ = shiftvec[i_shift_offset+ZZ];
845 /* Load limits for loop over neighbors */
846 j_index_start = jindex[iidx];
847 j_index_end = jindex[iidx+1];
849 /* Get outer coordinate index */
851 i_coord_offset = DIM*inr;
853 /* Load i particle coords and add shift vector */
854 ix0 = shX + x[i_coord_offset+DIM*0+XX];
855 iy0 = shY + x[i_coord_offset+DIM*0+YY];
856 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
857 ix1 = shX + x[i_coord_offset+DIM*1+XX];
858 iy1 = shY + x[i_coord_offset+DIM*1+YY];
859 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
860 ix2 = shX + x[i_coord_offset+DIM*2+XX];
861 iy2 = shY + x[i_coord_offset+DIM*2+YY];
862 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
874 /* Start inner kernel loop */
875 for(jidx=j_index_start; jidx<j_index_end; jidx++)
877 /* Get j neighbor index, and coordinate index */
879 j_coord_offset = DIM*jnr;
881 /* load j atom coordinates */
882 jx0 = x[j_coord_offset+DIM*0+XX];
883 jy0 = x[j_coord_offset+DIM*0+YY];
884 jz0 = x[j_coord_offset+DIM*0+ZZ];
885 jx1 = x[j_coord_offset+DIM*1+XX];
886 jy1 = x[j_coord_offset+DIM*1+YY];
887 jz1 = x[j_coord_offset+DIM*1+ZZ];
888 jx2 = x[j_coord_offset+DIM*2+XX];
889 jy2 = x[j_coord_offset+DIM*2+YY];
890 jz2 = x[j_coord_offset+DIM*2+ZZ];
892 /* Calculate displacement vector */
921 /* Calculate squared distance and things based on it */
922 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
923 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
924 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
925 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
926 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
927 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
928 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
929 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
930 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
932 rinv00 = gmx_invsqrt(rsq00);
933 rinv01 = gmx_invsqrt(rsq01);
934 rinv02 = gmx_invsqrt(rsq02);
935 rinv10 = gmx_invsqrt(rsq10);
936 rinv11 = gmx_invsqrt(rsq11);
937 rinv12 = gmx_invsqrt(rsq12);
938 rinv20 = gmx_invsqrt(rsq20);
939 rinv21 = gmx_invsqrt(rsq21);
940 rinv22 = gmx_invsqrt(rsq22);
942 rinvsq00 = rinv00*rinv00;
943 rinvsq01 = rinv01*rinv01;
944 rinvsq02 = rinv02*rinv02;
945 rinvsq10 = rinv10*rinv10;
946 rinvsq11 = rinv11*rinv11;
947 rinvsq12 = rinv12*rinv12;
948 rinvsq20 = rinv20*rinv20;
949 rinvsq21 = rinv21*rinv21;
950 rinvsq22 = rinv22*rinv22;
952 /**************************
953 * CALCULATE INTERACTIONS *
954 **************************/
961 /* EWALD ELECTROSTATICS */
963 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
964 ewrt = r00*ewtabscale;
967 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
968 felec = qq00*rinv00*(rinvsq00-felec);
970 rinvsix = rinvsq00*rinvsq00*rinvsq00;
971 ewcljrsq = ewclj2*rsq00;
972 exponent = exp(-ewcljrsq);
973 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
974 fvdw = (((c12_00*rinvsix - c6_00 + c6grid_00*(1.0-poly))*rinvsix) - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
978 /* Calculate temporary vectorial force */
983 /* Update vectorial force */
987 f[j_coord_offset+DIM*0+XX] -= tx;
988 f[j_coord_offset+DIM*0+YY] -= ty;
989 f[j_coord_offset+DIM*0+ZZ] -= tz;
993 /**************************
994 * CALCULATE INTERACTIONS *
995 **************************/
1002 /* EWALD ELECTROSTATICS */
1004 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1005 ewrt = r01*ewtabscale;
1007 eweps = ewrt-ewitab;
1008 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1009 felec = qq01*rinv01*(rinvsq01-felec);
1013 /* Calculate temporary vectorial force */
1018 /* Update vectorial force */
1022 f[j_coord_offset+DIM*1+XX] -= tx;
1023 f[j_coord_offset+DIM*1+YY] -= ty;
1024 f[j_coord_offset+DIM*1+ZZ] -= tz;
1028 /**************************
1029 * CALCULATE INTERACTIONS *
1030 **************************/
1037 /* EWALD ELECTROSTATICS */
1039 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1040 ewrt = r02*ewtabscale;
1042 eweps = ewrt-ewitab;
1043 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1044 felec = qq02*rinv02*(rinvsq02-felec);
1048 /* Calculate temporary vectorial force */
1053 /* Update vectorial force */
1057 f[j_coord_offset+DIM*2+XX] -= tx;
1058 f[j_coord_offset+DIM*2+YY] -= ty;
1059 f[j_coord_offset+DIM*2+ZZ] -= tz;
1063 /**************************
1064 * CALCULATE INTERACTIONS *
1065 **************************/
1072 /* EWALD ELECTROSTATICS */
1074 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1075 ewrt = r10*ewtabscale;
1077 eweps = ewrt-ewitab;
1078 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1079 felec = qq10*rinv10*(rinvsq10-felec);
1083 /* Calculate temporary vectorial force */
1088 /* Update vectorial force */
1092 f[j_coord_offset+DIM*0+XX] -= tx;
1093 f[j_coord_offset+DIM*0+YY] -= ty;
1094 f[j_coord_offset+DIM*0+ZZ] -= tz;
1098 /**************************
1099 * CALCULATE INTERACTIONS *
1100 **************************/
1107 /* EWALD ELECTROSTATICS */
1109 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1110 ewrt = r11*ewtabscale;
1112 eweps = ewrt-ewitab;
1113 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1114 felec = qq11*rinv11*(rinvsq11-felec);
1118 /* Calculate temporary vectorial force */
1123 /* Update vectorial force */
1127 f[j_coord_offset+DIM*1+XX] -= tx;
1128 f[j_coord_offset+DIM*1+YY] -= ty;
1129 f[j_coord_offset+DIM*1+ZZ] -= tz;
1133 /**************************
1134 * CALCULATE INTERACTIONS *
1135 **************************/
1142 /* EWALD ELECTROSTATICS */
1144 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1145 ewrt = r12*ewtabscale;
1147 eweps = ewrt-ewitab;
1148 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1149 felec = qq12*rinv12*(rinvsq12-felec);
1153 /* Calculate temporary vectorial force */
1158 /* Update vectorial force */
1162 f[j_coord_offset+DIM*2+XX] -= tx;
1163 f[j_coord_offset+DIM*2+YY] -= ty;
1164 f[j_coord_offset+DIM*2+ZZ] -= tz;
1168 /**************************
1169 * CALCULATE INTERACTIONS *
1170 **************************/
1177 /* EWALD ELECTROSTATICS */
1179 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1180 ewrt = r20*ewtabscale;
1182 eweps = ewrt-ewitab;
1183 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1184 felec = qq20*rinv20*(rinvsq20-felec);
1188 /* Calculate temporary vectorial force */
1193 /* Update vectorial force */
1197 f[j_coord_offset+DIM*0+XX] -= tx;
1198 f[j_coord_offset+DIM*0+YY] -= ty;
1199 f[j_coord_offset+DIM*0+ZZ] -= tz;
1203 /**************************
1204 * CALCULATE INTERACTIONS *
1205 **************************/
1212 /* EWALD ELECTROSTATICS */
1214 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1215 ewrt = r21*ewtabscale;
1217 eweps = ewrt-ewitab;
1218 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1219 felec = qq21*rinv21*(rinvsq21-felec);
1223 /* Calculate temporary vectorial force */
1228 /* Update vectorial force */
1232 f[j_coord_offset+DIM*1+XX] -= tx;
1233 f[j_coord_offset+DIM*1+YY] -= ty;
1234 f[j_coord_offset+DIM*1+ZZ] -= tz;
1238 /**************************
1239 * CALCULATE INTERACTIONS *
1240 **************************/
1247 /* EWALD ELECTROSTATICS */
1249 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1250 ewrt = r22*ewtabscale;
1252 eweps = ewrt-ewitab;
1253 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1254 felec = qq22*rinv22*(rinvsq22-felec);
1258 /* Calculate temporary vectorial force */
1263 /* Update vectorial force */
1267 f[j_coord_offset+DIM*2+XX] -= tx;
1268 f[j_coord_offset+DIM*2+YY] -= ty;
1269 f[j_coord_offset+DIM*2+ZZ] -= tz;
1273 /* Inner loop uses 318 flops */
1275 /* End of innermost loop */
1278 f[i_coord_offset+DIM*0+XX] += fix0;
1279 f[i_coord_offset+DIM*0+YY] += fiy0;
1280 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1284 f[i_coord_offset+DIM*1+XX] += fix1;
1285 f[i_coord_offset+DIM*1+YY] += fiy1;
1286 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1290 f[i_coord_offset+DIM*2+XX] += fix2;
1291 f[i_coord_offset+DIM*2+YY] += fiy2;
1292 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1296 fshift[i_shift_offset+XX] += tx;
1297 fshift[i_shift_offset+YY] += ty;
1298 fshift[i_shift_offset+ZZ] += tz;
1300 /* Increment number of inner iterations */
1301 inneriter += j_index_end - j_index_start;
1303 /* Outer loop uses 30 flops */
1306 /* Increment number of outer iterations */
1309 /* Update outer/inner flops */
1311 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*318);