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 "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW3W3_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwBhamSh_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 = 3*nvdwtype*vdwtype[inr+0];
135 vdwjidx0 = 3*vdwtype[inr+0];
137 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
138 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
139 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
149 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
150 rcutoff = fr->rcoulomb;
151 rcutoff2 = rcutoff*rcutoff;
153 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
159 /* Start outer loop over neighborlists */
160 for(iidx=0; iidx<nri; iidx++)
162 /* Load shift vector for this list */
163 i_shift_offset = DIM*shiftidx[iidx];
164 shX = shiftvec[i_shift_offset+XX];
165 shY = shiftvec[i_shift_offset+YY];
166 shZ = shiftvec[i_shift_offset+ZZ];
168 /* Load limits for loop over neighbors */
169 j_index_start = jindex[iidx];
170 j_index_end = jindex[iidx+1];
172 /* Get outer coordinate index */
174 i_coord_offset = DIM*inr;
176 /* Load i particle coords and add shift vector */
177 ix0 = shX + x[i_coord_offset+DIM*0+XX];
178 iy0 = shY + x[i_coord_offset+DIM*0+YY];
179 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
180 ix1 = shX + x[i_coord_offset+DIM*1+XX];
181 iy1 = shY + x[i_coord_offset+DIM*1+YY];
182 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
183 ix2 = shX + x[i_coord_offset+DIM*2+XX];
184 iy2 = shY + x[i_coord_offset+DIM*2+YY];
185 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
197 /* Reset potential sums */
201 /* Start inner kernel loop */
202 for(jidx=j_index_start; jidx<j_index_end; jidx++)
204 /* Get j neighbor index, and coordinate index */
206 j_coord_offset = DIM*jnr;
208 /* load j atom coordinates */
209 jx0 = x[j_coord_offset+DIM*0+XX];
210 jy0 = x[j_coord_offset+DIM*0+YY];
211 jz0 = x[j_coord_offset+DIM*0+ZZ];
212 jx1 = x[j_coord_offset+DIM*1+XX];
213 jy1 = x[j_coord_offset+DIM*1+YY];
214 jz1 = x[j_coord_offset+DIM*1+ZZ];
215 jx2 = x[j_coord_offset+DIM*2+XX];
216 jy2 = x[j_coord_offset+DIM*2+YY];
217 jz2 = x[j_coord_offset+DIM*2+ZZ];
219 /* Calculate displacement vector */
248 /* Calculate squared distance and things based on it */
249 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
250 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
251 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
252 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
253 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
254 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
255 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
256 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
257 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
259 rinv00 = gmx_invsqrt(rsq00);
260 rinv01 = gmx_invsqrt(rsq01);
261 rinv02 = gmx_invsqrt(rsq02);
262 rinv10 = gmx_invsqrt(rsq10);
263 rinv11 = gmx_invsqrt(rsq11);
264 rinv12 = gmx_invsqrt(rsq12);
265 rinv20 = gmx_invsqrt(rsq20);
266 rinv21 = gmx_invsqrt(rsq21);
267 rinv22 = gmx_invsqrt(rsq22);
269 rinvsq00 = rinv00*rinv00;
270 rinvsq01 = rinv01*rinv01;
271 rinvsq02 = rinv02*rinv02;
272 rinvsq10 = rinv10*rinv10;
273 rinvsq11 = rinv11*rinv11;
274 rinvsq12 = rinv12*rinv12;
275 rinvsq20 = rinv20*rinv20;
276 rinvsq21 = rinv21*rinv21;
277 rinvsq22 = rinv22*rinv22;
279 /**************************
280 * CALCULATE INTERACTIONS *
281 **************************/
288 /* EWALD ELECTROSTATICS */
290 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
291 ewrt = r00*ewtabscale;
295 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
296 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
297 felec = qq00*rinv00*(rinvsq00-felec);
299 /* BUCKINGHAM DISPERSION/REPULSION */
300 rinvsix = rinvsq00*rinvsq00*rinvsq00;
301 vvdw6 = c6_00*rinvsix;
303 vvdwexp = cexp1_00*exp(-br);
304 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
305 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
307 /* Update potential sums from outer loop */
313 /* Calculate temporary vectorial force */
318 /* Update vectorial force */
322 f[j_coord_offset+DIM*0+XX] -= tx;
323 f[j_coord_offset+DIM*0+YY] -= ty;
324 f[j_coord_offset+DIM*0+ZZ] -= tz;
328 /**************************
329 * CALCULATE INTERACTIONS *
330 **************************/
337 /* EWALD ELECTROSTATICS */
339 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
340 ewrt = r01*ewtabscale;
344 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
345 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
346 felec = qq01*rinv01*(rinvsq01-felec);
348 /* Update potential sums from outer loop */
353 /* Calculate temporary vectorial force */
358 /* Update vectorial force */
362 f[j_coord_offset+DIM*1+XX] -= tx;
363 f[j_coord_offset+DIM*1+YY] -= ty;
364 f[j_coord_offset+DIM*1+ZZ] -= tz;
368 /**************************
369 * CALCULATE INTERACTIONS *
370 **************************/
377 /* EWALD ELECTROSTATICS */
379 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
380 ewrt = r02*ewtabscale;
384 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
385 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
386 felec = qq02*rinv02*(rinvsq02-felec);
388 /* Update potential sums from outer loop */
393 /* Calculate temporary vectorial force */
398 /* Update vectorial force */
402 f[j_coord_offset+DIM*2+XX] -= tx;
403 f[j_coord_offset+DIM*2+YY] -= ty;
404 f[j_coord_offset+DIM*2+ZZ] -= tz;
408 /**************************
409 * CALCULATE INTERACTIONS *
410 **************************/
417 /* EWALD ELECTROSTATICS */
419 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
420 ewrt = r10*ewtabscale;
424 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
425 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
426 felec = qq10*rinv10*(rinvsq10-felec);
428 /* Update potential sums from outer loop */
433 /* Calculate temporary vectorial force */
438 /* Update vectorial force */
442 f[j_coord_offset+DIM*0+XX] -= tx;
443 f[j_coord_offset+DIM*0+YY] -= ty;
444 f[j_coord_offset+DIM*0+ZZ] -= tz;
448 /**************************
449 * CALCULATE INTERACTIONS *
450 **************************/
457 /* EWALD ELECTROSTATICS */
459 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
460 ewrt = r11*ewtabscale;
464 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
465 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
466 felec = qq11*rinv11*(rinvsq11-felec);
468 /* Update potential sums from outer loop */
473 /* Calculate temporary vectorial force */
478 /* Update vectorial force */
482 f[j_coord_offset+DIM*1+XX] -= tx;
483 f[j_coord_offset+DIM*1+YY] -= ty;
484 f[j_coord_offset+DIM*1+ZZ] -= tz;
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
497 /* EWALD ELECTROSTATICS */
499 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
500 ewrt = r12*ewtabscale;
504 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
505 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
506 felec = qq12*rinv12*(rinvsq12-felec);
508 /* Update potential sums from outer loop */
513 /* Calculate temporary vectorial force */
518 /* Update vectorial force */
522 f[j_coord_offset+DIM*2+XX] -= tx;
523 f[j_coord_offset+DIM*2+YY] -= ty;
524 f[j_coord_offset+DIM*2+ZZ] -= tz;
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
537 /* EWALD ELECTROSTATICS */
539 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
540 ewrt = r20*ewtabscale;
544 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
545 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
546 felec = qq20*rinv20*(rinvsq20-felec);
548 /* Update potential sums from outer loop */
553 /* Calculate temporary vectorial force */
558 /* Update vectorial force */
562 f[j_coord_offset+DIM*0+XX] -= tx;
563 f[j_coord_offset+DIM*0+YY] -= ty;
564 f[j_coord_offset+DIM*0+ZZ] -= tz;
568 /**************************
569 * CALCULATE INTERACTIONS *
570 **************************/
577 /* EWALD ELECTROSTATICS */
579 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
580 ewrt = r21*ewtabscale;
584 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
585 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
586 felec = qq21*rinv21*(rinvsq21-felec);
588 /* Update potential sums from outer loop */
593 /* Calculate temporary vectorial force */
598 /* Update vectorial force */
602 f[j_coord_offset+DIM*1+XX] -= tx;
603 f[j_coord_offset+DIM*1+YY] -= ty;
604 f[j_coord_offset+DIM*1+ZZ] -= tz;
608 /**************************
609 * CALCULATE INTERACTIONS *
610 **************************/
617 /* EWALD ELECTROSTATICS */
619 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
620 ewrt = r22*ewtabscale;
624 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
625 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
626 felec = qq22*rinv22*(rinvsq22-felec);
628 /* Update potential sums from outer loop */
633 /* Calculate temporary vectorial force */
638 /* Update vectorial force */
642 f[j_coord_offset+DIM*2+XX] -= tx;
643 f[j_coord_offset+DIM*2+YY] -= ty;
644 f[j_coord_offset+DIM*2+ZZ] -= tz;
648 /* Inner loop uses 438 flops */
650 /* End of innermost loop */
653 f[i_coord_offset+DIM*0+XX] += fix0;
654 f[i_coord_offset+DIM*0+YY] += fiy0;
655 f[i_coord_offset+DIM*0+ZZ] += fiz0;
659 f[i_coord_offset+DIM*1+XX] += fix1;
660 f[i_coord_offset+DIM*1+YY] += fiy1;
661 f[i_coord_offset+DIM*1+ZZ] += fiz1;
665 f[i_coord_offset+DIM*2+XX] += fix2;
666 f[i_coord_offset+DIM*2+YY] += fiy2;
667 f[i_coord_offset+DIM*2+ZZ] += fiz2;
671 fshift[i_shift_offset+XX] += tx;
672 fshift[i_shift_offset+YY] += ty;
673 fshift[i_shift_offset+ZZ] += tz;
676 /* Update potential energies */
677 kernel_data->energygrp_elec[ggid] += velecsum;
678 kernel_data->energygrp_vdw[ggid] += vvdwsum;
680 /* Increment number of inner iterations */
681 inneriter += j_index_end - j_index_start;
683 /* Outer loop uses 32 flops */
686 /* Increment number of outer iterations */
689 /* Update outer/inner flops */
691 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*438);
694 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW3W3_F_c
695 * Electrostatics interaction: Ewald
696 * VdW interaction: Buckingham
697 * Geometry: Water3-Water3
698 * Calculate force/pot: Force
701 nb_kernel_ElecEwSh_VdwBhamSh_GeomW3W3_F_c
702 (t_nblist * gmx_restrict nlist,
703 rvec * gmx_restrict xx,
704 rvec * gmx_restrict ff,
705 t_forcerec * gmx_restrict fr,
706 t_mdatoms * gmx_restrict mdatoms,
707 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
708 t_nrnb * gmx_restrict nrnb)
710 int i_shift_offset,i_coord_offset,j_coord_offset;
711 int j_index_start,j_index_end;
712 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
713 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
714 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
715 real *shiftvec,*fshift,*x,*f;
717 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
719 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
721 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
723 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
725 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
727 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
728 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
729 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
730 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
731 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
732 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
733 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
734 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
735 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
736 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
737 real velec,felec,velecsum,facel,crf,krf,krf2;
740 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
744 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
752 jindex = nlist->jindex;
754 shiftidx = nlist->shift;
756 shiftvec = fr->shift_vec[0];
757 fshift = fr->fshift[0];
759 charge = mdatoms->chargeA;
760 nvdwtype = fr->ntype;
762 vdwtype = mdatoms->typeA;
764 sh_ewald = fr->ic->sh_ewald;
765 ewtab = fr->ic->tabq_coul_F;
766 ewtabscale = fr->ic->tabq_scale;
767 ewtabhalfspace = 0.5/ewtabscale;
769 /* Setup water-specific parameters */
770 inr = nlist->iinr[0];
771 iq0 = facel*charge[inr+0];
772 iq1 = facel*charge[inr+1];
773 iq2 = facel*charge[inr+2];
774 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
779 vdwjidx0 = 3*vdwtype[inr+0];
781 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
782 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
783 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
793 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
794 rcutoff = fr->rcoulomb;
795 rcutoff2 = rcutoff*rcutoff;
797 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
803 /* Start outer loop over neighborlists */
804 for(iidx=0; iidx<nri; iidx++)
806 /* Load shift vector for this list */
807 i_shift_offset = DIM*shiftidx[iidx];
808 shX = shiftvec[i_shift_offset+XX];
809 shY = shiftvec[i_shift_offset+YY];
810 shZ = shiftvec[i_shift_offset+ZZ];
812 /* Load limits for loop over neighbors */
813 j_index_start = jindex[iidx];
814 j_index_end = jindex[iidx+1];
816 /* Get outer coordinate index */
818 i_coord_offset = DIM*inr;
820 /* Load i particle coords and add shift vector */
821 ix0 = shX + x[i_coord_offset+DIM*0+XX];
822 iy0 = shY + x[i_coord_offset+DIM*0+YY];
823 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
824 ix1 = shX + x[i_coord_offset+DIM*1+XX];
825 iy1 = shY + x[i_coord_offset+DIM*1+YY];
826 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
827 ix2 = shX + x[i_coord_offset+DIM*2+XX];
828 iy2 = shY + x[i_coord_offset+DIM*2+YY];
829 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
841 /* Start inner kernel loop */
842 for(jidx=j_index_start; jidx<j_index_end; jidx++)
844 /* Get j neighbor index, and coordinate index */
846 j_coord_offset = DIM*jnr;
848 /* load j atom coordinates */
849 jx0 = x[j_coord_offset+DIM*0+XX];
850 jy0 = x[j_coord_offset+DIM*0+YY];
851 jz0 = x[j_coord_offset+DIM*0+ZZ];
852 jx1 = x[j_coord_offset+DIM*1+XX];
853 jy1 = x[j_coord_offset+DIM*1+YY];
854 jz1 = x[j_coord_offset+DIM*1+ZZ];
855 jx2 = x[j_coord_offset+DIM*2+XX];
856 jy2 = x[j_coord_offset+DIM*2+YY];
857 jz2 = x[j_coord_offset+DIM*2+ZZ];
859 /* Calculate displacement vector */
888 /* Calculate squared distance and things based on it */
889 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
890 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
891 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
892 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
893 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
894 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
895 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
896 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
897 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
899 rinv00 = gmx_invsqrt(rsq00);
900 rinv01 = gmx_invsqrt(rsq01);
901 rinv02 = gmx_invsqrt(rsq02);
902 rinv10 = gmx_invsqrt(rsq10);
903 rinv11 = gmx_invsqrt(rsq11);
904 rinv12 = gmx_invsqrt(rsq12);
905 rinv20 = gmx_invsqrt(rsq20);
906 rinv21 = gmx_invsqrt(rsq21);
907 rinv22 = gmx_invsqrt(rsq22);
909 rinvsq00 = rinv00*rinv00;
910 rinvsq01 = rinv01*rinv01;
911 rinvsq02 = rinv02*rinv02;
912 rinvsq10 = rinv10*rinv10;
913 rinvsq11 = rinv11*rinv11;
914 rinvsq12 = rinv12*rinv12;
915 rinvsq20 = rinv20*rinv20;
916 rinvsq21 = rinv21*rinv21;
917 rinvsq22 = rinv22*rinv22;
919 /**************************
920 * CALCULATE INTERACTIONS *
921 **************************/
928 /* EWALD ELECTROSTATICS */
930 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
931 ewrt = r00*ewtabscale;
934 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
935 felec = qq00*rinv00*(rinvsq00-felec);
937 /* BUCKINGHAM DISPERSION/REPULSION */
938 rinvsix = rinvsq00*rinvsq00*rinvsq00;
939 vvdw6 = c6_00*rinvsix;
941 vvdwexp = cexp1_00*exp(-br);
942 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
946 /* Calculate temporary vectorial force */
951 /* Update vectorial force */
955 f[j_coord_offset+DIM*0+XX] -= tx;
956 f[j_coord_offset+DIM*0+YY] -= ty;
957 f[j_coord_offset+DIM*0+ZZ] -= tz;
961 /**************************
962 * CALCULATE INTERACTIONS *
963 **************************/
970 /* EWALD ELECTROSTATICS */
972 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
973 ewrt = r01*ewtabscale;
976 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
977 felec = qq01*rinv01*(rinvsq01-felec);
981 /* Calculate temporary vectorial force */
986 /* Update vectorial force */
990 f[j_coord_offset+DIM*1+XX] -= tx;
991 f[j_coord_offset+DIM*1+YY] -= ty;
992 f[j_coord_offset+DIM*1+ZZ] -= tz;
996 /**************************
997 * CALCULATE INTERACTIONS *
998 **************************/
1005 /* EWALD ELECTROSTATICS */
1007 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1008 ewrt = r02*ewtabscale;
1010 eweps = ewrt-ewitab;
1011 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1012 felec = qq02*rinv02*(rinvsq02-felec);
1016 /* Calculate temporary vectorial force */
1021 /* Update vectorial force */
1025 f[j_coord_offset+DIM*2+XX] -= tx;
1026 f[j_coord_offset+DIM*2+YY] -= ty;
1027 f[j_coord_offset+DIM*2+ZZ] -= tz;
1031 /**************************
1032 * CALCULATE INTERACTIONS *
1033 **************************/
1040 /* EWALD ELECTROSTATICS */
1042 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1043 ewrt = r10*ewtabscale;
1045 eweps = ewrt-ewitab;
1046 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1047 felec = qq10*rinv10*(rinvsq10-felec);
1051 /* Calculate temporary vectorial force */
1056 /* Update vectorial force */
1060 f[j_coord_offset+DIM*0+XX] -= tx;
1061 f[j_coord_offset+DIM*0+YY] -= ty;
1062 f[j_coord_offset+DIM*0+ZZ] -= tz;
1066 /**************************
1067 * CALCULATE INTERACTIONS *
1068 **************************/
1075 /* EWALD ELECTROSTATICS */
1077 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1078 ewrt = r11*ewtabscale;
1080 eweps = ewrt-ewitab;
1081 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1082 felec = qq11*rinv11*(rinvsq11-felec);
1086 /* Calculate temporary vectorial force */
1091 /* Update vectorial force */
1095 f[j_coord_offset+DIM*1+XX] -= tx;
1096 f[j_coord_offset+DIM*1+YY] -= ty;
1097 f[j_coord_offset+DIM*1+ZZ] -= tz;
1101 /**************************
1102 * CALCULATE INTERACTIONS *
1103 **************************/
1110 /* EWALD ELECTROSTATICS */
1112 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1113 ewrt = r12*ewtabscale;
1115 eweps = ewrt-ewitab;
1116 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1117 felec = qq12*rinv12*(rinvsq12-felec);
1121 /* Calculate temporary vectorial force */
1126 /* Update vectorial force */
1130 f[j_coord_offset+DIM*2+XX] -= tx;
1131 f[j_coord_offset+DIM*2+YY] -= ty;
1132 f[j_coord_offset+DIM*2+ZZ] -= tz;
1136 /**************************
1137 * CALCULATE INTERACTIONS *
1138 **************************/
1145 /* EWALD ELECTROSTATICS */
1147 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1148 ewrt = r20*ewtabscale;
1150 eweps = ewrt-ewitab;
1151 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1152 felec = qq20*rinv20*(rinvsq20-felec);
1156 /* Calculate temporary vectorial force */
1161 /* Update vectorial force */
1165 f[j_coord_offset+DIM*0+XX] -= tx;
1166 f[j_coord_offset+DIM*0+YY] -= ty;
1167 f[j_coord_offset+DIM*0+ZZ] -= tz;
1171 /**************************
1172 * CALCULATE INTERACTIONS *
1173 **************************/
1180 /* EWALD ELECTROSTATICS */
1182 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1183 ewrt = r21*ewtabscale;
1185 eweps = ewrt-ewitab;
1186 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1187 felec = qq21*rinv21*(rinvsq21-felec);
1191 /* Calculate temporary vectorial force */
1196 /* Update vectorial force */
1200 f[j_coord_offset+DIM*1+XX] -= tx;
1201 f[j_coord_offset+DIM*1+YY] -= ty;
1202 f[j_coord_offset+DIM*1+ZZ] -= tz;
1206 /**************************
1207 * CALCULATE INTERACTIONS *
1208 **************************/
1215 /* EWALD ELECTROSTATICS */
1217 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1218 ewrt = r22*ewtabscale;
1220 eweps = ewrt-ewitab;
1221 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1222 felec = qq22*rinv22*(rinvsq22-felec);
1226 /* Calculate temporary vectorial force */
1231 /* Update vectorial force */
1235 f[j_coord_offset+DIM*2+XX] -= tx;
1236 f[j_coord_offset+DIM*2+YY] -= ty;
1237 f[j_coord_offset+DIM*2+ZZ] -= tz;
1241 /* Inner loop uses 332 flops */
1243 /* End of innermost loop */
1246 f[i_coord_offset+DIM*0+XX] += fix0;
1247 f[i_coord_offset+DIM*0+YY] += fiy0;
1248 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1252 f[i_coord_offset+DIM*1+XX] += fix1;
1253 f[i_coord_offset+DIM*1+YY] += fiy1;
1254 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1258 f[i_coord_offset+DIM*2+XX] += fix2;
1259 f[i_coord_offset+DIM*2+YY] += fiy2;
1260 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1264 fshift[i_shift_offset+XX] += tx;
1265 fshift[i_shift_offset+YY] += ty;
1266 fshift[i_shift_offset+ZZ] += tz;
1268 /* Increment number of inner iterations */
1269 inneriter += j_index_end - j_index_start;
1271 /* Outer loop uses 30 flops */
1274 /* Increment number of outer iterations */
1277 /* Update outer/inner flops */
1279 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*332);