2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LJEwald
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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;
85 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
86 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
87 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
88 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
89 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
90 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
91 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
92 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
93 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
94 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
95 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
96 real velec,felec,velecsum,facel,crf,krf,krf2;
99 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
112 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
115 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
123 jindex = nlist->jindex;
125 shiftidx = nlist->shift;
127 shiftvec = fr->shift_vec[0];
128 fshift = fr->fshift[0];
130 charge = mdatoms->chargeA;
131 nvdwtype = fr->ntype;
133 vdwtype = mdatoms->typeA;
134 vdwgridparam = fr->ljpme_c6grid;
135 ewclj = fr->ewaldcoeff_lj;
136 sh_lj_ewald = fr->ic->sh_lj_ewald;
137 ewclj2 = ewclj*ewclj;
138 ewclj6 = ewclj2*ewclj2*ewclj2;
140 sh_ewald = fr->ic->sh_ewald;
141 ewtab = fr->ic->tabq_coul_FDV0;
142 ewtabscale = fr->ic->tabq_scale;
143 ewtabhalfspace = 0.5/ewtabscale;
145 /* Setup water-specific parameters */
146 inr = nlist->iinr[0];
147 iq1 = facel*charge[inr+1];
148 iq2 = facel*charge[inr+2];
149 iq3 = facel*charge[inr+3];
150 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
155 vdwjidx0 = 2*vdwtype[inr+0];
156 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
157 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
158 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
169 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
170 rcutoff = fr->rcoulomb;
171 rcutoff2 = rcutoff*rcutoff;
173 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
179 /* Start outer loop over neighborlists */
180 for(iidx=0; iidx<nri; iidx++)
182 /* Load shift vector for this list */
183 i_shift_offset = DIM*shiftidx[iidx];
184 shX = shiftvec[i_shift_offset+XX];
185 shY = shiftvec[i_shift_offset+YY];
186 shZ = shiftvec[i_shift_offset+ZZ];
188 /* Load limits for loop over neighbors */
189 j_index_start = jindex[iidx];
190 j_index_end = jindex[iidx+1];
192 /* Get outer coordinate index */
194 i_coord_offset = DIM*inr;
196 /* Load i particle coords and add shift vector */
197 ix0 = shX + x[i_coord_offset+DIM*0+XX];
198 iy0 = shY + x[i_coord_offset+DIM*0+YY];
199 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
200 ix1 = shX + x[i_coord_offset+DIM*1+XX];
201 iy1 = shY + x[i_coord_offset+DIM*1+YY];
202 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
203 ix2 = shX + x[i_coord_offset+DIM*2+XX];
204 iy2 = shY + x[i_coord_offset+DIM*2+YY];
205 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
206 ix3 = shX + x[i_coord_offset+DIM*3+XX];
207 iy3 = shY + x[i_coord_offset+DIM*3+YY];
208 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
223 /* Reset potential sums */
227 /* Start inner kernel loop */
228 for(jidx=j_index_start; jidx<j_index_end; jidx++)
230 /* Get j neighbor index, and coordinate index */
232 j_coord_offset = DIM*jnr;
234 /* load j atom coordinates */
235 jx0 = x[j_coord_offset+DIM*0+XX];
236 jy0 = x[j_coord_offset+DIM*0+YY];
237 jz0 = x[j_coord_offset+DIM*0+ZZ];
238 jx1 = x[j_coord_offset+DIM*1+XX];
239 jy1 = x[j_coord_offset+DIM*1+YY];
240 jz1 = x[j_coord_offset+DIM*1+ZZ];
241 jx2 = x[j_coord_offset+DIM*2+XX];
242 jy2 = x[j_coord_offset+DIM*2+YY];
243 jz2 = x[j_coord_offset+DIM*2+ZZ];
244 jx3 = x[j_coord_offset+DIM*3+XX];
245 jy3 = x[j_coord_offset+DIM*3+YY];
246 jz3 = x[j_coord_offset+DIM*3+ZZ];
248 /* Calculate displacement vector */
280 /* Calculate squared distance and things based on it */
281 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
282 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
283 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
284 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
285 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
286 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
287 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
288 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
289 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
290 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
292 rinv00 = gmx_invsqrt(rsq00);
293 rinv11 = gmx_invsqrt(rsq11);
294 rinv12 = gmx_invsqrt(rsq12);
295 rinv13 = gmx_invsqrt(rsq13);
296 rinv21 = gmx_invsqrt(rsq21);
297 rinv22 = gmx_invsqrt(rsq22);
298 rinv23 = gmx_invsqrt(rsq23);
299 rinv31 = gmx_invsqrt(rsq31);
300 rinv32 = gmx_invsqrt(rsq32);
301 rinv33 = gmx_invsqrt(rsq33);
303 rinvsq00 = rinv00*rinv00;
304 rinvsq11 = rinv11*rinv11;
305 rinvsq12 = rinv12*rinv12;
306 rinvsq13 = rinv13*rinv13;
307 rinvsq21 = rinv21*rinv21;
308 rinvsq22 = rinv22*rinv22;
309 rinvsq23 = rinv23*rinv23;
310 rinvsq31 = rinv31*rinv31;
311 rinvsq32 = rinv32*rinv32;
312 rinvsq33 = rinv33*rinv33;
314 /**************************
315 * CALCULATE INTERACTIONS *
316 **************************/
323 rinvsix = rinvsq00*rinvsq00*rinvsq00;
324 ewcljrsq = ewclj2*rsq00;
325 exponent = exp(-ewcljrsq);
326 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
327 vvdw6 = (c6_00-c6grid_00*(1.0-poly))*rinvsix;
328 vvdw12 = c12_00*rinvsix*rinvsix;
329 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);
330 fvdw = (vvdw12 - vvdw6 - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
332 /* Update potential sums from outer loop */
337 /* Calculate temporary vectorial force */
342 /* Update vectorial force */
346 f[j_coord_offset+DIM*0+XX] -= tx;
347 f[j_coord_offset+DIM*0+YY] -= ty;
348 f[j_coord_offset+DIM*0+ZZ] -= tz;
352 /**************************
353 * CALCULATE INTERACTIONS *
354 **************************/
361 /* EWALD ELECTROSTATICS */
363 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
364 ewrt = r11*ewtabscale;
368 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
369 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
370 felec = qq11*rinv11*(rinvsq11-felec);
372 /* Update potential sums from outer loop */
377 /* Calculate temporary vectorial force */
382 /* Update vectorial force */
386 f[j_coord_offset+DIM*1+XX] -= tx;
387 f[j_coord_offset+DIM*1+YY] -= ty;
388 f[j_coord_offset+DIM*1+ZZ] -= tz;
392 /**************************
393 * CALCULATE INTERACTIONS *
394 **************************/
401 /* EWALD ELECTROSTATICS */
403 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
404 ewrt = r12*ewtabscale;
408 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
409 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
410 felec = qq12*rinv12*(rinvsq12-felec);
412 /* Update potential sums from outer loop */
417 /* Calculate temporary vectorial force */
422 /* Update vectorial force */
426 f[j_coord_offset+DIM*2+XX] -= tx;
427 f[j_coord_offset+DIM*2+YY] -= ty;
428 f[j_coord_offset+DIM*2+ZZ] -= tz;
432 /**************************
433 * CALCULATE INTERACTIONS *
434 **************************/
441 /* EWALD ELECTROSTATICS */
443 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
444 ewrt = r13*ewtabscale;
448 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
449 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
450 felec = qq13*rinv13*(rinvsq13-felec);
452 /* Update potential sums from outer loop */
457 /* Calculate temporary vectorial force */
462 /* Update vectorial force */
466 f[j_coord_offset+DIM*3+XX] -= tx;
467 f[j_coord_offset+DIM*3+YY] -= ty;
468 f[j_coord_offset+DIM*3+ZZ] -= tz;
472 /**************************
473 * CALCULATE INTERACTIONS *
474 **************************/
481 /* EWALD ELECTROSTATICS */
483 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
484 ewrt = r21*ewtabscale;
488 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
489 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
490 felec = qq21*rinv21*(rinvsq21-felec);
492 /* Update potential sums from outer loop */
497 /* Calculate temporary vectorial force */
502 /* Update vectorial force */
506 f[j_coord_offset+DIM*1+XX] -= tx;
507 f[j_coord_offset+DIM*1+YY] -= ty;
508 f[j_coord_offset+DIM*1+ZZ] -= tz;
512 /**************************
513 * CALCULATE INTERACTIONS *
514 **************************/
521 /* EWALD ELECTROSTATICS */
523 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
524 ewrt = r22*ewtabscale;
528 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
529 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
530 felec = qq22*rinv22*(rinvsq22-felec);
532 /* Update potential sums from outer loop */
537 /* Calculate temporary vectorial force */
542 /* Update vectorial force */
546 f[j_coord_offset+DIM*2+XX] -= tx;
547 f[j_coord_offset+DIM*2+YY] -= ty;
548 f[j_coord_offset+DIM*2+ZZ] -= tz;
552 /**************************
553 * CALCULATE INTERACTIONS *
554 **************************/
561 /* EWALD ELECTROSTATICS */
563 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
564 ewrt = r23*ewtabscale;
568 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
569 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
570 felec = qq23*rinv23*(rinvsq23-felec);
572 /* Update potential sums from outer loop */
577 /* Calculate temporary vectorial force */
582 /* Update vectorial force */
586 f[j_coord_offset+DIM*3+XX] -= tx;
587 f[j_coord_offset+DIM*3+YY] -= ty;
588 f[j_coord_offset+DIM*3+ZZ] -= tz;
592 /**************************
593 * CALCULATE INTERACTIONS *
594 **************************/
601 /* EWALD ELECTROSTATICS */
603 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
604 ewrt = r31*ewtabscale;
608 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
609 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
610 felec = qq31*rinv31*(rinvsq31-felec);
612 /* Update potential sums from outer loop */
617 /* Calculate temporary vectorial force */
622 /* Update vectorial force */
626 f[j_coord_offset+DIM*1+XX] -= tx;
627 f[j_coord_offset+DIM*1+YY] -= ty;
628 f[j_coord_offset+DIM*1+ZZ] -= tz;
632 /**************************
633 * CALCULATE INTERACTIONS *
634 **************************/
641 /* EWALD ELECTROSTATICS */
643 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
644 ewrt = r32*ewtabscale;
648 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
649 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
650 felec = qq32*rinv32*(rinvsq32-felec);
652 /* Update potential sums from outer loop */
657 /* Calculate temporary vectorial force */
662 /* Update vectorial force */
666 f[j_coord_offset+DIM*2+XX] -= tx;
667 f[j_coord_offset+DIM*2+YY] -= ty;
668 f[j_coord_offset+DIM*2+ZZ] -= tz;
672 /**************************
673 * CALCULATE INTERACTIONS *
674 **************************/
681 /* EWALD ELECTROSTATICS */
683 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
684 ewrt = r33*ewtabscale;
688 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
689 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
690 felec = qq33*rinv33*(rinvsq33-felec);
692 /* Update potential sums from outer loop */
697 /* Calculate temporary vectorial force */
702 /* Update vectorial force */
706 f[j_coord_offset+DIM*3+XX] -= tx;
707 f[j_coord_offset+DIM*3+YY] -= ty;
708 f[j_coord_offset+DIM*3+ZZ] -= tz;
712 /* Inner loop uses 424 flops */
714 /* End of innermost loop */
717 f[i_coord_offset+DIM*0+XX] += fix0;
718 f[i_coord_offset+DIM*0+YY] += fiy0;
719 f[i_coord_offset+DIM*0+ZZ] += fiz0;
723 f[i_coord_offset+DIM*1+XX] += fix1;
724 f[i_coord_offset+DIM*1+YY] += fiy1;
725 f[i_coord_offset+DIM*1+ZZ] += fiz1;
729 f[i_coord_offset+DIM*2+XX] += fix2;
730 f[i_coord_offset+DIM*2+YY] += fiy2;
731 f[i_coord_offset+DIM*2+ZZ] += fiz2;
735 f[i_coord_offset+DIM*3+XX] += fix3;
736 f[i_coord_offset+DIM*3+YY] += fiy3;
737 f[i_coord_offset+DIM*3+ZZ] += fiz3;
741 fshift[i_shift_offset+XX] += tx;
742 fshift[i_shift_offset+YY] += ty;
743 fshift[i_shift_offset+ZZ] += tz;
746 /* Update potential energies */
747 kernel_data->energygrp_elec[ggid] += velecsum;
748 kernel_data->energygrp_vdw[ggid] += vvdwsum;
750 /* Increment number of inner iterations */
751 inneriter += j_index_end - j_index_start;
753 /* Outer loop uses 41 flops */
756 /* Increment number of outer iterations */
759 /* Update outer/inner flops */
761 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*424);
764 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_F_c
765 * Electrostatics interaction: Ewald
766 * VdW interaction: LJEwald
767 * Geometry: Water4-Water4
768 * Calculate force/pot: Force
771 nb_kernel_ElecEwSh_VdwLJEwSh_GeomW4W4_F_c
772 (t_nblist * gmx_restrict nlist,
773 rvec * gmx_restrict xx,
774 rvec * gmx_restrict ff,
775 t_forcerec * gmx_restrict fr,
776 t_mdatoms * gmx_restrict mdatoms,
777 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
778 t_nrnb * gmx_restrict nrnb)
780 int i_shift_offset,i_coord_offset,j_coord_offset;
781 int j_index_start,j_index_end;
782 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
783 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
784 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
785 real *shiftvec,*fshift,*x,*f;
787 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
789 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
791 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
793 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
795 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
797 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
799 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
801 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
802 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
803 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
804 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
805 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
806 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
807 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
808 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
809 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
810 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
811 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
812 real velec,felec,velecsum,facel,crf,krf,krf2;
815 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
828 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
831 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
839 jindex = nlist->jindex;
841 shiftidx = nlist->shift;
843 shiftvec = fr->shift_vec[0];
844 fshift = fr->fshift[0];
846 charge = mdatoms->chargeA;
847 nvdwtype = fr->ntype;
849 vdwtype = mdatoms->typeA;
850 vdwgridparam = fr->ljpme_c6grid;
851 ewclj = fr->ewaldcoeff_lj;
852 sh_lj_ewald = fr->ic->sh_lj_ewald;
853 ewclj2 = ewclj*ewclj;
854 ewclj6 = ewclj2*ewclj2*ewclj2;
856 sh_ewald = fr->ic->sh_ewald;
857 ewtab = fr->ic->tabq_coul_F;
858 ewtabscale = fr->ic->tabq_scale;
859 ewtabhalfspace = 0.5/ewtabscale;
861 /* Setup water-specific parameters */
862 inr = nlist->iinr[0];
863 iq1 = facel*charge[inr+1];
864 iq2 = facel*charge[inr+2];
865 iq3 = facel*charge[inr+3];
866 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
871 vdwjidx0 = 2*vdwtype[inr+0];
872 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
873 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
874 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
885 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
886 rcutoff = fr->rcoulomb;
887 rcutoff2 = rcutoff*rcutoff;
889 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
895 /* Start outer loop over neighborlists */
896 for(iidx=0; iidx<nri; iidx++)
898 /* Load shift vector for this list */
899 i_shift_offset = DIM*shiftidx[iidx];
900 shX = shiftvec[i_shift_offset+XX];
901 shY = shiftvec[i_shift_offset+YY];
902 shZ = shiftvec[i_shift_offset+ZZ];
904 /* Load limits for loop over neighbors */
905 j_index_start = jindex[iidx];
906 j_index_end = jindex[iidx+1];
908 /* Get outer coordinate index */
910 i_coord_offset = DIM*inr;
912 /* Load i particle coords and add shift vector */
913 ix0 = shX + x[i_coord_offset+DIM*0+XX];
914 iy0 = shY + x[i_coord_offset+DIM*0+YY];
915 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
916 ix1 = shX + x[i_coord_offset+DIM*1+XX];
917 iy1 = shY + x[i_coord_offset+DIM*1+YY];
918 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
919 ix2 = shX + x[i_coord_offset+DIM*2+XX];
920 iy2 = shY + x[i_coord_offset+DIM*2+YY];
921 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
922 ix3 = shX + x[i_coord_offset+DIM*3+XX];
923 iy3 = shY + x[i_coord_offset+DIM*3+YY];
924 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
939 /* Start inner kernel loop */
940 for(jidx=j_index_start; jidx<j_index_end; jidx++)
942 /* Get j neighbor index, and coordinate index */
944 j_coord_offset = DIM*jnr;
946 /* load j atom coordinates */
947 jx0 = x[j_coord_offset+DIM*0+XX];
948 jy0 = x[j_coord_offset+DIM*0+YY];
949 jz0 = x[j_coord_offset+DIM*0+ZZ];
950 jx1 = x[j_coord_offset+DIM*1+XX];
951 jy1 = x[j_coord_offset+DIM*1+YY];
952 jz1 = x[j_coord_offset+DIM*1+ZZ];
953 jx2 = x[j_coord_offset+DIM*2+XX];
954 jy2 = x[j_coord_offset+DIM*2+YY];
955 jz2 = x[j_coord_offset+DIM*2+ZZ];
956 jx3 = x[j_coord_offset+DIM*3+XX];
957 jy3 = x[j_coord_offset+DIM*3+YY];
958 jz3 = x[j_coord_offset+DIM*3+ZZ];
960 /* Calculate displacement vector */
992 /* Calculate squared distance and things based on it */
993 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
994 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
995 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
996 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
997 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
998 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
999 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
1000 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
1001 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
1002 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
1004 rinv00 = gmx_invsqrt(rsq00);
1005 rinv11 = gmx_invsqrt(rsq11);
1006 rinv12 = gmx_invsqrt(rsq12);
1007 rinv13 = gmx_invsqrt(rsq13);
1008 rinv21 = gmx_invsqrt(rsq21);
1009 rinv22 = gmx_invsqrt(rsq22);
1010 rinv23 = gmx_invsqrt(rsq23);
1011 rinv31 = gmx_invsqrt(rsq31);
1012 rinv32 = gmx_invsqrt(rsq32);
1013 rinv33 = gmx_invsqrt(rsq33);
1015 rinvsq00 = rinv00*rinv00;
1016 rinvsq11 = rinv11*rinv11;
1017 rinvsq12 = rinv12*rinv12;
1018 rinvsq13 = rinv13*rinv13;
1019 rinvsq21 = rinv21*rinv21;
1020 rinvsq22 = rinv22*rinv22;
1021 rinvsq23 = rinv23*rinv23;
1022 rinvsq31 = rinv31*rinv31;
1023 rinvsq32 = rinv32*rinv32;
1024 rinvsq33 = rinv33*rinv33;
1026 /**************************
1027 * CALCULATE INTERACTIONS *
1028 **************************/
1035 rinvsix = rinvsq00*rinvsq00*rinvsq00;
1036 ewcljrsq = ewclj2*rsq00;
1037 exponent = exp(-ewcljrsq);
1038 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
1039 fvdw = (((c12_00*rinvsix - c6_00 + c6grid_00*(1.0-poly))*rinvsix) - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
1043 /* Calculate temporary vectorial force */
1048 /* Update vectorial force */
1052 f[j_coord_offset+DIM*0+XX] -= tx;
1053 f[j_coord_offset+DIM*0+YY] -= ty;
1054 f[j_coord_offset+DIM*0+ZZ] -= tz;
1058 /**************************
1059 * CALCULATE INTERACTIONS *
1060 **************************/
1067 /* EWALD ELECTROSTATICS */
1069 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1070 ewrt = r11*ewtabscale;
1072 eweps = ewrt-ewitab;
1073 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1074 felec = qq11*rinv11*(rinvsq11-felec);
1078 /* Calculate temporary vectorial force */
1083 /* Update vectorial force */
1087 f[j_coord_offset+DIM*1+XX] -= tx;
1088 f[j_coord_offset+DIM*1+YY] -= ty;
1089 f[j_coord_offset+DIM*1+ZZ] -= tz;
1093 /**************************
1094 * CALCULATE INTERACTIONS *
1095 **************************/
1102 /* EWALD ELECTROSTATICS */
1104 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1105 ewrt = r12*ewtabscale;
1107 eweps = ewrt-ewitab;
1108 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1109 felec = qq12*rinv12*(rinvsq12-felec);
1113 /* Calculate temporary vectorial force */
1118 /* Update vectorial force */
1122 f[j_coord_offset+DIM*2+XX] -= tx;
1123 f[j_coord_offset+DIM*2+YY] -= ty;
1124 f[j_coord_offset+DIM*2+ZZ] -= tz;
1128 /**************************
1129 * CALCULATE INTERACTIONS *
1130 **************************/
1137 /* EWALD ELECTROSTATICS */
1139 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1140 ewrt = r13*ewtabscale;
1142 eweps = ewrt-ewitab;
1143 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1144 felec = qq13*rinv13*(rinvsq13-felec);
1148 /* Calculate temporary vectorial force */
1153 /* Update vectorial force */
1157 f[j_coord_offset+DIM*3+XX] -= tx;
1158 f[j_coord_offset+DIM*3+YY] -= ty;
1159 f[j_coord_offset+DIM*3+ZZ] -= tz;
1163 /**************************
1164 * CALCULATE INTERACTIONS *
1165 **************************/
1172 /* EWALD ELECTROSTATICS */
1174 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1175 ewrt = r21*ewtabscale;
1177 eweps = ewrt-ewitab;
1178 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1179 felec = qq21*rinv21*(rinvsq21-felec);
1183 /* Calculate temporary vectorial force */
1188 /* Update vectorial force */
1192 f[j_coord_offset+DIM*1+XX] -= tx;
1193 f[j_coord_offset+DIM*1+YY] -= ty;
1194 f[j_coord_offset+DIM*1+ZZ] -= tz;
1198 /**************************
1199 * CALCULATE INTERACTIONS *
1200 **************************/
1207 /* EWALD ELECTROSTATICS */
1209 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1210 ewrt = r22*ewtabscale;
1212 eweps = ewrt-ewitab;
1213 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1214 felec = qq22*rinv22*(rinvsq22-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;
1233 /**************************
1234 * CALCULATE INTERACTIONS *
1235 **************************/
1242 /* EWALD ELECTROSTATICS */
1244 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1245 ewrt = r23*ewtabscale;
1247 eweps = ewrt-ewitab;
1248 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1249 felec = qq23*rinv23*(rinvsq23-felec);
1253 /* Calculate temporary vectorial force */
1258 /* Update vectorial force */
1262 f[j_coord_offset+DIM*3+XX] -= tx;
1263 f[j_coord_offset+DIM*3+YY] -= ty;
1264 f[j_coord_offset+DIM*3+ZZ] -= tz;
1268 /**************************
1269 * CALCULATE INTERACTIONS *
1270 **************************/
1277 /* EWALD ELECTROSTATICS */
1279 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1280 ewrt = r31*ewtabscale;
1282 eweps = ewrt-ewitab;
1283 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1284 felec = qq31*rinv31*(rinvsq31-felec);
1288 /* Calculate temporary vectorial force */
1293 /* Update vectorial force */
1297 f[j_coord_offset+DIM*1+XX] -= tx;
1298 f[j_coord_offset+DIM*1+YY] -= ty;
1299 f[j_coord_offset+DIM*1+ZZ] -= tz;
1303 /**************************
1304 * CALCULATE INTERACTIONS *
1305 **************************/
1312 /* EWALD ELECTROSTATICS */
1314 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1315 ewrt = r32*ewtabscale;
1317 eweps = ewrt-ewitab;
1318 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1319 felec = qq32*rinv32*(rinvsq32-felec);
1323 /* Calculate temporary vectorial force */
1328 /* Update vectorial force */
1332 f[j_coord_offset+DIM*2+XX] -= tx;
1333 f[j_coord_offset+DIM*2+YY] -= ty;
1334 f[j_coord_offset+DIM*2+ZZ] -= tz;
1338 /**************************
1339 * CALCULATE INTERACTIONS *
1340 **************************/
1347 /* EWALD ELECTROSTATICS */
1349 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1350 ewrt = r33*ewtabscale;
1352 eweps = ewrt-ewitab;
1353 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1354 felec = qq33*rinv33*(rinvsq33-felec);
1358 /* Calculate temporary vectorial force */
1363 /* Update vectorial force */
1367 f[j_coord_offset+DIM*3+XX] -= tx;
1368 f[j_coord_offset+DIM*3+YY] -= ty;
1369 f[j_coord_offset+DIM*3+ZZ] -= tz;
1373 /* Inner loop uses 341 flops */
1375 /* End of innermost loop */
1378 f[i_coord_offset+DIM*0+XX] += fix0;
1379 f[i_coord_offset+DIM*0+YY] += fiy0;
1380 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1384 f[i_coord_offset+DIM*1+XX] += fix1;
1385 f[i_coord_offset+DIM*1+YY] += fiy1;
1386 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1390 f[i_coord_offset+DIM*2+XX] += fix2;
1391 f[i_coord_offset+DIM*2+YY] += fiy2;
1392 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1396 f[i_coord_offset+DIM*3+XX] += fix3;
1397 f[i_coord_offset+DIM*3+YY] += fiy3;
1398 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1402 fshift[i_shift_offset+XX] += tx;
1403 fshift[i_shift_offset+YY] += ty;
1404 fshift[i_shift_offset+ZZ] += tz;
1406 /* Increment number of inner iterations */
1407 inneriter += j_index_end - j_index_start;
1409 /* Outer loop uses 39 flops */
1412 /* Increment number of outer iterations */
1415 /* Update outer/inner flops */
1417 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*341);