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_VdwBhamSh_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_VdwBhamSh_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 = 3*nvdwtype*vdwtype[inr+0];
133 vdwjidx0 = 3*vdwtype[inr+0];
135 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
136 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
137 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
147 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
148 rcutoff = fr->rcoulomb;
149 rcutoff2 = rcutoff*rcutoff;
151 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
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 **************************/
286 /* EWALD ELECTROSTATICS */
288 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
289 ewrt = r00*ewtabscale;
293 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
294 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
295 felec = qq00*rinv00*(rinvsq00-felec);
297 /* BUCKINGHAM DISPERSION/REPULSION */
298 rinvsix = rinvsq00*rinvsq00*rinvsq00;
299 vvdw6 = c6_00*rinvsix;
301 vvdwexp = cexp1_00*exp(-br);
302 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
303 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
305 /* Update potential sums from outer loop */
311 /* Calculate temporary vectorial force */
316 /* Update vectorial force */
320 f[j_coord_offset+DIM*0+XX] -= tx;
321 f[j_coord_offset+DIM*0+YY] -= ty;
322 f[j_coord_offset+DIM*0+ZZ] -= tz;
326 /**************************
327 * CALCULATE INTERACTIONS *
328 **************************/
335 /* EWALD ELECTROSTATICS */
337 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
338 ewrt = r01*ewtabscale;
342 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
343 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
344 felec = qq01*rinv01*(rinvsq01-felec);
346 /* Update potential sums from outer loop */
351 /* Calculate temporary vectorial force */
356 /* Update vectorial force */
360 f[j_coord_offset+DIM*1+XX] -= tx;
361 f[j_coord_offset+DIM*1+YY] -= ty;
362 f[j_coord_offset+DIM*1+ZZ] -= tz;
366 /**************************
367 * CALCULATE INTERACTIONS *
368 **************************/
375 /* EWALD ELECTROSTATICS */
377 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
378 ewrt = r02*ewtabscale;
382 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
383 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
384 felec = qq02*rinv02*(rinvsq02-felec);
386 /* Update potential sums from outer loop */
391 /* Calculate temporary vectorial force */
396 /* Update vectorial force */
400 f[j_coord_offset+DIM*2+XX] -= tx;
401 f[j_coord_offset+DIM*2+YY] -= ty;
402 f[j_coord_offset+DIM*2+ZZ] -= tz;
406 /**************************
407 * CALCULATE INTERACTIONS *
408 **************************/
415 /* EWALD ELECTROSTATICS */
417 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
418 ewrt = r10*ewtabscale;
422 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
423 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
424 felec = qq10*rinv10*(rinvsq10-felec);
426 /* Update potential sums from outer loop */
431 /* Calculate temporary vectorial force */
436 /* Update vectorial force */
440 f[j_coord_offset+DIM*0+XX] -= tx;
441 f[j_coord_offset+DIM*0+YY] -= ty;
442 f[j_coord_offset+DIM*0+ZZ] -= tz;
446 /**************************
447 * CALCULATE INTERACTIONS *
448 **************************/
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-sh_ewald)-(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;
486 /**************************
487 * CALCULATE INTERACTIONS *
488 **************************/
495 /* EWALD ELECTROSTATICS */
497 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
498 ewrt = r12*ewtabscale;
502 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
503 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
504 felec = qq12*rinv12*(rinvsq12-felec);
506 /* Update potential sums from outer loop */
511 /* Calculate temporary vectorial force */
516 /* Update vectorial force */
520 f[j_coord_offset+DIM*2+XX] -= tx;
521 f[j_coord_offset+DIM*2+YY] -= ty;
522 f[j_coord_offset+DIM*2+ZZ] -= tz;
526 /**************************
527 * CALCULATE INTERACTIONS *
528 **************************/
535 /* EWALD ELECTROSTATICS */
537 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
538 ewrt = r20*ewtabscale;
542 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
543 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
544 felec = qq20*rinv20*(rinvsq20-felec);
546 /* Update potential sums from outer loop */
551 /* Calculate temporary vectorial force */
556 /* Update vectorial force */
560 f[j_coord_offset+DIM*0+XX] -= tx;
561 f[j_coord_offset+DIM*0+YY] -= ty;
562 f[j_coord_offset+DIM*0+ZZ] -= tz;
566 /**************************
567 * CALCULATE INTERACTIONS *
568 **************************/
575 /* EWALD ELECTROSTATICS */
577 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
578 ewrt = r21*ewtabscale;
582 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
583 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
584 felec = qq21*rinv21*(rinvsq21-felec);
586 /* Update potential sums from outer loop */
591 /* Calculate temporary vectorial force */
596 /* Update vectorial force */
600 f[j_coord_offset+DIM*1+XX] -= tx;
601 f[j_coord_offset+DIM*1+YY] -= ty;
602 f[j_coord_offset+DIM*1+ZZ] -= tz;
606 /**************************
607 * CALCULATE INTERACTIONS *
608 **************************/
615 /* EWALD ELECTROSTATICS */
617 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
618 ewrt = r22*ewtabscale;
622 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
623 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
624 felec = qq22*rinv22*(rinvsq22-felec);
626 /* Update potential sums from outer loop */
631 /* Calculate temporary vectorial force */
636 /* Update vectorial force */
640 f[j_coord_offset+DIM*2+XX] -= tx;
641 f[j_coord_offset+DIM*2+YY] -= ty;
642 f[j_coord_offset+DIM*2+ZZ] -= tz;
646 /* Inner loop uses 438 flops */
648 /* End of innermost loop */
651 f[i_coord_offset+DIM*0+XX] += fix0;
652 f[i_coord_offset+DIM*0+YY] += fiy0;
653 f[i_coord_offset+DIM*0+ZZ] += fiz0;
657 f[i_coord_offset+DIM*1+XX] += fix1;
658 f[i_coord_offset+DIM*1+YY] += fiy1;
659 f[i_coord_offset+DIM*1+ZZ] += fiz1;
663 f[i_coord_offset+DIM*2+XX] += fix2;
664 f[i_coord_offset+DIM*2+YY] += fiy2;
665 f[i_coord_offset+DIM*2+ZZ] += fiz2;
669 fshift[i_shift_offset+XX] += tx;
670 fshift[i_shift_offset+YY] += ty;
671 fshift[i_shift_offset+ZZ] += tz;
674 /* Update potential energies */
675 kernel_data->energygrp_elec[ggid] += velecsum;
676 kernel_data->energygrp_vdw[ggid] += vvdwsum;
678 /* Increment number of inner iterations */
679 inneriter += j_index_end - j_index_start;
681 /* Outer loop uses 32 flops */
684 /* Increment number of outer iterations */
687 /* Update outer/inner flops */
689 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*438);
692 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW3W3_F_c
693 * Electrostatics interaction: Ewald
694 * VdW interaction: Buckingham
695 * Geometry: Water3-Water3
696 * Calculate force/pot: Force
699 nb_kernel_ElecEwSh_VdwBhamSh_GeomW3W3_F_c
700 (t_nblist * gmx_restrict nlist,
701 rvec * gmx_restrict xx,
702 rvec * gmx_restrict ff,
703 t_forcerec * gmx_restrict fr,
704 t_mdatoms * gmx_restrict mdatoms,
705 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
706 t_nrnb * gmx_restrict nrnb)
708 int i_shift_offset,i_coord_offset,j_coord_offset;
709 int j_index_start,j_index_end;
710 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
711 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
712 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
713 real *shiftvec,*fshift,*x,*f;
715 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
717 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
719 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
721 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
723 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
725 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
726 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
727 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
728 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
729 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
730 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
731 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
732 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
733 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
734 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
735 real velec,felec,velecsum,facel,crf,krf,krf2;
738 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
742 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
750 jindex = nlist->jindex;
752 shiftidx = nlist->shift;
754 shiftvec = fr->shift_vec[0];
755 fshift = fr->fshift[0];
757 charge = mdatoms->chargeA;
758 nvdwtype = fr->ntype;
760 vdwtype = mdatoms->typeA;
762 sh_ewald = fr->ic->sh_ewald;
763 ewtab = fr->ic->tabq_coul_F;
764 ewtabscale = fr->ic->tabq_scale;
765 ewtabhalfspace = 0.5/ewtabscale;
767 /* Setup water-specific parameters */
768 inr = nlist->iinr[0];
769 iq0 = facel*charge[inr+0];
770 iq1 = facel*charge[inr+1];
771 iq2 = facel*charge[inr+2];
772 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
777 vdwjidx0 = 3*vdwtype[inr+0];
779 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
780 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
781 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
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 /* BUCKINGHAM DISPERSION/REPULSION */
936 rinvsix = rinvsq00*rinvsq00*rinvsq00;
937 vvdw6 = c6_00*rinvsix;
939 vvdwexp = cexp1_00*exp(-br);
940 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
944 /* Calculate temporary vectorial force */
949 /* Update vectorial force */
953 f[j_coord_offset+DIM*0+XX] -= tx;
954 f[j_coord_offset+DIM*0+YY] -= ty;
955 f[j_coord_offset+DIM*0+ZZ] -= tz;
959 /**************************
960 * CALCULATE INTERACTIONS *
961 **************************/
968 /* EWALD ELECTROSTATICS */
970 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
971 ewrt = r01*ewtabscale;
974 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
975 felec = qq01*rinv01*(rinvsq01-felec);
979 /* Calculate temporary vectorial force */
984 /* Update vectorial force */
988 f[j_coord_offset+DIM*1+XX] -= tx;
989 f[j_coord_offset+DIM*1+YY] -= ty;
990 f[j_coord_offset+DIM*1+ZZ] -= tz;
994 /**************************
995 * CALCULATE INTERACTIONS *
996 **************************/
1003 /* EWALD ELECTROSTATICS */
1005 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1006 ewrt = r02*ewtabscale;
1008 eweps = ewrt-ewitab;
1009 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1010 felec = qq02*rinv02*(rinvsq02-felec);
1014 /* Calculate temporary vectorial force */
1019 /* Update vectorial force */
1023 f[j_coord_offset+DIM*2+XX] -= tx;
1024 f[j_coord_offset+DIM*2+YY] -= ty;
1025 f[j_coord_offset+DIM*2+ZZ] -= tz;
1029 /**************************
1030 * CALCULATE INTERACTIONS *
1031 **************************/
1038 /* EWALD ELECTROSTATICS */
1040 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1041 ewrt = r10*ewtabscale;
1043 eweps = ewrt-ewitab;
1044 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1045 felec = qq10*rinv10*(rinvsq10-felec);
1049 /* Calculate temporary vectorial force */
1054 /* Update vectorial force */
1058 f[j_coord_offset+DIM*0+XX] -= tx;
1059 f[j_coord_offset+DIM*0+YY] -= ty;
1060 f[j_coord_offset+DIM*0+ZZ] -= tz;
1064 /**************************
1065 * CALCULATE INTERACTIONS *
1066 **************************/
1073 /* EWALD ELECTROSTATICS */
1075 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1076 ewrt = r11*ewtabscale;
1078 eweps = ewrt-ewitab;
1079 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1080 felec = qq11*rinv11*(rinvsq11-felec);
1084 /* Calculate temporary vectorial force */
1089 /* Update vectorial force */
1093 f[j_coord_offset+DIM*1+XX] -= tx;
1094 f[j_coord_offset+DIM*1+YY] -= ty;
1095 f[j_coord_offset+DIM*1+ZZ] -= tz;
1099 /**************************
1100 * CALCULATE INTERACTIONS *
1101 **************************/
1108 /* EWALD ELECTROSTATICS */
1110 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1111 ewrt = r12*ewtabscale;
1113 eweps = ewrt-ewitab;
1114 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1115 felec = qq12*rinv12*(rinvsq12-felec);
1119 /* Calculate temporary vectorial force */
1124 /* Update vectorial force */
1128 f[j_coord_offset+DIM*2+XX] -= tx;
1129 f[j_coord_offset+DIM*2+YY] -= ty;
1130 f[j_coord_offset+DIM*2+ZZ] -= tz;
1134 /**************************
1135 * CALCULATE INTERACTIONS *
1136 **************************/
1143 /* EWALD ELECTROSTATICS */
1145 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1146 ewrt = r20*ewtabscale;
1148 eweps = ewrt-ewitab;
1149 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1150 felec = qq20*rinv20*(rinvsq20-felec);
1154 /* Calculate temporary vectorial force */
1159 /* Update vectorial force */
1163 f[j_coord_offset+DIM*0+XX] -= tx;
1164 f[j_coord_offset+DIM*0+YY] -= ty;
1165 f[j_coord_offset+DIM*0+ZZ] -= tz;
1169 /**************************
1170 * CALCULATE INTERACTIONS *
1171 **************************/
1178 /* EWALD ELECTROSTATICS */
1180 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1181 ewrt = r21*ewtabscale;
1183 eweps = ewrt-ewitab;
1184 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1185 felec = qq21*rinv21*(rinvsq21-felec);
1189 /* Calculate temporary vectorial force */
1194 /* Update vectorial force */
1198 f[j_coord_offset+DIM*1+XX] -= tx;
1199 f[j_coord_offset+DIM*1+YY] -= ty;
1200 f[j_coord_offset+DIM*1+ZZ] -= tz;
1204 /**************************
1205 * CALCULATE INTERACTIONS *
1206 **************************/
1213 /* EWALD ELECTROSTATICS */
1215 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1216 ewrt = r22*ewtabscale;
1218 eweps = ewrt-ewitab;
1219 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1220 felec = qq22*rinv22*(rinvsq22-felec);
1224 /* Calculate temporary vectorial force */
1229 /* Update vectorial force */
1233 f[j_coord_offset+DIM*2+XX] -= tx;
1234 f[j_coord_offset+DIM*2+YY] -= ty;
1235 f[j_coord_offset+DIM*2+ZZ] -= tz;
1239 /* Inner loop uses 332 flops */
1241 /* End of innermost loop */
1244 f[i_coord_offset+DIM*0+XX] += fix0;
1245 f[i_coord_offset+DIM*0+YY] += fiy0;
1246 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1250 f[i_coord_offset+DIM*1+XX] += fix1;
1251 f[i_coord_offset+DIM*1+YY] += fiy1;
1252 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1256 f[i_coord_offset+DIM*2+XX] += fix2;
1257 f[i_coord_offset+DIM*2+YY] += fiy2;
1258 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1262 fshift[i_shift_offset+XX] += tx;
1263 fshift[i_shift_offset+YY] += ty;
1264 fshift[i_shift_offset+ZZ] += tz;
1266 /* Increment number of inner iterations */
1267 inneriter += j_index_end - j_index_start;
1269 /* Outer loop uses 30 flops */
1272 /* Increment number of outer iterations */
1275 /* Update outer/inner flops */
1277 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*332);