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_ElecEw_VdwLJEw_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LJEwald
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwLJEw_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];
174 /* Start outer loop over neighborlists */
175 for(iidx=0; iidx<nri; iidx++)
177 /* Load shift vector for this list */
178 i_shift_offset = DIM*shiftidx[iidx];
179 shX = shiftvec[i_shift_offset+XX];
180 shY = shiftvec[i_shift_offset+YY];
181 shZ = shiftvec[i_shift_offset+ZZ];
183 /* Load limits for loop over neighbors */
184 j_index_start = jindex[iidx];
185 j_index_end = jindex[iidx+1];
187 /* Get outer coordinate index */
189 i_coord_offset = DIM*inr;
191 /* Load i particle coords and add shift vector */
192 ix0 = shX + x[i_coord_offset+DIM*0+XX];
193 iy0 = shY + x[i_coord_offset+DIM*0+YY];
194 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
195 ix1 = shX + x[i_coord_offset+DIM*1+XX];
196 iy1 = shY + x[i_coord_offset+DIM*1+YY];
197 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
198 ix2 = shX + x[i_coord_offset+DIM*2+XX];
199 iy2 = shY + x[i_coord_offset+DIM*2+YY];
200 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
201 ix3 = shX + x[i_coord_offset+DIM*3+XX];
202 iy3 = shY + x[i_coord_offset+DIM*3+YY];
203 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
218 /* Reset potential sums */
222 /* Start inner kernel loop */
223 for(jidx=j_index_start; jidx<j_index_end; jidx++)
225 /* Get j neighbor index, and coordinate index */
227 j_coord_offset = DIM*jnr;
229 /* load j atom coordinates */
230 jx0 = x[j_coord_offset+DIM*0+XX];
231 jy0 = x[j_coord_offset+DIM*0+YY];
232 jz0 = x[j_coord_offset+DIM*0+ZZ];
233 jx1 = x[j_coord_offset+DIM*1+XX];
234 jy1 = x[j_coord_offset+DIM*1+YY];
235 jz1 = x[j_coord_offset+DIM*1+ZZ];
236 jx2 = x[j_coord_offset+DIM*2+XX];
237 jy2 = x[j_coord_offset+DIM*2+YY];
238 jz2 = x[j_coord_offset+DIM*2+ZZ];
239 jx3 = x[j_coord_offset+DIM*3+XX];
240 jy3 = x[j_coord_offset+DIM*3+YY];
241 jz3 = x[j_coord_offset+DIM*3+ZZ];
243 /* Calculate displacement vector */
275 /* Calculate squared distance and things based on it */
276 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
277 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
278 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
279 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
280 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
281 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
282 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
283 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
284 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
285 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
287 rinv00 = gmx_invsqrt(rsq00);
288 rinv11 = gmx_invsqrt(rsq11);
289 rinv12 = gmx_invsqrt(rsq12);
290 rinv13 = gmx_invsqrt(rsq13);
291 rinv21 = gmx_invsqrt(rsq21);
292 rinv22 = gmx_invsqrt(rsq22);
293 rinv23 = gmx_invsqrt(rsq23);
294 rinv31 = gmx_invsqrt(rsq31);
295 rinv32 = gmx_invsqrt(rsq32);
296 rinv33 = gmx_invsqrt(rsq33);
298 rinvsq00 = rinv00*rinv00;
299 rinvsq11 = rinv11*rinv11;
300 rinvsq12 = rinv12*rinv12;
301 rinvsq13 = rinv13*rinv13;
302 rinvsq21 = rinv21*rinv21;
303 rinvsq22 = rinv22*rinv22;
304 rinvsq23 = rinv23*rinv23;
305 rinvsq31 = rinv31*rinv31;
306 rinvsq32 = rinv32*rinv32;
307 rinvsq33 = rinv33*rinv33;
309 /**************************
310 * CALCULATE INTERACTIONS *
311 **************************/
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*(1.0/12.0) - vvdw6*(1.0/6.0);
322 fvdw = (vvdw12 - vvdw6 - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
324 /* Update potential sums from outer loop */
329 /* Calculate temporary vectorial force */
334 /* Update vectorial force */
338 f[j_coord_offset+DIM*0+XX] -= tx;
339 f[j_coord_offset+DIM*0+YY] -= ty;
340 f[j_coord_offset+DIM*0+ZZ] -= tz;
342 /**************************
343 * CALCULATE INTERACTIONS *
344 **************************/
348 /* EWALD ELECTROSTATICS */
350 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
351 ewrt = r11*ewtabscale;
355 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
356 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
357 felec = qq11*rinv11*(rinvsq11-felec);
359 /* Update potential sums from outer loop */
364 /* Calculate temporary vectorial force */
369 /* Update vectorial force */
373 f[j_coord_offset+DIM*1+XX] -= tx;
374 f[j_coord_offset+DIM*1+YY] -= ty;
375 f[j_coord_offset+DIM*1+ZZ] -= tz;
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
383 /* EWALD ELECTROSTATICS */
385 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
386 ewrt = r12*ewtabscale;
390 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
391 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
392 felec = qq12*rinv12*(rinvsq12-felec);
394 /* Update potential sums from outer loop */
399 /* Calculate temporary vectorial force */
404 /* Update vectorial force */
408 f[j_coord_offset+DIM*2+XX] -= tx;
409 f[j_coord_offset+DIM*2+YY] -= ty;
410 f[j_coord_offset+DIM*2+ZZ] -= tz;
412 /**************************
413 * CALCULATE INTERACTIONS *
414 **************************/
418 /* EWALD ELECTROSTATICS */
420 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
421 ewrt = r13*ewtabscale;
425 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
426 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
427 felec = qq13*rinv13*(rinvsq13-felec);
429 /* Update potential sums from outer loop */
434 /* Calculate temporary vectorial force */
439 /* Update vectorial force */
443 f[j_coord_offset+DIM*3+XX] -= tx;
444 f[j_coord_offset+DIM*3+YY] -= ty;
445 f[j_coord_offset+DIM*3+ZZ] -= tz;
447 /**************************
448 * CALCULATE INTERACTIONS *
449 **************************/
453 /* EWALD ELECTROSTATICS */
455 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
456 ewrt = r21*ewtabscale;
460 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
461 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
462 felec = qq21*rinv21*(rinvsq21-felec);
464 /* Update potential sums from outer loop */
469 /* Calculate temporary vectorial force */
474 /* Update vectorial force */
478 f[j_coord_offset+DIM*1+XX] -= tx;
479 f[j_coord_offset+DIM*1+YY] -= ty;
480 f[j_coord_offset+DIM*1+ZZ] -= tz;
482 /**************************
483 * CALCULATE INTERACTIONS *
484 **************************/
488 /* EWALD ELECTROSTATICS */
490 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
491 ewrt = r22*ewtabscale;
495 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
496 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
497 felec = qq22*rinv22*(rinvsq22-felec);
499 /* Update potential sums from outer loop */
504 /* Calculate temporary vectorial force */
509 /* Update vectorial force */
513 f[j_coord_offset+DIM*2+XX] -= tx;
514 f[j_coord_offset+DIM*2+YY] -= ty;
515 f[j_coord_offset+DIM*2+ZZ] -= tz;
517 /**************************
518 * CALCULATE INTERACTIONS *
519 **************************/
523 /* EWALD ELECTROSTATICS */
525 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
526 ewrt = r23*ewtabscale;
530 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
531 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
532 felec = qq23*rinv23*(rinvsq23-felec);
534 /* Update potential sums from outer loop */
539 /* Calculate temporary vectorial force */
544 /* Update vectorial force */
548 f[j_coord_offset+DIM*3+XX] -= tx;
549 f[j_coord_offset+DIM*3+YY] -= ty;
550 f[j_coord_offset+DIM*3+ZZ] -= tz;
552 /**************************
553 * CALCULATE INTERACTIONS *
554 **************************/
558 /* EWALD ELECTROSTATICS */
560 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
561 ewrt = r31*ewtabscale;
565 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
566 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
567 felec = qq31*rinv31*(rinvsq31-felec);
569 /* Update potential sums from outer loop */
574 /* Calculate temporary vectorial force */
579 /* Update vectorial force */
583 f[j_coord_offset+DIM*1+XX] -= tx;
584 f[j_coord_offset+DIM*1+YY] -= ty;
585 f[j_coord_offset+DIM*1+ZZ] -= tz;
587 /**************************
588 * CALCULATE INTERACTIONS *
589 **************************/
593 /* EWALD ELECTROSTATICS */
595 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
596 ewrt = r32*ewtabscale;
600 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
601 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
602 felec = qq32*rinv32*(rinvsq32-felec);
604 /* Update potential sums from outer loop */
609 /* Calculate temporary vectorial force */
614 /* Update vectorial force */
618 f[j_coord_offset+DIM*2+XX] -= tx;
619 f[j_coord_offset+DIM*2+YY] -= ty;
620 f[j_coord_offset+DIM*2+ZZ] -= tz;
622 /**************************
623 * CALCULATE INTERACTIONS *
624 **************************/
628 /* EWALD ELECTROSTATICS */
630 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
631 ewrt = r33*ewtabscale;
635 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
636 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
637 felec = qq33*rinv33*(rinvsq33-felec);
639 /* Update potential sums from outer loop */
644 /* Calculate temporary vectorial force */
649 /* Update vectorial force */
653 f[j_coord_offset+DIM*3+XX] -= tx;
654 f[j_coord_offset+DIM*3+YY] -= ty;
655 f[j_coord_offset+DIM*3+ZZ] -= tz;
657 /* Inner loop uses 409 flops */
659 /* End of innermost loop */
662 f[i_coord_offset+DIM*0+XX] += fix0;
663 f[i_coord_offset+DIM*0+YY] += fiy0;
664 f[i_coord_offset+DIM*0+ZZ] += fiz0;
668 f[i_coord_offset+DIM*1+XX] += fix1;
669 f[i_coord_offset+DIM*1+YY] += fiy1;
670 f[i_coord_offset+DIM*1+ZZ] += fiz1;
674 f[i_coord_offset+DIM*2+XX] += fix2;
675 f[i_coord_offset+DIM*2+YY] += fiy2;
676 f[i_coord_offset+DIM*2+ZZ] += fiz2;
680 f[i_coord_offset+DIM*3+XX] += fix3;
681 f[i_coord_offset+DIM*3+YY] += fiy3;
682 f[i_coord_offset+DIM*3+ZZ] += fiz3;
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 41 flops */
701 /* Increment number of outer iterations */
704 /* Update outer/inner flops */
706 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*409);
709 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJEw_GeomW4W4_F_c
710 * Electrostatics interaction: Ewald
711 * VdW interaction: LJEwald
712 * Geometry: Water4-Water4
713 * Calculate force/pot: Force
716 nb_kernel_ElecEw_VdwLJEw_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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;
746 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
747 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
748 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
749 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
750 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
751 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
752 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
753 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
754 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
755 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
756 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
757 real velec,felec,velecsum,facel,crf,krf,krf2;
760 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
773 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
776 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
784 jindex = nlist->jindex;
786 shiftidx = nlist->shift;
788 shiftvec = fr->shift_vec[0];
789 fshift = fr->fshift[0];
791 charge = mdatoms->chargeA;
792 nvdwtype = fr->ntype;
794 vdwtype = mdatoms->typeA;
795 vdwgridparam = fr->ljpme_c6grid;
796 ewclj = fr->ewaldcoeff_lj;
797 sh_lj_ewald = fr->ic->sh_lj_ewald;
798 ewclj2 = ewclj*ewclj;
799 ewclj6 = ewclj2*ewclj2*ewclj2;
801 sh_ewald = fr->ic->sh_ewald;
802 ewtab = fr->ic->tabq_coul_F;
803 ewtabscale = fr->ic->tabq_scale;
804 ewtabhalfspace = 0.5/ewtabscale;
806 /* Setup water-specific parameters */
807 inr = nlist->iinr[0];
808 iq1 = facel*charge[inr+1];
809 iq2 = facel*charge[inr+2];
810 iq3 = facel*charge[inr+3];
811 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
816 vdwjidx0 = 2*vdwtype[inr+0];
817 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
818 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
819 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
833 /* Start outer loop over neighborlists */
834 for(iidx=0; iidx<nri; iidx++)
836 /* Load shift vector for this list */
837 i_shift_offset = DIM*shiftidx[iidx];
838 shX = shiftvec[i_shift_offset+XX];
839 shY = shiftvec[i_shift_offset+YY];
840 shZ = shiftvec[i_shift_offset+ZZ];
842 /* Load limits for loop over neighbors */
843 j_index_start = jindex[iidx];
844 j_index_end = jindex[iidx+1];
846 /* Get outer coordinate index */
848 i_coord_offset = DIM*inr;
850 /* Load i particle coords and add shift vector */
851 ix0 = shX + x[i_coord_offset+DIM*0+XX];
852 iy0 = shY + x[i_coord_offset+DIM*0+YY];
853 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
854 ix1 = shX + x[i_coord_offset+DIM*1+XX];
855 iy1 = shY + x[i_coord_offset+DIM*1+YY];
856 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
857 ix2 = shX + x[i_coord_offset+DIM*2+XX];
858 iy2 = shY + x[i_coord_offset+DIM*2+YY];
859 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
860 ix3 = shX + x[i_coord_offset+DIM*3+XX];
861 iy3 = shY + x[i_coord_offset+DIM*3+YY];
862 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
877 /* Start inner kernel loop */
878 for(jidx=j_index_start; jidx<j_index_end; jidx++)
880 /* Get j neighbor index, and coordinate index */
882 j_coord_offset = DIM*jnr;
884 /* load j atom coordinates */
885 jx0 = x[j_coord_offset+DIM*0+XX];
886 jy0 = x[j_coord_offset+DIM*0+YY];
887 jz0 = x[j_coord_offset+DIM*0+ZZ];
888 jx1 = x[j_coord_offset+DIM*1+XX];
889 jy1 = x[j_coord_offset+DIM*1+YY];
890 jz1 = x[j_coord_offset+DIM*1+ZZ];
891 jx2 = x[j_coord_offset+DIM*2+XX];
892 jy2 = x[j_coord_offset+DIM*2+YY];
893 jz2 = x[j_coord_offset+DIM*2+ZZ];
894 jx3 = x[j_coord_offset+DIM*3+XX];
895 jy3 = x[j_coord_offset+DIM*3+YY];
896 jz3 = x[j_coord_offset+DIM*3+ZZ];
898 /* Calculate displacement vector */
930 /* Calculate squared distance and things based on it */
931 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
932 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
933 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
934 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
935 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
936 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
937 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
938 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
939 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
940 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
942 rinv00 = gmx_invsqrt(rsq00);
943 rinv11 = gmx_invsqrt(rsq11);
944 rinv12 = gmx_invsqrt(rsq12);
945 rinv13 = gmx_invsqrt(rsq13);
946 rinv21 = gmx_invsqrt(rsq21);
947 rinv22 = gmx_invsqrt(rsq22);
948 rinv23 = gmx_invsqrt(rsq23);
949 rinv31 = gmx_invsqrt(rsq31);
950 rinv32 = gmx_invsqrt(rsq32);
951 rinv33 = gmx_invsqrt(rsq33);
953 rinvsq00 = rinv00*rinv00;
954 rinvsq11 = rinv11*rinv11;
955 rinvsq12 = rinv12*rinv12;
956 rinvsq13 = rinv13*rinv13;
957 rinvsq21 = rinv21*rinv21;
958 rinvsq22 = rinv22*rinv22;
959 rinvsq23 = rinv23*rinv23;
960 rinvsq31 = rinv31*rinv31;
961 rinvsq32 = rinv32*rinv32;
962 rinvsq33 = rinv33*rinv33;
964 /**************************
965 * CALCULATE INTERACTIONS *
966 **************************/
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;
991 /**************************
992 * CALCULATE INTERACTIONS *
993 **************************/
997 /* EWALD ELECTROSTATICS */
999 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1000 ewrt = r11*ewtabscale;
1002 eweps = ewrt-ewitab;
1003 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1004 felec = qq11*rinv11*(rinvsq11-felec);
1008 /* Calculate temporary vectorial force */
1013 /* Update vectorial force */
1017 f[j_coord_offset+DIM*1+XX] -= tx;
1018 f[j_coord_offset+DIM*1+YY] -= ty;
1019 f[j_coord_offset+DIM*1+ZZ] -= tz;
1021 /**************************
1022 * CALCULATE INTERACTIONS *
1023 **************************/
1027 /* EWALD ELECTROSTATICS */
1029 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1030 ewrt = r12*ewtabscale;
1032 eweps = ewrt-ewitab;
1033 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1034 felec = qq12*rinv12*(rinvsq12-felec);
1038 /* Calculate temporary vectorial force */
1043 /* Update vectorial force */
1047 f[j_coord_offset+DIM*2+XX] -= tx;
1048 f[j_coord_offset+DIM*2+YY] -= ty;
1049 f[j_coord_offset+DIM*2+ZZ] -= tz;
1051 /**************************
1052 * CALCULATE INTERACTIONS *
1053 **************************/
1057 /* EWALD ELECTROSTATICS */
1059 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1060 ewrt = r13*ewtabscale;
1062 eweps = ewrt-ewitab;
1063 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1064 felec = qq13*rinv13*(rinvsq13-felec);
1068 /* Calculate temporary vectorial force */
1073 /* Update vectorial force */
1077 f[j_coord_offset+DIM*3+XX] -= tx;
1078 f[j_coord_offset+DIM*3+YY] -= ty;
1079 f[j_coord_offset+DIM*3+ZZ] -= tz;
1081 /**************************
1082 * CALCULATE INTERACTIONS *
1083 **************************/
1087 /* EWALD ELECTROSTATICS */
1089 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1090 ewrt = r21*ewtabscale;
1092 eweps = ewrt-ewitab;
1093 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1094 felec = qq21*rinv21*(rinvsq21-felec);
1098 /* Calculate temporary vectorial force */
1103 /* Update vectorial force */
1107 f[j_coord_offset+DIM*1+XX] -= tx;
1108 f[j_coord_offset+DIM*1+YY] -= ty;
1109 f[j_coord_offset+DIM*1+ZZ] -= tz;
1111 /**************************
1112 * CALCULATE INTERACTIONS *
1113 **************************/
1117 /* EWALD ELECTROSTATICS */
1119 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1120 ewrt = r22*ewtabscale;
1122 eweps = ewrt-ewitab;
1123 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1124 felec = qq22*rinv22*(rinvsq22-felec);
1128 /* Calculate temporary vectorial force */
1133 /* Update vectorial force */
1137 f[j_coord_offset+DIM*2+XX] -= tx;
1138 f[j_coord_offset+DIM*2+YY] -= ty;
1139 f[j_coord_offset+DIM*2+ZZ] -= tz;
1141 /**************************
1142 * CALCULATE INTERACTIONS *
1143 **************************/
1147 /* EWALD ELECTROSTATICS */
1149 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1150 ewrt = r23*ewtabscale;
1152 eweps = ewrt-ewitab;
1153 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1154 felec = qq23*rinv23*(rinvsq23-felec);
1158 /* Calculate temporary vectorial force */
1163 /* Update vectorial force */
1167 f[j_coord_offset+DIM*3+XX] -= tx;
1168 f[j_coord_offset+DIM*3+YY] -= ty;
1169 f[j_coord_offset+DIM*3+ZZ] -= tz;
1171 /**************************
1172 * CALCULATE INTERACTIONS *
1173 **************************/
1177 /* EWALD ELECTROSTATICS */
1179 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1180 ewrt = r31*ewtabscale;
1182 eweps = ewrt-ewitab;
1183 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1184 felec = qq31*rinv31*(rinvsq31-felec);
1188 /* Calculate temporary vectorial force */
1193 /* Update vectorial force */
1197 f[j_coord_offset+DIM*1+XX] -= tx;
1198 f[j_coord_offset+DIM*1+YY] -= ty;
1199 f[j_coord_offset+DIM*1+ZZ] -= tz;
1201 /**************************
1202 * CALCULATE INTERACTIONS *
1203 **************************/
1207 /* EWALD ELECTROSTATICS */
1209 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1210 ewrt = r32*ewtabscale;
1212 eweps = ewrt-ewitab;
1213 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1214 felec = qq32*rinv32*(rinvsq32-felec);
1218 /* Calculate temporary vectorial force */
1223 /* Update vectorial force */
1227 f[j_coord_offset+DIM*2+XX] -= tx;
1228 f[j_coord_offset+DIM*2+YY] -= ty;
1229 f[j_coord_offset+DIM*2+ZZ] -= tz;
1231 /**************************
1232 * CALCULATE INTERACTIONS *
1233 **************************/
1237 /* EWALD ELECTROSTATICS */
1239 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1240 ewrt = r33*ewtabscale;
1242 eweps = ewrt-ewitab;
1243 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1244 felec = qq33*rinv33*(rinvsq33-felec);
1248 /* Calculate temporary vectorial force */
1253 /* Update vectorial force */
1257 f[j_coord_offset+DIM*3+XX] -= tx;
1258 f[j_coord_offset+DIM*3+YY] -= ty;
1259 f[j_coord_offset+DIM*3+ZZ] -= tz;
1261 /* Inner loop uses 341 flops */
1263 /* End of innermost loop */
1266 f[i_coord_offset+DIM*0+XX] += fix0;
1267 f[i_coord_offset+DIM*0+YY] += fiy0;
1268 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1272 f[i_coord_offset+DIM*1+XX] += fix1;
1273 f[i_coord_offset+DIM*1+YY] += fiy1;
1274 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1278 f[i_coord_offset+DIM*2+XX] += fix2;
1279 f[i_coord_offset+DIM*2+YY] += fiy2;
1280 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1284 f[i_coord_offset+DIM*3+XX] += fix3;
1285 f[i_coord_offset+DIM*3+YY] += fiy3;
1286 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1290 fshift[i_shift_offset+XX] += tx;
1291 fshift[i_shift_offset+YY] += ty;
1292 fshift[i_shift_offset+ZZ] += tz;
1294 /* Increment number of inner iterations */
1295 inneriter += j_index_end - j_index_start;
1297 /* Outer loop uses 39 flops */
1300 /* Increment number of outer iterations */
1303 /* Update outer/inner flops */
1305 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*341);