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_ElecEw_VdwBham_GeomW3W3_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwBham_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];
152 /* Start outer loop over neighborlists */
153 for(iidx=0; iidx<nri; iidx++)
155 /* Load shift vector for this list */
156 i_shift_offset = DIM*shiftidx[iidx];
157 shX = shiftvec[i_shift_offset+XX];
158 shY = shiftvec[i_shift_offset+YY];
159 shZ = shiftvec[i_shift_offset+ZZ];
161 /* Load limits for loop over neighbors */
162 j_index_start = jindex[iidx];
163 j_index_end = jindex[iidx+1];
165 /* Get outer coordinate index */
167 i_coord_offset = DIM*inr;
169 /* Load i particle coords and add shift vector */
170 ix0 = shX + x[i_coord_offset+DIM*0+XX];
171 iy0 = shY + x[i_coord_offset+DIM*0+YY];
172 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
173 ix1 = shX + x[i_coord_offset+DIM*1+XX];
174 iy1 = shY + x[i_coord_offset+DIM*1+YY];
175 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
176 ix2 = shX + x[i_coord_offset+DIM*2+XX];
177 iy2 = shY + x[i_coord_offset+DIM*2+YY];
178 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
190 /* Reset potential sums */
194 /* Start inner kernel loop */
195 for(jidx=j_index_start; jidx<j_index_end; jidx++)
197 /* Get j neighbor index, and coordinate index */
199 j_coord_offset = DIM*jnr;
201 /* load j atom coordinates */
202 jx0 = x[j_coord_offset+DIM*0+XX];
203 jy0 = x[j_coord_offset+DIM*0+YY];
204 jz0 = x[j_coord_offset+DIM*0+ZZ];
205 jx1 = x[j_coord_offset+DIM*1+XX];
206 jy1 = x[j_coord_offset+DIM*1+YY];
207 jz1 = x[j_coord_offset+DIM*1+ZZ];
208 jx2 = x[j_coord_offset+DIM*2+XX];
209 jy2 = x[j_coord_offset+DIM*2+YY];
210 jz2 = x[j_coord_offset+DIM*2+ZZ];
212 /* Calculate displacement vector */
241 /* Calculate squared distance and things based on it */
242 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
243 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
244 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
245 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
246 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
247 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
248 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
249 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
250 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
252 rinv00 = gmx_invsqrt(rsq00);
253 rinv01 = gmx_invsqrt(rsq01);
254 rinv02 = gmx_invsqrt(rsq02);
255 rinv10 = gmx_invsqrt(rsq10);
256 rinv11 = gmx_invsqrt(rsq11);
257 rinv12 = gmx_invsqrt(rsq12);
258 rinv20 = gmx_invsqrt(rsq20);
259 rinv21 = gmx_invsqrt(rsq21);
260 rinv22 = gmx_invsqrt(rsq22);
262 rinvsq00 = rinv00*rinv00;
263 rinvsq01 = rinv01*rinv01;
264 rinvsq02 = rinv02*rinv02;
265 rinvsq10 = rinv10*rinv10;
266 rinvsq11 = rinv11*rinv11;
267 rinvsq12 = rinv12*rinv12;
268 rinvsq20 = rinv20*rinv20;
269 rinvsq21 = rinv21*rinv21;
270 rinvsq22 = rinv22*rinv22;
272 /**************************
273 * CALCULATE INTERACTIONS *
274 **************************/
278 /* EWALD ELECTROSTATICS */
280 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
281 ewrt = r00*ewtabscale;
285 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
286 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
287 felec = qq00*rinv00*(rinvsq00-felec);
289 /* BUCKINGHAM DISPERSION/REPULSION */
290 rinvsix = rinvsq00*rinvsq00*rinvsq00;
291 vvdw6 = c6_00*rinvsix;
293 vvdwexp = cexp1_00*exp(-br);
294 vvdw = vvdwexp - vvdw6*(1.0/6.0);
295 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
297 /* Update potential sums from outer loop */
303 /* Calculate temporary vectorial force */
308 /* Update vectorial force */
312 f[j_coord_offset+DIM*0+XX] -= tx;
313 f[j_coord_offset+DIM*0+YY] -= ty;
314 f[j_coord_offset+DIM*0+ZZ] -= tz;
316 /**************************
317 * CALCULATE INTERACTIONS *
318 **************************/
322 /* EWALD ELECTROSTATICS */
324 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
325 ewrt = r01*ewtabscale;
329 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
330 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
331 felec = qq01*rinv01*(rinvsq01-felec);
333 /* Update potential sums from outer loop */
338 /* Calculate temporary vectorial force */
343 /* Update vectorial force */
347 f[j_coord_offset+DIM*1+XX] -= tx;
348 f[j_coord_offset+DIM*1+YY] -= ty;
349 f[j_coord_offset+DIM*1+ZZ] -= tz;
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
357 /* EWALD ELECTROSTATICS */
359 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
360 ewrt = r02*ewtabscale;
364 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
365 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
366 felec = qq02*rinv02*(rinvsq02-felec);
368 /* Update potential sums from outer loop */
373 /* Calculate temporary vectorial force */
378 /* Update vectorial force */
382 f[j_coord_offset+DIM*2+XX] -= tx;
383 f[j_coord_offset+DIM*2+YY] -= ty;
384 f[j_coord_offset+DIM*2+ZZ] -= tz;
386 /**************************
387 * CALCULATE INTERACTIONS *
388 **************************/
392 /* EWALD ELECTROSTATICS */
394 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
395 ewrt = r10*ewtabscale;
399 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
400 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
401 felec = qq10*rinv10*(rinvsq10-felec);
403 /* Update potential sums from outer loop */
408 /* Calculate temporary vectorial force */
413 /* Update vectorial force */
417 f[j_coord_offset+DIM*0+XX] -= tx;
418 f[j_coord_offset+DIM*0+YY] -= ty;
419 f[j_coord_offset+DIM*0+ZZ] -= tz;
421 /**************************
422 * CALCULATE INTERACTIONS *
423 **************************/
427 /* EWALD ELECTROSTATICS */
429 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
430 ewrt = r11*ewtabscale;
434 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
435 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
436 felec = qq11*rinv11*(rinvsq11-felec);
438 /* Update potential sums from outer loop */
443 /* Calculate temporary vectorial force */
448 /* Update vectorial force */
452 f[j_coord_offset+DIM*1+XX] -= tx;
453 f[j_coord_offset+DIM*1+YY] -= ty;
454 f[j_coord_offset+DIM*1+ZZ] -= tz;
456 /**************************
457 * CALCULATE INTERACTIONS *
458 **************************/
462 /* EWALD ELECTROSTATICS */
464 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
465 ewrt = r12*ewtabscale;
469 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
470 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
471 felec = qq12*rinv12*(rinvsq12-felec);
473 /* Update potential sums from outer loop */
478 /* Calculate temporary vectorial force */
483 /* Update vectorial force */
487 f[j_coord_offset+DIM*2+XX] -= tx;
488 f[j_coord_offset+DIM*2+YY] -= ty;
489 f[j_coord_offset+DIM*2+ZZ] -= tz;
491 /**************************
492 * CALCULATE INTERACTIONS *
493 **************************/
497 /* EWALD ELECTROSTATICS */
499 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
500 ewrt = r20*ewtabscale;
504 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
505 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
506 felec = qq20*rinv20*(rinvsq20-felec);
508 /* Update potential sums from outer loop */
513 /* Calculate temporary vectorial force */
518 /* Update vectorial force */
522 f[j_coord_offset+DIM*0+XX] -= tx;
523 f[j_coord_offset+DIM*0+YY] -= ty;
524 f[j_coord_offset+DIM*0+ZZ] -= tz;
526 /**************************
527 * CALCULATE INTERACTIONS *
528 **************************/
532 /* EWALD ELECTROSTATICS */
534 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
535 ewrt = r21*ewtabscale;
539 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
540 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
541 felec = qq21*rinv21*(rinvsq21-felec);
543 /* Update potential sums from outer loop */
548 /* Calculate temporary vectorial force */
553 /* Update vectorial force */
557 f[j_coord_offset+DIM*1+XX] -= tx;
558 f[j_coord_offset+DIM*1+YY] -= ty;
559 f[j_coord_offset+DIM*1+ZZ] -= tz;
561 /**************************
562 * CALCULATE INTERACTIONS *
563 **************************/
567 /* EWALD ELECTROSTATICS */
569 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
570 ewrt = r22*ewtabscale;
574 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
575 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
576 felec = qq22*rinv22*(rinvsq22-felec);
578 /* Update potential sums from outer loop */
583 /* Calculate temporary vectorial force */
588 /* Update vectorial force */
592 f[j_coord_offset+DIM*2+XX] -= tx;
593 f[j_coord_offset+DIM*2+YY] -= ty;
594 f[j_coord_offset+DIM*2+ZZ] -= tz;
596 /* Inner loop uses 398 flops */
598 /* End of innermost loop */
601 f[i_coord_offset+DIM*0+XX] += fix0;
602 f[i_coord_offset+DIM*0+YY] += fiy0;
603 f[i_coord_offset+DIM*0+ZZ] += fiz0;
607 f[i_coord_offset+DIM*1+XX] += fix1;
608 f[i_coord_offset+DIM*1+YY] += fiy1;
609 f[i_coord_offset+DIM*1+ZZ] += fiz1;
613 f[i_coord_offset+DIM*2+XX] += fix2;
614 f[i_coord_offset+DIM*2+YY] += fiy2;
615 f[i_coord_offset+DIM*2+ZZ] += fiz2;
619 fshift[i_shift_offset+XX] += tx;
620 fshift[i_shift_offset+YY] += ty;
621 fshift[i_shift_offset+ZZ] += tz;
624 /* Update potential energies */
625 kernel_data->energygrp_elec[ggid] += velecsum;
626 kernel_data->energygrp_vdw[ggid] += vvdwsum;
628 /* Increment number of inner iterations */
629 inneriter += j_index_end - j_index_start;
631 /* Outer loop uses 32 flops */
634 /* Increment number of outer iterations */
637 /* Update outer/inner flops */
639 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*398);
642 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW3W3_F_c
643 * Electrostatics interaction: Ewald
644 * VdW interaction: Buckingham
645 * Geometry: Water3-Water3
646 * Calculate force/pot: Force
649 nb_kernel_ElecEw_VdwBham_GeomW3W3_F_c
650 (t_nblist * gmx_restrict nlist,
651 rvec * gmx_restrict xx,
652 rvec * gmx_restrict ff,
653 t_forcerec * gmx_restrict fr,
654 t_mdatoms * gmx_restrict mdatoms,
655 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
656 t_nrnb * gmx_restrict nrnb)
658 int i_shift_offset,i_coord_offset,j_coord_offset;
659 int j_index_start,j_index_end;
660 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
661 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
662 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
663 real *shiftvec,*fshift,*x,*f;
665 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
667 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
669 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
671 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
673 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
675 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
676 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
677 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
678 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
679 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
680 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
681 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
682 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
683 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
684 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
685 real velec,felec,velecsum,facel,crf,krf,krf2;
688 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
692 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
700 jindex = nlist->jindex;
702 shiftidx = nlist->shift;
704 shiftvec = fr->shift_vec[0];
705 fshift = fr->fshift[0];
707 charge = mdatoms->chargeA;
708 nvdwtype = fr->ntype;
710 vdwtype = mdatoms->typeA;
712 sh_ewald = fr->ic->sh_ewald;
713 ewtab = fr->ic->tabq_coul_F;
714 ewtabscale = fr->ic->tabq_scale;
715 ewtabhalfspace = 0.5/ewtabscale;
717 /* Setup water-specific parameters */
718 inr = nlist->iinr[0];
719 iq0 = facel*charge[inr+0];
720 iq1 = facel*charge[inr+1];
721 iq2 = facel*charge[inr+2];
722 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
727 vdwjidx0 = 3*vdwtype[inr+0];
729 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
730 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
731 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
744 /* Start outer loop over neighborlists */
745 for(iidx=0; iidx<nri; iidx++)
747 /* Load shift vector for this list */
748 i_shift_offset = DIM*shiftidx[iidx];
749 shX = shiftvec[i_shift_offset+XX];
750 shY = shiftvec[i_shift_offset+YY];
751 shZ = shiftvec[i_shift_offset+ZZ];
753 /* Load limits for loop over neighbors */
754 j_index_start = jindex[iidx];
755 j_index_end = jindex[iidx+1];
757 /* Get outer coordinate index */
759 i_coord_offset = DIM*inr;
761 /* Load i particle coords and add shift vector */
762 ix0 = shX + x[i_coord_offset+DIM*0+XX];
763 iy0 = shY + x[i_coord_offset+DIM*0+YY];
764 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
765 ix1 = shX + x[i_coord_offset+DIM*1+XX];
766 iy1 = shY + x[i_coord_offset+DIM*1+YY];
767 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
768 ix2 = shX + x[i_coord_offset+DIM*2+XX];
769 iy2 = shY + x[i_coord_offset+DIM*2+YY];
770 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
782 /* Start inner kernel loop */
783 for(jidx=j_index_start; jidx<j_index_end; jidx++)
785 /* Get j neighbor index, and coordinate index */
787 j_coord_offset = DIM*jnr;
789 /* load j atom coordinates */
790 jx0 = x[j_coord_offset+DIM*0+XX];
791 jy0 = x[j_coord_offset+DIM*0+YY];
792 jz0 = x[j_coord_offset+DIM*0+ZZ];
793 jx1 = x[j_coord_offset+DIM*1+XX];
794 jy1 = x[j_coord_offset+DIM*1+YY];
795 jz1 = x[j_coord_offset+DIM*1+ZZ];
796 jx2 = x[j_coord_offset+DIM*2+XX];
797 jy2 = x[j_coord_offset+DIM*2+YY];
798 jz2 = x[j_coord_offset+DIM*2+ZZ];
800 /* Calculate displacement vector */
829 /* Calculate squared distance and things based on it */
830 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
831 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
832 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
833 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
834 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
835 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
836 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
837 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
838 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
840 rinv00 = gmx_invsqrt(rsq00);
841 rinv01 = gmx_invsqrt(rsq01);
842 rinv02 = gmx_invsqrt(rsq02);
843 rinv10 = gmx_invsqrt(rsq10);
844 rinv11 = gmx_invsqrt(rsq11);
845 rinv12 = gmx_invsqrt(rsq12);
846 rinv20 = gmx_invsqrt(rsq20);
847 rinv21 = gmx_invsqrt(rsq21);
848 rinv22 = gmx_invsqrt(rsq22);
850 rinvsq00 = rinv00*rinv00;
851 rinvsq01 = rinv01*rinv01;
852 rinvsq02 = rinv02*rinv02;
853 rinvsq10 = rinv10*rinv10;
854 rinvsq11 = rinv11*rinv11;
855 rinvsq12 = rinv12*rinv12;
856 rinvsq20 = rinv20*rinv20;
857 rinvsq21 = rinv21*rinv21;
858 rinvsq22 = rinv22*rinv22;
860 /**************************
861 * CALCULATE INTERACTIONS *
862 **************************/
866 /* EWALD ELECTROSTATICS */
868 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
869 ewrt = r00*ewtabscale;
872 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
873 felec = qq00*rinv00*(rinvsq00-felec);
875 /* BUCKINGHAM DISPERSION/REPULSION */
876 rinvsix = rinvsq00*rinvsq00*rinvsq00;
877 vvdw6 = c6_00*rinvsix;
879 vvdwexp = cexp1_00*exp(-br);
880 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
884 /* Calculate temporary vectorial force */
889 /* Update vectorial force */
893 f[j_coord_offset+DIM*0+XX] -= tx;
894 f[j_coord_offset+DIM*0+YY] -= ty;
895 f[j_coord_offset+DIM*0+ZZ] -= tz;
897 /**************************
898 * CALCULATE INTERACTIONS *
899 **************************/
903 /* EWALD ELECTROSTATICS */
905 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
906 ewrt = r01*ewtabscale;
909 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
910 felec = qq01*rinv01*(rinvsq01-felec);
914 /* Calculate temporary vectorial force */
919 /* Update vectorial force */
923 f[j_coord_offset+DIM*1+XX] -= tx;
924 f[j_coord_offset+DIM*1+YY] -= ty;
925 f[j_coord_offset+DIM*1+ZZ] -= tz;
927 /**************************
928 * CALCULATE INTERACTIONS *
929 **************************/
933 /* EWALD ELECTROSTATICS */
935 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
936 ewrt = r02*ewtabscale;
939 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
940 felec = qq02*rinv02*(rinvsq02-felec);
944 /* Calculate temporary vectorial force */
949 /* Update vectorial force */
953 f[j_coord_offset+DIM*2+XX] -= tx;
954 f[j_coord_offset+DIM*2+YY] -= ty;
955 f[j_coord_offset+DIM*2+ZZ] -= tz;
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
963 /* EWALD ELECTROSTATICS */
965 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
966 ewrt = r10*ewtabscale;
969 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
970 felec = qq10*rinv10*(rinvsq10-felec);
974 /* Calculate temporary vectorial force */
979 /* Update vectorial force */
983 f[j_coord_offset+DIM*0+XX] -= tx;
984 f[j_coord_offset+DIM*0+YY] -= ty;
985 f[j_coord_offset+DIM*0+ZZ] -= tz;
987 /**************************
988 * CALCULATE INTERACTIONS *
989 **************************/
993 /* EWALD ELECTROSTATICS */
995 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
996 ewrt = r11*ewtabscale;
999 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1000 felec = qq11*rinv11*(rinvsq11-felec);
1004 /* Calculate temporary vectorial force */
1009 /* Update vectorial force */
1013 f[j_coord_offset+DIM*1+XX] -= tx;
1014 f[j_coord_offset+DIM*1+YY] -= ty;
1015 f[j_coord_offset+DIM*1+ZZ] -= tz;
1017 /**************************
1018 * CALCULATE INTERACTIONS *
1019 **************************/
1023 /* EWALD ELECTROSTATICS */
1025 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1026 ewrt = r12*ewtabscale;
1028 eweps = ewrt-ewitab;
1029 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1030 felec = qq12*rinv12*(rinvsq12-felec);
1034 /* Calculate temporary vectorial force */
1039 /* Update vectorial force */
1043 f[j_coord_offset+DIM*2+XX] -= tx;
1044 f[j_coord_offset+DIM*2+YY] -= ty;
1045 f[j_coord_offset+DIM*2+ZZ] -= tz;
1047 /**************************
1048 * CALCULATE INTERACTIONS *
1049 **************************/
1053 /* EWALD ELECTROSTATICS */
1055 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1056 ewrt = r20*ewtabscale;
1058 eweps = ewrt-ewitab;
1059 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1060 felec = qq20*rinv20*(rinvsq20-felec);
1064 /* Calculate temporary vectorial force */
1069 /* Update vectorial force */
1073 f[j_coord_offset+DIM*0+XX] -= tx;
1074 f[j_coord_offset+DIM*0+YY] -= ty;
1075 f[j_coord_offset+DIM*0+ZZ] -= tz;
1077 /**************************
1078 * CALCULATE INTERACTIONS *
1079 **************************/
1083 /* EWALD ELECTROSTATICS */
1085 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1086 ewrt = r21*ewtabscale;
1088 eweps = ewrt-ewitab;
1089 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1090 felec = qq21*rinv21*(rinvsq21-felec);
1094 /* Calculate temporary vectorial force */
1099 /* Update vectorial force */
1103 f[j_coord_offset+DIM*1+XX] -= tx;
1104 f[j_coord_offset+DIM*1+YY] -= ty;
1105 f[j_coord_offset+DIM*1+ZZ] -= tz;
1107 /**************************
1108 * CALCULATE INTERACTIONS *
1109 **************************/
1113 /* EWALD ELECTROSTATICS */
1115 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1116 ewrt = r22*ewtabscale;
1118 eweps = ewrt-ewitab;
1119 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1120 felec = qq22*rinv22*(rinvsq22-felec);
1124 /* Calculate temporary vectorial force */
1129 /* Update vectorial force */
1133 f[j_coord_offset+DIM*2+XX] -= tx;
1134 f[j_coord_offset+DIM*2+YY] -= ty;
1135 f[j_coord_offset+DIM*2+ZZ] -= tz;
1137 /* Inner loop uses 332 flops */
1139 /* End of innermost loop */
1142 f[i_coord_offset+DIM*0+XX] += fix0;
1143 f[i_coord_offset+DIM*0+YY] += fiy0;
1144 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1148 f[i_coord_offset+DIM*1+XX] += fix1;
1149 f[i_coord_offset+DIM*1+YY] += fiy1;
1150 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1154 f[i_coord_offset+DIM*2+XX] += fix2;
1155 f[i_coord_offset+DIM*2+YY] += fiy2;
1156 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1160 fshift[i_shift_offset+XX] += tx;
1161 fshift[i_shift_offset+YY] += ty;
1162 fshift[i_shift_offset+ZZ] += tz;
1164 /* Increment number of inner iterations */
1165 inneriter += j_index_end - j_index_start;
1167 /* Outer loop uses 30 flops */
1170 /* Increment number of outer iterations */
1173 /* Update outer/inner flops */
1175 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*332);