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 "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LJEwald
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
85 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
87 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
88 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
89 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
90 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
91 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
92 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
93 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
94 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
95 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
96 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
97 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
98 real velec,felec,velecsum,facel,crf,krf,krf2;
101 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
114 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
117 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
125 jindex = nlist->jindex;
127 shiftidx = nlist->shift;
129 shiftvec = fr->shift_vec[0];
130 fshift = fr->fshift[0];
132 charge = mdatoms->chargeA;
133 nvdwtype = fr->ntype;
135 vdwtype = mdatoms->typeA;
136 vdwgridparam = fr->ljpme_c6grid;
137 ewclj = fr->ewaldcoeff_lj;
138 sh_lj_ewald = fr->ic->sh_lj_ewald;
139 ewclj2 = ewclj*ewclj;
140 ewclj6 = ewclj2*ewclj2*ewclj2;
142 sh_ewald = fr->ic->sh_ewald;
143 ewtab = fr->ic->tabq_coul_FDV0;
144 ewtabscale = fr->ic->tabq_scale;
145 ewtabhalfspace = 0.5/ewtabscale;
147 /* Setup water-specific parameters */
148 inr = nlist->iinr[0];
149 iq1 = facel*charge[inr+1];
150 iq2 = facel*charge[inr+2];
151 iq3 = facel*charge[inr+3];
152 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
157 vdwjidx0 = 2*vdwtype[inr+0];
158 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
159 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
160 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
171 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
172 rcutoff = fr->rcoulomb;
173 rcutoff2 = rcutoff*rcutoff;
175 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
181 /* Start outer loop over neighborlists */
182 for(iidx=0; iidx<nri; iidx++)
184 /* Load shift vector for this list */
185 i_shift_offset = DIM*shiftidx[iidx];
186 shX = shiftvec[i_shift_offset+XX];
187 shY = shiftvec[i_shift_offset+YY];
188 shZ = shiftvec[i_shift_offset+ZZ];
190 /* Load limits for loop over neighbors */
191 j_index_start = jindex[iidx];
192 j_index_end = jindex[iidx+1];
194 /* Get outer coordinate index */
196 i_coord_offset = DIM*inr;
198 /* Load i particle coords and add shift vector */
199 ix0 = shX + x[i_coord_offset+DIM*0+XX];
200 iy0 = shY + x[i_coord_offset+DIM*0+YY];
201 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
202 ix1 = shX + x[i_coord_offset+DIM*1+XX];
203 iy1 = shY + x[i_coord_offset+DIM*1+YY];
204 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
205 ix2 = shX + x[i_coord_offset+DIM*2+XX];
206 iy2 = shY + x[i_coord_offset+DIM*2+YY];
207 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
208 ix3 = shX + x[i_coord_offset+DIM*3+XX];
209 iy3 = shY + x[i_coord_offset+DIM*3+YY];
210 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
225 /* Reset potential sums */
229 /* Start inner kernel loop */
230 for(jidx=j_index_start; jidx<j_index_end; jidx++)
232 /* Get j neighbor index, and coordinate index */
234 j_coord_offset = DIM*jnr;
236 /* load j atom coordinates */
237 jx0 = x[j_coord_offset+DIM*0+XX];
238 jy0 = x[j_coord_offset+DIM*0+YY];
239 jz0 = x[j_coord_offset+DIM*0+ZZ];
240 jx1 = x[j_coord_offset+DIM*1+XX];
241 jy1 = x[j_coord_offset+DIM*1+YY];
242 jz1 = x[j_coord_offset+DIM*1+ZZ];
243 jx2 = x[j_coord_offset+DIM*2+XX];
244 jy2 = x[j_coord_offset+DIM*2+YY];
245 jz2 = x[j_coord_offset+DIM*2+ZZ];
246 jx3 = x[j_coord_offset+DIM*3+XX];
247 jy3 = x[j_coord_offset+DIM*3+YY];
248 jz3 = x[j_coord_offset+DIM*3+ZZ];
250 /* Calculate displacement vector */
282 /* Calculate squared distance and things based on it */
283 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
284 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
285 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
286 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
287 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
288 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
289 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
290 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
291 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
292 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
294 rinv00 = gmx_invsqrt(rsq00);
295 rinv11 = gmx_invsqrt(rsq11);
296 rinv12 = gmx_invsqrt(rsq12);
297 rinv13 = gmx_invsqrt(rsq13);
298 rinv21 = gmx_invsqrt(rsq21);
299 rinv22 = gmx_invsqrt(rsq22);
300 rinv23 = gmx_invsqrt(rsq23);
301 rinv31 = gmx_invsqrt(rsq31);
302 rinv32 = gmx_invsqrt(rsq32);
303 rinv33 = gmx_invsqrt(rsq33);
305 rinvsq00 = rinv00*rinv00;
306 rinvsq11 = rinv11*rinv11;
307 rinvsq12 = rinv12*rinv12;
308 rinvsq13 = rinv13*rinv13;
309 rinvsq21 = rinv21*rinv21;
310 rinvsq22 = rinv22*rinv22;
311 rinvsq23 = rinv23*rinv23;
312 rinvsq31 = rinv31*rinv31;
313 rinvsq32 = rinv32*rinv32;
314 rinvsq33 = rinv33*rinv33;
316 /**************************
317 * CALCULATE INTERACTIONS *
318 **************************/
325 rinvsix = rinvsq00*rinvsq00*rinvsq00;
326 ewcljrsq = ewclj2*rsq00;
327 exponent = exp(-ewcljrsq);
328 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
329 vvdw6 = (c6_00-c6grid_00*(1.0-poly))*rinvsix;
330 vvdw12 = c12_00*rinvsix*rinvsix;
331 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);
332 fvdw = (vvdw12 - vvdw6 - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
334 /* Update potential sums from outer loop */
339 /* Calculate temporary vectorial force */
344 /* Update vectorial force */
348 f[j_coord_offset+DIM*0+XX] -= tx;
349 f[j_coord_offset+DIM*0+YY] -= ty;
350 f[j_coord_offset+DIM*0+ZZ] -= tz;
354 /**************************
355 * CALCULATE INTERACTIONS *
356 **************************/
363 /* EWALD ELECTROSTATICS */
365 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
366 ewrt = r11*ewtabscale;
370 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
371 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
372 felec = qq11*rinv11*(rinvsq11-felec);
374 /* Update potential sums from outer loop */
379 /* Calculate temporary vectorial force */
384 /* Update vectorial force */
388 f[j_coord_offset+DIM*1+XX] -= tx;
389 f[j_coord_offset+DIM*1+YY] -= ty;
390 f[j_coord_offset+DIM*1+ZZ] -= tz;
394 /**************************
395 * CALCULATE INTERACTIONS *
396 **************************/
403 /* EWALD ELECTROSTATICS */
405 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
406 ewrt = r12*ewtabscale;
410 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
411 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
412 felec = qq12*rinv12*(rinvsq12-felec);
414 /* Update potential sums from outer loop */
419 /* Calculate temporary vectorial force */
424 /* Update vectorial force */
428 f[j_coord_offset+DIM*2+XX] -= tx;
429 f[j_coord_offset+DIM*2+YY] -= ty;
430 f[j_coord_offset+DIM*2+ZZ] -= tz;
434 /**************************
435 * CALCULATE INTERACTIONS *
436 **************************/
443 /* EWALD ELECTROSTATICS */
445 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
446 ewrt = r13*ewtabscale;
450 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
451 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
452 felec = qq13*rinv13*(rinvsq13-felec);
454 /* Update potential sums from outer loop */
459 /* Calculate temporary vectorial force */
464 /* Update vectorial force */
468 f[j_coord_offset+DIM*3+XX] -= tx;
469 f[j_coord_offset+DIM*3+YY] -= ty;
470 f[j_coord_offset+DIM*3+ZZ] -= tz;
474 /**************************
475 * CALCULATE INTERACTIONS *
476 **************************/
483 /* EWALD ELECTROSTATICS */
485 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
486 ewrt = r21*ewtabscale;
490 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
491 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
492 felec = qq21*rinv21*(rinvsq21-felec);
494 /* Update potential sums from outer loop */
499 /* Calculate temporary vectorial force */
504 /* Update vectorial force */
508 f[j_coord_offset+DIM*1+XX] -= tx;
509 f[j_coord_offset+DIM*1+YY] -= ty;
510 f[j_coord_offset+DIM*1+ZZ] -= tz;
514 /**************************
515 * CALCULATE INTERACTIONS *
516 **************************/
523 /* EWALD ELECTROSTATICS */
525 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
526 ewrt = r22*ewtabscale;
530 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
531 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
532 felec = qq22*rinv22*(rinvsq22-felec);
534 /* Update potential sums from outer loop */
539 /* Calculate temporary vectorial force */
544 /* Update vectorial force */
548 f[j_coord_offset+DIM*2+XX] -= tx;
549 f[j_coord_offset+DIM*2+YY] -= ty;
550 f[j_coord_offset+DIM*2+ZZ] -= tz;
554 /**************************
555 * CALCULATE INTERACTIONS *
556 **************************/
563 /* EWALD ELECTROSTATICS */
565 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
566 ewrt = r23*ewtabscale;
570 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
571 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
572 felec = qq23*rinv23*(rinvsq23-felec);
574 /* Update potential sums from outer loop */
579 /* Calculate temporary vectorial force */
584 /* Update vectorial force */
588 f[j_coord_offset+DIM*3+XX] -= tx;
589 f[j_coord_offset+DIM*3+YY] -= ty;
590 f[j_coord_offset+DIM*3+ZZ] -= tz;
594 /**************************
595 * CALCULATE INTERACTIONS *
596 **************************/
603 /* EWALD ELECTROSTATICS */
605 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
606 ewrt = r31*ewtabscale;
610 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
611 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
612 felec = qq31*rinv31*(rinvsq31-felec);
614 /* Update potential sums from outer loop */
619 /* Calculate temporary vectorial force */
624 /* Update vectorial force */
628 f[j_coord_offset+DIM*1+XX] -= tx;
629 f[j_coord_offset+DIM*1+YY] -= ty;
630 f[j_coord_offset+DIM*1+ZZ] -= tz;
634 /**************************
635 * CALCULATE INTERACTIONS *
636 **************************/
643 /* EWALD ELECTROSTATICS */
645 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
646 ewrt = r32*ewtabscale;
650 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
651 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
652 felec = qq32*rinv32*(rinvsq32-felec);
654 /* Update potential sums from outer loop */
659 /* Calculate temporary vectorial force */
664 /* Update vectorial force */
668 f[j_coord_offset+DIM*2+XX] -= tx;
669 f[j_coord_offset+DIM*2+YY] -= ty;
670 f[j_coord_offset+DIM*2+ZZ] -= tz;
674 /**************************
675 * CALCULATE INTERACTIONS *
676 **************************/
683 /* EWALD ELECTROSTATICS */
685 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
686 ewrt = r33*ewtabscale;
690 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
691 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
692 felec = qq33*rinv33*(rinvsq33-felec);
694 /* Update potential sums from outer loop */
699 /* Calculate temporary vectorial force */
704 /* Update vectorial force */
708 f[j_coord_offset+DIM*3+XX] -= tx;
709 f[j_coord_offset+DIM*3+YY] -= ty;
710 f[j_coord_offset+DIM*3+ZZ] -= tz;
714 /* Inner loop uses 424 flops */
716 /* End of innermost loop */
719 f[i_coord_offset+DIM*0+XX] += fix0;
720 f[i_coord_offset+DIM*0+YY] += fiy0;
721 f[i_coord_offset+DIM*0+ZZ] += fiz0;
725 f[i_coord_offset+DIM*1+XX] += fix1;
726 f[i_coord_offset+DIM*1+YY] += fiy1;
727 f[i_coord_offset+DIM*1+ZZ] += fiz1;
731 f[i_coord_offset+DIM*2+XX] += fix2;
732 f[i_coord_offset+DIM*2+YY] += fiy2;
733 f[i_coord_offset+DIM*2+ZZ] += fiz2;
737 f[i_coord_offset+DIM*3+XX] += fix3;
738 f[i_coord_offset+DIM*3+YY] += fiy3;
739 f[i_coord_offset+DIM*3+ZZ] += fiz3;
743 fshift[i_shift_offset+XX] += tx;
744 fshift[i_shift_offset+YY] += ty;
745 fshift[i_shift_offset+ZZ] += tz;
748 /* Update potential energies */
749 kernel_data->energygrp_elec[ggid] += velecsum;
750 kernel_data->energygrp_vdw[ggid] += vvdwsum;
752 /* Increment number of inner iterations */
753 inneriter += j_index_end - j_index_start;
755 /* Outer loop uses 41 flops */
758 /* Increment number of outer iterations */
761 /* Update outer/inner flops */
763 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*424);
766 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_F_c
767 * Electrostatics interaction: Ewald
768 * VdW interaction: LJEwald
769 * Geometry: Water4-Water4
770 * Calculate force/pot: Force
773 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_F_c
774 (t_nblist * gmx_restrict nlist,
775 rvec * gmx_restrict xx,
776 rvec * gmx_restrict ff,
777 t_forcerec * gmx_restrict fr,
778 t_mdatoms * gmx_restrict mdatoms,
779 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
780 t_nrnb * gmx_restrict nrnb)
782 int i_shift_offset,i_coord_offset,j_coord_offset;
783 int j_index_start,j_index_end;
784 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
785 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
786 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
787 real *shiftvec,*fshift,*x,*f;
789 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
791 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
793 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
795 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
797 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
799 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
801 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
803 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
804 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
805 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
806 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
807 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
808 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
809 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
810 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
811 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
812 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
813 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
814 real velec,felec,velecsum,facel,crf,krf,krf2;
817 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
830 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
833 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
841 jindex = nlist->jindex;
843 shiftidx = nlist->shift;
845 shiftvec = fr->shift_vec[0];
846 fshift = fr->fshift[0];
848 charge = mdatoms->chargeA;
849 nvdwtype = fr->ntype;
851 vdwtype = mdatoms->typeA;
852 vdwgridparam = fr->ljpme_c6grid;
853 ewclj = fr->ewaldcoeff_lj;
854 sh_lj_ewald = fr->ic->sh_lj_ewald;
855 ewclj2 = ewclj*ewclj;
856 ewclj6 = ewclj2*ewclj2*ewclj2;
858 sh_ewald = fr->ic->sh_ewald;
859 ewtab = fr->ic->tabq_coul_F;
860 ewtabscale = fr->ic->tabq_scale;
861 ewtabhalfspace = 0.5/ewtabscale;
863 /* Setup water-specific parameters */
864 inr = nlist->iinr[0];
865 iq1 = facel*charge[inr+1];
866 iq2 = facel*charge[inr+2];
867 iq3 = facel*charge[inr+3];
868 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
873 vdwjidx0 = 2*vdwtype[inr+0];
874 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
875 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
876 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
887 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
888 rcutoff = fr->rcoulomb;
889 rcutoff2 = rcutoff*rcutoff;
891 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
897 /* Start outer loop over neighborlists */
898 for(iidx=0; iidx<nri; iidx++)
900 /* Load shift vector for this list */
901 i_shift_offset = DIM*shiftidx[iidx];
902 shX = shiftvec[i_shift_offset+XX];
903 shY = shiftvec[i_shift_offset+YY];
904 shZ = shiftvec[i_shift_offset+ZZ];
906 /* Load limits for loop over neighbors */
907 j_index_start = jindex[iidx];
908 j_index_end = jindex[iidx+1];
910 /* Get outer coordinate index */
912 i_coord_offset = DIM*inr;
914 /* Load i particle coords and add shift vector */
915 ix0 = shX + x[i_coord_offset+DIM*0+XX];
916 iy0 = shY + x[i_coord_offset+DIM*0+YY];
917 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
918 ix1 = shX + x[i_coord_offset+DIM*1+XX];
919 iy1 = shY + x[i_coord_offset+DIM*1+YY];
920 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
921 ix2 = shX + x[i_coord_offset+DIM*2+XX];
922 iy2 = shY + x[i_coord_offset+DIM*2+YY];
923 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
924 ix3 = shX + x[i_coord_offset+DIM*3+XX];
925 iy3 = shY + x[i_coord_offset+DIM*3+YY];
926 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
941 /* Start inner kernel loop */
942 for(jidx=j_index_start; jidx<j_index_end; jidx++)
944 /* Get j neighbor index, and coordinate index */
946 j_coord_offset = DIM*jnr;
948 /* load j atom coordinates */
949 jx0 = x[j_coord_offset+DIM*0+XX];
950 jy0 = x[j_coord_offset+DIM*0+YY];
951 jz0 = x[j_coord_offset+DIM*0+ZZ];
952 jx1 = x[j_coord_offset+DIM*1+XX];
953 jy1 = x[j_coord_offset+DIM*1+YY];
954 jz1 = x[j_coord_offset+DIM*1+ZZ];
955 jx2 = x[j_coord_offset+DIM*2+XX];
956 jy2 = x[j_coord_offset+DIM*2+YY];
957 jz2 = x[j_coord_offset+DIM*2+ZZ];
958 jx3 = x[j_coord_offset+DIM*3+XX];
959 jy3 = x[j_coord_offset+DIM*3+YY];
960 jz3 = x[j_coord_offset+DIM*3+ZZ];
962 /* Calculate displacement vector */
994 /* Calculate squared distance and things based on it */
995 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
996 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
997 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
998 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
999 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
1000 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
1001 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
1002 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
1003 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
1004 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
1006 rinv00 = gmx_invsqrt(rsq00);
1007 rinv11 = gmx_invsqrt(rsq11);
1008 rinv12 = gmx_invsqrt(rsq12);
1009 rinv13 = gmx_invsqrt(rsq13);
1010 rinv21 = gmx_invsqrt(rsq21);
1011 rinv22 = gmx_invsqrt(rsq22);
1012 rinv23 = gmx_invsqrt(rsq23);
1013 rinv31 = gmx_invsqrt(rsq31);
1014 rinv32 = gmx_invsqrt(rsq32);
1015 rinv33 = gmx_invsqrt(rsq33);
1017 rinvsq00 = rinv00*rinv00;
1018 rinvsq11 = rinv11*rinv11;
1019 rinvsq12 = rinv12*rinv12;
1020 rinvsq13 = rinv13*rinv13;
1021 rinvsq21 = rinv21*rinv21;
1022 rinvsq22 = rinv22*rinv22;
1023 rinvsq23 = rinv23*rinv23;
1024 rinvsq31 = rinv31*rinv31;
1025 rinvsq32 = rinv32*rinv32;
1026 rinvsq33 = rinv33*rinv33;
1028 /**************************
1029 * CALCULATE INTERACTIONS *
1030 **************************/
1037 rinvsix = rinvsq00*rinvsq00*rinvsq00;
1038 ewcljrsq = ewclj2*rsq00;
1039 exponent = exp(-ewcljrsq);
1040 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
1041 fvdw = (((c12_00*rinvsix - c6_00 + c6grid_00*(1.0-poly))*rinvsix) - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
1045 /* Calculate temporary vectorial force */
1050 /* Update vectorial force */
1054 f[j_coord_offset+DIM*0+XX] -= tx;
1055 f[j_coord_offset+DIM*0+YY] -= ty;
1056 f[j_coord_offset+DIM*0+ZZ] -= tz;
1060 /**************************
1061 * CALCULATE INTERACTIONS *
1062 **************************/
1069 /* EWALD ELECTROSTATICS */
1071 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1072 ewrt = r11*ewtabscale;
1074 eweps = ewrt-ewitab;
1075 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1076 felec = qq11*rinv11*(rinvsq11-felec);
1080 /* Calculate temporary vectorial force */
1085 /* Update vectorial force */
1089 f[j_coord_offset+DIM*1+XX] -= tx;
1090 f[j_coord_offset+DIM*1+YY] -= ty;
1091 f[j_coord_offset+DIM*1+ZZ] -= tz;
1095 /**************************
1096 * CALCULATE INTERACTIONS *
1097 **************************/
1104 /* EWALD ELECTROSTATICS */
1106 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1107 ewrt = r12*ewtabscale;
1109 eweps = ewrt-ewitab;
1110 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1111 felec = qq12*rinv12*(rinvsq12-felec);
1115 /* Calculate temporary vectorial force */
1120 /* Update vectorial force */
1124 f[j_coord_offset+DIM*2+XX] -= tx;
1125 f[j_coord_offset+DIM*2+YY] -= ty;
1126 f[j_coord_offset+DIM*2+ZZ] -= tz;
1130 /**************************
1131 * CALCULATE INTERACTIONS *
1132 **************************/
1139 /* EWALD ELECTROSTATICS */
1141 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1142 ewrt = r13*ewtabscale;
1144 eweps = ewrt-ewitab;
1145 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1146 felec = qq13*rinv13*(rinvsq13-felec);
1150 /* Calculate temporary vectorial force */
1155 /* Update vectorial force */
1159 f[j_coord_offset+DIM*3+XX] -= tx;
1160 f[j_coord_offset+DIM*3+YY] -= ty;
1161 f[j_coord_offset+DIM*3+ZZ] -= tz;
1165 /**************************
1166 * CALCULATE INTERACTIONS *
1167 **************************/
1174 /* EWALD ELECTROSTATICS */
1176 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1177 ewrt = r21*ewtabscale;
1179 eweps = ewrt-ewitab;
1180 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1181 felec = qq21*rinv21*(rinvsq21-felec);
1185 /* Calculate temporary vectorial force */
1190 /* Update vectorial force */
1194 f[j_coord_offset+DIM*1+XX] -= tx;
1195 f[j_coord_offset+DIM*1+YY] -= ty;
1196 f[j_coord_offset+DIM*1+ZZ] -= tz;
1200 /**************************
1201 * CALCULATE INTERACTIONS *
1202 **************************/
1209 /* EWALD ELECTROSTATICS */
1211 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1212 ewrt = r22*ewtabscale;
1214 eweps = ewrt-ewitab;
1215 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1216 felec = qq22*rinv22*(rinvsq22-felec);
1220 /* Calculate temporary vectorial force */
1225 /* Update vectorial force */
1229 f[j_coord_offset+DIM*2+XX] -= tx;
1230 f[j_coord_offset+DIM*2+YY] -= ty;
1231 f[j_coord_offset+DIM*2+ZZ] -= tz;
1235 /**************************
1236 * CALCULATE INTERACTIONS *
1237 **************************/
1244 /* EWALD ELECTROSTATICS */
1246 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1247 ewrt = r23*ewtabscale;
1249 eweps = ewrt-ewitab;
1250 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1251 felec = qq23*rinv23*(rinvsq23-felec);
1255 /* Calculate temporary vectorial force */
1260 /* Update vectorial force */
1264 f[j_coord_offset+DIM*3+XX] -= tx;
1265 f[j_coord_offset+DIM*3+YY] -= ty;
1266 f[j_coord_offset+DIM*3+ZZ] -= tz;
1270 /**************************
1271 * CALCULATE INTERACTIONS *
1272 **************************/
1279 /* EWALD ELECTROSTATICS */
1281 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1282 ewrt = r31*ewtabscale;
1284 eweps = ewrt-ewitab;
1285 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1286 felec = qq31*rinv31*(rinvsq31-felec);
1290 /* Calculate temporary vectorial force */
1295 /* Update vectorial force */
1299 f[j_coord_offset+DIM*1+XX] -= tx;
1300 f[j_coord_offset+DIM*1+YY] -= ty;
1301 f[j_coord_offset+DIM*1+ZZ] -= tz;
1305 /**************************
1306 * CALCULATE INTERACTIONS *
1307 **************************/
1314 /* EWALD ELECTROSTATICS */
1316 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1317 ewrt = r32*ewtabscale;
1319 eweps = ewrt-ewitab;
1320 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1321 felec = qq32*rinv32*(rinvsq32-felec);
1325 /* Calculate temporary vectorial force */
1330 /* Update vectorial force */
1334 f[j_coord_offset+DIM*2+XX] -= tx;
1335 f[j_coord_offset+DIM*2+YY] -= ty;
1336 f[j_coord_offset+DIM*2+ZZ] -= tz;
1340 /**************************
1341 * CALCULATE INTERACTIONS *
1342 **************************/
1349 /* EWALD ELECTROSTATICS */
1351 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1352 ewrt = r33*ewtabscale;
1354 eweps = ewrt-ewitab;
1355 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1356 felec = qq33*rinv33*(rinvsq33-felec);
1360 /* Calculate temporary vectorial force */
1365 /* Update vectorial force */
1369 f[j_coord_offset+DIM*3+XX] -= tx;
1370 f[j_coord_offset+DIM*3+YY] -= ty;
1371 f[j_coord_offset+DIM*3+ZZ] -= tz;
1375 /* Inner loop uses 341 flops */
1377 /* End of innermost loop */
1380 f[i_coord_offset+DIM*0+XX] += fix0;
1381 f[i_coord_offset+DIM*0+YY] += fiy0;
1382 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1386 f[i_coord_offset+DIM*1+XX] += fix1;
1387 f[i_coord_offset+DIM*1+YY] += fiy1;
1388 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1392 f[i_coord_offset+DIM*2+XX] += fix2;
1393 f[i_coord_offset+DIM*2+YY] += fiy2;
1394 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1398 f[i_coord_offset+DIM*3+XX] += fix3;
1399 f[i_coord_offset+DIM*3+YY] += fiy3;
1400 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1404 fshift[i_shift_offset+XX] += tx;
1405 fshift[i_shift_offset+YY] += ty;
1406 fshift[i_shift_offset+ZZ] += tz;
1408 /* Increment number of inner iterations */
1409 inneriter += j_index_end - j_index_start;
1411 /* Outer loop uses 39 flops */
1414 /* Increment number of outer iterations */
1417 /* Update outer/inner flops */
1419 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*341);