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 "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJEw_GeomW3W3_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LJEwald
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwLJEw_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;
108 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
111 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
119 jindex = nlist->jindex;
121 shiftidx = nlist->shift;
123 shiftvec = fr->shift_vec[0];
124 fshift = fr->fshift[0];
126 charge = mdatoms->chargeA;
127 nvdwtype = fr->ntype;
129 vdwtype = mdatoms->typeA;
130 vdwgridparam = fr->ljpme_c6grid;
131 ewclj = fr->ewaldcoeff_lj;
132 sh_lj_ewald = fr->ic->sh_lj_ewald;
133 ewclj2 = ewclj*ewclj;
134 ewclj6 = ewclj2*ewclj2*ewclj2;
136 sh_ewald = fr->ic->sh_ewald;
137 ewtab = fr->ic->tabq_coul_FDV0;
138 ewtabscale = fr->ic->tabq_scale;
139 ewtabhalfspace = 0.5/ewtabscale;
141 /* Setup water-specific parameters */
142 inr = nlist->iinr[0];
143 iq0 = facel*charge[inr+0];
144 iq1 = facel*charge[inr+1];
145 iq2 = facel*charge[inr+2];
146 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
151 vdwjidx0 = 2*vdwtype[inr+0];
153 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
154 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
155 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
168 /* Start outer loop over neighborlists */
169 for(iidx=0; iidx<nri; iidx++)
171 /* Load shift vector for this list */
172 i_shift_offset = DIM*shiftidx[iidx];
173 shX = shiftvec[i_shift_offset+XX];
174 shY = shiftvec[i_shift_offset+YY];
175 shZ = shiftvec[i_shift_offset+ZZ];
177 /* Load limits for loop over neighbors */
178 j_index_start = jindex[iidx];
179 j_index_end = jindex[iidx+1];
181 /* Get outer coordinate index */
183 i_coord_offset = DIM*inr;
185 /* Load i particle coords and add shift vector */
186 ix0 = shX + x[i_coord_offset+DIM*0+XX];
187 iy0 = shY + x[i_coord_offset+DIM*0+YY];
188 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
189 ix1 = shX + x[i_coord_offset+DIM*1+XX];
190 iy1 = shY + x[i_coord_offset+DIM*1+YY];
191 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
192 ix2 = shX + x[i_coord_offset+DIM*2+XX];
193 iy2 = shY + x[i_coord_offset+DIM*2+YY];
194 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
206 /* Reset potential sums */
210 /* Start inner kernel loop */
211 for(jidx=j_index_start; jidx<j_index_end; jidx++)
213 /* Get j neighbor index, and coordinate index */
215 j_coord_offset = DIM*jnr;
217 /* load j atom coordinates */
218 jx0 = x[j_coord_offset+DIM*0+XX];
219 jy0 = x[j_coord_offset+DIM*0+YY];
220 jz0 = x[j_coord_offset+DIM*0+ZZ];
221 jx1 = x[j_coord_offset+DIM*1+XX];
222 jy1 = x[j_coord_offset+DIM*1+YY];
223 jz1 = x[j_coord_offset+DIM*1+ZZ];
224 jx2 = x[j_coord_offset+DIM*2+XX];
225 jy2 = x[j_coord_offset+DIM*2+YY];
226 jz2 = x[j_coord_offset+DIM*2+ZZ];
228 /* Calculate displacement vector */
257 /* Calculate squared distance and things based on it */
258 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
259 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
260 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
261 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
262 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
263 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
264 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
265 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
266 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
268 rinv00 = gmx_invsqrt(rsq00);
269 rinv01 = gmx_invsqrt(rsq01);
270 rinv02 = gmx_invsqrt(rsq02);
271 rinv10 = gmx_invsqrt(rsq10);
272 rinv11 = gmx_invsqrt(rsq11);
273 rinv12 = gmx_invsqrt(rsq12);
274 rinv20 = gmx_invsqrt(rsq20);
275 rinv21 = gmx_invsqrt(rsq21);
276 rinv22 = gmx_invsqrt(rsq22);
278 rinvsq00 = rinv00*rinv00;
279 rinvsq01 = rinv01*rinv01;
280 rinvsq02 = rinv02*rinv02;
281 rinvsq10 = rinv10*rinv10;
282 rinvsq11 = rinv11*rinv11;
283 rinvsq12 = rinv12*rinv12;
284 rinvsq20 = rinv20*rinv20;
285 rinvsq21 = rinv21*rinv21;
286 rinvsq22 = rinv22*rinv22;
288 /**************************
289 * CALCULATE INTERACTIONS *
290 **************************/
294 /* EWALD ELECTROSTATICS */
296 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
297 ewrt = r00*ewtabscale;
301 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
302 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
303 felec = qq00*rinv00*(rinvsq00-felec);
305 rinvsix = rinvsq00*rinvsq00*rinvsq00;
306 ewcljrsq = ewclj2*rsq00;
307 exponent = exp(-ewcljrsq);
308 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
309 vvdw6 = (c6_00-c6grid_00*(1.0-poly))*rinvsix;
310 vvdw12 = c12_00*rinvsix*rinvsix;
311 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
312 fvdw = (vvdw12 - vvdw6 - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
314 /* Update potential sums from outer loop */
320 /* Calculate temporary vectorial force */
325 /* Update vectorial force */
329 f[j_coord_offset+DIM*0+XX] -= tx;
330 f[j_coord_offset+DIM*0+YY] -= ty;
331 f[j_coord_offset+DIM*0+ZZ] -= tz;
333 /**************************
334 * CALCULATE INTERACTIONS *
335 **************************/
339 /* EWALD ELECTROSTATICS */
341 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
342 ewrt = r01*ewtabscale;
346 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
347 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
348 felec = qq01*rinv01*(rinvsq01-felec);
350 /* Update potential sums from outer loop */
355 /* Calculate temporary vectorial force */
360 /* Update vectorial force */
364 f[j_coord_offset+DIM*1+XX] -= tx;
365 f[j_coord_offset+DIM*1+YY] -= ty;
366 f[j_coord_offset+DIM*1+ZZ] -= tz;
368 /**************************
369 * CALCULATE INTERACTIONS *
370 **************************/
374 /* EWALD ELECTROSTATICS */
376 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
377 ewrt = r02*ewtabscale;
381 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
382 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
383 felec = qq02*rinv02*(rinvsq02-felec);
385 /* Update potential sums from outer loop */
390 /* Calculate temporary vectorial force */
395 /* Update vectorial force */
399 f[j_coord_offset+DIM*2+XX] -= tx;
400 f[j_coord_offset+DIM*2+YY] -= ty;
401 f[j_coord_offset+DIM*2+ZZ] -= tz;
403 /**************************
404 * CALCULATE INTERACTIONS *
405 **************************/
409 /* EWALD ELECTROSTATICS */
411 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
412 ewrt = r10*ewtabscale;
416 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
417 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
418 felec = qq10*rinv10*(rinvsq10-felec);
420 /* Update potential sums from outer loop */
425 /* Calculate temporary vectorial force */
430 /* Update vectorial force */
434 f[j_coord_offset+DIM*0+XX] -= tx;
435 f[j_coord_offset+DIM*0+YY] -= ty;
436 f[j_coord_offset+DIM*0+ZZ] -= tz;
438 /**************************
439 * CALCULATE INTERACTIONS *
440 **************************/
444 /* EWALD ELECTROSTATICS */
446 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
447 ewrt = r11*ewtabscale;
451 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
452 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
453 felec = qq11*rinv11*(rinvsq11-felec);
455 /* Update potential sums from outer loop */
460 /* Calculate temporary vectorial force */
465 /* Update vectorial force */
469 f[j_coord_offset+DIM*1+XX] -= tx;
470 f[j_coord_offset+DIM*1+YY] -= ty;
471 f[j_coord_offset+DIM*1+ZZ] -= tz;
473 /**************************
474 * CALCULATE INTERACTIONS *
475 **************************/
479 /* EWALD ELECTROSTATICS */
481 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
482 ewrt = r12*ewtabscale;
486 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
487 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
488 felec = qq12*rinv12*(rinvsq12-felec);
490 /* Update potential sums from outer loop */
495 /* Calculate temporary vectorial force */
500 /* Update vectorial force */
504 f[j_coord_offset+DIM*2+XX] -= tx;
505 f[j_coord_offset+DIM*2+YY] -= ty;
506 f[j_coord_offset+DIM*2+ZZ] -= tz;
508 /**************************
509 * CALCULATE INTERACTIONS *
510 **************************/
514 /* EWALD ELECTROSTATICS */
516 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
517 ewrt = r20*ewtabscale;
521 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
522 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
523 felec = qq20*rinv20*(rinvsq20-felec);
525 /* Update potential sums from outer loop */
530 /* Calculate temporary vectorial force */
535 /* Update vectorial force */
539 f[j_coord_offset+DIM*0+XX] -= tx;
540 f[j_coord_offset+DIM*0+YY] -= ty;
541 f[j_coord_offset+DIM*0+ZZ] -= tz;
543 /**************************
544 * CALCULATE INTERACTIONS *
545 **************************/
549 /* EWALD ELECTROSTATICS */
551 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
552 ewrt = r21*ewtabscale;
556 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
557 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
558 felec = qq21*rinv21*(rinvsq21-felec);
560 /* Update potential sums from outer loop */
565 /* Calculate temporary vectorial force */
570 /* Update vectorial force */
574 f[j_coord_offset+DIM*1+XX] -= tx;
575 f[j_coord_offset+DIM*1+YY] -= ty;
576 f[j_coord_offset+DIM*1+ZZ] -= tz;
578 /**************************
579 * CALCULATE INTERACTIONS *
580 **************************/
584 /* EWALD ELECTROSTATICS */
586 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
587 ewrt = r22*ewtabscale;
591 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
592 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
593 felec = qq22*rinv22*(rinvsq22-felec);
595 /* Update potential sums from outer loop */
600 /* Calculate temporary vectorial force */
605 /* Update vectorial force */
609 f[j_coord_offset+DIM*2+XX] -= tx;
610 f[j_coord_offset+DIM*2+YY] -= ty;
611 f[j_coord_offset+DIM*2+ZZ] -= tz;
613 /* Inner loop uses 386 flops */
615 /* End of innermost loop */
618 f[i_coord_offset+DIM*0+XX] += fix0;
619 f[i_coord_offset+DIM*0+YY] += fiy0;
620 f[i_coord_offset+DIM*0+ZZ] += fiz0;
624 f[i_coord_offset+DIM*1+XX] += fix1;
625 f[i_coord_offset+DIM*1+YY] += fiy1;
626 f[i_coord_offset+DIM*1+ZZ] += fiz1;
630 f[i_coord_offset+DIM*2+XX] += fix2;
631 f[i_coord_offset+DIM*2+YY] += fiy2;
632 f[i_coord_offset+DIM*2+ZZ] += fiz2;
636 fshift[i_shift_offset+XX] += tx;
637 fshift[i_shift_offset+YY] += ty;
638 fshift[i_shift_offset+ZZ] += tz;
641 /* Update potential energies */
642 kernel_data->energygrp_elec[ggid] += velecsum;
643 kernel_data->energygrp_vdw[ggid] += vvdwsum;
645 /* Increment number of inner iterations */
646 inneriter += j_index_end - j_index_start;
648 /* Outer loop uses 32 flops */
651 /* Increment number of outer iterations */
654 /* Update outer/inner flops */
656 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*386);
659 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJEw_GeomW3W3_F_c
660 * Electrostatics interaction: Ewald
661 * VdW interaction: LJEwald
662 * Geometry: Water3-Water3
663 * Calculate force/pot: Force
666 nb_kernel_ElecEw_VdwLJEw_GeomW3W3_F_c
667 (t_nblist * gmx_restrict nlist,
668 rvec * gmx_restrict xx,
669 rvec * gmx_restrict ff,
670 t_forcerec * gmx_restrict fr,
671 t_mdatoms * gmx_restrict mdatoms,
672 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
673 t_nrnb * gmx_restrict nrnb)
675 int i_shift_offset,i_coord_offset,j_coord_offset;
676 int j_index_start,j_index_end;
677 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
678 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
679 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
680 real *shiftvec,*fshift,*x,*f;
682 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
684 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
686 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
688 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
690 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
692 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
693 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
694 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
695 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
696 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
697 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
698 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
699 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
700 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
701 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
702 real velec,felec,velecsum,facel,crf,krf,krf2;
705 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
717 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
720 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
728 jindex = nlist->jindex;
730 shiftidx = nlist->shift;
732 shiftvec = fr->shift_vec[0];
733 fshift = fr->fshift[0];
735 charge = mdatoms->chargeA;
736 nvdwtype = fr->ntype;
738 vdwtype = mdatoms->typeA;
739 vdwgridparam = fr->ljpme_c6grid;
740 ewclj = fr->ewaldcoeff_lj;
741 sh_lj_ewald = fr->ic->sh_lj_ewald;
742 ewclj2 = ewclj*ewclj;
743 ewclj6 = ewclj2*ewclj2*ewclj2;
745 sh_ewald = fr->ic->sh_ewald;
746 ewtab = fr->ic->tabq_coul_F;
747 ewtabscale = fr->ic->tabq_scale;
748 ewtabhalfspace = 0.5/ewtabscale;
750 /* Setup water-specific parameters */
751 inr = nlist->iinr[0];
752 iq0 = facel*charge[inr+0];
753 iq1 = facel*charge[inr+1];
754 iq2 = facel*charge[inr+2];
755 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
760 vdwjidx0 = 2*vdwtype[inr+0];
762 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
763 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
764 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
777 /* Start outer loop over neighborlists */
778 for(iidx=0; iidx<nri; iidx++)
780 /* Load shift vector for this list */
781 i_shift_offset = DIM*shiftidx[iidx];
782 shX = shiftvec[i_shift_offset+XX];
783 shY = shiftvec[i_shift_offset+YY];
784 shZ = shiftvec[i_shift_offset+ZZ];
786 /* Load limits for loop over neighbors */
787 j_index_start = jindex[iidx];
788 j_index_end = jindex[iidx+1];
790 /* Get outer coordinate index */
792 i_coord_offset = DIM*inr;
794 /* Load i particle coords and add shift vector */
795 ix0 = shX + x[i_coord_offset+DIM*0+XX];
796 iy0 = shY + x[i_coord_offset+DIM*0+YY];
797 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
798 ix1 = shX + x[i_coord_offset+DIM*1+XX];
799 iy1 = shY + x[i_coord_offset+DIM*1+YY];
800 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
801 ix2 = shX + x[i_coord_offset+DIM*2+XX];
802 iy2 = shY + x[i_coord_offset+DIM*2+YY];
803 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
815 /* Start inner kernel loop */
816 for(jidx=j_index_start; jidx<j_index_end; jidx++)
818 /* Get j neighbor index, and coordinate index */
820 j_coord_offset = DIM*jnr;
822 /* load j atom coordinates */
823 jx0 = x[j_coord_offset+DIM*0+XX];
824 jy0 = x[j_coord_offset+DIM*0+YY];
825 jz0 = x[j_coord_offset+DIM*0+ZZ];
826 jx1 = x[j_coord_offset+DIM*1+XX];
827 jy1 = x[j_coord_offset+DIM*1+YY];
828 jz1 = x[j_coord_offset+DIM*1+ZZ];
829 jx2 = x[j_coord_offset+DIM*2+XX];
830 jy2 = x[j_coord_offset+DIM*2+YY];
831 jz2 = x[j_coord_offset+DIM*2+ZZ];
833 /* Calculate displacement vector */
862 /* Calculate squared distance and things based on it */
863 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
864 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
865 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
866 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
867 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
868 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
869 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
870 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
871 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
873 rinv00 = gmx_invsqrt(rsq00);
874 rinv01 = gmx_invsqrt(rsq01);
875 rinv02 = gmx_invsqrt(rsq02);
876 rinv10 = gmx_invsqrt(rsq10);
877 rinv11 = gmx_invsqrt(rsq11);
878 rinv12 = gmx_invsqrt(rsq12);
879 rinv20 = gmx_invsqrt(rsq20);
880 rinv21 = gmx_invsqrt(rsq21);
881 rinv22 = gmx_invsqrt(rsq22);
883 rinvsq00 = rinv00*rinv00;
884 rinvsq01 = rinv01*rinv01;
885 rinvsq02 = rinv02*rinv02;
886 rinvsq10 = rinv10*rinv10;
887 rinvsq11 = rinv11*rinv11;
888 rinvsq12 = rinv12*rinv12;
889 rinvsq20 = rinv20*rinv20;
890 rinvsq21 = rinv21*rinv21;
891 rinvsq22 = rinv22*rinv22;
893 /**************************
894 * CALCULATE INTERACTIONS *
895 **************************/
899 /* EWALD ELECTROSTATICS */
901 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
902 ewrt = r00*ewtabscale;
905 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
906 felec = qq00*rinv00*(rinvsq00-felec);
908 rinvsix = rinvsq00*rinvsq00*rinvsq00;
909 ewcljrsq = ewclj2*rsq00;
910 exponent = exp(-ewcljrsq);
911 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
912 fvdw = (((c12_00*rinvsix - c6_00 + c6grid_00*(1.0-poly))*rinvsix) - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
916 /* Calculate temporary vectorial force */
921 /* Update vectorial force */
925 f[j_coord_offset+DIM*0+XX] -= tx;
926 f[j_coord_offset+DIM*0+YY] -= ty;
927 f[j_coord_offset+DIM*0+ZZ] -= tz;
929 /**************************
930 * CALCULATE INTERACTIONS *
931 **************************/
935 /* EWALD ELECTROSTATICS */
937 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
938 ewrt = r01*ewtabscale;
941 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
942 felec = qq01*rinv01*(rinvsq01-felec);
946 /* Calculate temporary vectorial force */
951 /* Update vectorial force */
955 f[j_coord_offset+DIM*1+XX] -= tx;
956 f[j_coord_offset+DIM*1+YY] -= ty;
957 f[j_coord_offset+DIM*1+ZZ] -= tz;
959 /**************************
960 * CALCULATE INTERACTIONS *
961 **************************/
965 /* EWALD ELECTROSTATICS */
967 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
968 ewrt = r02*ewtabscale;
971 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
972 felec = qq02*rinv02*(rinvsq02-felec);
976 /* Calculate temporary vectorial force */
981 /* Update vectorial force */
985 f[j_coord_offset+DIM*2+XX] -= tx;
986 f[j_coord_offset+DIM*2+YY] -= ty;
987 f[j_coord_offset+DIM*2+ZZ] -= tz;
989 /**************************
990 * CALCULATE INTERACTIONS *
991 **************************/
995 /* EWALD ELECTROSTATICS */
997 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
998 ewrt = r10*ewtabscale;
1000 eweps = ewrt-ewitab;
1001 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1002 felec = qq10*rinv10*(rinvsq10-felec);
1006 /* Calculate temporary vectorial force */
1011 /* Update vectorial force */
1015 f[j_coord_offset+DIM*0+XX] -= tx;
1016 f[j_coord_offset+DIM*0+YY] -= ty;
1017 f[j_coord_offset+DIM*0+ZZ] -= tz;
1019 /**************************
1020 * CALCULATE INTERACTIONS *
1021 **************************/
1025 /* EWALD ELECTROSTATICS */
1027 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1028 ewrt = r11*ewtabscale;
1030 eweps = ewrt-ewitab;
1031 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1032 felec = qq11*rinv11*(rinvsq11-felec);
1036 /* Calculate temporary vectorial force */
1041 /* Update vectorial force */
1045 f[j_coord_offset+DIM*1+XX] -= tx;
1046 f[j_coord_offset+DIM*1+YY] -= ty;
1047 f[j_coord_offset+DIM*1+ZZ] -= tz;
1049 /**************************
1050 * CALCULATE INTERACTIONS *
1051 **************************/
1055 /* EWALD ELECTROSTATICS */
1057 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1058 ewrt = r12*ewtabscale;
1060 eweps = ewrt-ewitab;
1061 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1062 felec = qq12*rinv12*(rinvsq12-felec);
1066 /* Calculate temporary vectorial force */
1071 /* Update vectorial force */
1075 f[j_coord_offset+DIM*2+XX] -= tx;
1076 f[j_coord_offset+DIM*2+YY] -= ty;
1077 f[j_coord_offset+DIM*2+ZZ] -= tz;
1079 /**************************
1080 * CALCULATE INTERACTIONS *
1081 **************************/
1085 /* EWALD ELECTROSTATICS */
1087 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1088 ewrt = r20*ewtabscale;
1090 eweps = ewrt-ewitab;
1091 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1092 felec = qq20*rinv20*(rinvsq20-felec);
1096 /* Calculate temporary vectorial force */
1101 /* Update vectorial force */
1105 f[j_coord_offset+DIM*0+XX] -= tx;
1106 f[j_coord_offset+DIM*0+YY] -= ty;
1107 f[j_coord_offset+DIM*0+ZZ] -= tz;
1109 /**************************
1110 * CALCULATE INTERACTIONS *
1111 **************************/
1115 /* EWALD ELECTROSTATICS */
1117 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1118 ewrt = r21*ewtabscale;
1120 eweps = ewrt-ewitab;
1121 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1122 felec = qq21*rinv21*(rinvsq21-felec);
1126 /* Calculate temporary vectorial force */
1131 /* Update vectorial force */
1135 f[j_coord_offset+DIM*1+XX] -= tx;
1136 f[j_coord_offset+DIM*1+YY] -= ty;
1137 f[j_coord_offset+DIM*1+ZZ] -= tz;
1139 /**************************
1140 * CALCULATE INTERACTIONS *
1141 **************************/
1145 /* EWALD ELECTROSTATICS */
1147 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1148 ewrt = r22*ewtabscale;
1150 eweps = ewrt-ewitab;
1151 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1152 felec = qq22*rinv22*(rinvsq22-felec);
1156 /* Calculate temporary vectorial force */
1161 /* Update vectorial force */
1165 f[j_coord_offset+DIM*2+XX] -= tx;
1166 f[j_coord_offset+DIM*2+YY] -= ty;
1167 f[j_coord_offset+DIM*2+ZZ] -= tz;
1169 /* Inner loop uses 318 flops */
1171 /* End of innermost loop */
1174 f[i_coord_offset+DIM*0+XX] += fix0;
1175 f[i_coord_offset+DIM*0+YY] += fiy0;
1176 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1180 f[i_coord_offset+DIM*1+XX] += fix1;
1181 f[i_coord_offset+DIM*1+YY] += fiy1;
1182 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1186 f[i_coord_offset+DIM*2+XX] += fix2;
1187 f[i_coord_offset+DIM*2+YY] += fiy2;
1188 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1192 fshift[i_shift_offset+XX] += tx;
1193 fshift[i_shift_offset+YY] += ty;
1194 fshift[i_shift_offset+ZZ] += tz;
1196 /* Increment number of inner iterations */
1197 inneriter += j_index_end - j_index_start;
1199 /* Outer loop uses 30 flops */
1202 /* Increment number of outer iterations */
1205 /* Update outer/inner flops */
1207 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*318);