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_VdwCSTab_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwCSTab_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 rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
108 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
116 jindex = nlist->jindex;
118 shiftidx = nlist->shift;
120 shiftvec = fr->shift_vec[0];
121 fshift = fr->fshift[0];
123 charge = mdatoms->chargeA;
124 nvdwtype = fr->ntype;
126 vdwtype = mdatoms->typeA;
128 vftab = kernel_data->table_vdw->data;
129 vftabscale = kernel_data->table_vdw->scale;
131 sh_ewald = fr->ic->sh_ewald;
132 ewtab = fr->ic->tabq_coul_FDV0;
133 ewtabscale = fr->ic->tabq_scale;
134 ewtabhalfspace = 0.5/ewtabscale;
136 /* Setup water-specific parameters */
137 inr = nlist->iinr[0];
138 iq1 = facel*charge[inr+1];
139 iq2 = facel*charge[inr+2];
140 iq3 = facel*charge[inr+3];
141 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
146 vdwjidx0 = 2*vdwtype[inr+0];
147 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
148 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
162 /* Start outer loop over neighborlists */
163 for(iidx=0; iidx<nri; iidx++)
165 /* Load shift vector for this list */
166 i_shift_offset = DIM*shiftidx[iidx];
167 shX = shiftvec[i_shift_offset+XX];
168 shY = shiftvec[i_shift_offset+YY];
169 shZ = shiftvec[i_shift_offset+ZZ];
171 /* Load limits for loop over neighbors */
172 j_index_start = jindex[iidx];
173 j_index_end = jindex[iidx+1];
175 /* Get outer coordinate index */
177 i_coord_offset = DIM*inr;
179 /* Load i particle coords and add shift vector */
180 ix0 = shX + x[i_coord_offset+DIM*0+XX];
181 iy0 = shY + x[i_coord_offset+DIM*0+YY];
182 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
183 ix1 = shX + x[i_coord_offset+DIM*1+XX];
184 iy1 = shY + x[i_coord_offset+DIM*1+YY];
185 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
186 ix2 = shX + x[i_coord_offset+DIM*2+XX];
187 iy2 = shY + x[i_coord_offset+DIM*2+YY];
188 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
189 ix3 = shX + x[i_coord_offset+DIM*3+XX];
190 iy3 = shY + x[i_coord_offset+DIM*3+YY];
191 iz3 = shZ + x[i_coord_offset+DIM*3+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];
227 jx3 = x[j_coord_offset+DIM*3+XX];
228 jy3 = x[j_coord_offset+DIM*3+YY];
229 jz3 = x[j_coord_offset+DIM*3+ZZ];
231 /* Calculate displacement vector */
263 /* Calculate squared distance and things based on it */
264 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
265 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
266 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
267 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
268 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
269 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
270 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
271 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
272 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
273 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
275 rinv00 = gmx_invsqrt(rsq00);
276 rinv11 = gmx_invsqrt(rsq11);
277 rinv12 = gmx_invsqrt(rsq12);
278 rinv13 = gmx_invsqrt(rsq13);
279 rinv21 = gmx_invsqrt(rsq21);
280 rinv22 = gmx_invsqrt(rsq22);
281 rinv23 = gmx_invsqrt(rsq23);
282 rinv31 = gmx_invsqrt(rsq31);
283 rinv32 = gmx_invsqrt(rsq32);
284 rinv33 = gmx_invsqrt(rsq33);
286 rinvsq11 = rinv11*rinv11;
287 rinvsq12 = rinv12*rinv12;
288 rinvsq13 = rinv13*rinv13;
289 rinvsq21 = rinv21*rinv21;
290 rinvsq22 = rinv22*rinv22;
291 rinvsq23 = rinv23*rinv23;
292 rinvsq31 = rinv31*rinv31;
293 rinvsq32 = rinv32*rinv32;
294 rinvsq33 = rinv33*rinv33;
296 /**************************
297 * CALCULATE INTERACTIONS *
298 **************************/
302 /* Calculate table index by multiplying r with table scale and truncate to integer */
308 /* CUBIC SPLINE TABLE DISPERSION */
312 Geps = vfeps*vftab[vfitab+2];
313 Heps2 = vfeps*vfeps*vftab[vfitab+3];
317 FF = Fp+Geps+2.0*Heps2;
320 /* CUBIC SPLINE TABLE REPULSION */
323 Geps = vfeps*vftab[vfitab+6];
324 Heps2 = vfeps*vfeps*vftab[vfitab+7];
328 FF = Fp+Geps+2.0*Heps2;
331 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
333 /* Update potential sums from outer loop */
338 /* Calculate temporary vectorial force */
343 /* Update vectorial force */
347 f[j_coord_offset+DIM*0+XX] -= tx;
348 f[j_coord_offset+DIM*0+YY] -= ty;
349 f[j_coord_offset+DIM*0+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 = r11*ewtabscale;
364 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
365 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
366 felec = qq11*rinv11*(rinvsq11-felec);
368 /* Update potential sums from outer loop */
373 /* Calculate temporary vectorial force */
378 /* Update vectorial force */
382 f[j_coord_offset+DIM*1+XX] -= tx;
383 f[j_coord_offset+DIM*1+YY] -= ty;
384 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
399 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
400 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
401 felec = qq12*rinv12*(rinvsq12-felec);
403 /* Update potential sums from outer loop */
408 /* Calculate temporary vectorial force */
413 /* Update vectorial force */
417 f[j_coord_offset+DIM*2+XX] -= tx;
418 f[j_coord_offset+DIM*2+YY] -= ty;
419 f[j_coord_offset+DIM*2+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 = r13*ewtabscale;
434 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
435 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
436 felec = qq13*rinv13*(rinvsq13-felec);
438 /* Update potential sums from outer loop */
443 /* Calculate temporary vectorial force */
448 /* Update vectorial force */
452 f[j_coord_offset+DIM*3+XX] -= tx;
453 f[j_coord_offset+DIM*3+YY] -= ty;
454 f[j_coord_offset+DIM*3+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 = r21*ewtabscale;
469 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
470 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
471 felec = qq21*rinv21*(rinvsq21-felec);
473 /* Update potential sums from outer loop */
478 /* Calculate temporary vectorial force */
483 /* Update vectorial force */
487 f[j_coord_offset+DIM*1+XX] -= tx;
488 f[j_coord_offset+DIM*1+YY] -= ty;
489 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
504 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
505 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
506 felec = qq22*rinv22*(rinvsq22-felec);
508 /* Update potential sums from outer loop */
513 /* Calculate temporary vectorial force */
518 /* Update vectorial force */
522 f[j_coord_offset+DIM*2+XX] -= tx;
523 f[j_coord_offset+DIM*2+YY] -= ty;
524 f[j_coord_offset+DIM*2+ZZ] -= tz;
526 /**************************
527 * CALCULATE INTERACTIONS *
528 **************************/
532 /* EWALD ELECTROSTATICS */
534 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
535 ewrt = r23*ewtabscale;
539 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
540 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
541 felec = qq23*rinv23*(rinvsq23-felec);
543 /* Update potential sums from outer loop */
548 /* Calculate temporary vectorial force */
553 /* Update vectorial force */
557 f[j_coord_offset+DIM*3+XX] -= tx;
558 f[j_coord_offset+DIM*3+YY] -= ty;
559 f[j_coord_offset+DIM*3+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 = r31*ewtabscale;
574 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
575 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
576 felec = qq31*rinv31*(rinvsq31-felec);
578 /* Update potential sums from outer loop */
583 /* Calculate temporary vectorial force */
588 /* Update vectorial force */
592 f[j_coord_offset+DIM*1+XX] -= tx;
593 f[j_coord_offset+DIM*1+YY] -= ty;
594 f[j_coord_offset+DIM*1+ZZ] -= tz;
596 /**************************
597 * CALCULATE INTERACTIONS *
598 **************************/
602 /* EWALD ELECTROSTATICS */
604 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
605 ewrt = r32*ewtabscale;
609 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
610 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
611 felec = qq32*rinv32*(rinvsq32-felec);
613 /* Update potential sums from outer loop */
618 /* Calculate temporary vectorial force */
623 /* Update vectorial force */
627 f[j_coord_offset+DIM*2+XX] -= tx;
628 f[j_coord_offset+DIM*2+YY] -= ty;
629 f[j_coord_offset+DIM*2+ZZ] -= tz;
631 /**************************
632 * CALCULATE INTERACTIONS *
633 **************************/
637 /* EWALD ELECTROSTATICS */
639 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
640 ewrt = r33*ewtabscale;
644 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
645 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
646 felec = qq33*rinv33*(rinvsq33-felec);
648 /* Update potential sums from outer loop */
653 /* Calculate temporary vectorial force */
658 /* Update vectorial force */
662 f[j_coord_offset+DIM*3+XX] -= tx;
663 f[j_coord_offset+DIM*3+YY] -= ty;
664 f[j_coord_offset+DIM*3+ZZ] -= tz;
666 /* Inner loop uses 415 flops */
668 /* End of innermost loop */
671 f[i_coord_offset+DIM*0+XX] += fix0;
672 f[i_coord_offset+DIM*0+YY] += fiy0;
673 f[i_coord_offset+DIM*0+ZZ] += fiz0;
677 f[i_coord_offset+DIM*1+XX] += fix1;
678 f[i_coord_offset+DIM*1+YY] += fiy1;
679 f[i_coord_offset+DIM*1+ZZ] += fiz1;
683 f[i_coord_offset+DIM*2+XX] += fix2;
684 f[i_coord_offset+DIM*2+YY] += fiy2;
685 f[i_coord_offset+DIM*2+ZZ] += fiz2;
689 f[i_coord_offset+DIM*3+XX] += fix3;
690 f[i_coord_offset+DIM*3+YY] += fiy3;
691 f[i_coord_offset+DIM*3+ZZ] += fiz3;
695 fshift[i_shift_offset+XX] += tx;
696 fshift[i_shift_offset+YY] += ty;
697 fshift[i_shift_offset+ZZ] += tz;
700 /* Update potential energies */
701 kernel_data->energygrp_elec[ggid] += velecsum;
702 kernel_data->energygrp_vdw[ggid] += vvdwsum;
704 /* Increment number of inner iterations */
705 inneriter += j_index_end - j_index_start;
707 /* Outer loop uses 41 flops */
710 /* Increment number of outer iterations */
713 /* Update outer/inner flops */
715 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*415);
718 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW4W4_F_c
719 * Electrostatics interaction: Ewald
720 * VdW interaction: CubicSplineTable
721 * Geometry: Water4-Water4
722 * Calculate force/pot: Force
725 nb_kernel_ElecEw_VdwCSTab_GeomW4W4_F_c
726 (t_nblist * gmx_restrict nlist,
727 rvec * gmx_restrict xx,
728 rvec * gmx_restrict ff,
729 t_forcerec * gmx_restrict fr,
730 t_mdatoms * gmx_restrict mdatoms,
731 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
732 t_nrnb * gmx_restrict nrnb)
734 int i_shift_offset,i_coord_offset,j_coord_offset;
735 int j_index_start,j_index_end;
736 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
737 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
738 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
739 real *shiftvec,*fshift,*x,*f;
741 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
743 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
745 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
747 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
749 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
751 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
753 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
755 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
756 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
757 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
758 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
759 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
760 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
761 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
762 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
763 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
764 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
765 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
766 real velec,felec,velecsum,facel,crf,krf,krf2;
769 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
773 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
776 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
784 jindex = nlist->jindex;
786 shiftidx = nlist->shift;
788 shiftvec = fr->shift_vec[0];
789 fshift = fr->fshift[0];
791 charge = mdatoms->chargeA;
792 nvdwtype = fr->ntype;
794 vdwtype = mdatoms->typeA;
796 vftab = kernel_data->table_vdw->data;
797 vftabscale = kernel_data->table_vdw->scale;
799 sh_ewald = fr->ic->sh_ewald;
800 ewtab = fr->ic->tabq_coul_F;
801 ewtabscale = fr->ic->tabq_scale;
802 ewtabhalfspace = 0.5/ewtabscale;
804 /* Setup water-specific parameters */
805 inr = nlist->iinr[0];
806 iq1 = facel*charge[inr+1];
807 iq2 = facel*charge[inr+2];
808 iq3 = facel*charge[inr+3];
809 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
814 vdwjidx0 = 2*vdwtype[inr+0];
815 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
816 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
830 /* Start outer loop over neighborlists */
831 for(iidx=0; iidx<nri; iidx++)
833 /* Load shift vector for this list */
834 i_shift_offset = DIM*shiftidx[iidx];
835 shX = shiftvec[i_shift_offset+XX];
836 shY = shiftvec[i_shift_offset+YY];
837 shZ = shiftvec[i_shift_offset+ZZ];
839 /* Load limits for loop over neighbors */
840 j_index_start = jindex[iidx];
841 j_index_end = jindex[iidx+1];
843 /* Get outer coordinate index */
845 i_coord_offset = DIM*inr;
847 /* Load i particle coords and add shift vector */
848 ix0 = shX + x[i_coord_offset+DIM*0+XX];
849 iy0 = shY + x[i_coord_offset+DIM*0+YY];
850 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
851 ix1 = shX + x[i_coord_offset+DIM*1+XX];
852 iy1 = shY + x[i_coord_offset+DIM*1+YY];
853 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
854 ix2 = shX + x[i_coord_offset+DIM*2+XX];
855 iy2 = shY + x[i_coord_offset+DIM*2+YY];
856 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
857 ix3 = shX + x[i_coord_offset+DIM*3+XX];
858 iy3 = shY + x[i_coord_offset+DIM*3+YY];
859 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
874 /* Start inner kernel loop */
875 for(jidx=j_index_start; jidx<j_index_end; jidx++)
877 /* Get j neighbor index, and coordinate index */
879 j_coord_offset = DIM*jnr;
881 /* load j atom coordinates */
882 jx0 = x[j_coord_offset+DIM*0+XX];
883 jy0 = x[j_coord_offset+DIM*0+YY];
884 jz0 = x[j_coord_offset+DIM*0+ZZ];
885 jx1 = x[j_coord_offset+DIM*1+XX];
886 jy1 = x[j_coord_offset+DIM*1+YY];
887 jz1 = x[j_coord_offset+DIM*1+ZZ];
888 jx2 = x[j_coord_offset+DIM*2+XX];
889 jy2 = x[j_coord_offset+DIM*2+YY];
890 jz2 = x[j_coord_offset+DIM*2+ZZ];
891 jx3 = x[j_coord_offset+DIM*3+XX];
892 jy3 = x[j_coord_offset+DIM*3+YY];
893 jz3 = x[j_coord_offset+DIM*3+ZZ];
895 /* Calculate displacement vector */
927 /* Calculate squared distance and things based on it */
928 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
929 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
930 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
931 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
932 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
933 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
934 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
935 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
936 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
937 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
939 rinv00 = gmx_invsqrt(rsq00);
940 rinv11 = gmx_invsqrt(rsq11);
941 rinv12 = gmx_invsqrt(rsq12);
942 rinv13 = gmx_invsqrt(rsq13);
943 rinv21 = gmx_invsqrt(rsq21);
944 rinv22 = gmx_invsqrt(rsq22);
945 rinv23 = gmx_invsqrt(rsq23);
946 rinv31 = gmx_invsqrt(rsq31);
947 rinv32 = gmx_invsqrt(rsq32);
948 rinv33 = gmx_invsqrt(rsq33);
950 rinvsq11 = rinv11*rinv11;
951 rinvsq12 = rinv12*rinv12;
952 rinvsq13 = rinv13*rinv13;
953 rinvsq21 = rinv21*rinv21;
954 rinvsq22 = rinv22*rinv22;
955 rinvsq23 = rinv23*rinv23;
956 rinvsq31 = rinv31*rinv31;
957 rinvsq32 = rinv32*rinv32;
958 rinvsq33 = rinv33*rinv33;
960 /**************************
961 * CALCULATE INTERACTIONS *
962 **************************/
966 /* Calculate table index by multiplying r with table scale and truncate to integer */
972 /* CUBIC SPLINE TABLE DISPERSION */
975 Geps = vfeps*vftab[vfitab+2];
976 Heps2 = vfeps*vfeps*vftab[vfitab+3];
978 FF = Fp+Geps+2.0*Heps2;
981 /* CUBIC SPLINE TABLE REPULSION */
983 Geps = vfeps*vftab[vfitab+6];
984 Heps2 = vfeps*vfeps*vftab[vfitab+7];
986 FF = Fp+Geps+2.0*Heps2;
988 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
992 /* Calculate temporary vectorial force */
997 /* Update vectorial force */
1001 f[j_coord_offset+DIM*0+XX] -= tx;
1002 f[j_coord_offset+DIM*0+YY] -= ty;
1003 f[j_coord_offset+DIM*0+ZZ] -= tz;
1005 /**************************
1006 * CALCULATE INTERACTIONS *
1007 **************************/
1011 /* EWALD ELECTROSTATICS */
1013 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1014 ewrt = r11*ewtabscale;
1016 eweps = ewrt-ewitab;
1017 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1018 felec = qq11*rinv11*(rinvsq11-felec);
1022 /* Calculate temporary vectorial force */
1027 /* Update vectorial force */
1031 f[j_coord_offset+DIM*1+XX] -= tx;
1032 f[j_coord_offset+DIM*1+YY] -= ty;
1033 f[j_coord_offset+DIM*1+ZZ] -= tz;
1035 /**************************
1036 * CALCULATE INTERACTIONS *
1037 **************************/
1041 /* EWALD ELECTROSTATICS */
1043 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1044 ewrt = r12*ewtabscale;
1046 eweps = ewrt-ewitab;
1047 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1048 felec = qq12*rinv12*(rinvsq12-felec);
1052 /* Calculate temporary vectorial force */
1057 /* Update vectorial force */
1061 f[j_coord_offset+DIM*2+XX] -= tx;
1062 f[j_coord_offset+DIM*2+YY] -= ty;
1063 f[j_coord_offset+DIM*2+ZZ] -= tz;
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1071 /* EWALD ELECTROSTATICS */
1073 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1074 ewrt = r13*ewtabscale;
1076 eweps = ewrt-ewitab;
1077 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1078 felec = qq13*rinv13*(rinvsq13-felec);
1082 /* Calculate temporary vectorial force */
1087 /* Update vectorial force */
1091 f[j_coord_offset+DIM*3+XX] -= tx;
1092 f[j_coord_offset+DIM*3+YY] -= ty;
1093 f[j_coord_offset+DIM*3+ZZ] -= tz;
1095 /**************************
1096 * CALCULATE INTERACTIONS *
1097 **************************/
1101 /* EWALD ELECTROSTATICS */
1103 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1104 ewrt = r21*ewtabscale;
1106 eweps = ewrt-ewitab;
1107 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1108 felec = qq21*rinv21*(rinvsq21-felec);
1112 /* Calculate temporary vectorial force */
1117 /* Update vectorial force */
1121 f[j_coord_offset+DIM*1+XX] -= tx;
1122 f[j_coord_offset+DIM*1+YY] -= ty;
1123 f[j_coord_offset+DIM*1+ZZ] -= tz;
1125 /**************************
1126 * CALCULATE INTERACTIONS *
1127 **************************/
1131 /* EWALD ELECTROSTATICS */
1133 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1134 ewrt = r22*ewtabscale;
1136 eweps = ewrt-ewitab;
1137 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1138 felec = qq22*rinv22*(rinvsq22-felec);
1142 /* Calculate temporary vectorial force */
1147 /* Update vectorial force */
1151 f[j_coord_offset+DIM*2+XX] -= tx;
1152 f[j_coord_offset+DIM*2+YY] -= ty;
1153 f[j_coord_offset+DIM*2+ZZ] -= tz;
1155 /**************************
1156 * CALCULATE INTERACTIONS *
1157 **************************/
1161 /* EWALD ELECTROSTATICS */
1163 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1164 ewrt = r23*ewtabscale;
1166 eweps = ewrt-ewitab;
1167 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1168 felec = qq23*rinv23*(rinvsq23-felec);
1172 /* Calculate temporary vectorial force */
1177 /* Update vectorial force */
1181 f[j_coord_offset+DIM*3+XX] -= tx;
1182 f[j_coord_offset+DIM*3+YY] -= ty;
1183 f[j_coord_offset+DIM*3+ZZ] -= tz;
1185 /**************************
1186 * CALCULATE INTERACTIONS *
1187 **************************/
1191 /* EWALD ELECTROSTATICS */
1193 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1194 ewrt = r31*ewtabscale;
1196 eweps = ewrt-ewitab;
1197 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1198 felec = qq31*rinv31*(rinvsq31-felec);
1202 /* Calculate temporary vectorial force */
1207 /* Update vectorial force */
1211 f[j_coord_offset+DIM*1+XX] -= tx;
1212 f[j_coord_offset+DIM*1+YY] -= ty;
1213 f[j_coord_offset+DIM*1+ZZ] -= tz;
1215 /**************************
1216 * CALCULATE INTERACTIONS *
1217 **************************/
1221 /* EWALD ELECTROSTATICS */
1223 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1224 ewrt = r32*ewtabscale;
1226 eweps = ewrt-ewitab;
1227 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1228 felec = qq32*rinv32*(rinvsq32-felec);
1232 /* Calculate temporary vectorial force */
1237 /* Update vectorial force */
1241 f[j_coord_offset+DIM*2+XX] -= tx;
1242 f[j_coord_offset+DIM*2+YY] -= ty;
1243 f[j_coord_offset+DIM*2+ZZ] -= tz;
1245 /**************************
1246 * CALCULATE INTERACTIONS *
1247 **************************/
1251 /* EWALD ELECTROSTATICS */
1253 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1254 ewrt = r33*ewtabscale;
1256 eweps = ewrt-ewitab;
1257 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1258 felec = qq33*rinv33*(rinvsq33-felec);
1262 /* Calculate temporary vectorial force */
1267 /* Update vectorial force */
1271 f[j_coord_offset+DIM*3+XX] -= tx;
1272 f[j_coord_offset+DIM*3+YY] -= ty;
1273 f[j_coord_offset+DIM*3+ZZ] -= tz;
1275 /* Inner loop uses 344 flops */
1277 /* End of innermost loop */
1280 f[i_coord_offset+DIM*0+XX] += fix0;
1281 f[i_coord_offset+DIM*0+YY] += fiy0;
1282 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1286 f[i_coord_offset+DIM*1+XX] += fix1;
1287 f[i_coord_offset+DIM*1+YY] += fiy1;
1288 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1292 f[i_coord_offset+DIM*2+XX] += fix2;
1293 f[i_coord_offset+DIM*2+YY] += fiy2;
1294 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1298 f[i_coord_offset+DIM*3+XX] += fix3;
1299 f[i_coord_offset+DIM*3+YY] += fiy3;
1300 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1304 fshift[i_shift_offset+XX] += tx;
1305 fshift[i_shift_offset+YY] += ty;
1306 fshift[i_shift_offset+ZZ] += tz;
1308 /* Increment number of inner iterations */
1309 inneriter += j_index_end - j_index_start;
1311 /* Outer loop uses 39 flops */
1314 /* Increment number of outer iterations */
1317 /* Update outer/inner flops */
1319 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*344);