2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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_VdwLJ_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwLJ_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
85 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
87 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
88 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
89 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
90 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
91 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
92 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
93 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
94 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
95 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
96 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
97 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
98 real velec,felec,velecsum,facel,crf,krf,krf2;
101 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
105 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
113 jindex = nlist->jindex;
115 shiftidx = nlist->shift;
117 shiftvec = fr->shift_vec[0];
118 fshift = fr->fshift[0];
120 charge = mdatoms->chargeA;
121 nvdwtype = fr->ntype;
123 vdwtype = mdatoms->typeA;
125 sh_ewald = fr->ic->sh_ewald;
126 ewtab = fr->ic->tabq_coul_FDV0;
127 ewtabscale = fr->ic->tabq_scale;
128 ewtabhalfspace = 0.5/ewtabscale;
130 /* Setup water-specific parameters */
131 inr = nlist->iinr[0];
132 iq1 = facel*charge[inr+1];
133 iq2 = facel*charge[inr+2];
134 iq3 = facel*charge[inr+3];
135 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
140 vdwjidx0 = 2*vdwtype[inr+0];
141 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
142 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
156 /* Start outer loop over neighborlists */
157 for(iidx=0; iidx<nri; iidx++)
159 /* Load shift vector for this list */
160 i_shift_offset = DIM*shiftidx[iidx];
161 shX = shiftvec[i_shift_offset+XX];
162 shY = shiftvec[i_shift_offset+YY];
163 shZ = shiftvec[i_shift_offset+ZZ];
165 /* Load limits for loop over neighbors */
166 j_index_start = jindex[iidx];
167 j_index_end = jindex[iidx+1];
169 /* Get outer coordinate index */
171 i_coord_offset = DIM*inr;
173 /* Load i particle coords and add shift vector */
174 ix0 = shX + x[i_coord_offset+DIM*0+XX];
175 iy0 = shY + x[i_coord_offset+DIM*0+YY];
176 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
177 ix1 = shX + x[i_coord_offset+DIM*1+XX];
178 iy1 = shY + x[i_coord_offset+DIM*1+YY];
179 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
180 ix2 = shX + x[i_coord_offset+DIM*2+XX];
181 iy2 = shY + x[i_coord_offset+DIM*2+YY];
182 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
183 ix3 = shX + x[i_coord_offset+DIM*3+XX];
184 iy3 = shY + x[i_coord_offset+DIM*3+YY];
185 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
200 /* Reset potential sums */
204 /* Start inner kernel loop */
205 for(jidx=j_index_start; jidx<j_index_end; jidx++)
207 /* Get j neighbor index, and coordinate index */
209 j_coord_offset = DIM*jnr;
211 /* load j atom coordinates */
212 jx0 = x[j_coord_offset+DIM*0+XX];
213 jy0 = x[j_coord_offset+DIM*0+YY];
214 jz0 = x[j_coord_offset+DIM*0+ZZ];
215 jx1 = x[j_coord_offset+DIM*1+XX];
216 jy1 = x[j_coord_offset+DIM*1+YY];
217 jz1 = x[j_coord_offset+DIM*1+ZZ];
218 jx2 = x[j_coord_offset+DIM*2+XX];
219 jy2 = x[j_coord_offset+DIM*2+YY];
220 jz2 = x[j_coord_offset+DIM*2+ZZ];
221 jx3 = x[j_coord_offset+DIM*3+XX];
222 jy3 = x[j_coord_offset+DIM*3+YY];
223 jz3 = x[j_coord_offset+DIM*3+ZZ];
225 /* Calculate displacement vector */
257 /* Calculate squared distance and things based on it */
258 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
259 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
260 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
261 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
262 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
263 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
264 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
265 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
266 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
267 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
269 rinv11 = gmx_invsqrt(rsq11);
270 rinv12 = gmx_invsqrt(rsq12);
271 rinv13 = gmx_invsqrt(rsq13);
272 rinv21 = gmx_invsqrt(rsq21);
273 rinv22 = gmx_invsqrt(rsq22);
274 rinv23 = gmx_invsqrt(rsq23);
275 rinv31 = gmx_invsqrt(rsq31);
276 rinv32 = gmx_invsqrt(rsq32);
277 rinv33 = gmx_invsqrt(rsq33);
279 rinvsq00 = 1.0/rsq00;
280 rinvsq11 = rinv11*rinv11;
281 rinvsq12 = rinv12*rinv12;
282 rinvsq13 = rinv13*rinv13;
283 rinvsq21 = rinv21*rinv21;
284 rinvsq22 = rinv22*rinv22;
285 rinvsq23 = rinv23*rinv23;
286 rinvsq31 = rinv31*rinv31;
287 rinvsq32 = rinv32*rinv32;
288 rinvsq33 = rinv33*rinv33;
290 /**************************
291 * CALCULATE INTERACTIONS *
292 **************************/
294 /* LENNARD-JONES DISPERSION/REPULSION */
296 rinvsix = rinvsq00*rinvsq00*rinvsq00;
297 vvdw6 = c6_00*rinvsix;
298 vvdw12 = c12_00*rinvsix*rinvsix;
299 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
300 fvdw = (vvdw12-vvdw6)*rinvsq00;
302 /* Update potential sums from outer loop */
307 /* Calculate temporary vectorial force */
312 /* Update vectorial force */
316 f[j_coord_offset+DIM*0+XX] -= tx;
317 f[j_coord_offset+DIM*0+YY] -= ty;
318 f[j_coord_offset+DIM*0+ZZ] -= tz;
320 /**************************
321 * CALCULATE INTERACTIONS *
322 **************************/
326 /* EWALD ELECTROSTATICS */
328 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
329 ewrt = r11*ewtabscale;
333 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
334 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
335 felec = qq11*rinv11*(rinvsq11-felec);
337 /* Update potential sums from outer loop */
342 /* Calculate temporary vectorial force */
347 /* Update vectorial force */
351 f[j_coord_offset+DIM*1+XX] -= tx;
352 f[j_coord_offset+DIM*1+YY] -= ty;
353 f[j_coord_offset+DIM*1+ZZ] -= tz;
355 /**************************
356 * CALCULATE INTERACTIONS *
357 **************************/
361 /* EWALD ELECTROSTATICS */
363 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
364 ewrt = r12*ewtabscale;
368 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
369 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
370 felec = qq12*rinv12*(rinvsq12-felec);
372 /* Update potential sums from outer loop */
377 /* Calculate temporary vectorial force */
382 /* Update vectorial force */
386 f[j_coord_offset+DIM*2+XX] -= tx;
387 f[j_coord_offset+DIM*2+YY] -= ty;
388 f[j_coord_offset+DIM*2+ZZ] -= tz;
390 /**************************
391 * CALCULATE INTERACTIONS *
392 **************************/
396 /* EWALD ELECTROSTATICS */
398 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
399 ewrt = r13*ewtabscale;
403 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
404 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
405 felec = qq13*rinv13*(rinvsq13-felec);
407 /* Update potential sums from outer loop */
412 /* Calculate temporary vectorial force */
417 /* Update vectorial force */
421 f[j_coord_offset+DIM*3+XX] -= tx;
422 f[j_coord_offset+DIM*3+YY] -= ty;
423 f[j_coord_offset+DIM*3+ZZ] -= tz;
425 /**************************
426 * CALCULATE INTERACTIONS *
427 **************************/
431 /* EWALD ELECTROSTATICS */
433 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
434 ewrt = r21*ewtabscale;
438 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
439 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
440 felec = qq21*rinv21*(rinvsq21-felec);
442 /* Update potential sums from outer loop */
447 /* Calculate temporary vectorial force */
452 /* Update vectorial force */
456 f[j_coord_offset+DIM*1+XX] -= tx;
457 f[j_coord_offset+DIM*1+YY] -= ty;
458 f[j_coord_offset+DIM*1+ZZ] -= tz;
460 /**************************
461 * CALCULATE INTERACTIONS *
462 **************************/
466 /* EWALD ELECTROSTATICS */
468 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
469 ewrt = r22*ewtabscale;
473 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
474 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
475 felec = qq22*rinv22*(rinvsq22-felec);
477 /* Update potential sums from outer loop */
482 /* Calculate temporary vectorial force */
487 /* Update vectorial force */
491 f[j_coord_offset+DIM*2+XX] -= tx;
492 f[j_coord_offset+DIM*2+YY] -= ty;
493 f[j_coord_offset+DIM*2+ZZ] -= tz;
495 /**************************
496 * CALCULATE INTERACTIONS *
497 **************************/
501 /* EWALD ELECTROSTATICS */
503 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
504 ewrt = r23*ewtabscale;
508 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
509 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
510 felec = qq23*rinv23*(rinvsq23-felec);
512 /* Update potential sums from outer loop */
517 /* Calculate temporary vectorial force */
522 /* Update vectorial force */
526 f[j_coord_offset+DIM*3+XX] -= tx;
527 f[j_coord_offset+DIM*3+YY] -= ty;
528 f[j_coord_offset+DIM*3+ZZ] -= tz;
530 /**************************
531 * CALCULATE INTERACTIONS *
532 **************************/
536 /* EWALD ELECTROSTATICS */
538 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
539 ewrt = r31*ewtabscale;
543 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
544 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
545 felec = qq31*rinv31*(rinvsq31-felec);
547 /* Update potential sums from outer loop */
552 /* Calculate temporary vectorial force */
557 /* Update vectorial force */
561 f[j_coord_offset+DIM*1+XX] -= tx;
562 f[j_coord_offset+DIM*1+YY] -= ty;
563 f[j_coord_offset+DIM*1+ZZ] -= tz;
565 /**************************
566 * CALCULATE INTERACTIONS *
567 **************************/
571 /* EWALD ELECTROSTATICS */
573 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
574 ewrt = r32*ewtabscale;
578 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
579 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
580 felec = qq32*rinv32*(rinvsq32-felec);
582 /* Update potential sums from outer loop */
587 /* Calculate temporary vectorial force */
592 /* Update vectorial force */
596 f[j_coord_offset+DIM*2+XX] -= tx;
597 f[j_coord_offset+DIM*2+YY] -= ty;
598 f[j_coord_offset+DIM*2+ZZ] -= tz;
600 /**************************
601 * CALCULATE INTERACTIONS *
602 **************************/
606 /* EWALD ELECTROSTATICS */
608 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
609 ewrt = r33*ewtabscale;
613 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
614 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
615 felec = qq33*rinv33*(rinvsq33-felec);
617 /* Update potential sums from outer loop */
622 /* Calculate temporary vectorial force */
627 /* Update vectorial force */
631 f[j_coord_offset+DIM*3+XX] -= tx;
632 f[j_coord_offset+DIM*3+YY] -= ty;
633 f[j_coord_offset+DIM*3+ZZ] -= tz;
635 /* Inner loop uses 392 flops */
637 /* End of innermost loop */
640 f[i_coord_offset+DIM*0+XX] += fix0;
641 f[i_coord_offset+DIM*0+YY] += fiy0;
642 f[i_coord_offset+DIM*0+ZZ] += fiz0;
646 f[i_coord_offset+DIM*1+XX] += fix1;
647 f[i_coord_offset+DIM*1+YY] += fiy1;
648 f[i_coord_offset+DIM*1+ZZ] += fiz1;
652 f[i_coord_offset+DIM*2+XX] += fix2;
653 f[i_coord_offset+DIM*2+YY] += fiy2;
654 f[i_coord_offset+DIM*2+ZZ] += fiz2;
658 f[i_coord_offset+DIM*3+XX] += fix3;
659 f[i_coord_offset+DIM*3+YY] += fiy3;
660 f[i_coord_offset+DIM*3+ZZ] += fiz3;
664 fshift[i_shift_offset+XX] += tx;
665 fshift[i_shift_offset+YY] += ty;
666 fshift[i_shift_offset+ZZ] += tz;
669 /* Update potential energies */
670 kernel_data->energygrp_elec[ggid] += velecsum;
671 kernel_data->energygrp_vdw[ggid] += vvdwsum;
673 /* Increment number of inner iterations */
674 inneriter += j_index_end - j_index_start;
676 /* Outer loop uses 41 flops */
679 /* Increment number of outer iterations */
682 /* Update outer/inner flops */
684 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*392);
687 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW4W4_F_c
688 * Electrostatics interaction: Ewald
689 * VdW interaction: LennardJones
690 * Geometry: Water4-Water4
691 * Calculate force/pot: Force
694 nb_kernel_ElecEw_VdwLJ_GeomW4W4_F_c
695 (t_nblist * gmx_restrict nlist,
696 rvec * gmx_restrict xx,
697 rvec * gmx_restrict ff,
698 t_forcerec * gmx_restrict fr,
699 t_mdatoms * gmx_restrict mdatoms,
700 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
701 t_nrnb * gmx_restrict nrnb)
703 int i_shift_offset,i_coord_offset,j_coord_offset;
704 int j_index_start,j_index_end;
705 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
706 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
707 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
708 real *shiftvec,*fshift,*x,*f;
710 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
712 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
714 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
716 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
718 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
720 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
722 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
724 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
725 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
726 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
727 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
728 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
729 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
730 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
731 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
732 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
733 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
734 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
735 real velec,felec,velecsum,facel,crf,krf,krf2;
738 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
742 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
750 jindex = nlist->jindex;
752 shiftidx = nlist->shift;
754 shiftvec = fr->shift_vec[0];
755 fshift = fr->fshift[0];
757 charge = mdatoms->chargeA;
758 nvdwtype = fr->ntype;
760 vdwtype = mdatoms->typeA;
762 sh_ewald = fr->ic->sh_ewald;
763 ewtab = fr->ic->tabq_coul_F;
764 ewtabscale = fr->ic->tabq_scale;
765 ewtabhalfspace = 0.5/ewtabscale;
767 /* Setup water-specific parameters */
768 inr = nlist->iinr[0];
769 iq1 = facel*charge[inr+1];
770 iq2 = facel*charge[inr+2];
771 iq3 = facel*charge[inr+3];
772 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
777 vdwjidx0 = 2*vdwtype[inr+0];
778 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
779 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
793 /* Start outer loop over neighborlists */
794 for(iidx=0; iidx<nri; iidx++)
796 /* Load shift vector for this list */
797 i_shift_offset = DIM*shiftidx[iidx];
798 shX = shiftvec[i_shift_offset+XX];
799 shY = shiftvec[i_shift_offset+YY];
800 shZ = shiftvec[i_shift_offset+ZZ];
802 /* Load limits for loop over neighbors */
803 j_index_start = jindex[iidx];
804 j_index_end = jindex[iidx+1];
806 /* Get outer coordinate index */
808 i_coord_offset = DIM*inr;
810 /* Load i particle coords and add shift vector */
811 ix0 = shX + x[i_coord_offset+DIM*0+XX];
812 iy0 = shY + x[i_coord_offset+DIM*0+YY];
813 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
814 ix1 = shX + x[i_coord_offset+DIM*1+XX];
815 iy1 = shY + x[i_coord_offset+DIM*1+YY];
816 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
817 ix2 = shX + x[i_coord_offset+DIM*2+XX];
818 iy2 = shY + x[i_coord_offset+DIM*2+YY];
819 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
820 ix3 = shX + x[i_coord_offset+DIM*3+XX];
821 iy3 = shY + x[i_coord_offset+DIM*3+YY];
822 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
837 /* Start inner kernel loop */
838 for(jidx=j_index_start; jidx<j_index_end; jidx++)
840 /* Get j neighbor index, and coordinate index */
842 j_coord_offset = DIM*jnr;
844 /* load j atom coordinates */
845 jx0 = x[j_coord_offset+DIM*0+XX];
846 jy0 = x[j_coord_offset+DIM*0+YY];
847 jz0 = x[j_coord_offset+DIM*0+ZZ];
848 jx1 = x[j_coord_offset+DIM*1+XX];
849 jy1 = x[j_coord_offset+DIM*1+YY];
850 jz1 = x[j_coord_offset+DIM*1+ZZ];
851 jx2 = x[j_coord_offset+DIM*2+XX];
852 jy2 = x[j_coord_offset+DIM*2+YY];
853 jz2 = x[j_coord_offset+DIM*2+ZZ];
854 jx3 = x[j_coord_offset+DIM*3+XX];
855 jy3 = x[j_coord_offset+DIM*3+YY];
856 jz3 = x[j_coord_offset+DIM*3+ZZ];
858 /* Calculate displacement vector */
890 /* Calculate squared distance and things based on it */
891 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
892 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
893 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
894 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
895 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
896 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
897 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
898 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
899 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
900 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
902 rinv11 = gmx_invsqrt(rsq11);
903 rinv12 = gmx_invsqrt(rsq12);
904 rinv13 = gmx_invsqrt(rsq13);
905 rinv21 = gmx_invsqrt(rsq21);
906 rinv22 = gmx_invsqrt(rsq22);
907 rinv23 = gmx_invsqrt(rsq23);
908 rinv31 = gmx_invsqrt(rsq31);
909 rinv32 = gmx_invsqrt(rsq32);
910 rinv33 = gmx_invsqrt(rsq33);
912 rinvsq00 = 1.0/rsq00;
913 rinvsq11 = rinv11*rinv11;
914 rinvsq12 = rinv12*rinv12;
915 rinvsq13 = rinv13*rinv13;
916 rinvsq21 = rinv21*rinv21;
917 rinvsq22 = rinv22*rinv22;
918 rinvsq23 = rinv23*rinv23;
919 rinvsq31 = rinv31*rinv31;
920 rinvsq32 = rinv32*rinv32;
921 rinvsq33 = rinv33*rinv33;
923 /**************************
924 * CALCULATE INTERACTIONS *
925 **************************/
927 /* LENNARD-JONES DISPERSION/REPULSION */
929 rinvsix = rinvsq00*rinvsq00*rinvsq00;
930 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
934 /* Calculate temporary vectorial force */
939 /* Update vectorial force */
943 f[j_coord_offset+DIM*0+XX] -= tx;
944 f[j_coord_offset+DIM*0+YY] -= ty;
945 f[j_coord_offset+DIM*0+ZZ] -= tz;
947 /**************************
948 * CALCULATE INTERACTIONS *
949 **************************/
953 /* EWALD ELECTROSTATICS */
955 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
956 ewrt = r11*ewtabscale;
959 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
960 felec = qq11*rinv11*(rinvsq11-felec);
964 /* Calculate temporary vectorial force */
969 /* Update vectorial force */
973 f[j_coord_offset+DIM*1+XX] -= tx;
974 f[j_coord_offset+DIM*1+YY] -= ty;
975 f[j_coord_offset+DIM*1+ZZ] -= tz;
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
983 /* EWALD ELECTROSTATICS */
985 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
986 ewrt = r12*ewtabscale;
989 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
990 felec = qq12*rinv12*(rinvsq12-felec);
994 /* Calculate temporary vectorial force */
999 /* Update vectorial force */
1003 f[j_coord_offset+DIM*2+XX] -= tx;
1004 f[j_coord_offset+DIM*2+YY] -= ty;
1005 f[j_coord_offset+DIM*2+ZZ] -= tz;
1007 /**************************
1008 * CALCULATE INTERACTIONS *
1009 **************************/
1013 /* EWALD ELECTROSTATICS */
1015 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1016 ewrt = r13*ewtabscale;
1018 eweps = ewrt-ewitab;
1019 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1020 felec = qq13*rinv13*(rinvsq13-felec);
1024 /* Calculate temporary vectorial force */
1029 /* Update vectorial force */
1033 f[j_coord_offset+DIM*3+XX] -= tx;
1034 f[j_coord_offset+DIM*3+YY] -= ty;
1035 f[j_coord_offset+DIM*3+ZZ] -= tz;
1037 /**************************
1038 * CALCULATE INTERACTIONS *
1039 **************************/
1043 /* EWALD ELECTROSTATICS */
1045 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1046 ewrt = r21*ewtabscale;
1048 eweps = ewrt-ewitab;
1049 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1050 felec = qq21*rinv21*(rinvsq21-felec);
1054 /* Calculate temporary vectorial force */
1059 /* Update vectorial force */
1063 f[j_coord_offset+DIM*1+XX] -= tx;
1064 f[j_coord_offset+DIM*1+YY] -= ty;
1065 f[j_coord_offset+DIM*1+ZZ] -= tz;
1067 /**************************
1068 * CALCULATE INTERACTIONS *
1069 **************************/
1073 /* EWALD ELECTROSTATICS */
1075 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1076 ewrt = r22*ewtabscale;
1078 eweps = ewrt-ewitab;
1079 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1080 felec = qq22*rinv22*(rinvsq22-felec);
1084 /* Calculate temporary vectorial force */
1089 /* Update vectorial force */
1093 f[j_coord_offset+DIM*2+XX] -= tx;
1094 f[j_coord_offset+DIM*2+YY] -= ty;
1095 f[j_coord_offset+DIM*2+ZZ] -= tz;
1097 /**************************
1098 * CALCULATE INTERACTIONS *
1099 **************************/
1103 /* EWALD ELECTROSTATICS */
1105 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1106 ewrt = r23*ewtabscale;
1108 eweps = ewrt-ewitab;
1109 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1110 felec = qq23*rinv23*(rinvsq23-felec);
1114 /* Calculate temporary vectorial force */
1119 /* Update vectorial force */
1123 f[j_coord_offset+DIM*3+XX] -= tx;
1124 f[j_coord_offset+DIM*3+YY] -= ty;
1125 f[j_coord_offset+DIM*3+ZZ] -= tz;
1127 /**************************
1128 * CALCULATE INTERACTIONS *
1129 **************************/
1133 /* EWALD ELECTROSTATICS */
1135 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1136 ewrt = r31*ewtabscale;
1138 eweps = ewrt-ewitab;
1139 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1140 felec = qq31*rinv31*(rinvsq31-felec);
1144 /* Calculate temporary vectorial force */
1149 /* Update vectorial force */
1153 f[j_coord_offset+DIM*1+XX] -= tx;
1154 f[j_coord_offset+DIM*1+YY] -= ty;
1155 f[j_coord_offset+DIM*1+ZZ] -= tz;
1157 /**************************
1158 * CALCULATE INTERACTIONS *
1159 **************************/
1163 /* EWALD ELECTROSTATICS */
1165 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1166 ewrt = r32*ewtabscale;
1168 eweps = ewrt-ewitab;
1169 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1170 felec = qq32*rinv32*(rinvsq32-felec);
1174 /* Calculate temporary vectorial force */
1179 /* Update vectorial force */
1183 f[j_coord_offset+DIM*2+XX] -= tx;
1184 f[j_coord_offset+DIM*2+YY] -= ty;
1185 f[j_coord_offset+DIM*2+ZZ] -= tz;
1187 /**************************
1188 * CALCULATE INTERACTIONS *
1189 **************************/
1193 /* EWALD ELECTROSTATICS */
1195 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1196 ewrt = r33*ewtabscale;
1198 eweps = ewrt-ewitab;
1199 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1200 felec = qq33*rinv33*(rinvsq33-felec);
1204 /* Calculate temporary vectorial force */
1209 /* Update vectorial force */
1213 f[j_coord_offset+DIM*3+XX] -= tx;
1214 f[j_coord_offset+DIM*3+YY] -= ty;
1215 f[j_coord_offset+DIM*3+ZZ] -= tz;
1217 /* Inner loop uses 324 flops */
1219 /* End of innermost loop */
1222 f[i_coord_offset+DIM*0+XX] += fix0;
1223 f[i_coord_offset+DIM*0+YY] += fiy0;
1224 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1228 f[i_coord_offset+DIM*1+XX] += fix1;
1229 f[i_coord_offset+DIM*1+YY] += fiy1;
1230 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1234 f[i_coord_offset+DIM*2+XX] += fix2;
1235 f[i_coord_offset+DIM*2+YY] += fiy2;
1236 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1240 f[i_coord_offset+DIM*3+XX] += fix3;
1241 f[i_coord_offset+DIM*3+YY] += fiy3;
1242 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1246 fshift[i_shift_offset+XX] += tx;
1247 fshift[i_shift_offset+YY] += ty;
1248 fshift[i_shift_offset+ZZ] += tz;
1250 /* Increment number of inner iterations */
1251 inneriter += j_index_end - j_index_start;
1253 /* Outer loop uses 39 flops */
1256 /* Increment number of outer iterations */
1259 /* Update outer/inner flops */
1261 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*324);