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_VdwBham_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwBham_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];
150 /* Start outer loop over neighborlists */
151 for(iidx=0; iidx<nri; iidx++)
153 /* Load shift vector for this list */
154 i_shift_offset = DIM*shiftidx[iidx];
155 shX = shiftvec[i_shift_offset+XX];
156 shY = shiftvec[i_shift_offset+YY];
157 shZ = shiftvec[i_shift_offset+ZZ];
159 /* Load limits for loop over neighbors */
160 j_index_start = jindex[iidx];
161 j_index_end = jindex[iidx+1];
163 /* Get outer coordinate index */
165 i_coord_offset = DIM*inr;
167 /* Load i particle coords and add shift vector */
168 ix0 = shX + x[i_coord_offset+DIM*0+XX];
169 iy0 = shY + x[i_coord_offset+DIM*0+YY];
170 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
171 ix1 = shX + x[i_coord_offset+DIM*1+XX];
172 iy1 = shY + x[i_coord_offset+DIM*1+YY];
173 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
174 ix2 = shX + x[i_coord_offset+DIM*2+XX];
175 iy2 = shY + x[i_coord_offset+DIM*2+YY];
176 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
188 /* Reset potential sums */
192 /* Start inner kernel loop */
193 for(jidx=j_index_start; jidx<j_index_end; jidx++)
195 /* Get j neighbor index, and coordinate index */
197 j_coord_offset = DIM*jnr;
199 /* load j atom coordinates */
200 jx0 = x[j_coord_offset+DIM*0+XX];
201 jy0 = x[j_coord_offset+DIM*0+YY];
202 jz0 = x[j_coord_offset+DIM*0+ZZ];
203 jx1 = x[j_coord_offset+DIM*1+XX];
204 jy1 = x[j_coord_offset+DIM*1+YY];
205 jz1 = x[j_coord_offset+DIM*1+ZZ];
206 jx2 = x[j_coord_offset+DIM*2+XX];
207 jy2 = x[j_coord_offset+DIM*2+YY];
208 jz2 = x[j_coord_offset+DIM*2+ZZ];
210 /* Calculate displacement vector */
239 /* Calculate squared distance and things based on it */
240 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
241 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
242 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
243 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
244 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
245 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
246 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
247 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
248 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
250 rinv00 = gmx_invsqrt(rsq00);
251 rinv01 = gmx_invsqrt(rsq01);
252 rinv02 = gmx_invsqrt(rsq02);
253 rinv10 = gmx_invsqrt(rsq10);
254 rinv11 = gmx_invsqrt(rsq11);
255 rinv12 = gmx_invsqrt(rsq12);
256 rinv20 = gmx_invsqrt(rsq20);
257 rinv21 = gmx_invsqrt(rsq21);
258 rinv22 = gmx_invsqrt(rsq22);
260 rinvsq00 = rinv00*rinv00;
261 rinvsq01 = rinv01*rinv01;
262 rinvsq02 = rinv02*rinv02;
263 rinvsq10 = rinv10*rinv10;
264 rinvsq11 = rinv11*rinv11;
265 rinvsq12 = rinv12*rinv12;
266 rinvsq20 = rinv20*rinv20;
267 rinvsq21 = rinv21*rinv21;
268 rinvsq22 = rinv22*rinv22;
270 /**************************
271 * CALCULATE INTERACTIONS *
272 **************************/
276 /* EWALD ELECTROSTATICS */
278 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
279 ewrt = r00*ewtabscale;
283 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
284 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
285 felec = qq00*rinv00*(rinvsq00-felec);
287 /* BUCKINGHAM DISPERSION/REPULSION */
288 rinvsix = rinvsq00*rinvsq00*rinvsq00;
289 vvdw6 = c6_00*rinvsix;
291 vvdwexp = cexp1_00*exp(-br);
292 vvdw = vvdwexp - vvdw6*(1.0/6.0);
293 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
295 /* Update potential sums from outer loop */
301 /* Calculate temporary vectorial force */
306 /* Update vectorial force */
310 f[j_coord_offset+DIM*0+XX] -= tx;
311 f[j_coord_offset+DIM*0+YY] -= ty;
312 f[j_coord_offset+DIM*0+ZZ] -= tz;
314 /**************************
315 * CALCULATE INTERACTIONS *
316 **************************/
320 /* EWALD ELECTROSTATICS */
322 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
323 ewrt = r01*ewtabscale;
327 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
328 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
329 felec = qq01*rinv01*(rinvsq01-felec);
331 /* Update potential sums from outer loop */
336 /* Calculate temporary vectorial force */
341 /* Update vectorial force */
345 f[j_coord_offset+DIM*1+XX] -= tx;
346 f[j_coord_offset+DIM*1+YY] -= ty;
347 f[j_coord_offset+DIM*1+ZZ] -= tz;
349 /**************************
350 * CALCULATE INTERACTIONS *
351 **************************/
355 /* EWALD ELECTROSTATICS */
357 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
358 ewrt = r02*ewtabscale;
362 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
363 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
364 felec = qq02*rinv02*(rinvsq02-felec);
366 /* Update potential sums from outer loop */
371 /* Calculate temporary vectorial force */
376 /* Update vectorial force */
380 f[j_coord_offset+DIM*2+XX] -= tx;
381 f[j_coord_offset+DIM*2+YY] -= ty;
382 f[j_coord_offset+DIM*2+ZZ] -= tz;
384 /**************************
385 * CALCULATE INTERACTIONS *
386 **************************/
390 /* EWALD ELECTROSTATICS */
392 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
393 ewrt = r10*ewtabscale;
397 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
398 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
399 felec = qq10*rinv10*(rinvsq10-felec);
401 /* Update potential sums from outer loop */
406 /* Calculate temporary vectorial force */
411 /* Update vectorial force */
415 f[j_coord_offset+DIM*0+XX] -= tx;
416 f[j_coord_offset+DIM*0+YY] -= ty;
417 f[j_coord_offset+DIM*0+ZZ] -= tz;
419 /**************************
420 * CALCULATE INTERACTIONS *
421 **************************/
425 /* EWALD ELECTROSTATICS */
427 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
428 ewrt = r11*ewtabscale;
432 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
433 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
434 felec = qq11*rinv11*(rinvsq11-felec);
436 /* Update potential sums from outer loop */
441 /* Calculate temporary vectorial force */
446 /* Update vectorial force */
450 f[j_coord_offset+DIM*1+XX] -= tx;
451 f[j_coord_offset+DIM*1+YY] -= ty;
452 f[j_coord_offset+DIM*1+ZZ] -= tz;
454 /**************************
455 * CALCULATE INTERACTIONS *
456 **************************/
460 /* EWALD ELECTROSTATICS */
462 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
463 ewrt = r12*ewtabscale;
467 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
468 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
469 felec = qq12*rinv12*(rinvsq12-felec);
471 /* Update potential sums from outer loop */
476 /* Calculate temporary vectorial force */
481 /* Update vectorial force */
485 f[j_coord_offset+DIM*2+XX] -= tx;
486 f[j_coord_offset+DIM*2+YY] -= ty;
487 f[j_coord_offset+DIM*2+ZZ] -= tz;
489 /**************************
490 * CALCULATE INTERACTIONS *
491 **************************/
495 /* EWALD ELECTROSTATICS */
497 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
498 ewrt = r20*ewtabscale;
502 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
503 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
504 felec = qq20*rinv20*(rinvsq20-felec);
506 /* Update potential sums from outer loop */
511 /* Calculate temporary vectorial force */
516 /* Update vectorial force */
520 f[j_coord_offset+DIM*0+XX] -= tx;
521 f[j_coord_offset+DIM*0+YY] -= ty;
522 f[j_coord_offset+DIM*0+ZZ] -= tz;
524 /**************************
525 * CALCULATE INTERACTIONS *
526 **************************/
530 /* EWALD ELECTROSTATICS */
532 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
533 ewrt = r21*ewtabscale;
537 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
538 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
539 felec = qq21*rinv21*(rinvsq21-felec);
541 /* Update potential sums from outer loop */
546 /* Calculate temporary vectorial force */
551 /* Update vectorial force */
555 f[j_coord_offset+DIM*1+XX] -= tx;
556 f[j_coord_offset+DIM*1+YY] -= ty;
557 f[j_coord_offset+DIM*1+ZZ] -= tz;
559 /**************************
560 * CALCULATE INTERACTIONS *
561 **************************/
565 /* EWALD ELECTROSTATICS */
567 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
568 ewrt = r22*ewtabscale;
572 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
573 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
574 felec = qq22*rinv22*(rinvsq22-felec);
576 /* Update potential sums from outer loop */
581 /* Calculate temporary vectorial force */
586 /* Update vectorial force */
590 f[j_coord_offset+DIM*2+XX] -= tx;
591 f[j_coord_offset+DIM*2+YY] -= ty;
592 f[j_coord_offset+DIM*2+ZZ] -= tz;
594 /* Inner loop uses 398 flops */
596 /* End of innermost loop */
599 f[i_coord_offset+DIM*0+XX] += fix0;
600 f[i_coord_offset+DIM*0+YY] += fiy0;
601 f[i_coord_offset+DIM*0+ZZ] += fiz0;
605 f[i_coord_offset+DIM*1+XX] += fix1;
606 f[i_coord_offset+DIM*1+YY] += fiy1;
607 f[i_coord_offset+DIM*1+ZZ] += fiz1;
611 f[i_coord_offset+DIM*2+XX] += fix2;
612 f[i_coord_offset+DIM*2+YY] += fiy2;
613 f[i_coord_offset+DIM*2+ZZ] += fiz2;
617 fshift[i_shift_offset+XX] += tx;
618 fshift[i_shift_offset+YY] += ty;
619 fshift[i_shift_offset+ZZ] += tz;
622 /* Update potential energies */
623 kernel_data->energygrp_elec[ggid] += velecsum;
624 kernel_data->energygrp_vdw[ggid] += vvdwsum;
626 /* Increment number of inner iterations */
627 inneriter += j_index_end - j_index_start;
629 /* Outer loop uses 32 flops */
632 /* Increment number of outer iterations */
635 /* Update outer/inner flops */
637 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*398);
640 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW3W3_F_c
641 * Electrostatics interaction: Ewald
642 * VdW interaction: Buckingham
643 * Geometry: Water3-Water3
644 * Calculate force/pot: Force
647 nb_kernel_ElecEw_VdwBham_GeomW3W3_F_c
648 (t_nblist * gmx_restrict nlist,
649 rvec * gmx_restrict xx,
650 rvec * gmx_restrict ff,
651 t_forcerec * gmx_restrict fr,
652 t_mdatoms * gmx_restrict mdatoms,
653 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
654 t_nrnb * gmx_restrict nrnb)
656 int i_shift_offset,i_coord_offset,j_coord_offset;
657 int j_index_start,j_index_end;
658 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
659 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
660 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
661 real *shiftvec,*fshift,*x,*f;
663 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
665 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
667 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
669 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
671 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
673 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
674 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
675 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
676 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
677 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
678 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
679 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
680 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
681 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
682 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
683 real velec,felec,velecsum,facel,crf,krf,krf2;
686 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
690 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
698 jindex = nlist->jindex;
700 shiftidx = nlist->shift;
702 shiftvec = fr->shift_vec[0];
703 fshift = fr->fshift[0];
705 charge = mdatoms->chargeA;
706 nvdwtype = fr->ntype;
708 vdwtype = mdatoms->typeA;
710 sh_ewald = fr->ic->sh_ewald;
711 ewtab = fr->ic->tabq_coul_F;
712 ewtabscale = fr->ic->tabq_scale;
713 ewtabhalfspace = 0.5/ewtabscale;
715 /* Setup water-specific parameters */
716 inr = nlist->iinr[0];
717 iq0 = facel*charge[inr+0];
718 iq1 = facel*charge[inr+1];
719 iq2 = facel*charge[inr+2];
720 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
725 vdwjidx0 = 3*vdwtype[inr+0];
727 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
728 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
729 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
742 /* Start outer loop over neighborlists */
743 for(iidx=0; iidx<nri; iidx++)
745 /* Load shift vector for this list */
746 i_shift_offset = DIM*shiftidx[iidx];
747 shX = shiftvec[i_shift_offset+XX];
748 shY = shiftvec[i_shift_offset+YY];
749 shZ = shiftvec[i_shift_offset+ZZ];
751 /* Load limits for loop over neighbors */
752 j_index_start = jindex[iidx];
753 j_index_end = jindex[iidx+1];
755 /* Get outer coordinate index */
757 i_coord_offset = DIM*inr;
759 /* Load i particle coords and add shift vector */
760 ix0 = shX + x[i_coord_offset+DIM*0+XX];
761 iy0 = shY + x[i_coord_offset+DIM*0+YY];
762 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
763 ix1 = shX + x[i_coord_offset+DIM*1+XX];
764 iy1 = shY + x[i_coord_offset+DIM*1+YY];
765 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
766 ix2 = shX + x[i_coord_offset+DIM*2+XX];
767 iy2 = shY + x[i_coord_offset+DIM*2+YY];
768 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
780 /* Start inner kernel loop */
781 for(jidx=j_index_start; jidx<j_index_end; jidx++)
783 /* Get j neighbor index, and coordinate index */
785 j_coord_offset = DIM*jnr;
787 /* load j atom coordinates */
788 jx0 = x[j_coord_offset+DIM*0+XX];
789 jy0 = x[j_coord_offset+DIM*0+YY];
790 jz0 = x[j_coord_offset+DIM*0+ZZ];
791 jx1 = x[j_coord_offset+DIM*1+XX];
792 jy1 = x[j_coord_offset+DIM*1+YY];
793 jz1 = x[j_coord_offset+DIM*1+ZZ];
794 jx2 = x[j_coord_offset+DIM*2+XX];
795 jy2 = x[j_coord_offset+DIM*2+YY];
796 jz2 = x[j_coord_offset+DIM*2+ZZ];
798 /* Calculate displacement vector */
827 /* Calculate squared distance and things based on it */
828 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
829 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
830 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
831 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
832 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
833 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
834 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
835 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
836 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
838 rinv00 = gmx_invsqrt(rsq00);
839 rinv01 = gmx_invsqrt(rsq01);
840 rinv02 = gmx_invsqrt(rsq02);
841 rinv10 = gmx_invsqrt(rsq10);
842 rinv11 = gmx_invsqrt(rsq11);
843 rinv12 = gmx_invsqrt(rsq12);
844 rinv20 = gmx_invsqrt(rsq20);
845 rinv21 = gmx_invsqrt(rsq21);
846 rinv22 = gmx_invsqrt(rsq22);
848 rinvsq00 = rinv00*rinv00;
849 rinvsq01 = rinv01*rinv01;
850 rinvsq02 = rinv02*rinv02;
851 rinvsq10 = rinv10*rinv10;
852 rinvsq11 = rinv11*rinv11;
853 rinvsq12 = rinv12*rinv12;
854 rinvsq20 = rinv20*rinv20;
855 rinvsq21 = rinv21*rinv21;
856 rinvsq22 = rinv22*rinv22;
858 /**************************
859 * CALCULATE INTERACTIONS *
860 **************************/
864 /* EWALD ELECTROSTATICS */
866 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
867 ewrt = r00*ewtabscale;
870 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
871 felec = qq00*rinv00*(rinvsq00-felec);
873 /* BUCKINGHAM DISPERSION/REPULSION */
874 rinvsix = rinvsq00*rinvsq00*rinvsq00;
875 vvdw6 = c6_00*rinvsix;
877 vvdwexp = cexp1_00*exp(-br);
878 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
882 /* Calculate temporary vectorial force */
887 /* Update vectorial force */
891 f[j_coord_offset+DIM*0+XX] -= tx;
892 f[j_coord_offset+DIM*0+YY] -= ty;
893 f[j_coord_offset+DIM*0+ZZ] -= tz;
895 /**************************
896 * CALCULATE INTERACTIONS *
897 **************************/
901 /* EWALD ELECTROSTATICS */
903 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
904 ewrt = r01*ewtabscale;
907 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
908 felec = qq01*rinv01*(rinvsq01-felec);
912 /* Calculate temporary vectorial force */
917 /* Update vectorial force */
921 f[j_coord_offset+DIM*1+XX] -= tx;
922 f[j_coord_offset+DIM*1+YY] -= ty;
923 f[j_coord_offset+DIM*1+ZZ] -= tz;
925 /**************************
926 * CALCULATE INTERACTIONS *
927 **************************/
931 /* EWALD ELECTROSTATICS */
933 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
934 ewrt = r02*ewtabscale;
937 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
938 felec = qq02*rinv02*(rinvsq02-felec);
942 /* Calculate temporary vectorial force */
947 /* Update vectorial force */
951 f[j_coord_offset+DIM*2+XX] -= tx;
952 f[j_coord_offset+DIM*2+YY] -= ty;
953 f[j_coord_offset+DIM*2+ZZ] -= tz;
955 /**************************
956 * CALCULATE INTERACTIONS *
957 **************************/
961 /* EWALD ELECTROSTATICS */
963 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
964 ewrt = r10*ewtabscale;
967 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
968 felec = qq10*rinv10*(rinvsq10-felec);
972 /* Calculate temporary vectorial force */
977 /* Update vectorial force */
981 f[j_coord_offset+DIM*0+XX] -= tx;
982 f[j_coord_offset+DIM*0+YY] -= ty;
983 f[j_coord_offset+DIM*0+ZZ] -= tz;
985 /**************************
986 * CALCULATE INTERACTIONS *
987 **************************/
991 /* EWALD ELECTROSTATICS */
993 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
994 ewrt = r11*ewtabscale;
997 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
998 felec = qq11*rinv11*(rinvsq11-felec);
1002 /* Calculate temporary vectorial force */
1007 /* Update vectorial force */
1011 f[j_coord_offset+DIM*1+XX] -= tx;
1012 f[j_coord_offset+DIM*1+YY] -= ty;
1013 f[j_coord_offset+DIM*1+ZZ] -= tz;
1015 /**************************
1016 * CALCULATE INTERACTIONS *
1017 **************************/
1021 /* EWALD ELECTROSTATICS */
1023 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1024 ewrt = r12*ewtabscale;
1026 eweps = ewrt-ewitab;
1027 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1028 felec = qq12*rinv12*(rinvsq12-felec);
1032 /* Calculate temporary vectorial force */
1037 /* Update vectorial force */
1041 f[j_coord_offset+DIM*2+XX] -= tx;
1042 f[j_coord_offset+DIM*2+YY] -= ty;
1043 f[j_coord_offset+DIM*2+ZZ] -= tz;
1045 /**************************
1046 * CALCULATE INTERACTIONS *
1047 **************************/
1051 /* EWALD ELECTROSTATICS */
1053 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1054 ewrt = r20*ewtabscale;
1056 eweps = ewrt-ewitab;
1057 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1058 felec = qq20*rinv20*(rinvsq20-felec);
1062 /* Calculate temporary vectorial force */
1067 /* Update vectorial force */
1071 f[j_coord_offset+DIM*0+XX] -= tx;
1072 f[j_coord_offset+DIM*0+YY] -= ty;
1073 f[j_coord_offset+DIM*0+ZZ] -= tz;
1075 /**************************
1076 * CALCULATE INTERACTIONS *
1077 **************************/
1081 /* EWALD ELECTROSTATICS */
1083 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1084 ewrt = r21*ewtabscale;
1086 eweps = ewrt-ewitab;
1087 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1088 felec = qq21*rinv21*(rinvsq21-felec);
1092 /* Calculate temporary vectorial force */
1097 /* Update vectorial force */
1101 f[j_coord_offset+DIM*1+XX] -= tx;
1102 f[j_coord_offset+DIM*1+YY] -= ty;
1103 f[j_coord_offset+DIM*1+ZZ] -= tz;
1105 /**************************
1106 * CALCULATE INTERACTIONS *
1107 **************************/
1111 /* EWALD ELECTROSTATICS */
1113 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1114 ewrt = r22*ewtabscale;
1116 eweps = ewrt-ewitab;
1117 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1118 felec = qq22*rinv22*(rinvsq22-felec);
1122 /* Calculate temporary vectorial force */
1127 /* Update vectorial force */
1131 f[j_coord_offset+DIM*2+XX] -= tx;
1132 f[j_coord_offset+DIM*2+YY] -= ty;
1133 f[j_coord_offset+DIM*2+ZZ] -= tz;
1135 /* Inner loop uses 332 flops */
1137 /* End of innermost loop */
1140 f[i_coord_offset+DIM*0+XX] += fix0;
1141 f[i_coord_offset+DIM*0+YY] += fiy0;
1142 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1146 f[i_coord_offset+DIM*1+XX] += fix1;
1147 f[i_coord_offset+DIM*1+YY] += fiy1;
1148 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1152 f[i_coord_offset+DIM*2+XX] += fix2;
1153 f[i_coord_offset+DIM*2+YY] += fiy2;
1154 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1158 fshift[i_shift_offset+XX] += tx;
1159 fshift[i_shift_offset+YY] += ty;
1160 fshift[i_shift_offset+ZZ] += tz;
1162 /* Increment number of inner iterations */
1163 inneriter += j_index_end - j_index_start;
1165 /* Outer loop uses 30 flops */
1168 /* Increment number of outer iterations */
1171 /* Update outer/inner flops */
1173 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*332);