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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LennardJones
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
98 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
106 jindex = nlist->jindex;
108 shiftidx = nlist->shift;
110 shiftvec = fr->shift_vec[0];
111 fshift = fr->fshift[0];
113 charge = mdatoms->chargeA;
114 nvdwtype = fr->ntype;
116 vdwtype = mdatoms->typeA;
118 sh_ewald = fr->ic->sh_ewald;
119 ewtab = fr->ic->tabq_coul_FDV0;
120 ewtabscale = fr->ic->tabq_scale;
121 ewtabhalfspace = 0.5/ewtabscale;
123 /* Setup water-specific parameters */
124 inr = nlist->iinr[0];
125 iq0 = facel*charge[inr+0];
126 iq1 = facel*charge[inr+1];
127 iq2 = facel*charge[inr+2];
128 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
133 vdwjidx0 = 2*vdwtype[inr+0];
135 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
136 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
146 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
147 rcutoff = fr->rcoulomb;
148 rcutoff2 = rcutoff*rcutoff;
150 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
156 /* Start outer loop over neighborlists */
157 for(iidx=0; iidx<nri; iidx++)
159 /* Load shift vector for this list */
160 i_shift_offset = DIM*shiftidx[iidx];
161 shX = shiftvec[i_shift_offset+XX];
162 shY = shiftvec[i_shift_offset+YY];
163 shZ = shiftvec[i_shift_offset+ZZ];
165 /* Load limits for loop over neighbors */
166 j_index_start = jindex[iidx];
167 j_index_end = jindex[iidx+1];
169 /* Get outer coordinate index */
171 i_coord_offset = DIM*inr;
173 /* Load i particle coords and add shift vector */
174 ix0 = shX + x[i_coord_offset+DIM*0+XX];
175 iy0 = shY + x[i_coord_offset+DIM*0+YY];
176 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
177 ix1 = shX + x[i_coord_offset+DIM*1+XX];
178 iy1 = shY + x[i_coord_offset+DIM*1+YY];
179 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
180 ix2 = shX + x[i_coord_offset+DIM*2+XX];
181 iy2 = shY + x[i_coord_offset+DIM*2+YY];
182 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
194 /* Reset potential sums */
198 /* Start inner kernel loop */
199 for(jidx=j_index_start; jidx<j_index_end; jidx++)
201 /* Get j neighbor index, and coordinate index */
203 j_coord_offset = DIM*jnr;
205 /* load j atom coordinates */
206 jx0 = x[j_coord_offset+DIM*0+XX];
207 jy0 = x[j_coord_offset+DIM*0+YY];
208 jz0 = x[j_coord_offset+DIM*0+ZZ];
209 jx1 = x[j_coord_offset+DIM*1+XX];
210 jy1 = x[j_coord_offset+DIM*1+YY];
211 jz1 = x[j_coord_offset+DIM*1+ZZ];
212 jx2 = x[j_coord_offset+DIM*2+XX];
213 jy2 = x[j_coord_offset+DIM*2+YY];
214 jz2 = x[j_coord_offset+DIM*2+ZZ];
216 /* Calculate displacement vector */
245 /* Calculate squared distance and things based on it */
246 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
247 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
248 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
249 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
250 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
251 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
252 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
253 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
254 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
256 rinv00 = gmx_invsqrt(rsq00);
257 rinv01 = gmx_invsqrt(rsq01);
258 rinv02 = gmx_invsqrt(rsq02);
259 rinv10 = gmx_invsqrt(rsq10);
260 rinv11 = gmx_invsqrt(rsq11);
261 rinv12 = gmx_invsqrt(rsq12);
262 rinv20 = gmx_invsqrt(rsq20);
263 rinv21 = gmx_invsqrt(rsq21);
264 rinv22 = gmx_invsqrt(rsq22);
266 rinvsq00 = rinv00*rinv00;
267 rinvsq01 = rinv01*rinv01;
268 rinvsq02 = rinv02*rinv02;
269 rinvsq10 = rinv10*rinv10;
270 rinvsq11 = rinv11*rinv11;
271 rinvsq12 = rinv12*rinv12;
272 rinvsq20 = rinv20*rinv20;
273 rinvsq21 = rinv21*rinv21;
274 rinvsq22 = rinv22*rinv22;
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
285 /* EWALD ELECTROSTATICS */
287 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
288 ewrt = r00*ewtabscale;
292 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
293 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
294 felec = qq00*rinv00*(rinvsq00-felec);
296 /* LENNARD-JONES DISPERSION/REPULSION */
298 rinvsix = rinvsq00*rinvsq00*rinvsq00;
299 vvdw6 = c6_00*rinvsix;
300 vvdw12 = c12_00*rinvsix*rinvsix;
301 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
302 fvdw = (vvdw12-vvdw6)*rinvsq00;
304 /* Update potential sums from outer loop */
310 /* Calculate temporary vectorial force */
315 /* Update vectorial force */
319 f[j_coord_offset+DIM*0+XX] -= tx;
320 f[j_coord_offset+DIM*0+YY] -= ty;
321 f[j_coord_offset+DIM*0+ZZ] -= tz;
325 /**************************
326 * CALCULATE INTERACTIONS *
327 **************************/
334 /* EWALD ELECTROSTATICS */
336 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
337 ewrt = r01*ewtabscale;
341 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
342 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
343 felec = qq01*rinv01*(rinvsq01-felec);
345 /* Update potential sums from outer loop */
350 /* Calculate temporary vectorial force */
355 /* Update vectorial force */
359 f[j_coord_offset+DIM*1+XX] -= tx;
360 f[j_coord_offset+DIM*1+YY] -= ty;
361 f[j_coord_offset+DIM*1+ZZ] -= tz;
365 /**************************
366 * CALCULATE INTERACTIONS *
367 **************************/
374 /* EWALD ELECTROSTATICS */
376 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
377 ewrt = r02*ewtabscale;
381 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
382 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
383 felec = qq02*rinv02*(rinvsq02-felec);
385 /* Update potential sums from outer loop */
390 /* Calculate temporary vectorial force */
395 /* Update vectorial force */
399 f[j_coord_offset+DIM*2+XX] -= tx;
400 f[j_coord_offset+DIM*2+YY] -= ty;
401 f[j_coord_offset+DIM*2+ZZ] -= tz;
405 /**************************
406 * CALCULATE INTERACTIONS *
407 **************************/
414 /* EWALD ELECTROSTATICS */
416 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
417 ewrt = r10*ewtabscale;
421 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
422 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
423 felec = qq10*rinv10*(rinvsq10-felec);
425 /* Update potential sums from outer loop */
430 /* Calculate temporary vectorial force */
435 /* Update vectorial force */
439 f[j_coord_offset+DIM*0+XX] -= tx;
440 f[j_coord_offset+DIM*0+YY] -= ty;
441 f[j_coord_offset+DIM*0+ZZ] -= tz;
445 /**************************
446 * CALCULATE INTERACTIONS *
447 **************************/
454 /* EWALD ELECTROSTATICS */
456 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
457 ewrt = r11*ewtabscale;
461 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
462 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
463 felec = qq11*rinv11*(rinvsq11-felec);
465 /* Update potential sums from outer loop */
470 /* Calculate temporary vectorial force */
475 /* Update vectorial force */
479 f[j_coord_offset+DIM*1+XX] -= tx;
480 f[j_coord_offset+DIM*1+YY] -= ty;
481 f[j_coord_offset+DIM*1+ZZ] -= tz;
485 /**************************
486 * CALCULATE INTERACTIONS *
487 **************************/
494 /* EWALD ELECTROSTATICS */
496 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
497 ewrt = r12*ewtabscale;
501 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
502 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
503 felec = qq12*rinv12*(rinvsq12-felec);
505 /* Update potential sums from outer loop */
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*2+XX] -= tx;
520 f[j_coord_offset+DIM*2+YY] -= ty;
521 f[j_coord_offset+DIM*2+ZZ] -= tz;
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
534 /* EWALD ELECTROSTATICS */
536 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
537 ewrt = r20*ewtabscale;
541 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
542 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
543 felec = qq20*rinv20*(rinvsq20-felec);
545 /* Update potential sums from outer loop */
550 /* Calculate temporary vectorial force */
555 /* Update vectorial force */
559 f[j_coord_offset+DIM*0+XX] -= tx;
560 f[j_coord_offset+DIM*0+YY] -= ty;
561 f[j_coord_offset+DIM*0+ZZ] -= tz;
565 /**************************
566 * CALCULATE INTERACTIONS *
567 **************************/
574 /* EWALD ELECTROSTATICS */
576 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
577 ewrt = r21*ewtabscale;
581 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
582 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
583 felec = qq21*rinv21*(rinvsq21-felec);
585 /* Update potential sums from outer loop */
590 /* Calculate temporary vectorial force */
595 /* Update vectorial force */
599 f[j_coord_offset+DIM*1+XX] -= tx;
600 f[j_coord_offset+DIM*1+YY] -= ty;
601 f[j_coord_offset+DIM*1+ZZ] -= tz;
605 /**************************
606 * CALCULATE INTERACTIONS *
607 **************************/
614 /* EWALD ELECTROSTATICS */
616 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
617 ewrt = r22*ewtabscale;
621 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
622 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
623 felec = qq22*rinv22*(rinvsq22-felec);
625 /* Update potential sums from outer loop */
630 /* Calculate temporary vectorial force */
635 /* Update vectorial force */
639 f[j_coord_offset+DIM*2+XX] -= tx;
640 f[j_coord_offset+DIM*2+YY] -= ty;
641 f[j_coord_offset+DIM*2+ZZ] -= tz;
645 /* Inner loop uses 386 flops */
647 /* End of innermost loop */
650 f[i_coord_offset+DIM*0+XX] += fix0;
651 f[i_coord_offset+DIM*0+YY] += fiy0;
652 f[i_coord_offset+DIM*0+ZZ] += fiz0;
656 f[i_coord_offset+DIM*1+XX] += fix1;
657 f[i_coord_offset+DIM*1+YY] += fiy1;
658 f[i_coord_offset+DIM*1+ZZ] += fiz1;
662 f[i_coord_offset+DIM*2+XX] += fix2;
663 f[i_coord_offset+DIM*2+YY] += fiy2;
664 f[i_coord_offset+DIM*2+ZZ] += fiz2;
668 fshift[i_shift_offset+XX] += tx;
669 fshift[i_shift_offset+YY] += ty;
670 fshift[i_shift_offset+ZZ] += tz;
673 /* Update potential energies */
674 kernel_data->energygrp_elec[ggid] += velecsum;
675 kernel_data->energygrp_vdw[ggid] += vvdwsum;
677 /* Increment number of inner iterations */
678 inneriter += j_index_end - j_index_start;
680 /* Outer loop uses 32 flops */
683 /* Increment number of outer iterations */
686 /* Update outer/inner flops */
688 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*386);
691 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_F_c
692 * Electrostatics interaction: Ewald
693 * VdW interaction: LennardJones
694 * Geometry: Water3-Water3
695 * Calculate force/pot: Force
698 nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_F_c
699 (t_nblist * gmx_restrict nlist,
700 rvec * gmx_restrict xx,
701 rvec * gmx_restrict ff,
702 t_forcerec * gmx_restrict fr,
703 t_mdatoms * gmx_restrict mdatoms,
704 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
705 t_nrnb * gmx_restrict nrnb)
707 int i_shift_offset,i_coord_offset,j_coord_offset;
708 int j_index_start,j_index_end;
709 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
710 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
711 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
712 real *shiftvec,*fshift,*x,*f;
714 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
716 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
718 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
720 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
722 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
724 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
725 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
726 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
727 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
728 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
729 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
730 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
731 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
732 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
733 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
734 real velec,felec,velecsum,facel,crf,krf,krf2;
737 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
741 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
749 jindex = nlist->jindex;
751 shiftidx = nlist->shift;
753 shiftvec = fr->shift_vec[0];
754 fshift = fr->fshift[0];
756 charge = mdatoms->chargeA;
757 nvdwtype = fr->ntype;
759 vdwtype = mdatoms->typeA;
761 sh_ewald = fr->ic->sh_ewald;
762 ewtab = fr->ic->tabq_coul_F;
763 ewtabscale = fr->ic->tabq_scale;
764 ewtabhalfspace = 0.5/ewtabscale;
766 /* Setup water-specific parameters */
767 inr = nlist->iinr[0];
768 iq0 = facel*charge[inr+0];
769 iq1 = facel*charge[inr+1];
770 iq2 = facel*charge[inr+2];
771 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
776 vdwjidx0 = 2*vdwtype[inr+0];
778 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
779 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
789 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
790 rcutoff = fr->rcoulomb;
791 rcutoff2 = rcutoff*rcutoff;
793 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
799 /* Start outer loop over neighborlists */
800 for(iidx=0; iidx<nri; iidx++)
802 /* Load shift vector for this list */
803 i_shift_offset = DIM*shiftidx[iidx];
804 shX = shiftvec[i_shift_offset+XX];
805 shY = shiftvec[i_shift_offset+YY];
806 shZ = shiftvec[i_shift_offset+ZZ];
808 /* Load limits for loop over neighbors */
809 j_index_start = jindex[iidx];
810 j_index_end = jindex[iidx+1];
812 /* Get outer coordinate index */
814 i_coord_offset = DIM*inr;
816 /* Load i particle coords and add shift vector */
817 ix0 = shX + x[i_coord_offset+DIM*0+XX];
818 iy0 = shY + x[i_coord_offset+DIM*0+YY];
819 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
820 ix1 = shX + x[i_coord_offset+DIM*1+XX];
821 iy1 = shY + x[i_coord_offset+DIM*1+YY];
822 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
823 ix2 = shX + x[i_coord_offset+DIM*2+XX];
824 iy2 = shY + x[i_coord_offset+DIM*2+YY];
825 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
837 /* Start inner kernel loop */
838 for(jidx=j_index_start; jidx<j_index_end; jidx++)
840 /* Get j neighbor index, and coordinate index */
842 j_coord_offset = DIM*jnr;
844 /* load j atom coordinates */
845 jx0 = x[j_coord_offset+DIM*0+XX];
846 jy0 = x[j_coord_offset+DIM*0+YY];
847 jz0 = x[j_coord_offset+DIM*0+ZZ];
848 jx1 = x[j_coord_offset+DIM*1+XX];
849 jy1 = x[j_coord_offset+DIM*1+YY];
850 jz1 = x[j_coord_offset+DIM*1+ZZ];
851 jx2 = x[j_coord_offset+DIM*2+XX];
852 jy2 = x[j_coord_offset+DIM*2+YY];
853 jz2 = x[j_coord_offset+DIM*2+ZZ];
855 /* Calculate displacement vector */
884 /* Calculate squared distance and things based on it */
885 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
886 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
887 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
888 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
889 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
890 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
891 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
892 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
893 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
895 rinv00 = gmx_invsqrt(rsq00);
896 rinv01 = gmx_invsqrt(rsq01);
897 rinv02 = gmx_invsqrt(rsq02);
898 rinv10 = gmx_invsqrt(rsq10);
899 rinv11 = gmx_invsqrt(rsq11);
900 rinv12 = gmx_invsqrt(rsq12);
901 rinv20 = gmx_invsqrt(rsq20);
902 rinv21 = gmx_invsqrt(rsq21);
903 rinv22 = gmx_invsqrt(rsq22);
905 rinvsq00 = rinv00*rinv00;
906 rinvsq01 = rinv01*rinv01;
907 rinvsq02 = rinv02*rinv02;
908 rinvsq10 = rinv10*rinv10;
909 rinvsq11 = rinv11*rinv11;
910 rinvsq12 = rinv12*rinv12;
911 rinvsq20 = rinv20*rinv20;
912 rinvsq21 = rinv21*rinv21;
913 rinvsq22 = rinv22*rinv22;
915 /**************************
916 * CALCULATE INTERACTIONS *
917 **************************/
924 /* EWALD ELECTROSTATICS */
926 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
927 ewrt = r00*ewtabscale;
930 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
931 felec = qq00*rinv00*(rinvsq00-felec);
933 /* LENNARD-JONES DISPERSION/REPULSION */
935 rinvsix = rinvsq00*rinvsq00*rinvsq00;
936 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
940 /* Calculate temporary vectorial force */
945 /* Update vectorial force */
949 f[j_coord_offset+DIM*0+XX] -= tx;
950 f[j_coord_offset+DIM*0+YY] -= ty;
951 f[j_coord_offset+DIM*0+ZZ] -= tz;
955 /**************************
956 * CALCULATE INTERACTIONS *
957 **************************/
964 /* EWALD ELECTROSTATICS */
966 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
967 ewrt = r01*ewtabscale;
970 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
971 felec = qq01*rinv01*(rinvsq01-felec);
975 /* Calculate temporary vectorial force */
980 /* Update vectorial force */
984 f[j_coord_offset+DIM*1+XX] -= tx;
985 f[j_coord_offset+DIM*1+YY] -= ty;
986 f[j_coord_offset+DIM*1+ZZ] -= tz;
990 /**************************
991 * CALCULATE INTERACTIONS *
992 **************************/
999 /* EWALD ELECTROSTATICS */
1001 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1002 ewrt = r02*ewtabscale;
1004 eweps = ewrt-ewitab;
1005 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1006 felec = qq02*rinv02*(rinvsq02-felec);
1010 /* Calculate temporary vectorial force */
1015 /* Update vectorial force */
1019 f[j_coord_offset+DIM*2+XX] -= tx;
1020 f[j_coord_offset+DIM*2+YY] -= ty;
1021 f[j_coord_offset+DIM*2+ZZ] -= tz;
1025 /**************************
1026 * CALCULATE INTERACTIONS *
1027 **************************/
1034 /* EWALD ELECTROSTATICS */
1036 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1037 ewrt = r10*ewtabscale;
1039 eweps = ewrt-ewitab;
1040 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1041 felec = qq10*rinv10*(rinvsq10-felec);
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 = r20*ewtabscale;
1144 eweps = ewrt-ewitab;
1145 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1146 felec = qq20*rinv20*(rinvsq20-felec);
1150 /* Calculate temporary vectorial force */
1155 /* Update vectorial force */
1159 f[j_coord_offset+DIM*0+XX] -= tx;
1160 f[j_coord_offset+DIM*0+YY] -= ty;
1161 f[j_coord_offset+DIM*0+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 /* Inner loop uses 304 flops */
1237 /* End of innermost loop */
1240 f[i_coord_offset+DIM*0+XX] += fix0;
1241 f[i_coord_offset+DIM*0+YY] += fiy0;
1242 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1246 f[i_coord_offset+DIM*1+XX] += fix1;
1247 f[i_coord_offset+DIM*1+YY] += fiy1;
1248 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1252 f[i_coord_offset+DIM*2+XX] += fix2;
1253 f[i_coord_offset+DIM*2+YY] += fiy2;
1254 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1258 fshift[i_shift_offset+XX] += tx;
1259 fshift[i_shift_offset+YY] += ty;
1260 fshift[i_shift_offset+ZZ] += tz;
1262 /* Increment number of inner iterations */
1263 inneriter += j_index_end - j_index_start;
1265 /* Outer loop uses 30 flops */
1268 /* Increment number of outer iterations */
1271 /* Update outer/inner flops */
1273 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*304);