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_ElecEw_VdwCSTab_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwCSTab_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 rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
101 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
109 jindex = nlist->jindex;
111 shiftidx = nlist->shift;
113 shiftvec = fr->shift_vec[0];
114 fshift = fr->fshift[0];
116 charge = mdatoms->chargeA;
117 nvdwtype = fr->ntype;
119 vdwtype = mdatoms->typeA;
121 vftab = kernel_data->table_vdw->data;
122 vftabscale = kernel_data->table_vdw->scale;
124 sh_ewald = fr->ic->sh_ewald;
125 ewtab = fr->ic->tabq_coul_FDV0;
126 ewtabscale = fr->ic->tabq_scale;
127 ewtabhalfspace = 0.5/ewtabscale;
129 /* Setup water-specific parameters */
130 inr = nlist->iinr[0];
131 iq0 = facel*charge[inr+0];
132 iq1 = facel*charge[inr+1];
133 iq2 = facel*charge[inr+2];
134 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
139 vdwjidx0 = 2*vdwtype[inr+0];
141 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
142 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
155 /* Start outer loop over neighborlists */
156 for(iidx=0; iidx<nri; iidx++)
158 /* Load shift vector for this list */
159 i_shift_offset = DIM*shiftidx[iidx];
160 shX = shiftvec[i_shift_offset+XX];
161 shY = shiftvec[i_shift_offset+YY];
162 shZ = shiftvec[i_shift_offset+ZZ];
164 /* Load limits for loop over neighbors */
165 j_index_start = jindex[iidx];
166 j_index_end = jindex[iidx+1];
168 /* Get outer coordinate index */
170 i_coord_offset = DIM*inr;
172 /* Load i particle coords and add shift vector */
173 ix0 = shX + x[i_coord_offset+DIM*0+XX];
174 iy0 = shY + x[i_coord_offset+DIM*0+YY];
175 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
176 ix1 = shX + x[i_coord_offset+DIM*1+XX];
177 iy1 = shY + x[i_coord_offset+DIM*1+YY];
178 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
179 ix2 = shX + x[i_coord_offset+DIM*2+XX];
180 iy2 = shY + x[i_coord_offset+DIM*2+YY];
181 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
193 /* Reset potential sums */
197 /* Start inner kernel loop */
198 for(jidx=j_index_start; jidx<j_index_end; jidx++)
200 /* Get j neighbor index, and coordinate index */
202 j_coord_offset = DIM*jnr;
204 /* load j atom coordinates */
205 jx0 = x[j_coord_offset+DIM*0+XX];
206 jy0 = x[j_coord_offset+DIM*0+YY];
207 jz0 = x[j_coord_offset+DIM*0+ZZ];
208 jx1 = x[j_coord_offset+DIM*1+XX];
209 jy1 = x[j_coord_offset+DIM*1+YY];
210 jz1 = x[j_coord_offset+DIM*1+ZZ];
211 jx2 = x[j_coord_offset+DIM*2+XX];
212 jy2 = x[j_coord_offset+DIM*2+YY];
213 jz2 = x[j_coord_offset+DIM*2+ZZ];
215 /* Calculate displacement vector */
244 /* Calculate squared distance and things based on it */
245 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
246 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
247 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
248 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
249 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
250 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
251 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
252 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
253 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
255 rinv00 = gmx_invsqrt(rsq00);
256 rinv01 = gmx_invsqrt(rsq01);
257 rinv02 = gmx_invsqrt(rsq02);
258 rinv10 = gmx_invsqrt(rsq10);
259 rinv11 = gmx_invsqrt(rsq11);
260 rinv12 = gmx_invsqrt(rsq12);
261 rinv20 = gmx_invsqrt(rsq20);
262 rinv21 = gmx_invsqrt(rsq21);
263 rinv22 = gmx_invsqrt(rsq22);
265 rinvsq00 = rinv00*rinv00;
266 rinvsq01 = rinv01*rinv01;
267 rinvsq02 = rinv02*rinv02;
268 rinvsq10 = rinv10*rinv10;
269 rinvsq11 = rinv11*rinv11;
270 rinvsq12 = rinv12*rinv12;
271 rinvsq20 = rinv20*rinv20;
272 rinvsq21 = rinv21*rinv21;
273 rinvsq22 = rinv22*rinv22;
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
281 /* Calculate table index by multiplying r with table scale and truncate to integer */
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-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
296 felec = qq00*rinv00*(rinvsq00-felec);
298 /* CUBIC SPLINE TABLE DISPERSION */
302 Geps = vfeps*vftab[vfitab+2];
303 Heps2 = vfeps*vfeps*vftab[vfitab+3];
307 FF = Fp+Geps+2.0*Heps2;
310 /* CUBIC SPLINE TABLE REPULSION */
313 Geps = vfeps*vftab[vfitab+6];
314 Heps2 = vfeps*vfeps*vftab[vfitab+7];
318 FF = Fp+Geps+2.0*Heps2;
321 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
323 /* Update potential sums from outer loop */
329 /* Calculate temporary vectorial force */
334 /* Update vectorial force */
338 f[j_coord_offset+DIM*0+XX] -= tx;
339 f[j_coord_offset+DIM*0+YY] -= ty;
340 f[j_coord_offset+DIM*0+ZZ] -= tz;
342 /**************************
343 * CALCULATE INTERACTIONS *
344 **************************/
348 /* EWALD ELECTROSTATICS */
350 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
351 ewrt = r01*ewtabscale;
355 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
356 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
357 felec = qq01*rinv01*(rinvsq01-felec);
359 /* Update potential sums from outer loop */
364 /* Calculate temporary vectorial force */
369 /* Update vectorial force */
373 f[j_coord_offset+DIM*1+XX] -= tx;
374 f[j_coord_offset+DIM*1+YY] -= ty;
375 f[j_coord_offset+DIM*1+ZZ] -= tz;
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
383 /* EWALD ELECTROSTATICS */
385 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
386 ewrt = r02*ewtabscale;
390 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
391 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
392 felec = qq02*rinv02*(rinvsq02-felec);
394 /* Update potential sums from outer loop */
399 /* Calculate temporary vectorial force */
404 /* Update vectorial force */
408 f[j_coord_offset+DIM*2+XX] -= tx;
409 f[j_coord_offset+DIM*2+YY] -= ty;
410 f[j_coord_offset+DIM*2+ZZ] -= tz;
412 /**************************
413 * CALCULATE INTERACTIONS *
414 **************************/
418 /* EWALD ELECTROSTATICS */
420 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
421 ewrt = r10*ewtabscale;
425 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
426 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
427 felec = qq10*rinv10*(rinvsq10-felec);
429 /* Update potential sums from outer loop */
434 /* Calculate temporary vectorial force */
439 /* Update vectorial force */
443 f[j_coord_offset+DIM*0+XX] -= tx;
444 f[j_coord_offset+DIM*0+YY] -= ty;
445 f[j_coord_offset+DIM*0+ZZ] -= tz;
447 /**************************
448 * CALCULATE INTERACTIONS *
449 **************************/
453 /* EWALD ELECTROSTATICS */
455 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
456 ewrt = r11*ewtabscale;
460 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
461 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
462 felec = qq11*rinv11*(rinvsq11-felec);
464 /* Update potential sums from outer loop */
469 /* Calculate temporary vectorial force */
474 /* Update vectorial force */
478 f[j_coord_offset+DIM*1+XX] -= tx;
479 f[j_coord_offset+DIM*1+YY] -= ty;
480 f[j_coord_offset+DIM*1+ZZ] -= tz;
482 /**************************
483 * CALCULATE INTERACTIONS *
484 **************************/
488 /* EWALD ELECTROSTATICS */
490 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
491 ewrt = r12*ewtabscale;
495 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
496 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
497 felec = qq12*rinv12*(rinvsq12-felec);
499 /* Update potential sums from outer loop */
504 /* Calculate temporary vectorial force */
509 /* Update vectorial force */
513 f[j_coord_offset+DIM*2+XX] -= tx;
514 f[j_coord_offset+DIM*2+YY] -= ty;
515 f[j_coord_offset+DIM*2+ZZ] -= tz;
517 /**************************
518 * CALCULATE INTERACTIONS *
519 **************************/
523 /* EWALD ELECTROSTATICS */
525 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
526 ewrt = r20*ewtabscale;
530 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
531 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
532 felec = qq20*rinv20*(rinvsq20-felec);
534 /* Update potential sums from outer loop */
539 /* Calculate temporary vectorial force */
544 /* Update vectorial force */
548 f[j_coord_offset+DIM*0+XX] -= tx;
549 f[j_coord_offset+DIM*0+YY] -= ty;
550 f[j_coord_offset+DIM*0+ZZ] -= tz;
552 /**************************
553 * CALCULATE INTERACTIONS *
554 **************************/
558 /* EWALD ELECTROSTATICS */
560 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
561 ewrt = r21*ewtabscale;
565 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
566 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
567 felec = qq21*rinv21*(rinvsq21-felec);
569 /* Update potential sums from outer loop */
574 /* Calculate temporary vectorial force */
579 /* Update vectorial force */
583 f[j_coord_offset+DIM*1+XX] -= tx;
584 f[j_coord_offset+DIM*1+YY] -= ty;
585 f[j_coord_offset+DIM*1+ZZ] -= tz;
587 /**************************
588 * CALCULATE INTERACTIONS *
589 **************************/
593 /* EWALD ELECTROSTATICS */
595 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
596 ewrt = r22*ewtabscale;
600 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
601 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
602 felec = qq22*rinv22*(rinvsq22-felec);
604 /* Update potential sums from outer loop */
609 /* Calculate temporary vectorial force */
614 /* Update vectorial force */
618 f[j_coord_offset+DIM*2+XX] -= tx;
619 f[j_coord_offset+DIM*2+YY] -= ty;
620 f[j_coord_offset+DIM*2+ZZ] -= tz;
622 /* Inner loop uses 393 flops */
624 /* End of innermost loop */
627 f[i_coord_offset+DIM*0+XX] += fix0;
628 f[i_coord_offset+DIM*0+YY] += fiy0;
629 f[i_coord_offset+DIM*0+ZZ] += fiz0;
633 f[i_coord_offset+DIM*1+XX] += fix1;
634 f[i_coord_offset+DIM*1+YY] += fiy1;
635 f[i_coord_offset+DIM*1+ZZ] += fiz1;
639 f[i_coord_offset+DIM*2+XX] += fix2;
640 f[i_coord_offset+DIM*2+YY] += fiy2;
641 f[i_coord_offset+DIM*2+ZZ] += fiz2;
645 fshift[i_shift_offset+XX] += tx;
646 fshift[i_shift_offset+YY] += ty;
647 fshift[i_shift_offset+ZZ] += tz;
650 /* Update potential energies */
651 kernel_data->energygrp_elec[ggid] += velecsum;
652 kernel_data->energygrp_vdw[ggid] += vvdwsum;
654 /* Increment number of inner iterations */
655 inneriter += j_index_end - j_index_start;
657 /* Outer loop uses 32 flops */
660 /* Increment number of outer iterations */
663 /* Update outer/inner flops */
665 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*393);
668 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3W3_F_c
669 * Electrostatics interaction: Ewald
670 * VdW interaction: CubicSplineTable
671 * Geometry: Water3-Water3
672 * Calculate force/pot: Force
675 nb_kernel_ElecEw_VdwCSTab_GeomW3W3_F_c
676 (t_nblist * gmx_restrict nlist,
677 rvec * gmx_restrict xx,
678 rvec * gmx_restrict ff,
679 t_forcerec * gmx_restrict fr,
680 t_mdatoms * gmx_restrict mdatoms,
681 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
682 t_nrnb * gmx_restrict nrnb)
684 int i_shift_offset,i_coord_offset,j_coord_offset;
685 int j_index_start,j_index_end;
686 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
687 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
688 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
689 real *shiftvec,*fshift,*x,*f;
691 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
693 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
695 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
697 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
699 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
701 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
702 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
703 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
704 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
705 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
706 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
707 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
708 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
709 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
710 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
711 real velec,felec,velecsum,facel,crf,krf,krf2;
714 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
718 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
721 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
729 jindex = nlist->jindex;
731 shiftidx = nlist->shift;
733 shiftvec = fr->shift_vec[0];
734 fshift = fr->fshift[0];
736 charge = mdatoms->chargeA;
737 nvdwtype = fr->ntype;
739 vdwtype = mdatoms->typeA;
741 vftab = kernel_data->table_vdw->data;
742 vftabscale = kernel_data->table_vdw->scale;
744 sh_ewald = fr->ic->sh_ewald;
745 ewtab = fr->ic->tabq_coul_F;
746 ewtabscale = fr->ic->tabq_scale;
747 ewtabhalfspace = 0.5/ewtabscale;
749 /* Setup water-specific parameters */
750 inr = nlist->iinr[0];
751 iq0 = facel*charge[inr+0];
752 iq1 = facel*charge[inr+1];
753 iq2 = facel*charge[inr+2];
754 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
759 vdwjidx0 = 2*vdwtype[inr+0];
761 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
762 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
775 /* Start outer loop over neighborlists */
776 for(iidx=0; iidx<nri; iidx++)
778 /* Load shift vector for this list */
779 i_shift_offset = DIM*shiftidx[iidx];
780 shX = shiftvec[i_shift_offset+XX];
781 shY = shiftvec[i_shift_offset+YY];
782 shZ = shiftvec[i_shift_offset+ZZ];
784 /* Load limits for loop over neighbors */
785 j_index_start = jindex[iidx];
786 j_index_end = jindex[iidx+1];
788 /* Get outer coordinate index */
790 i_coord_offset = DIM*inr;
792 /* Load i particle coords and add shift vector */
793 ix0 = shX + x[i_coord_offset+DIM*0+XX];
794 iy0 = shY + x[i_coord_offset+DIM*0+YY];
795 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
796 ix1 = shX + x[i_coord_offset+DIM*1+XX];
797 iy1 = shY + x[i_coord_offset+DIM*1+YY];
798 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
799 ix2 = shX + x[i_coord_offset+DIM*2+XX];
800 iy2 = shY + x[i_coord_offset+DIM*2+YY];
801 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
813 /* Start inner kernel loop */
814 for(jidx=j_index_start; jidx<j_index_end; jidx++)
816 /* Get j neighbor index, and coordinate index */
818 j_coord_offset = DIM*jnr;
820 /* load j atom coordinates */
821 jx0 = x[j_coord_offset+DIM*0+XX];
822 jy0 = x[j_coord_offset+DIM*0+YY];
823 jz0 = x[j_coord_offset+DIM*0+ZZ];
824 jx1 = x[j_coord_offset+DIM*1+XX];
825 jy1 = x[j_coord_offset+DIM*1+YY];
826 jz1 = x[j_coord_offset+DIM*1+ZZ];
827 jx2 = x[j_coord_offset+DIM*2+XX];
828 jy2 = x[j_coord_offset+DIM*2+YY];
829 jz2 = x[j_coord_offset+DIM*2+ZZ];
831 /* Calculate displacement vector */
860 /* Calculate squared distance and things based on it */
861 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
862 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
863 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
864 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
865 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
866 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
867 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
868 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
869 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
871 rinv00 = gmx_invsqrt(rsq00);
872 rinv01 = gmx_invsqrt(rsq01);
873 rinv02 = gmx_invsqrt(rsq02);
874 rinv10 = gmx_invsqrt(rsq10);
875 rinv11 = gmx_invsqrt(rsq11);
876 rinv12 = gmx_invsqrt(rsq12);
877 rinv20 = gmx_invsqrt(rsq20);
878 rinv21 = gmx_invsqrt(rsq21);
879 rinv22 = gmx_invsqrt(rsq22);
881 rinvsq00 = rinv00*rinv00;
882 rinvsq01 = rinv01*rinv01;
883 rinvsq02 = rinv02*rinv02;
884 rinvsq10 = rinv10*rinv10;
885 rinvsq11 = rinv11*rinv11;
886 rinvsq12 = rinv12*rinv12;
887 rinvsq20 = rinv20*rinv20;
888 rinvsq21 = rinv21*rinv21;
889 rinvsq22 = rinv22*rinv22;
891 /**************************
892 * CALCULATE INTERACTIONS *
893 **************************/
897 /* Calculate table index by multiplying r with table scale and truncate to integer */
903 /* EWALD ELECTROSTATICS */
905 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
906 ewrt = r00*ewtabscale;
909 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
910 felec = qq00*rinv00*(rinvsq00-felec);
912 /* CUBIC SPLINE TABLE DISPERSION */
915 Geps = vfeps*vftab[vfitab+2];
916 Heps2 = vfeps*vfeps*vftab[vfitab+3];
918 FF = Fp+Geps+2.0*Heps2;
921 /* CUBIC SPLINE TABLE REPULSION */
923 Geps = vfeps*vftab[vfitab+6];
924 Heps2 = vfeps*vfeps*vftab[vfitab+7];
926 FF = Fp+Geps+2.0*Heps2;
928 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
932 /* Calculate temporary vectorial force */
937 /* Update vectorial force */
941 f[j_coord_offset+DIM*0+XX] -= tx;
942 f[j_coord_offset+DIM*0+YY] -= ty;
943 f[j_coord_offset+DIM*0+ZZ] -= tz;
945 /**************************
946 * CALCULATE INTERACTIONS *
947 **************************/
951 /* EWALD ELECTROSTATICS */
953 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
954 ewrt = r01*ewtabscale;
957 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
958 felec = qq01*rinv01*(rinvsq01-felec);
962 /* Calculate temporary vectorial force */
967 /* Update vectorial force */
971 f[j_coord_offset+DIM*1+XX] -= tx;
972 f[j_coord_offset+DIM*1+YY] -= ty;
973 f[j_coord_offset+DIM*1+ZZ] -= tz;
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
981 /* EWALD ELECTROSTATICS */
983 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
984 ewrt = r02*ewtabscale;
987 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
988 felec = qq02*rinv02*(rinvsq02-felec);
992 /* Calculate temporary vectorial force */
997 /* Update vectorial force */
1001 f[j_coord_offset+DIM*2+XX] -= tx;
1002 f[j_coord_offset+DIM*2+YY] -= ty;
1003 f[j_coord_offset+DIM*2+ZZ] -= tz;
1005 /**************************
1006 * CALCULATE INTERACTIONS *
1007 **************************/
1011 /* EWALD ELECTROSTATICS */
1013 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1014 ewrt = r10*ewtabscale;
1016 eweps = ewrt-ewitab;
1017 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1018 felec = qq10*rinv10*(rinvsq10-felec);
1022 /* Calculate temporary vectorial force */
1027 /* Update vectorial force */
1031 f[j_coord_offset+DIM*0+XX] -= tx;
1032 f[j_coord_offset+DIM*0+YY] -= ty;
1033 f[j_coord_offset+DIM*0+ZZ] -= tz;
1035 /**************************
1036 * CALCULATE INTERACTIONS *
1037 **************************/
1041 /* EWALD ELECTROSTATICS */
1043 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1044 ewrt = r11*ewtabscale;
1046 eweps = ewrt-ewitab;
1047 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1048 felec = qq11*rinv11*(rinvsq11-felec);
1052 /* Calculate temporary vectorial force */
1057 /* Update vectorial force */
1061 f[j_coord_offset+DIM*1+XX] -= tx;
1062 f[j_coord_offset+DIM*1+YY] -= ty;
1063 f[j_coord_offset+DIM*1+ZZ] -= tz;
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1071 /* EWALD ELECTROSTATICS */
1073 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1074 ewrt = r12*ewtabscale;
1076 eweps = ewrt-ewitab;
1077 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1078 felec = qq12*rinv12*(rinvsq12-felec);
1082 /* Calculate temporary vectorial force */
1087 /* Update vectorial force */
1091 f[j_coord_offset+DIM*2+XX] -= tx;
1092 f[j_coord_offset+DIM*2+YY] -= ty;
1093 f[j_coord_offset+DIM*2+ZZ] -= tz;
1095 /**************************
1096 * CALCULATE INTERACTIONS *
1097 **************************/
1101 /* EWALD ELECTROSTATICS */
1103 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1104 ewrt = r20*ewtabscale;
1106 eweps = ewrt-ewitab;
1107 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1108 felec = qq20*rinv20*(rinvsq20-felec);
1112 /* Calculate temporary vectorial force */
1117 /* Update vectorial force */
1121 f[j_coord_offset+DIM*0+XX] -= tx;
1122 f[j_coord_offset+DIM*0+YY] -= ty;
1123 f[j_coord_offset+DIM*0+ZZ] -= tz;
1125 /**************************
1126 * CALCULATE INTERACTIONS *
1127 **************************/
1131 /* EWALD ELECTROSTATICS */
1133 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1134 ewrt = r21*ewtabscale;
1136 eweps = ewrt-ewitab;
1137 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1138 felec = qq21*rinv21*(rinvsq21-felec);
1142 /* Calculate temporary vectorial force */
1147 /* Update vectorial force */
1151 f[j_coord_offset+DIM*1+XX] -= tx;
1152 f[j_coord_offset+DIM*1+YY] -= ty;
1153 f[j_coord_offset+DIM*1+ZZ] -= tz;
1155 /**************************
1156 * CALCULATE INTERACTIONS *
1157 **************************/
1161 /* EWALD ELECTROSTATICS */
1163 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1164 ewrt = r22*ewtabscale;
1166 eweps = ewrt-ewitab;
1167 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1168 felec = qq22*rinv22*(rinvsq22-felec);
1172 /* Calculate temporary vectorial force */
1177 /* Update vectorial force */
1181 f[j_coord_offset+DIM*2+XX] -= tx;
1182 f[j_coord_offset+DIM*2+YY] -= ty;
1183 f[j_coord_offset+DIM*2+ZZ] -= tz;
1185 /* Inner loop uses 322 flops */
1187 /* End of innermost loop */
1190 f[i_coord_offset+DIM*0+XX] += fix0;
1191 f[i_coord_offset+DIM*0+YY] += fiy0;
1192 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1196 f[i_coord_offset+DIM*1+XX] += fix1;
1197 f[i_coord_offset+DIM*1+YY] += fiy1;
1198 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1202 f[i_coord_offset+DIM*2+XX] += fix2;
1203 f[i_coord_offset+DIM*2+YY] += fiy2;
1204 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1208 fshift[i_shift_offset+XX] += tx;
1209 fshift[i_shift_offset+YY] += ty;
1210 fshift[i_shift_offset+ZZ] += tz;
1212 /* Increment number of inner iterations */
1213 inneriter += j_index_end - j_index_start;
1215 /* Outer loop uses 30 flops */
1218 /* Increment number of outer iterations */
1221 /* Update outer/inner flops */
1223 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*322);