2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwBhamSh_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;
105 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
113 jindex = nlist->jindex;
115 shiftidx = nlist->shift;
117 shiftvec = fr->shift_vec[0];
118 fshift = fr->fshift[0];
120 charge = mdatoms->chargeA;
121 nvdwtype = fr->ntype;
123 vdwtype = mdatoms->typeA;
125 sh_ewald = fr->ic->sh_ewald;
126 ewtab = fr->ic->tabq_coul_FDV0;
127 ewtabscale = fr->ic->tabq_scale;
128 ewtabhalfspace = 0.5/ewtabscale;
130 /* Setup water-specific parameters */
131 inr = nlist->iinr[0];
132 iq1 = facel*charge[inr+1];
133 iq2 = facel*charge[inr+2];
134 iq3 = facel*charge[inr+3];
135 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
140 vdwjidx0 = 3*vdwtype[inr+0];
141 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
142 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
143 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
154 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
155 rcutoff = fr->rcoulomb;
156 rcutoff2 = rcutoff*rcutoff;
158 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
164 /* Start outer loop over neighborlists */
165 for(iidx=0; iidx<nri; iidx++)
167 /* Load shift vector for this list */
168 i_shift_offset = DIM*shiftidx[iidx];
169 shX = shiftvec[i_shift_offset+XX];
170 shY = shiftvec[i_shift_offset+YY];
171 shZ = shiftvec[i_shift_offset+ZZ];
173 /* Load limits for loop over neighbors */
174 j_index_start = jindex[iidx];
175 j_index_end = jindex[iidx+1];
177 /* Get outer coordinate index */
179 i_coord_offset = DIM*inr;
181 /* Load i particle coords and add shift vector */
182 ix0 = shX + x[i_coord_offset+DIM*0+XX];
183 iy0 = shY + x[i_coord_offset+DIM*0+YY];
184 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
185 ix1 = shX + x[i_coord_offset+DIM*1+XX];
186 iy1 = shY + x[i_coord_offset+DIM*1+YY];
187 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
188 ix2 = shX + x[i_coord_offset+DIM*2+XX];
189 iy2 = shY + x[i_coord_offset+DIM*2+YY];
190 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
191 ix3 = shX + x[i_coord_offset+DIM*3+XX];
192 iy3 = shY + x[i_coord_offset+DIM*3+YY];
193 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
208 /* Reset potential sums */
212 /* Start inner kernel loop */
213 for(jidx=j_index_start; jidx<j_index_end; jidx++)
215 /* Get j neighbor index, and coordinate index */
217 j_coord_offset = DIM*jnr;
219 /* load j atom coordinates */
220 jx0 = x[j_coord_offset+DIM*0+XX];
221 jy0 = x[j_coord_offset+DIM*0+YY];
222 jz0 = x[j_coord_offset+DIM*0+ZZ];
223 jx1 = x[j_coord_offset+DIM*1+XX];
224 jy1 = x[j_coord_offset+DIM*1+YY];
225 jz1 = x[j_coord_offset+DIM*1+ZZ];
226 jx2 = x[j_coord_offset+DIM*2+XX];
227 jy2 = x[j_coord_offset+DIM*2+YY];
228 jz2 = x[j_coord_offset+DIM*2+ZZ];
229 jx3 = x[j_coord_offset+DIM*3+XX];
230 jy3 = x[j_coord_offset+DIM*3+YY];
231 jz3 = x[j_coord_offset+DIM*3+ZZ];
233 /* Calculate displacement vector */
265 /* Calculate squared distance and things based on it */
266 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
267 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
268 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
269 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
270 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
271 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
272 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
273 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
274 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
275 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
277 rinv00 = gmx_invsqrt(rsq00);
278 rinv11 = gmx_invsqrt(rsq11);
279 rinv12 = gmx_invsqrt(rsq12);
280 rinv13 = gmx_invsqrt(rsq13);
281 rinv21 = gmx_invsqrt(rsq21);
282 rinv22 = gmx_invsqrt(rsq22);
283 rinv23 = gmx_invsqrt(rsq23);
284 rinv31 = gmx_invsqrt(rsq31);
285 rinv32 = gmx_invsqrt(rsq32);
286 rinv33 = gmx_invsqrt(rsq33);
288 rinvsq00 = rinv00*rinv00;
289 rinvsq11 = rinv11*rinv11;
290 rinvsq12 = rinv12*rinv12;
291 rinvsq13 = rinv13*rinv13;
292 rinvsq21 = rinv21*rinv21;
293 rinvsq22 = rinv22*rinv22;
294 rinvsq23 = rinv23*rinv23;
295 rinvsq31 = rinv31*rinv31;
296 rinvsq32 = rinv32*rinv32;
297 rinvsq33 = rinv33*rinv33;
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
308 /* BUCKINGHAM DISPERSION/REPULSION */
309 rinvsix = rinvsq00*rinvsq00*rinvsq00;
310 vvdw6 = c6_00*rinvsix;
312 vvdwexp = cexp1_00*exp(-br);
313 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
314 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
316 /* Update potential sums from outer loop */
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*0+XX] -= tx;
331 f[j_coord_offset+DIM*0+YY] -= ty;
332 f[j_coord_offset+DIM*0+ZZ] -= tz;
336 /**************************
337 * CALCULATE INTERACTIONS *
338 **************************/
345 /* EWALD ELECTROSTATICS */
347 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
348 ewrt = r11*ewtabscale;
352 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
353 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
354 felec = qq11*rinv11*(rinvsq11-felec);
356 /* Update potential sums from outer loop */
361 /* Calculate temporary vectorial force */
366 /* Update vectorial force */
370 f[j_coord_offset+DIM*1+XX] -= tx;
371 f[j_coord_offset+DIM*1+YY] -= ty;
372 f[j_coord_offset+DIM*1+ZZ] -= tz;
376 /**************************
377 * CALCULATE INTERACTIONS *
378 **************************/
385 /* EWALD ELECTROSTATICS */
387 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
388 ewrt = r12*ewtabscale;
392 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
393 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
394 felec = qq12*rinv12*(rinvsq12-felec);
396 /* Update potential sums from outer loop */
401 /* Calculate temporary vectorial force */
406 /* Update vectorial force */
410 f[j_coord_offset+DIM*2+XX] -= tx;
411 f[j_coord_offset+DIM*2+YY] -= ty;
412 f[j_coord_offset+DIM*2+ZZ] -= tz;
416 /**************************
417 * CALCULATE INTERACTIONS *
418 **************************/
425 /* EWALD ELECTROSTATICS */
427 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
428 ewrt = r13*ewtabscale;
432 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
433 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
434 felec = qq13*rinv13*(rinvsq13-felec);
436 /* Update potential sums from outer loop */
441 /* Calculate temporary vectorial force */
446 /* Update vectorial force */
450 f[j_coord_offset+DIM*3+XX] -= tx;
451 f[j_coord_offset+DIM*3+YY] -= ty;
452 f[j_coord_offset+DIM*3+ZZ] -= tz;
456 /**************************
457 * CALCULATE INTERACTIONS *
458 **************************/
465 /* EWALD ELECTROSTATICS */
467 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
468 ewrt = r21*ewtabscale;
472 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
473 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
474 felec = qq21*rinv21*(rinvsq21-felec);
476 /* Update potential sums from outer loop */
481 /* Calculate temporary vectorial force */
486 /* Update vectorial force */
490 f[j_coord_offset+DIM*1+XX] -= tx;
491 f[j_coord_offset+DIM*1+YY] -= ty;
492 f[j_coord_offset+DIM*1+ZZ] -= tz;
496 /**************************
497 * CALCULATE INTERACTIONS *
498 **************************/
505 /* EWALD ELECTROSTATICS */
507 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
508 ewrt = r22*ewtabscale;
512 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
513 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
514 felec = qq22*rinv22*(rinvsq22-felec);
516 /* Update potential sums from outer loop */
521 /* Calculate temporary vectorial force */
526 /* Update vectorial force */
530 f[j_coord_offset+DIM*2+XX] -= tx;
531 f[j_coord_offset+DIM*2+YY] -= ty;
532 f[j_coord_offset+DIM*2+ZZ] -= tz;
536 /**************************
537 * CALCULATE INTERACTIONS *
538 **************************/
545 /* EWALD ELECTROSTATICS */
547 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
548 ewrt = r23*ewtabscale;
552 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
553 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
554 felec = qq23*rinv23*(rinvsq23-felec);
556 /* Update potential sums from outer loop */
561 /* Calculate temporary vectorial force */
566 /* Update vectorial force */
570 f[j_coord_offset+DIM*3+XX] -= tx;
571 f[j_coord_offset+DIM*3+YY] -= ty;
572 f[j_coord_offset+DIM*3+ZZ] -= tz;
576 /**************************
577 * CALCULATE INTERACTIONS *
578 **************************/
585 /* EWALD ELECTROSTATICS */
587 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
588 ewrt = r31*ewtabscale;
592 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
593 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
594 felec = qq31*rinv31*(rinvsq31-felec);
596 /* Update potential sums from outer loop */
601 /* Calculate temporary vectorial force */
606 /* Update vectorial force */
610 f[j_coord_offset+DIM*1+XX] -= tx;
611 f[j_coord_offset+DIM*1+YY] -= ty;
612 f[j_coord_offset+DIM*1+ZZ] -= tz;
616 /**************************
617 * CALCULATE INTERACTIONS *
618 **************************/
625 /* EWALD ELECTROSTATICS */
627 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
628 ewrt = r32*ewtabscale;
632 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
633 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
634 felec = qq32*rinv32*(rinvsq32-felec);
636 /* Update potential sums from outer loop */
641 /* Calculate temporary vectorial force */
646 /* Update vectorial force */
650 f[j_coord_offset+DIM*2+XX] -= tx;
651 f[j_coord_offset+DIM*2+YY] -= ty;
652 f[j_coord_offset+DIM*2+ZZ] -= tz;
656 /**************************
657 * CALCULATE INTERACTIONS *
658 **************************/
665 /* EWALD ELECTROSTATICS */
667 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
668 ewrt = r33*ewtabscale;
672 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
673 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
674 felec = qq33*rinv33*(rinvsq33-felec);
676 /* Update potential sums from outer loop */
681 /* Calculate temporary vectorial force */
686 /* Update vectorial force */
690 f[j_coord_offset+DIM*3+XX] -= tx;
691 f[j_coord_offset+DIM*3+YY] -= ty;
692 f[j_coord_offset+DIM*3+ZZ] -= tz;
696 /* Inner loop uses 461 flops */
698 /* End of innermost loop */
701 f[i_coord_offset+DIM*0+XX] += fix0;
702 f[i_coord_offset+DIM*0+YY] += fiy0;
703 f[i_coord_offset+DIM*0+ZZ] += fiz0;
707 f[i_coord_offset+DIM*1+XX] += fix1;
708 f[i_coord_offset+DIM*1+YY] += fiy1;
709 f[i_coord_offset+DIM*1+ZZ] += fiz1;
713 f[i_coord_offset+DIM*2+XX] += fix2;
714 f[i_coord_offset+DIM*2+YY] += fiy2;
715 f[i_coord_offset+DIM*2+ZZ] += fiz2;
719 f[i_coord_offset+DIM*3+XX] += fix3;
720 f[i_coord_offset+DIM*3+YY] += fiy3;
721 f[i_coord_offset+DIM*3+ZZ] += fiz3;
725 fshift[i_shift_offset+XX] += tx;
726 fshift[i_shift_offset+YY] += ty;
727 fshift[i_shift_offset+ZZ] += tz;
730 /* Update potential energies */
731 kernel_data->energygrp_elec[ggid] += velecsum;
732 kernel_data->energygrp_vdw[ggid] += vvdwsum;
734 /* Increment number of inner iterations */
735 inneriter += j_index_end - j_index_start;
737 /* Outer loop uses 41 flops */
740 /* Increment number of outer iterations */
743 /* Update outer/inner flops */
745 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*461);
748 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW4W4_F_c
749 * Electrostatics interaction: Ewald
750 * VdW interaction: Buckingham
751 * Geometry: Water4-Water4
752 * Calculate force/pot: Force
755 nb_kernel_ElecEwSh_VdwBhamSh_GeomW4W4_F_c
756 (t_nblist * gmx_restrict nlist,
757 rvec * gmx_restrict xx,
758 rvec * gmx_restrict ff,
759 t_forcerec * gmx_restrict fr,
760 t_mdatoms * gmx_restrict mdatoms,
761 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
762 t_nrnb * gmx_restrict nrnb)
764 int i_shift_offset,i_coord_offset,j_coord_offset;
765 int j_index_start,j_index_end;
766 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
767 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
768 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
769 real *shiftvec,*fshift,*x,*f;
771 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
773 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
775 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
777 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
779 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
781 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
783 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
785 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
786 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
787 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
788 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
789 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
790 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
791 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
792 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
793 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
794 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
795 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
796 real velec,felec,velecsum,facel,crf,krf,krf2;
799 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
803 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
811 jindex = nlist->jindex;
813 shiftidx = nlist->shift;
815 shiftvec = fr->shift_vec[0];
816 fshift = fr->fshift[0];
818 charge = mdatoms->chargeA;
819 nvdwtype = fr->ntype;
821 vdwtype = mdatoms->typeA;
823 sh_ewald = fr->ic->sh_ewald;
824 ewtab = fr->ic->tabq_coul_F;
825 ewtabscale = fr->ic->tabq_scale;
826 ewtabhalfspace = 0.5/ewtabscale;
828 /* Setup water-specific parameters */
829 inr = nlist->iinr[0];
830 iq1 = facel*charge[inr+1];
831 iq2 = facel*charge[inr+2];
832 iq3 = facel*charge[inr+3];
833 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
838 vdwjidx0 = 3*vdwtype[inr+0];
839 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
840 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
841 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
852 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
853 rcutoff = fr->rcoulomb;
854 rcutoff2 = rcutoff*rcutoff;
856 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
862 /* Start outer loop over neighborlists */
863 for(iidx=0; iidx<nri; iidx++)
865 /* Load shift vector for this list */
866 i_shift_offset = DIM*shiftidx[iidx];
867 shX = shiftvec[i_shift_offset+XX];
868 shY = shiftvec[i_shift_offset+YY];
869 shZ = shiftvec[i_shift_offset+ZZ];
871 /* Load limits for loop over neighbors */
872 j_index_start = jindex[iidx];
873 j_index_end = jindex[iidx+1];
875 /* Get outer coordinate index */
877 i_coord_offset = DIM*inr;
879 /* Load i particle coords and add shift vector */
880 ix0 = shX + x[i_coord_offset+DIM*0+XX];
881 iy0 = shY + x[i_coord_offset+DIM*0+YY];
882 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
883 ix1 = shX + x[i_coord_offset+DIM*1+XX];
884 iy1 = shY + x[i_coord_offset+DIM*1+YY];
885 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
886 ix2 = shX + x[i_coord_offset+DIM*2+XX];
887 iy2 = shY + x[i_coord_offset+DIM*2+YY];
888 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
889 ix3 = shX + x[i_coord_offset+DIM*3+XX];
890 iy3 = shY + x[i_coord_offset+DIM*3+YY];
891 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
906 /* Start inner kernel loop */
907 for(jidx=j_index_start; jidx<j_index_end; jidx++)
909 /* Get j neighbor index, and coordinate index */
911 j_coord_offset = DIM*jnr;
913 /* load j atom coordinates */
914 jx0 = x[j_coord_offset+DIM*0+XX];
915 jy0 = x[j_coord_offset+DIM*0+YY];
916 jz0 = x[j_coord_offset+DIM*0+ZZ];
917 jx1 = x[j_coord_offset+DIM*1+XX];
918 jy1 = x[j_coord_offset+DIM*1+YY];
919 jz1 = x[j_coord_offset+DIM*1+ZZ];
920 jx2 = x[j_coord_offset+DIM*2+XX];
921 jy2 = x[j_coord_offset+DIM*2+YY];
922 jz2 = x[j_coord_offset+DIM*2+ZZ];
923 jx3 = x[j_coord_offset+DIM*3+XX];
924 jy3 = x[j_coord_offset+DIM*3+YY];
925 jz3 = x[j_coord_offset+DIM*3+ZZ];
927 /* Calculate displacement vector */
959 /* Calculate squared distance and things based on it */
960 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
961 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
962 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
963 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
964 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
965 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
966 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
967 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
968 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
969 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
971 rinv00 = gmx_invsqrt(rsq00);
972 rinv11 = gmx_invsqrt(rsq11);
973 rinv12 = gmx_invsqrt(rsq12);
974 rinv13 = gmx_invsqrt(rsq13);
975 rinv21 = gmx_invsqrt(rsq21);
976 rinv22 = gmx_invsqrt(rsq22);
977 rinv23 = gmx_invsqrt(rsq23);
978 rinv31 = gmx_invsqrt(rsq31);
979 rinv32 = gmx_invsqrt(rsq32);
980 rinv33 = gmx_invsqrt(rsq33);
982 rinvsq00 = rinv00*rinv00;
983 rinvsq11 = rinv11*rinv11;
984 rinvsq12 = rinv12*rinv12;
985 rinvsq13 = rinv13*rinv13;
986 rinvsq21 = rinv21*rinv21;
987 rinvsq22 = rinv22*rinv22;
988 rinvsq23 = rinv23*rinv23;
989 rinvsq31 = rinv31*rinv31;
990 rinvsq32 = rinv32*rinv32;
991 rinvsq33 = rinv33*rinv33;
993 /**************************
994 * CALCULATE INTERACTIONS *
995 **************************/
1002 /* BUCKINGHAM DISPERSION/REPULSION */
1003 rinvsix = rinvsq00*rinvsq00*rinvsq00;
1004 vvdw6 = c6_00*rinvsix;
1006 vvdwexp = cexp1_00*exp(-br);
1007 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
1011 /* Calculate temporary vectorial force */
1016 /* Update vectorial force */
1020 f[j_coord_offset+DIM*0+XX] -= tx;
1021 f[j_coord_offset+DIM*0+YY] -= ty;
1022 f[j_coord_offset+DIM*0+ZZ] -= tz;
1026 /**************************
1027 * CALCULATE INTERACTIONS *
1028 **************************/
1035 /* EWALD ELECTROSTATICS */
1037 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1038 ewrt = r11*ewtabscale;
1040 eweps = ewrt-ewitab;
1041 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1042 felec = qq11*rinv11*(rinvsq11-felec);
1046 /* Calculate temporary vectorial force */
1051 /* Update vectorial force */
1055 f[j_coord_offset+DIM*1+XX] -= tx;
1056 f[j_coord_offset+DIM*1+YY] -= ty;
1057 f[j_coord_offset+DIM*1+ZZ] -= tz;
1061 /**************************
1062 * CALCULATE INTERACTIONS *
1063 **************************/
1070 /* EWALD ELECTROSTATICS */
1072 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1073 ewrt = r12*ewtabscale;
1075 eweps = ewrt-ewitab;
1076 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1077 felec = qq12*rinv12*(rinvsq12-felec);
1081 /* Calculate temporary vectorial force */
1086 /* Update vectorial force */
1090 f[j_coord_offset+DIM*2+XX] -= tx;
1091 f[j_coord_offset+DIM*2+YY] -= ty;
1092 f[j_coord_offset+DIM*2+ZZ] -= tz;
1096 /**************************
1097 * CALCULATE INTERACTIONS *
1098 **************************/
1105 /* EWALD ELECTROSTATICS */
1107 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1108 ewrt = r13*ewtabscale;
1110 eweps = ewrt-ewitab;
1111 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1112 felec = qq13*rinv13*(rinvsq13-felec);
1116 /* Calculate temporary vectorial force */
1121 /* Update vectorial force */
1125 f[j_coord_offset+DIM*3+XX] -= tx;
1126 f[j_coord_offset+DIM*3+YY] -= ty;
1127 f[j_coord_offset+DIM*3+ZZ] -= tz;
1131 /**************************
1132 * CALCULATE INTERACTIONS *
1133 **************************/
1140 /* EWALD ELECTROSTATICS */
1142 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1143 ewrt = r21*ewtabscale;
1145 eweps = ewrt-ewitab;
1146 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1147 felec = qq21*rinv21*(rinvsq21-felec);
1151 /* Calculate temporary vectorial force */
1156 /* Update vectorial force */
1160 f[j_coord_offset+DIM*1+XX] -= tx;
1161 f[j_coord_offset+DIM*1+YY] -= ty;
1162 f[j_coord_offset+DIM*1+ZZ] -= tz;
1166 /**************************
1167 * CALCULATE INTERACTIONS *
1168 **************************/
1175 /* EWALD ELECTROSTATICS */
1177 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1178 ewrt = r22*ewtabscale;
1180 eweps = ewrt-ewitab;
1181 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1182 felec = qq22*rinv22*(rinvsq22-felec);
1186 /* Calculate temporary vectorial force */
1191 /* Update vectorial force */
1195 f[j_coord_offset+DIM*2+XX] -= tx;
1196 f[j_coord_offset+DIM*2+YY] -= ty;
1197 f[j_coord_offset+DIM*2+ZZ] -= tz;
1201 /**************************
1202 * CALCULATE INTERACTIONS *
1203 **************************/
1210 /* EWALD ELECTROSTATICS */
1212 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1213 ewrt = r23*ewtabscale;
1215 eweps = ewrt-ewitab;
1216 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1217 felec = qq23*rinv23*(rinvsq23-felec);
1221 /* Calculate temporary vectorial force */
1226 /* Update vectorial force */
1230 f[j_coord_offset+DIM*3+XX] -= tx;
1231 f[j_coord_offset+DIM*3+YY] -= ty;
1232 f[j_coord_offset+DIM*3+ZZ] -= tz;
1236 /**************************
1237 * CALCULATE INTERACTIONS *
1238 **************************/
1245 /* EWALD ELECTROSTATICS */
1247 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1248 ewrt = r31*ewtabscale;
1250 eweps = ewrt-ewitab;
1251 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1252 felec = qq31*rinv31*(rinvsq31-felec);
1256 /* Calculate temporary vectorial force */
1261 /* Update vectorial force */
1265 f[j_coord_offset+DIM*1+XX] -= tx;
1266 f[j_coord_offset+DIM*1+YY] -= ty;
1267 f[j_coord_offset+DIM*1+ZZ] -= tz;
1271 /**************************
1272 * CALCULATE INTERACTIONS *
1273 **************************/
1280 /* EWALD ELECTROSTATICS */
1282 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1283 ewrt = r32*ewtabscale;
1285 eweps = ewrt-ewitab;
1286 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1287 felec = qq32*rinv32*(rinvsq32-felec);
1291 /* Calculate temporary vectorial force */
1296 /* Update vectorial force */
1300 f[j_coord_offset+DIM*2+XX] -= tx;
1301 f[j_coord_offset+DIM*2+YY] -= ty;
1302 f[j_coord_offset+DIM*2+ZZ] -= tz;
1306 /**************************
1307 * CALCULATE INTERACTIONS *
1308 **************************/
1315 /* EWALD ELECTROSTATICS */
1317 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1318 ewrt = r33*ewtabscale;
1320 eweps = ewrt-ewitab;
1321 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1322 felec = qq33*rinv33*(rinvsq33-felec);
1326 /* Calculate temporary vectorial force */
1331 /* Update vectorial force */
1335 f[j_coord_offset+DIM*3+XX] -= tx;
1336 f[j_coord_offset+DIM*3+YY] -= ty;
1337 f[j_coord_offset+DIM*3+ZZ] -= tz;
1341 /* Inner loop uses 355 flops */
1343 /* End of innermost loop */
1346 f[i_coord_offset+DIM*0+XX] += fix0;
1347 f[i_coord_offset+DIM*0+YY] += fiy0;
1348 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1352 f[i_coord_offset+DIM*1+XX] += fix1;
1353 f[i_coord_offset+DIM*1+YY] += fiy1;
1354 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1358 f[i_coord_offset+DIM*2+XX] += fix2;
1359 f[i_coord_offset+DIM*2+YY] += fiy2;
1360 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1364 f[i_coord_offset+DIM*3+XX] += fix3;
1365 f[i_coord_offset+DIM*3+YY] += fiy3;
1366 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1370 fshift[i_shift_offset+XX] += tx;
1371 fshift[i_shift_offset+YY] += ty;
1372 fshift[i_shift_offset+ZZ] += tz;
1374 /* Increment number of inner iterations */
1375 inneriter += j_index_end - j_index_start;
1377 /* Outer loop uses 39 flops */
1380 /* Increment number of outer iterations */
1383 /* Update outer/inner flops */
1385 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*355);