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_ElecEw_VdwCSTab_GeomW3W3_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwCSTab_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 rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
103 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
118 charge = mdatoms->chargeA;
119 nvdwtype = fr->ntype;
121 vdwtype = mdatoms->typeA;
123 vftab = kernel_data->table_vdw->data;
124 vftabscale = kernel_data->table_vdw->scale;
126 sh_ewald = fr->ic->sh_ewald;
127 ewtab = fr->ic->tabq_coul_FDV0;
128 ewtabscale = fr->ic->tabq_scale;
129 ewtabhalfspace = 0.5/ewtabscale;
131 /* Setup water-specific parameters */
132 inr = nlist->iinr[0];
133 iq0 = facel*charge[inr+0];
134 iq1 = facel*charge[inr+1];
135 iq2 = facel*charge[inr+2];
136 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
141 vdwjidx0 = 2*vdwtype[inr+0];
143 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
144 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
157 /* Start outer loop over neighborlists */
158 for(iidx=0; iidx<nri; iidx++)
160 /* Load shift vector for this list */
161 i_shift_offset = DIM*shiftidx[iidx];
162 shX = shiftvec[i_shift_offset+XX];
163 shY = shiftvec[i_shift_offset+YY];
164 shZ = shiftvec[i_shift_offset+ZZ];
166 /* Load limits for loop over neighbors */
167 j_index_start = jindex[iidx];
168 j_index_end = jindex[iidx+1];
170 /* Get outer coordinate index */
172 i_coord_offset = DIM*inr;
174 /* Load i particle coords and add shift vector */
175 ix0 = shX + x[i_coord_offset+DIM*0+XX];
176 iy0 = shY + x[i_coord_offset+DIM*0+YY];
177 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
178 ix1 = shX + x[i_coord_offset+DIM*1+XX];
179 iy1 = shY + x[i_coord_offset+DIM*1+YY];
180 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
181 ix2 = shX + x[i_coord_offset+DIM*2+XX];
182 iy2 = shY + x[i_coord_offset+DIM*2+YY];
183 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
195 /* Reset potential sums */
199 /* Start inner kernel loop */
200 for(jidx=j_index_start; jidx<j_index_end; jidx++)
202 /* Get j neighbor index, and coordinate index */
204 j_coord_offset = DIM*jnr;
206 /* load j atom coordinates */
207 jx0 = x[j_coord_offset+DIM*0+XX];
208 jy0 = x[j_coord_offset+DIM*0+YY];
209 jz0 = x[j_coord_offset+DIM*0+ZZ];
210 jx1 = x[j_coord_offset+DIM*1+XX];
211 jy1 = x[j_coord_offset+DIM*1+YY];
212 jz1 = x[j_coord_offset+DIM*1+ZZ];
213 jx2 = x[j_coord_offset+DIM*2+XX];
214 jy2 = x[j_coord_offset+DIM*2+YY];
215 jz2 = x[j_coord_offset+DIM*2+ZZ];
217 /* Calculate displacement vector */
246 /* Calculate squared distance and things based on it */
247 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
248 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
249 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
250 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
251 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
252 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
253 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
254 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
255 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
257 rinv00 = gmx_invsqrt(rsq00);
258 rinv01 = gmx_invsqrt(rsq01);
259 rinv02 = gmx_invsqrt(rsq02);
260 rinv10 = gmx_invsqrt(rsq10);
261 rinv11 = gmx_invsqrt(rsq11);
262 rinv12 = gmx_invsqrt(rsq12);
263 rinv20 = gmx_invsqrt(rsq20);
264 rinv21 = gmx_invsqrt(rsq21);
265 rinv22 = gmx_invsqrt(rsq22);
267 rinvsq00 = rinv00*rinv00;
268 rinvsq01 = rinv01*rinv01;
269 rinvsq02 = rinv02*rinv02;
270 rinvsq10 = rinv10*rinv10;
271 rinvsq11 = rinv11*rinv11;
272 rinvsq12 = rinv12*rinv12;
273 rinvsq20 = rinv20*rinv20;
274 rinvsq21 = rinv21*rinv21;
275 rinvsq22 = rinv22*rinv22;
277 /**************************
278 * CALCULATE INTERACTIONS *
279 **************************/
283 /* Calculate table index by multiplying r with table scale and truncate to integer */
289 /* EWALD ELECTROSTATICS */
291 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
292 ewrt = r00*ewtabscale;
296 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
297 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
298 felec = qq00*rinv00*(rinvsq00-felec);
300 /* CUBIC SPLINE TABLE DISPERSION */
304 Geps = vfeps*vftab[vfitab+2];
305 Heps2 = vfeps*vfeps*vftab[vfitab+3];
309 FF = Fp+Geps+2.0*Heps2;
312 /* CUBIC SPLINE TABLE REPULSION */
315 Geps = vfeps*vftab[vfitab+6];
316 Heps2 = vfeps*vfeps*vftab[vfitab+7];
320 FF = Fp+Geps+2.0*Heps2;
323 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
325 /* Update potential sums from outer loop */
331 /* Calculate temporary vectorial force */
336 /* Update vectorial force */
340 f[j_coord_offset+DIM*0+XX] -= tx;
341 f[j_coord_offset+DIM*0+YY] -= ty;
342 f[j_coord_offset+DIM*0+ZZ] -= tz;
344 /**************************
345 * CALCULATE INTERACTIONS *
346 **************************/
350 /* EWALD ELECTROSTATICS */
352 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
353 ewrt = r01*ewtabscale;
357 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
358 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
359 felec = qq01*rinv01*(rinvsq01-felec);
361 /* Update potential sums from outer loop */
366 /* Calculate temporary vectorial force */
371 /* Update vectorial force */
375 f[j_coord_offset+DIM*1+XX] -= tx;
376 f[j_coord_offset+DIM*1+YY] -= ty;
377 f[j_coord_offset+DIM*1+ZZ] -= tz;
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
385 /* EWALD ELECTROSTATICS */
387 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
388 ewrt = r02*ewtabscale;
392 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
393 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
394 felec = qq02*rinv02*(rinvsq02-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;
414 /**************************
415 * CALCULATE INTERACTIONS *
416 **************************/
420 /* EWALD ELECTROSTATICS */
422 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
423 ewrt = r10*ewtabscale;
427 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
428 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
429 felec = qq10*rinv10*(rinvsq10-felec);
431 /* Update potential sums from outer loop */
436 /* Calculate temporary vectorial force */
441 /* Update vectorial force */
445 f[j_coord_offset+DIM*0+XX] -= tx;
446 f[j_coord_offset+DIM*0+YY] -= ty;
447 f[j_coord_offset+DIM*0+ZZ] -= tz;
449 /**************************
450 * CALCULATE INTERACTIONS *
451 **************************/
455 /* EWALD ELECTROSTATICS */
457 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
458 ewrt = r11*ewtabscale;
462 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
463 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
464 felec = qq11*rinv11*(rinvsq11-felec);
466 /* Update potential sums from outer loop */
471 /* Calculate temporary vectorial force */
476 /* Update vectorial force */
480 f[j_coord_offset+DIM*1+XX] -= tx;
481 f[j_coord_offset+DIM*1+YY] -= ty;
482 f[j_coord_offset+DIM*1+ZZ] -= tz;
484 /**************************
485 * CALCULATE INTERACTIONS *
486 **************************/
490 /* EWALD ELECTROSTATICS */
492 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
493 ewrt = r12*ewtabscale;
497 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
498 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
499 felec = qq12*rinv12*(rinvsq12-felec);
501 /* Update potential sums from outer loop */
506 /* Calculate temporary vectorial force */
511 /* Update vectorial force */
515 f[j_coord_offset+DIM*2+XX] -= tx;
516 f[j_coord_offset+DIM*2+YY] -= ty;
517 f[j_coord_offset+DIM*2+ZZ] -= tz;
519 /**************************
520 * CALCULATE INTERACTIONS *
521 **************************/
525 /* EWALD ELECTROSTATICS */
527 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
528 ewrt = r20*ewtabscale;
532 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
533 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
534 felec = qq20*rinv20*(rinvsq20-felec);
536 /* Update potential sums from outer loop */
541 /* Calculate temporary vectorial force */
546 /* Update vectorial force */
550 f[j_coord_offset+DIM*0+XX] -= tx;
551 f[j_coord_offset+DIM*0+YY] -= ty;
552 f[j_coord_offset+DIM*0+ZZ] -= tz;
554 /**************************
555 * CALCULATE INTERACTIONS *
556 **************************/
560 /* EWALD ELECTROSTATICS */
562 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
563 ewrt = r21*ewtabscale;
567 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
568 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
569 felec = qq21*rinv21*(rinvsq21-felec);
571 /* Update potential sums from outer loop */
576 /* Calculate temporary vectorial force */
581 /* Update vectorial force */
585 f[j_coord_offset+DIM*1+XX] -= tx;
586 f[j_coord_offset+DIM*1+YY] -= ty;
587 f[j_coord_offset+DIM*1+ZZ] -= tz;
589 /**************************
590 * CALCULATE INTERACTIONS *
591 **************************/
595 /* EWALD ELECTROSTATICS */
597 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
598 ewrt = r22*ewtabscale;
602 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
603 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
604 felec = qq22*rinv22*(rinvsq22-felec);
606 /* Update potential sums from outer loop */
611 /* Calculate temporary vectorial force */
616 /* Update vectorial force */
620 f[j_coord_offset+DIM*2+XX] -= tx;
621 f[j_coord_offset+DIM*2+YY] -= ty;
622 f[j_coord_offset+DIM*2+ZZ] -= tz;
624 /* Inner loop uses 393 flops */
626 /* End of innermost loop */
629 f[i_coord_offset+DIM*0+XX] += fix0;
630 f[i_coord_offset+DIM*0+YY] += fiy0;
631 f[i_coord_offset+DIM*0+ZZ] += fiz0;
635 f[i_coord_offset+DIM*1+XX] += fix1;
636 f[i_coord_offset+DIM*1+YY] += fiy1;
637 f[i_coord_offset+DIM*1+ZZ] += fiz1;
641 f[i_coord_offset+DIM*2+XX] += fix2;
642 f[i_coord_offset+DIM*2+YY] += fiy2;
643 f[i_coord_offset+DIM*2+ZZ] += fiz2;
647 fshift[i_shift_offset+XX] += tx;
648 fshift[i_shift_offset+YY] += ty;
649 fshift[i_shift_offset+ZZ] += tz;
652 /* Update potential energies */
653 kernel_data->energygrp_elec[ggid] += velecsum;
654 kernel_data->energygrp_vdw[ggid] += vvdwsum;
656 /* Increment number of inner iterations */
657 inneriter += j_index_end - j_index_start;
659 /* Outer loop uses 32 flops */
662 /* Increment number of outer iterations */
665 /* Update outer/inner flops */
667 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*393);
670 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3W3_F_c
671 * Electrostatics interaction: Ewald
672 * VdW interaction: CubicSplineTable
673 * Geometry: Water3-Water3
674 * Calculate force/pot: Force
677 nb_kernel_ElecEw_VdwCSTab_GeomW3W3_F_c
678 (t_nblist * gmx_restrict nlist,
679 rvec * gmx_restrict xx,
680 rvec * gmx_restrict ff,
681 t_forcerec * gmx_restrict fr,
682 t_mdatoms * gmx_restrict mdatoms,
683 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
684 t_nrnb * gmx_restrict nrnb)
686 int i_shift_offset,i_coord_offset,j_coord_offset;
687 int j_index_start,j_index_end;
688 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
689 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
690 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
691 real *shiftvec,*fshift,*x,*f;
693 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
695 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
697 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
699 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
701 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
703 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
704 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
705 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
706 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
707 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
708 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
709 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
710 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
711 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
712 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
713 real velec,felec,velecsum,facel,crf,krf,krf2;
716 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
720 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
723 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
731 jindex = nlist->jindex;
733 shiftidx = nlist->shift;
735 shiftvec = fr->shift_vec[0];
736 fshift = fr->fshift[0];
738 charge = mdatoms->chargeA;
739 nvdwtype = fr->ntype;
741 vdwtype = mdatoms->typeA;
743 vftab = kernel_data->table_vdw->data;
744 vftabscale = kernel_data->table_vdw->scale;
746 sh_ewald = fr->ic->sh_ewald;
747 ewtab = fr->ic->tabq_coul_F;
748 ewtabscale = fr->ic->tabq_scale;
749 ewtabhalfspace = 0.5/ewtabscale;
751 /* Setup water-specific parameters */
752 inr = nlist->iinr[0];
753 iq0 = facel*charge[inr+0];
754 iq1 = facel*charge[inr+1];
755 iq2 = facel*charge[inr+2];
756 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
761 vdwjidx0 = 2*vdwtype[inr+0];
763 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
764 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
777 /* Start outer loop over neighborlists */
778 for(iidx=0; iidx<nri; iidx++)
780 /* Load shift vector for this list */
781 i_shift_offset = DIM*shiftidx[iidx];
782 shX = shiftvec[i_shift_offset+XX];
783 shY = shiftvec[i_shift_offset+YY];
784 shZ = shiftvec[i_shift_offset+ZZ];
786 /* Load limits for loop over neighbors */
787 j_index_start = jindex[iidx];
788 j_index_end = jindex[iidx+1];
790 /* Get outer coordinate index */
792 i_coord_offset = DIM*inr;
794 /* Load i particle coords and add shift vector */
795 ix0 = shX + x[i_coord_offset+DIM*0+XX];
796 iy0 = shY + x[i_coord_offset+DIM*0+YY];
797 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
798 ix1 = shX + x[i_coord_offset+DIM*1+XX];
799 iy1 = shY + x[i_coord_offset+DIM*1+YY];
800 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
801 ix2 = shX + x[i_coord_offset+DIM*2+XX];
802 iy2 = shY + x[i_coord_offset+DIM*2+YY];
803 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
815 /* Start inner kernel loop */
816 for(jidx=j_index_start; jidx<j_index_end; jidx++)
818 /* Get j neighbor index, and coordinate index */
820 j_coord_offset = DIM*jnr;
822 /* load j atom coordinates */
823 jx0 = x[j_coord_offset+DIM*0+XX];
824 jy0 = x[j_coord_offset+DIM*0+YY];
825 jz0 = x[j_coord_offset+DIM*0+ZZ];
826 jx1 = x[j_coord_offset+DIM*1+XX];
827 jy1 = x[j_coord_offset+DIM*1+YY];
828 jz1 = x[j_coord_offset+DIM*1+ZZ];
829 jx2 = x[j_coord_offset+DIM*2+XX];
830 jy2 = x[j_coord_offset+DIM*2+YY];
831 jz2 = x[j_coord_offset+DIM*2+ZZ];
833 /* Calculate displacement vector */
862 /* Calculate squared distance and things based on it */
863 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
864 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
865 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
866 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
867 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
868 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
869 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
870 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
871 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
873 rinv00 = gmx_invsqrt(rsq00);
874 rinv01 = gmx_invsqrt(rsq01);
875 rinv02 = gmx_invsqrt(rsq02);
876 rinv10 = gmx_invsqrt(rsq10);
877 rinv11 = gmx_invsqrt(rsq11);
878 rinv12 = gmx_invsqrt(rsq12);
879 rinv20 = gmx_invsqrt(rsq20);
880 rinv21 = gmx_invsqrt(rsq21);
881 rinv22 = gmx_invsqrt(rsq22);
883 rinvsq00 = rinv00*rinv00;
884 rinvsq01 = rinv01*rinv01;
885 rinvsq02 = rinv02*rinv02;
886 rinvsq10 = rinv10*rinv10;
887 rinvsq11 = rinv11*rinv11;
888 rinvsq12 = rinv12*rinv12;
889 rinvsq20 = rinv20*rinv20;
890 rinvsq21 = rinv21*rinv21;
891 rinvsq22 = rinv22*rinv22;
893 /**************************
894 * CALCULATE INTERACTIONS *
895 **************************/
899 /* Calculate table index by multiplying r with table scale and truncate to integer */
905 /* EWALD ELECTROSTATICS */
907 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
908 ewrt = r00*ewtabscale;
911 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
912 felec = qq00*rinv00*(rinvsq00-felec);
914 /* CUBIC SPLINE TABLE DISPERSION */
917 Geps = vfeps*vftab[vfitab+2];
918 Heps2 = vfeps*vfeps*vftab[vfitab+3];
920 FF = Fp+Geps+2.0*Heps2;
923 /* CUBIC SPLINE TABLE REPULSION */
925 Geps = vfeps*vftab[vfitab+6];
926 Heps2 = vfeps*vfeps*vftab[vfitab+7];
928 FF = Fp+Geps+2.0*Heps2;
930 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
934 /* Calculate temporary vectorial force */
939 /* Update vectorial force */
943 f[j_coord_offset+DIM*0+XX] -= tx;
944 f[j_coord_offset+DIM*0+YY] -= ty;
945 f[j_coord_offset+DIM*0+ZZ] -= tz;
947 /**************************
948 * CALCULATE INTERACTIONS *
949 **************************/
953 /* EWALD ELECTROSTATICS */
955 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
956 ewrt = r01*ewtabscale;
959 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
960 felec = qq01*rinv01*(rinvsq01-felec);
964 /* Calculate temporary vectorial force */
969 /* Update vectorial force */
973 f[j_coord_offset+DIM*1+XX] -= tx;
974 f[j_coord_offset+DIM*1+YY] -= ty;
975 f[j_coord_offset+DIM*1+ZZ] -= tz;
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
983 /* EWALD ELECTROSTATICS */
985 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
986 ewrt = r02*ewtabscale;
989 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
990 felec = qq02*rinv02*(rinvsq02-felec);
994 /* Calculate temporary vectorial force */
999 /* Update vectorial force */
1003 f[j_coord_offset+DIM*2+XX] -= tx;
1004 f[j_coord_offset+DIM*2+YY] -= ty;
1005 f[j_coord_offset+DIM*2+ZZ] -= tz;
1007 /**************************
1008 * CALCULATE INTERACTIONS *
1009 **************************/
1013 /* EWALD ELECTROSTATICS */
1015 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1016 ewrt = r10*ewtabscale;
1018 eweps = ewrt-ewitab;
1019 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1020 felec = qq10*rinv10*(rinvsq10-felec);
1024 /* Calculate temporary vectorial force */
1029 /* Update vectorial force */
1033 f[j_coord_offset+DIM*0+XX] -= tx;
1034 f[j_coord_offset+DIM*0+YY] -= ty;
1035 f[j_coord_offset+DIM*0+ZZ] -= tz;
1037 /**************************
1038 * CALCULATE INTERACTIONS *
1039 **************************/
1043 /* EWALD ELECTROSTATICS */
1045 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1046 ewrt = r11*ewtabscale;
1048 eweps = ewrt-ewitab;
1049 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1050 felec = qq11*rinv11*(rinvsq11-felec);
1054 /* Calculate temporary vectorial force */
1059 /* Update vectorial force */
1063 f[j_coord_offset+DIM*1+XX] -= tx;
1064 f[j_coord_offset+DIM*1+YY] -= ty;
1065 f[j_coord_offset+DIM*1+ZZ] -= tz;
1067 /**************************
1068 * CALCULATE INTERACTIONS *
1069 **************************/
1073 /* EWALD ELECTROSTATICS */
1075 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1076 ewrt = r12*ewtabscale;
1078 eweps = ewrt-ewitab;
1079 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1080 felec = qq12*rinv12*(rinvsq12-felec);
1084 /* Calculate temporary vectorial force */
1089 /* Update vectorial force */
1093 f[j_coord_offset+DIM*2+XX] -= tx;
1094 f[j_coord_offset+DIM*2+YY] -= ty;
1095 f[j_coord_offset+DIM*2+ZZ] -= tz;
1097 /**************************
1098 * CALCULATE INTERACTIONS *
1099 **************************/
1103 /* EWALD ELECTROSTATICS */
1105 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1106 ewrt = r20*ewtabscale;
1108 eweps = ewrt-ewitab;
1109 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1110 felec = qq20*rinv20*(rinvsq20-felec);
1114 /* Calculate temporary vectorial force */
1119 /* Update vectorial force */
1123 f[j_coord_offset+DIM*0+XX] -= tx;
1124 f[j_coord_offset+DIM*0+YY] -= ty;
1125 f[j_coord_offset+DIM*0+ZZ] -= tz;
1127 /**************************
1128 * CALCULATE INTERACTIONS *
1129 **************************/
1133 /* EWALD ELECTROSTATICS */
1135 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1136 ewrt = r21*ewtabscale;
1138 eweps = ewrt-ewitab;
1139 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1140 felec = qq21*rinv21*(rinvsq21-felec);
1144 /* Calculate temporary vectorial force */
1149 /* Update vectorial force */
1153 f[j_coord_offset+DIM*1+XX] -= tx;
1154 f[j_coord_offset+DIM*1+YY] -= ty;
1155 f[j_coord_offset+DIM*1+ZZ] -= tz;
1157 /**************************
1158 * CALCULATE INTERACTIONS *
1159 **************************/
1163 /* EWALD ELECTROSTATICS */
1165 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1166 ewrt = r22*ewtabscale;
1168 eweps = ewrt-ewitab;
1169 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1170 felec = qq22*rinv22*(rinvsq22-felec);
1174 /* Calculate temporary vectorial force */
1179 /* Update vectorial force */
1183 f[j_coord_offset+DIM*2+XX] -= tx;
1184 f[j_coord_offset+DIM*2+YY] -= ty;
1185 f[j_coord_offset+DIM*2+ZZ] -= tz;
1187 /* Inner loop uses 322 flops */
1189 /* End of innermost loop */
1192 f[i_coord_offset+DIM*0+XX] += fix0;
1193 f[i_coord_offset+DIM*0+YY] += fiy0;
1194 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1198 f[i_coord_offset+DIM*1+XX] += fix1;
1199 f[i_coord_offset+DIM*1+YY] += fiy1;
1200 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1204 f[i_coord_offset+DIM*2+XX] += fix2;
1205 f[i_coord_offset+DIM*2+YY] += fiy2;
1206 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1210 fshift[i_shift_offset+XX] += tx;
1211 fshift[i_shift_offset+YY] += ty;
1212 fshift[i_shift_offset+ZZ] += tz;
1214 /* Increment number of inner iterations */
1215 inneriter += j_index_end - j_index_start;
1217 /* Outer loop uses 30 flops */
1220 /* Increment number of outer iterations */
1223 /* Update outer/inner flops */
1225 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*322);