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_ElecEw_VdwLJEw_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LJEwald
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwLJEw_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];
166 /* Start outer loop over neighborlists */
167 for(iidx=0; iidx<nri; iidx++)
169 /* Load shift vector for this list */
170 i_shift_offset = DIM*shiftidx[iidx];
171 shX = shiftvec[i_shift_offset+XX];
172 shY = shiftvec[i_shift_offset+YY];
173 shZ = shiftvec[i_shift_offset+ZZ];
175 /* Load limits for loop over neighbors */
176 j_index_start = jindex[iidx];
177 j_index_end = jindex[iidx+1];
179 /* Get outer coordinate index */
181 i_coord_offset = DIM*inr;
183 /* Load i particle coords and add shift vector */
184 ix0 = shX + x[i_coord_offset+DIM*0+XX];
185 iy0 = shY + x[i_coord_offset+DIM*0+YY];
186 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
187 ix1 = shX + x[i_coord_offset+DIM*1+XX];
188 iy1 = shY + x[i_coord_offset+DIM*1+YY];
189 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
190 ix2 = shX + x[i_coord_offset+DIM*2+XX];
191 iy2 = shY + x[i_coord_offset+DIM*2+YY];
192 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
204 /* Reset potential sums */
208 /* Start inner kernel loop */
209 for(jidx=j_index_start; jidx<j_index_end; jidx++)
211 /* Get j neighbor index, and coordinate index */
213 j_coord_offset = DIM*jnr;
215 /* load j atom coordinates */
216 jx0 = x[j_coord_offset+DIM*0+XX];
217 jy0 = x[j_coord_offset+DIM*0+YY];
218 jz0 = x[j_coord_offset+DIM*0+ZZ];
219 jx1 = x[j_coord_offset+DIM*1+XX];
220 jy1 = x[j_coord_offset+DIM*1+YY];
221 jz1 = x[j_coord_offset+DIM*1+ZZ];
222 jx2 = x[j_coord_offset+DIM*2+XX];
223 jy2 = x[j_coord_offset+DIM*2+YY];
224 jz2 = x[j_coord_offset+DIM*2+ZZ];
226 /* Calculate displacement vector */
255 /* Calculate squared distance and things based on it */
256 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
257 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
258 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
259 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
260 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
261 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
262 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
263 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
264 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
266 rinv00 = gmx_invsqrt(rsq00);
267 rinv01 = gmx_invsqrt(rsq01);
268 rinv02 = gmx_invsqrt(rsq02);
269 rinv10 = gmx_invsqrt(rsq10);
270 rinv11 = gmx_invsqrt(rsq11);
271 rinv12 = gmx_invsqrt(rsq12);
272 rinv20 = gmx_invsqrt(rsq20);
273 rinv21 = gmx_invsqrt(rsq21);
274 rinv22 = gmx_invsqrt(rsq22);
276 rinvsq00 = rinv00*rinv00;
277 rinvsq01 = rinv01*rinv01;
278 rinvsq02 = rinv02*rinv02;
279 rinvsq10 = rinv10*rinv10;
280 rinvsq11 = rinv11*rinv11;
281 rinvsq12 = rinv12*rinv12;
282 rinvsq20 = rinv20*rinv20;
283 rinvsq21 = rinv21*rinv21;
284 rinvsq22 = rinv22*rinv22;
286 /**************************
287 * CALCULATE INTERACTIONS *
288 **************************/
292 /* EWALD ELECTROSTATICS */
294 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
295 ewrt = r00*ewtabscale;
299 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
300 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
301 felec = qq00*rinv00*(rinvsq00-felec);
303 rinvsix = rinvsq00*rinvsq00*rinvsq00;
304 ewcljrsq = ewclj2*rsq00;
305 exponent = exp(-ewcljrsq);
306 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
307 vvdw6 = (c6_00-c6grid_00*(1.0-poly))*rinvsix;
308 vvdw12 = c12_00*rinvsix*rinvsix;
309 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
310 fvdw = (vvdw12 - vvdw6 - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
312 /* Update potential sums from outer loop */
318 /* Calculate temporary vectorial force */
323 /* Update vectorial force */
327 f[j_coord_offset+DIM*0+XX] -= tx;
328 f[j_coord_offset+DIM*0+YY] -= ty;
329 f[j_coord_offset+DIM*0+ZZ] -= tz;
331 /**************************
332 * CALCULATE INTERACTIONS *
333 **************************/
337 /* EWALD ELECTROSTATICS */
339 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
340 ewrt = r01*ewtabscale;
344 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
345 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
346 felec = qq01*rinv01*(rinvsq01-felec);
348 /* Update potential sums from outer loop */
353 /* Calculate temporary vectorial force */
358 /* Update vectorial force */
362 f[j_coord_offset+DIM*1+XX] -= tx;
363 f[j_coord_offset+DIM*1+YY] -= ty;
364 f[j_coord_offset+DIM*1+ZZ] -= tz;
366 /**************************
367 * CALCULATE INTERACTIONS *
368 **************************/
372 /* EWALD ELECTROSTATICS */
374 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
375 ewrt = r02*ewtabscale;
379 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
380 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
381 felec = qq02*rinv02*(rinvsq02-felec);
383 /* Update potential sums from outer loop */
388 /* Calculate temporary vectorial force */
393 /* Update vectorial force */
397 f[j_coord_offset+DIM*2+XX] -= tx;
398 f[j_coord_offset+DIM*2+YY] -= ty;
399 f[j_coord_offset+DIM*2+ZZ] -= tz;
401 /**************************
402 * CALCULATE INTERACTIONS *
403 **************************/
407 /* EWALD ELECTROSTATICS */
409 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
410 ewrt = r10*ewtabscale;
414 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
415 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
416 felec = qq10*rinv10*(rinvsq10-felec);
418 /* Update potential sums from outer loop */
423 /* Calculate temporary vectorial force */
428 /* Update vectorial force */
432 f[j_coord_offset+DIM*0+XX] -= tx;
433 f[j_coord_offset+DIM*0+YY] -= ty;
434 f[j_coord_offset+DIM*0+ZZ] -= tz;
436 /**************************
437 * CALCULATE INTERACTIONS *
438 **************************/
442 /* EWALD ELECTROSTATICS */
444 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
445 ewrt = r11*ewtabscale;
449 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
450 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
451 felec = qq11*rinv11*(rinvsq11-felec);
453 /* Update potential sums from outer loop */
458 /* Calculate temporary vectorial force */
463 /* Update vectorial force */
467 f[j_coord_offset+DIM*1+XX] -= tx;
468 f[j_coord_offset+DIM*1+YY] -= ty;
469 f[j_coord_offset+DIM*1+ZZ] -= tz;
471 /**************************
472 * CALCULATE INTERACTIONS *
473 **************************/
477 /* EWALD ELECTROSTATICS */
479 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
480 ewrt = r12*ewtabscale;
484 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
485 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
486 felec = qq12*rinv12*(rinvsq12-felec);
488 /* Update potential sums from outer loop */
493 /* Calculate temporary vectorial force */
498 /* Update vectorial force */
502 f[j_coord_offset+DIM*2+XX] -= tx;
503 f[j_coord_offset+DIM*2+YY] -= ty;
504 f[j_coord_offset+DIM*2+ZZ] -= tz;
506 /**************************
507 * CALCULATE INTERACTIONS *
508 **************************/
512 /* EWALD ELECTROSTATICS */
514 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
515 ewrt = r20*ewtabscale;
519 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
520 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
521 felec = qq20*rinv20*(rinvsq20-felec);
523 /* Update potential sums from outer loop */
528 /* Calculate temporary vectorial force */
533 /* Update vectorial force */
537 f[j_coord_offset+DIM*0+XX] -= tx;
538 f[j_coord_offset+DIM*0+YY] -= ty;
539 f[j_coord_offset+DIM*0+ZZ] -= tz;
541 /**************************
542 * CALCULATE INTERACTIONS *
543 **************************/
547 /* EWALD ELECTROSTATICS */
549 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
550 ewrt = r21*ewtabscale;
554 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
555 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
556 felec = qq21*rinv21*(rinvsq21-felec);
558 /* Update potential sums from outer loop */
563 /* Calculate temporary vectorial force */
568 /* Update vectorial force */
572 f[j_coord_offset+DIM*1+XX] -= tx;
573 f[j_coord_offset+DIM*1+YY] -= ty;
574 f[j_coord_offset+DIM*1+ZZ] -= tz;
576 /**************************
577 * CALCULATE INTERACTIONS *
578 **************************/
582 /* EWALD ELECTROSTATICS */
584 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
585 ewrt = r22*ewtabscale;
589 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
590 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
591 felec = qq22*rinv22*(rinvsq22-felec);
593 /* Update potential sums from outer loop */
598 /* Calculate temporary vectorial force */
603 /* Update vectorial force */
607 f[j_coord_offset+DIM*2+XX] -= tx;
608 f[j_coord_offset+DIM*2+YY] -= ty;
609 f[j_coord_offset+DIM*2+ZZ] -= tz;
611 /* Inner loop uses 386 flops */
613 /* End of innermost loop */
616 f[i_coord_offset+DIM*0+XX] += fix0;
617 f[i_coord_offset+DIM*0+YY] += fiy0;
618 f[i_coord_offset+DIM*0+ZZ] += fiz0;
622 f[i_coord_offset+DIM*1+XX] += fix1;
623 f[i_coord_offset+DIM*1+YY] += fiy1;
624 f[i_coord_offset+DIM*1+ZZ] += fiz1;
628 f[i_coord_offset+DIM*2+XX] += fix2;
629 f[i_coord_offset+DIM*2+YY] += fiy2;
630 f[i_coord_offset+DIM*2+ZZ] += fiz2;
634 fshift[i_shift_offset+XX] += tx;
635 fshift[i_shift_offset+YY] += ty;
636 fshift[i_shift_offset+ZZ] += tz;
639 /* Update potential energies */
640 kernel_data->energygrp_elec[ggid] += velecsum;
641 kernel_data->energygrp_vdw[ggid] += vvdwsum;
643 /* Increment number of inner iterations */
644 inneriter += j_index_end - j_index_start;
646 /* Outer loop uses 32 flops */
649 /* Increment number of outer iterations */
652 /* Update outer/inner flops */
654 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*386);
657 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJEw_GeomW3W3_F_c
658 * Electrostatics interaction: Ewald
659 * VdW interaction: LJEwald
660 * Geometry: Water3-Water3
661 * Calculate force/pot: Force
664 nb_kernel_ElecEw_VdwLJEw_GeomW3W3_F_c
665 (t_nblist * gmx_restrict nlist,
666 rvec * gmx_restrict xx,
667 rvec * gmx_restrict ff,
668 t_forcerec * gmx_restrict fr,
669 t_mdatoms * gmx_restrict mdatoms,
670 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
671 t_nrnb * gmx_restrict nrnb)
673 int i_shift_offset,i_coord_offset,j_coord_offset;
674 int j_index_start,j_index_end;
675 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
676 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
677 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
678 real *shiftvec,*fshift,*x,*f;
680 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
682 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
684 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
686 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
688 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
690 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
691 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
692 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
693 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
694 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
695 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
696 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
697 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
698 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
699 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
700 real velec,felec,velecsum,facel,crf,krf,krf2;
703 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
715 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
718 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
726 jindex = nlist->jindex;
728 shiftidx = nlist->shift;
730 shiftvec = fr->shift_vec[0];
731 fshift = fr->fshift[0];
733 charge = mdatoms->chargeA;
734 nvdwtype = fr->ntype;
736 vdwtype = mdatoms->typeA;
737 vdwgridparam = fr->ljpme_c6grid;
738 ewclj = fr->ewaldcoeff_lj;
739 sh_lj_ewald = fr->ic->sh_lj_ewald;
740 ewclj2 = ewclj*ewclj;
741 ewclj6 = ewclj2*ewclj2*ewclj2;
743 sh_ewald = fr->ic->sh_ewald;
744 ewtab = fr->ic->tabq_coul_F;
745 ewtabscale = fr->ic->tabq_scale;
746 ewtabhalfspace = 0.5/ewtabscale;
748 /* Setup water-specific parameters */
749 inr = nlist->iinr[0];
750 iq0 = facel*charge[inr+0];
751 iq1 = facel*charge[inr+1];
752 iq2 = facel*charge[inr+2];
753 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
758 vdwjidx0 = 2*vdwtype[inr+0];
760 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
761 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
762 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
775 /* Start outer loop over neighborlists */
776 for(iidx=0; iidx<nri; iidx++)
778 /* Load shift vector for this list */
779 i_shift_offset = DIM*shiftidx[iidx];
780 shX = shiftvec[i_shift_offset+XX];
781 shY = shiftvec[i_shift_offset+YY];
782 shZ = shiftvec[i_shift_offset+ZZ];
784 /* Load limits for loop over neighbors */
785 j_index_start = jindex[iidx];
786 j_index_end = jindex[iidx+1];
788 /* Get outer coordinate index */
790 i_coord_offset = DIM*inr;
792 /* Load i particle coords and add shift vector */
793 ix0 = shX + x[i_coord_offset+DIM*0+XX];
794 iy0 = shY + x[i_coord_offset+DIM*0+YY];
795 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
796 ix1 = shX + x[i_coord_offset+DIM*1+XX];
797 iy1 = shY + x[i_coord_offset+DIM*1+YY];
798 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
799 ix2 = shX + x[i_coord_offset+DIM*2+XX];
800 iy2 = shY + x[i_coord_offset+DIM*2+YY];
801 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
813 /* Start inner kernel loop */
814 for(jidx=j_index_start; jidx<j_index_end; jidx++)
816 /* Get j neighbor index, and coordinate index */
818 j_coord_offset = DIM*jnr;
820 /* load j atom coordinates */
821 jx0 = x[j_coord_offset+DIM*0+XX];
822 jy0 = x[j_coord_offset+DIM*0+YY];
823 jz0 = x[j_coord_offset+DIM*0+ZZ];
824 jx1 = x[j_coord_offset+DIM*1+XX];
825 jy1 = x[j_coord_offset+DIM*1+YY];
826 jz1 = x[j_coord_offset+DIM*1+ZZ];
827 jx2 = x[j_coord_offset+DIM*2+XX];
828 jy2 = x[j_coord_offset+DIM*2+YY];
829 jz2 = x[j_coord_offset+DIM*2+ZZ];
831 /* Calculate displacement vector */
860 /* Calculate squared distance and things based on it */
861 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
862 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
863 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
864 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
865 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
866 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
867 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
868 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
869 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
871 rinv00 = gmx_invsqrt(rsq00);
872 rinv01 = gmx_invsqrt(rsq01);
873 rinv02 = gmx_invsqrt(rsq02);
874 rinv10 = gmx_invsqrt(rsq10);
875 rinv11 = gmx_invsqrt(rsq11);
876 rinv12 = gmx_invsqrt(rsq12);
877 rinv20 = gmx_invsqrt(rsq20);
878 rinv21 = gmx_invsqrt(rsq21);
879 rinv22 = gmx_invsqrt(rsq22);
881 rinvsq00 = rinv00*rinv00;
882 rinvsq01 = rinv01*rinv01;
883 rinvsq02 = rinv02*rinv02;
884 rinvsq10 = rinv10*rinv10;
885 rinvsq11 = rinv11*rinv11;
886 rinvsq12 = rinv12*rinv12;
887 rinvsq20 = rinv20*rinv20;
888 rinvsq21 = rinv21*rinv21;
889 rinvsq22 = rinv22*rinv22;
891 /**************************
892 * CALCULATE INTERACTIONS *
893 **************************/
897 /* EWALD ELECTROSTATICS */
899 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
900 ewrt = r00*ewtabscale;
903 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
904 felec = qq00*rinv00*(rinvsq00-felec);
906 rinvsix = rinvsq00*rinvsq00*rinvsq00;
907 ewcljrsq = ewclj2*rsq00;
908 exponent = exp(-ewcljrsq);
909 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
910 fvdw = (((c12_00*rinvsix - c6_00 + c6grid_00*(1.0-poly))*rinvsix) - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
914 /* Calculate temporary vectorial force */
919 /* Update vectorial force */
923 f[j_coord_offset+DIM*0+XX] -= tx;
924 f[j_coord_offset+DIM*0+YY] -= ty;
925 f[j_coord_offset+DIM*0+ZZ] -= tz;
927 /**************************
928 * CALCULATE INTERACTIONS *
929 **************************/
933 /* EWALD ELECTROSTATICS */
935 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
936 ewrt = r01*ewtabscale;
939 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
940 felec = qq01*rinv01*(rinvsq01-felec);
944 /* Calculate temporary vectorial force */
949 /* Update vectorial force */
953 f[j_coord_offset+DIM*1+XX] -= tx;
954 f[j_coord_offset+DIM*1+YY] -= ty;
955 f[j_coord_offset+DIM*1+ZZ] -= tz;
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
963 /* EWALD ELECTROSTATICS */
965 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
966 ewrt = r02*ewtabscale;
969 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
970 felec = qq02*rinv02*(rinvsq02-felec);
974 /* Calculate temporary vectorial force */
979 /* Update vectorial force */
983 f[j_coord_offset+DIM*2+XX] -= tx;
984 f[j_coord_offset+DIM*2+YY] -= ty;
985 f[j_coord_offset+DIM*2+ZZ] -= tz;
987 /**************************
988 * CALCULATE INTERACTIONS *
989 **************************/
993 /* EWALD ELECTROSTATICS */
995 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
996 ewrt = r10*ewtabscale;
999 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1000 felec = qq10*rinv10*(rinvsq10-felec);
1004 /* Calculate temporary vectorial force */
1009 /* Update vectorial force */
1013 f[j_coord_offset+DIM*0+XX] -= tx;
1014 f[j_coord_offset+DIM*0+YY] -= ty;
1015 f[j_coord_offset+DIM*0+ZZ] -= tz;
1017 /**************************
1018 * CALCULATE INTERACTIONS *
1019 **************************/
1023 /* EWALD ELECTROSTATICS */
1025 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1026 ewrt = r11*ewtabscale;
1028 eweps = ewrt-ewitab;
1029 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1030 felec = qq11*rinv11*(rinvsq11-felec);
1034 /* Calculate temporary vectorial force */
1039 /* Update vectorial force */
1043 f[j_coord_offset+DIM*1+XX] -= tx;
1044 f[j_coord_offset+DIM*1+YY] -= ty;
1045 f[j_coord_offset+DIM*1+ZZ] -= tz;
1047 /**************************
1048 * CALCULATE INTERACTIONS *
1049 **************************/
1053 /* EWALD ELECTROSTATICS */
1055 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1056 ewrt = r12*ewtabscale;
1058 eweps = ewrt-ewitab;
1059 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1060 felec = qq12*rinv12*(rinvsq12-felec);
1064 /* Calculate temporary vectorial force */
1069 /* Update vectorial force */
1073 f[j_coord_offset+DIM*2+XX] -= tx;
1074 f[j_coord_offset+DIM*2+YY] -= ty;
1075 f[j_coord_offset+DIM*2+ZZ] -= tz;
1077 /**************************
1078 * CALCULATE INTERACTIONS *
1079 **************************/
1083 /* EWALD ELECTROSTATICS */
1085 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1086 ewrt = r20*ewtabscale;
1088 eweps = ewrt-ewitab;
1089 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1090 felec = qq20*rinv20*(rinvsq20-felec);
1094 /* Calculate temporary vectorial force */
1099 /* Update vectorial force */
1103 f[j_coord_offset+DIM*0+XX] -= tx;
1104 f[j_coord_offset+DIM*0+YY] -= ty;
1105 f[j_coord_offset+DIM*0+ZZ] -= tz;
1107 /**************************
1108 * CALCULATE INTERACTIONS *
1109 **************************/
1113 /* EWALD ELECTROSTATICS */
1115 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1116 ewrt = r21*ewtabscale;
1118 eweps = ewrt-ewitab;
1119 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1120 felec = qq21*rinv21*(rinvsq21-felec);
1124 /* Calculate temporary vectorial force */
1129 /* Update vectorial force */
1133 f[j_coord_offset+DIM*1+XX] -= tx;
1134 f[j_coord_offset+DIM*1+YY] -= ty;
1135 f[j_coord_offset+DIM*1+ZZ] -= tz;
1137 /**************************
1138 * CALCULATE INTERACTIONS *
1139 **************************/
1143 /* EWALD ELECTROSTATICS */
1145 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1146 ewrt = r22*ewtabscale;
1148 eweps = ewrt-ewitab;
1149 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1150 felec = qq22*rinv22*(rinvsq22-felec);
1154 /* Calculate temporary vectorial force */
1159 /* Update vectorial force */
1163 f[j_coord_offset+DIM*2+XX] -= tx;
1164 f[j_coord_offset+DIM*2+YY] -= ty;
1165 f[j_coord_offset+DIM*2+ZZ] -= tz;
1167 /* Inner loop uses 318 flops */
1169 /* End of innermost loop */
1172 f[i_coord_offset+DIM*0+XX] += fix0;
1173 f[i_coord_offset+DIM*0+YY] += fiy0;
1174 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1178 f[i_coord_offset+DIM*1+XX] += fix1;
1179 f[i_coord_offset+DIM*1+YY] += fiy1;
1180 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1184 f[i_coord_offset+DIM*2+XX] += fix2;
1185 f[i_coord_offset+DIM*2+YY] += fiy2;
1186 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1190 fshift[i_shift_offset+XX] += tx;
1191 fshift[i_shift_offset+YY] += ty;
1192 fshift[i_shift_offset+ZZ] += tz;
1194 /* Increment number of inner iterations */
1195 inneriter += j_index_end - j_index_start;
1197 /* Outer loop uses 30 flops */
1200 /* Increment number of outer iterations */
1203 /* Update outer/inner flops */
1205 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*318);