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"
46 #include "gromacs/math/vec.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LennardJones
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_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 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;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
100 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
108 jindex = nlist->jindex;
110 shiftidx = nlist->shift;
112 shiftvec = fr->shift_vec[0];
113 fshift = fr->fshift[0];
115 charge = mdatoms->chargeA;
116 nvdwtype = fr->ntype;
118 vdwtype = mdatoms->typeA;
120 sh_ewald = fr->ic->sh_ewald;
121 ewtab = fr->ic->tabq_coul_FDV0;
122 ewtabscale = fr->ic->tabq_scale;
123 ewtabhalfspace = 0.5/ewtabscale;
125 /* Setup water-specific parameters */
126 inr = nlist->iinr[0];
127 iq0 = facel*charge[inr+0];
128 iq1 = facel*charge[inr+1];
129 iq2 = facel*charge[inr+2];
130 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
135 vdwjidx0 = 2*vdwtype[inr+0];
137 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
138 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
148 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
149 rcutoff = fr->rcoulomb;
150 rcutoff2 = rcutoff*rcutoff;
152 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
158 /* Start outer loop over neighborlists */
159 for(iidx=0; iidx<nri; iidx++)
161 /* Load shift vector for this list */
162 i_shift_offset = DIM*shiftidx[iidx];
163 shX = shiftvec[i_shift_offset+XX];
164 shY = shiftvec[i_shift_offset+YY];
165 shZ = shiftvec[i_shift_offset+ZZ];
167 /* Load limits for loop over neighbors */
168 j_index_start = jindex[iidx];
169 j_index_end = jindex[iidx+1];
171 /* Get outer coordinate index */
173 i_coord_offset = DIM*inr;
175 /* Load i particle coords and add shift vector */
176 ix0 = shX + x[i_coord_offset+DIM*0+XX];
177 iy0 = shY + x[i_coord_offset+DIM*0+YY];
178 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
179 ix1 = shX + x[i_coord_offset+DIM*1+XX];
180 iy1 = shY + x[i_coord_offset+DIM*1+YY];
181 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
182 ix2 = shX + x[i_coord_offset+DIM*2+XX];
183 iy2 = shY + x[i_coord_offset+DIM*2+YY];
184 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
196 /* Reset potential sums */
200 /* Start inner kernel loop */
201 for(jidx=j_index_start; jidx<j_index_end; jidx++)
203 /* Get j neighbor index, and coordinate index */
205 j_coord_offset = DIM*jnr;
207 /* load j atom coordinates */
208 jx0 = x[j_coord_offset+DIM*0+XX];
209 jy0 = x[j_coord_offset+DIM*0+YY];
210 jz0 = x[j_coord_offset+DIM*0+ZZ];
211 jx1 = x[j_coord_offset+DIM*1+XX];
212 jy1 = x[j_coord_offset+DIM*1+YY];
213 jz1 = x[j_coord_offset+DIM*1+ZZ];
214 jx2 = x[j_coord_offset+DIM*2+XX];
215 jy2 = x[j_coord_offset+DIM*2+YY];
216 jz2 = x[j_coord_offset+DIM*2+ZZ];
218 /* Calculate displacement vector */
247 /* Calculate squared distance and things based on it */
248 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
249 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
250 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
251 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
252 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
253 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
254 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
255 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
256 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
258 rinv00 = gmx_invsqrt(rsq00);
259 rinv01 = gmx_invsqrt(rsq01);
260 rinv02 = gmx_invsqrt(rsq02);
261 rinv10 = gmx_invsqrt(rsq10);
262 rinv11 = gmx_invsqrt(rsq11);
263 rinv12 = gmx_invsqrt(rsq12);
264 rinv20 = gmx_invsqrt(rsq20);
265 rinv21 = gmx_invsqrt(rsq21);
266 rinv22 = gmx_invsqrt(rsq22);
268 rinvsq00 = rinv00*rinv00;
269 rinvsq01 = rinv01*rinv01;
270 rinvsq02 = rinv02*rinv02;
271 rinvsq10 = rinv10*rinv10;
272 rinvsq11 = rinv11*rinv11;
273 rinvsq12 = rinv12*rinv12;
274 rinvsq20 = rinv20*rinv20;
275 rinvsq21 = rinv21*rinv21;
276 rinvsq22 = rinv22*rinv22;
278 /**************************
279 * CALCULATE INTERACTIONS *
280 **************************/
287 /* EWALD ELECTROSTATICS */
289 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
290 ewrt = r00*ewtabscale;
294 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
295 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
296 felec = qq00*rinv00*(rinvsq00-felec);
298 /* LENNARD-JONES DISPERSION/REPULSION */
300 rinvsix = rinvsq00*rinvsq00*rinvsq00;
301 vvdw6 = c6_00*rinvsix;
302 vvdw12 = c12_00*rinvsix*rinvsix;
303 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
304 fvdw = (vvdw12-vvdw6)*rinvsq00;
306 /* Update potential sums from outer loop */
312 /* Calculate temporary vectorial force */
317 /* Update vectorial force */
321 f[j_coord_offset+DIM*0+XX] -= tx;
322 f[j_coord_offset+DIM*0+YY] -= ty;
323 f[j_coord_offset+DIM*0+ZZ] -= tz;
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
336 /* EWALD ELECTROSTATICS */
338 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
339 ewrt = r01*ewtabscale;
343 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
344 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
345 felec = qq01*rinv01*(rinvsq01-felec);
347 /* Update potential sums from outer loop */
352 /* Calculate temporary vectorial force */
357 /* Update vectorial force */
361 f[j_coord_offset+DIM*1+XX] -= tx;
362 f[j_coord_offset+DIM*1+YY] -= ty;
363 f[j_coord_offset+DIM*1+ZZ] -= tz;
367 /**************************
368 * CALCULATE INTERACTIONS *
369 **************************/
376 /* EWALD ELECTROSTATICS */
378 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
379 ewrt = r02*ewtabscale;
383 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
384 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
385 felec = qq02*rinv02*(rinvsq02-felec);
387 /* Update potential sums from outer loop */
392 /* Calculate temporary vectorial force */
397 /* Update vectorial force */
401 f[j_coord_offset+DIM*2+XX] -= tx;
402 f[j_coord_offset+DIM*2+YY] -= ty;
403 f[j_coord_offset+DIM*2+ZZ] -= tz;
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
416 /* EWALD ELECTROSTATICS */
418 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
419 ewrt = r10*ewtabscale;
423 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
424 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
425 felec = qq10*rinv10*(rinvsq10-felec);
427 /* Update potential sums from outer loop */
432 /* Calculate temporary vectorial force */
437 /* Update vectorial force */
441 f[j_coord_offset+DIM*0+XX] -= tx;
442 f[j_coord_offset+DIM*0+YY] -= ty;
443 f[j_coord_offset+DIM*0+ZZ] -= tz;
447 /**************************
448 * CALCULATE INTERACTIONS *
449 **************************/
456 /* EWALD ELECTROSTATICS */
458 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
459 ewrt = r11*ewtabscale;
463 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
464 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
465 felec = qq11*rinv11*(rinvsq11-felec);
467 /* Update potential sums from outer loop */
472 /* Calculate temporary vectorial force */
477 /* Update vectorial force */
481 f[j_coord_offset+DIM*1+XX] -= tx;
482 f[j_coord_offset+DIM*1+YY] -= ty;
483 f[j_coord_offset+DIM*1+ZZ] -= tz;
487 /**************************
488 * CALCULATE INTERACTIONS *
489 **************************/
496 /* EWALD ELECTROSTATICS */
498 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
499 ewrt = r12*ewtabscale;
503 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
504 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
505 felec = qq12*rinv12*(rinvsq12-felec);
507 /* Update potential sums from outer loop */
512 /* Calculate temporary vectorial force */
517 /* Update vectorial force */
521 f[j_coord_offset+DIM*2+XX] -= tx;
522 f[j_coord_offset+DIM*2+YY] -= ty;
523 f[j_coord_offset+DIM*2+ZZ] -= tz;
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
536 /* EWALD ELECTROSTATICS */
538 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
539 ewrt = r20*ewtabscale;
543 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
544 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
545 felec = qq20*rinv20*(rinvsq20-felec);
547 /* Update potential sums from outer loop */
552 /* Calculate temporary vectorial force */
557 /* Update vectorial force */
561 f[j_coord_offset+DIM*0+XX] -= tx;
562 f[j_coord_offset+DIM*0+YY] -= ty;
563 f[j_coord_offset+DIM*0+ZZ] -= tz;
567 /**************************
568 * CALCULATE INTERACTIONS *
569 **************************/
576 /* EWALD ELECTROSTATICS */
578 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
579 ewrt = r21*ewtabscale;
583 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
584 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
585 felec = qq21*rinv21*(rinvsq21-felec);
587 /* Update potential sums from outer loop */
592 /* Calculate temporary vectorial force */
597 /* Update vectorial force */
601 f[j_coord_offset+DIM*1+XX] -= tx;
602 f[j_coord_offset+DIM*1+YY] -= ty;
603 f[j_coord_offset+DIM*1+ZZ] -= tz;
607 /**************************
608 * CALCULATE INTERACTIONS *
609 **************************/
616 /* EWALD ELECTROSTATICS */
618 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
619 ewrt = r22*ewtabscale;
623 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
624 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
625 felec = qq22*rinv22*(rinvsq22-felec);
627 /* Update potential sums from outer loop */
632 /* Calculate temporary vectorial force */
637 /* Update vectorial force */
641 f[j_coord_offset+DIM*2+XX] -= tx;
642 f[j_coord_offset+DIM*2+YY] -= ty;
643 f[j_coord_offset+DIM*2+ZZ] -= tz;
647 /* Inner loop uses 386 flops */
649 /* End of innermost loop */
652 f[i_coord_offset+DIM*0+XX] += fix0;
653 f[i_coord_offset+DIM*0+YY] += fiy0;
654 f[i_coord_offset+DIM*0+ZZ] += fiz0;
658 f[i_coord_offset+DIM*1+XX] += fix1;
659 f[i_coord_offset+DIM*1+YY] += fiy1;
660 f[i_coord_offset+DIM*1+ZZ] += fiz1;
664 f[i_coord_offset+DIM*2+XX] += fix2;
665 f[i_coord_offset+DIM*2+YY] += fiy2;
666 f[i_coord_offset+DIM*2+ZZ] += fiz2;
670 fshift[i_shift_offset+XX] += tx;
671 fshift[i_shift_offset+YY] += ty;
672 fshift[i_shift_offset+ZZ] += tz;
675 /* Update potential energies */
676 kernel_data->energygrp_elec[ggid] += velecsum;
677 kernel_data->energygrp_vdw[ggid] += vvdwsum;
679 /* Increment number of inner iterations */
680 inneriter += j_index_end - j_index_start;
682 /* Outer loop uses 32 flops */
685 /* Increment number of outer iterations */
688 /* Update outer/inner flops */
690 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*386);
693 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_F_c
694 * Electrostatics interaction: Ewald
695 * VdW interaction: LennardJones
696 * Geometry: Water3-Water3
697 * Calculate force/pot: Force
700 nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_F_c
701 (t_nblist * gmx_restrict nlist,
702 rvec * gmx_restrict xx,
703 rvec * gmx_restrict ff,
704 t_forcerec * gmx_restrict fr,
705 t_mdatoms * gmx_restrict mdatoms,
706 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
707 t_nrnb * gmx_restrict nrnb)
709 int i_shift_offset,i_coord_offset,j_coord_offset;
710 int j_index_start,j_index_end;
711 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
712 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
713 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
714 real *shiftvec,*fshift,*x,*f;
716 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
718 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
720 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
722 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
724 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
726 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
727 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
728 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
729 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
730 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
731 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
732 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
733 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
734 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
735 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
736 real velec,felec,velecsum,facel,crf,krf,krf2;
739 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
743 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
751 jindex = nlist->jindex;
753 shiftidx = nlist->shift;
755 shiftvec = fr->shift_vec[0];
756 fshift = fr->fshift[0];
758 charge = mdatoms->chargeA;
759 nvdwtype = fr->ntype;
761 vdwtype = mdatoms->typeA;
763 sh_ewald = fr->ic->sh_ewald;
764 ewtab = fr->ic->tabq_coul_F;
765 ewtabscale = fr->ic->tabq_scale;
766 ewtabhalfspace = 0.5/ewtabscale;
768 /* Setup water-specific parameters */
769 inr = nlist->iinr[0];
770 iq0 = facel*charge[inr+0];
771 iq1 = facel*charge[inr+1];
772 iq2 = facel*charge[inr+2];
773 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
778 vdwjidx0 = 2*vdwtype[inr+0];
780 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
781 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
791 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
792 rcutoff = fr->rcoulomb;
793 rcutoff2 = rcutoff*rcutoff;
795 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
801 /* Start outer loop over neighborlists */
802 for(iidx=0; iidx<nri; iidx++)
804 /* Load shift vector for this list */
805 i_shift_offset = DIM*shiftidx[iidx];
806 shX = shiftvec[i_shift_offset+XX];
807 shY = shiftvec[i_shift_offset+YY];
808 shZ = shiftvec[i_shift_offset+ZZ];
810 /* Load limits for loop over neighbors */
811 j_index_start = jindex[iidx];
812 j_index_end = jindex[iidx+1];
814 /* Get outer coordinate index */
816 i_coord_offset = DIM*inr;
818 /* Load i particle coords and add shift vector */
819 ix0 = shX + x[i_coord_offset+DIM*0+XX];
820 iy0 = shY + x[i_coord_offset+DIM*0+YY];
821 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
822 ix1 = shX + x[i_coord_offset+DIM*1+XX];
823 iy1 = shY + x[i_coord_offset+DIM*1+YY];
824 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
825 ix2 = shX + x[i_coord_offset+DIM*2+XX];
826 iy2 = shY + x[i_coord_offset+DIM*2+YY];
827 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
839 /* Start inner kernel loop */
840 for(jidx=j_index_start; jidx<j_index_end; jidx++)
842 /* Get j neighbor index, and coordinate index */
844 j_coord_offset = DIM*jnr;
846 /* load j atom coordinates */
847 jx0 = x[j_coord_offset+DIM*0+XX];
848 jy0 = x[j_coord_offset+DIM*0+YY];
849 jz0 = x[j_coord_offset+DIM*0+ZZ];
850 jx1 = x[j_coord_offset+DIM*1+XX];
851 jy1 = x[j_coord_offset+DIM*1+YY];
852 jz1 = x[j_coord_offset+DIM*1+ZZ];
853 jx2 = x[j_coord_offset+DIM*2+XX];
854 jy2 = x[j_coord_offset+DIM*2+YY];
855 jz2 = x[j_coord_offset+DIM*2+ZZ];
857 /* Calculate displacement vector */
886 /* Calculate squared distance and things based on it */
887 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
888 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
889 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
890 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
891 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
892 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
893 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
894 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
895 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
897 rinv00 = gmx_invsqrt(rsq00);
898 rinv01 = gmx_invsqrt(rsq01);
899 rinv02 = gmx_invsqrt(rsq02);
900 rinv10 = gmx_invsqrt(rsq10);
901 rinv11 = gmx_invsqrt(rsq11);
902 rinv12 = gmx_invsqrt(rsq12);
903 rinv20 = gmx_invsqrt(rsq20);
904 rinv21 = gmx_invsqrt(rsq21);
905 rinv22 = gmx_invsqrt(rsq22);
907 rinvsq00 = rinv00*rinv00;
908 rinvsq01 = rinv01*rinv01;
909 rinvsq02 = rinv02*rinv02;
910 rinvsq10 = rinv10*rinv10;
911 rinvsq11 = rinv11*rinv11;
912 rinvsq12 = rinv12*rinv12;
913 rinvsq20 = rinv20*rinv20;
914 rinvsq21 = rinv21*rinv21;
915 rinvsq22 = rinv22*rinv22;
917 /**************************
918 * CALCULATE INTERACTIONS *
919 **************************/
926 /* EWALD ELECTROSTATICS */
928 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
929 ewrt = r00*ewtabscale;
932 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
933 felec = qq00*rinv00*(rinvsq00-felec);
935 /* LENNARD-JONES DISPERSION/REPULSION */
937 rinvsix = rinvsq00*rinvsq00*rinvsq00;
938 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
942 /* Calculate temporary vectorial force */
947 /* Update vectorial force */
951 f[j_coord_offset+DIM*0+XX] -= tx;
952 f[j_coord_offset+DIM*0+YY] -= ty;
953 f[j_coord_offset+DIM*0+ZZ] -= tz;
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
966 /* EWALD ELECTROSTATICS */
968 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
969 ewrt = r01*ewtabscale;
972 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
973 felec = qq01*rinv01*(rinvsq01-felec);
977 /* Calculate temporary vectorial force */
982 /* Update vectorial force */
986 f[j_coord_offset+DIM*1+XX] -= tx;
987 f[j_coord_offset+DIM*1+YY] -= ty;
988 f[j_coord_offset+DIM*1+ZZ] -= tz;
992 /**************************
993 * CALCULATE INTERACTIONS *
994 **************************/
1001 /* EWALD ELECTROSTATICS */
1003 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1004 ewrt = r02*ewtabscale;
1006 eweps = ewrt-ewitab;
1007 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1008 felec = qq02*rinv02*(rinvsq02-felec);
1012 /* Calculate temporary vectorial force */
1017 /* Update vectorial force */
1021 f[j_coord_offset+DIM*2+XX] -= tx;
1022 f[j_coord_offset+DIM*2+YY] -= ty;
1023 f[j_coord_offset+DIM*2+ZZ] -= tz;
1027 /**************************
1028 * CALCULATE INTERACTIONS *
1029 **************************/
1036 /* EWALD ELECTROSTATICS */
1038 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1039 ewrt = r10*ewtabscale;
1041 eweps = ewrt-ewitab;
1042 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1043 felec = qq10*rinv10*(rinvsq10-felec);
1047 /* Calculate temporary vectorial force */
1052 /* Update vectorial force */
1056 f[j_coord_offset+DIM*0+XX] -= tx;
1057 f[j_coord_offset+DIM*0+YY] -= ty;
1058 f[j_coord_offset+DIM*0+ZZ] -= tz;
1062 /**************************
1063 * CALCULATE INTERACTIONS *
1064 **************************/
1071 /* EWALD ELECTROSTATICS */
1073 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1074 ewrt = r11*ewtabscale;
1076 eweps = ewrt-ewitab;
1077 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1078 felec = qq11*rinv11*(rinvsq11-felec);
1082 /* Calculate temporary vectorial force */
1087 /* Update vectorial force */
1091 f[j_coord_offset+DIM*1+XX] -= tx;
1092 f[j_coord_offset+DIM*1+YY] -= ty;
1093 f[j_coord_offset+DIM*1+ZZ] -= tz;
1097 /**************************
1098 * CALCULATE INTERACTIONS *
1099 **************************/
1106 /* EWALD ELECTROSTATICS */
1108 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1109 ewrt = r12*ewtabscale;
1111 eweps = ewrt-ewitab;
1112 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1113 felec = qq12*rinv12*(rinvsq12-felec);
1117 /* Calculate temporary vectorial force */
1122 /* Update vectorial force */
1126 f[j_coord_offset+DIM*2+XX] -= tx;
1127 f[j_coord_offset+DIM*2+YY] -= ty;
1128 f[j_coord_offset+DIM*2+ZZ] -= tz;
1132 /**************************
1133 * CALCULATE INTERACTIONS *
1134 **************************/
1141 /* EWALD ELECTROSTATICS */
1143 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1144 ewrt = r20*ewtabscale;
1146 eweps = ewrt-ewitab;
1147 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1148 felec = qq20*rinv20*(rinvsq20-felec);
1152 /* Calculate temporary vectorial force */
1157 /* Update vectorial force */
1161 f[j_coord_offset+DIM*0+XX] -= tx;
1162 f[j_coord_offset+DIM*0+YY] -= ty;
1163 f[j_coord_offset+DIM*0+ZZ] -= tz;
1167 /**************************
1168 * CALCULATE INTERACTIONS *
1169 **************************/
1176 /* EWALD ELECTROSTATICS */
1178 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1179 ewrt = r21*ewtabscale;
1181 eweps = ewrt-ewitab;
1182 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1183 felec = qq21*rinv21*(rinvsq21-felec);
1187 /* Calculate temporary vectorial force */
1192 /* Update vectorial force */
1196 f[j_coord_offset+DIM*1+XX] -= tx;
1197 f[j_coord_offset+DIM*1+YY] -= ty;
1198 f[j_coord_offset+DIM*1+ZZ] -= tz;
1202 /**************************
1203 * CALCULATE INTERACTIONS *
1204 **************************/
1211 /* EWALD ELECTROSTATICS */
1213 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1214 ewrt = r22*ewtabscale;
1216 eweps = ewrt-ewitab;
1217 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1218 felec = qq22*rinv22*(rinvsq22-felec);
1222 /* Calculate temporary vectorial force */
1227 /* Update vectorial force */
1231 f[j_coord_offset+DIM*2+XX] -= tx;
1232 f[j_coord_offset+DIM*2+YY] -= ty;
1233 f[j_coord_offset+DIM*2+ZZ] -= tz;
1237 /* Inner loop uses 304 flops */
1239 /* End of innermost loop */
1242 f[i_coord_offset+DIM*0+XX] += fix0;
1243 f[i_coord_offset+DIM*0+YY] += fiy0;
1244 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1248 f[i_coord_offset+DIM*1+XX] += fix1;
1249 f[i_coord_offset+DIM*1+YY] += fiy1;
1250 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1254 f[i_coord_offset+DIM*2+XX] += fix2;
1255 f[i_coord_offset+DIM*2+YY] += fiy2;
1256 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1260 fshift[i_shift_offset+XX] += tx;
1261 fshift[i_shift_offset+YY] += ty;
1262 fshift[i_shift_offset+ZZ] += tz;
1264 /* Increment number of inner iterations */
1265 inneriter += j_index_end - j_index_start;
1267 /* Outer loop uses 30 flops */
1270 /* Increment number of outer iterations */
1273 /* Update outer/inner flops */
1275 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*304);