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_ElecEwSh_VdwLJSh_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwLJSh_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];
153 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
154 rcutoff = fr->rcoulomb;
155 rcutoff2 = rcutoff*rcutoff;
157 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
163 /* Start outer loop over neighborlists */
164 for(iidx=0; iidx<nri; iidx++)
166 /* Load shift vector for this list */
167 i_shift_offset = DIM*shiftidx[iidx];
168 shX = shiftvec[i_shift_offset+XX];
169 shY = shiftvec[i_shift_offset+YY];
170 shZ = shiftvec[i_shift_offset+ZZ];
172 /* Load limits for loop over neighbors */
173 j_index_start = jindex[iidx];
174 j_index_end = jindex[iidx+1];
176 /* Get outer coordinate index */
178 i_coord_offset = DIM*inr;
180 /* Load i particle coords and add shift vector */
181 ix0 = shX + x[i_coord_offset+DIM*0+XX];
182 iy0 = shY + x[i_coord_offset+DIM*0+YY];
183 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
184 ix1 = shX + x[i_coord_offset+DIM*1+XX];
185 iy1 = shY + x[i_coord_offset+DIM*1+YY];
186 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
187 ix2 = shX + x[i_coord_offset+DIM*2+XX];
188 iy2 = shY + x[i_coord_offset+DIM*2+YY];
189 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
190 ix3 = shX + x[i_coord_offset+DIM*3+XX];
191 iy3 = shY + x[i_coord_offset+DIM*3+YY];
192 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
207 /* Reset potential sums */
211 /* Start inner kernel loop */
212 for(jidx=j_index_start; jidx<j_index_end; jidx++)
214 /* Get j neighbor index, and coordinate index */
216 j_coord_offset = DIM*jnr;
218 /* load j atom coordinates */
219 jx0 = x[j_coord_offset+DIM*0+XX];
220 jy0 = x[j_coord_offset+DIM*0+YY];
221 jz0 = x[j_coord_offset+DIM*0+ZZ];
222 jx1 = x[j_coord_offset+DIM*1+XX];
223 jy1 = x[j_coord_offset+DIM*1+YY];
224 jz1 = x[j_coord_offset+DIM*1+ZZ];
225 jx2 = x[j_coord_offset+DIM*2+XX];
226 jy2 = x[j_coord_offset+DIM*2+YY];
227 jz2 = x[j_coord_offset+DIM*2+ZZ];
228 jx3 = x[j_coord_offset+DIM*3+XX];
229 jy3 = x[j_coord_offset+DIM*3+YY];
230 jz3 = x[j_coord_offset+DIM*3+ZZ];
232 /* Calculate displacement vector */
264 /* Calculate squared distance and things based on it */
265 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
266 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
267 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
268 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
269 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
270 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
271 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
272 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
273 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
274 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
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 rinvsq00 = 1.0/rsq00;
287 rinvsq11 = rinv11*rinv11;
288 rinvsq12 = rinv12*rinv12;
289 rinvsq13 = rinv13*rinv13;
290 rinvsq21 = rinv21*rinv21;
291 rinvsq22 = rinv22*rinv22;
292 rinvsq23 = rinv23*rinv23;
293 rinvsq31 = rinv31*rinv31;
294 rinvsq32 = rinv32*rinv32;
295 rinvsq33 = rinv33*rinv33;
297 /**************************
298 * CALCULATE INTERACTIONS *
299 **************************/
304 /* LENNARD-JONES DISPERSION/REPULSION */
306 rinvsix = rinvsq00*rinvsq00*rinvsq00;
307 vvdw6 = c6_00*rinvsix;
308 vvdw12 = c12_00*rinvsix*rinvsix;
309 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
310 fvdw = (vvdw12-vvdw6)*rinvsq00;
312 /* Update potential sums from outer loop */
317 /* Calculate temporary vectorial force */
322 /* Update vectorial force */
326 f[j_coord_offset+DIM*0+XX] -= tx;
327 f[j_coord_offset+DIM*0+YY] -= ty;
328 f[j_coord_offset+DIM*0+ZZ] -= tz;
332 /**************************
333 * CALCULATE INTERACTIONS *
334 **************************/
341 /* EWALD ELECTROSTATICS */
343 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
344 ewrt = r11*ewtabscale;
348 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
349 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
350 felec = qq11*rinv11*(rinvsq11-felec);
352 /* Update potential sums from outer loop */
357 /* Calculate temporary vectorial force */
362 /* Update vectorial force */
366 f[j_coord_offset+DIM*1+XX] -= tx;
367 f[j_coord_offset+DIM*1+YY] -= ty;
368 f[j_coord_offset+DIM*1+ZZ] -= tz;
372 /**************************
373 * CALCULATE INTERACTIONS *
374 **************************/
381 /* EWALD ELECTROSTATICS */
383 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
384 ewrt = r12*ewtabscale;
388 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
389 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
390 felec = qq12*rinv12*(rinvsq12-felec);
392 /* Update potential sums from outer loop */
397 /* Calculate temporary vectorial force */
402 /* Update vectorial force */
406 f[j_coord_offset+DIM*2+XX] -= tx;
407 f[j_coord_offset+DIM*2+YY] -= ty;
408 f[j_coord_offset+DIM*2+ZZ] -= tz;
412 /**************************
413 * CALCULATE INTERACTIONS *
414 **************************/
421 /* EWALD ELECTROSTATICS */
423 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
424 ewrt = r13*ewtabscale;
428 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
429 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
430 felec = qq13*rinv13*(rinvsq13-felec);
432 /* Update potential sums from outer loop */
437 /* Calculate temporary vectorial force */
442 /* Update vectorial force */
446 f[j_coord_offset+DIM*3+XX] -= tx;
447 f[j_coord_offset+DIM*3+YY] -= ty;
448 f[j_coord_offset+DIM*3+ZZ] -= tz;
452 /**************************
453 * CALCULATE INTERACTIONS *
454 **************************/
461 /* EWALD ELECTROSTATICS */
463 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
464 ewrt = r21*ewtabscale;
468 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
469 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
470 felec = qq21*rinv21*(rinvsq21-felec);
472 /* Update potential sums from outer loop */
477 /* Calculate temporary vectorial force */
482 /* Update vectorial force */
486 f[j_coord_offset+DIM*1+XX] -= tx;
487 f[j_coord_offset+DIM*1+YY] -= ty;
488 f[j_coord_offset+DIM*1+ZZ] -= tz;
492 /**************************
493 * CALCULATE INTERACTIONS *
494 **************************/
501 /* EWALD ELECTROSTATICS */
503 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
504 ewrt = r22*ewtabscale;
508 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
509 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
510 felec = qq22*rinv22*(rinvsq22-felec);
512 /* Update potential sums from outer loop */
517 /* Calculate temporary vectorial force */
522 /* Update vectorial force */
526 f[j_coord_offset+DIM*2+XX] -= tx;
527 f[j_coord_offset+DIM*2+YY] -= ty;
528 f[j_coord_offset+DIM*2+ZZ] -= tz;
532 /**************************
533 * CALCULATE INTERACTIONS *
534 **************************/
541 /* EWALD ELECTROSTATICS */
543 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
544 ewrt = r23*ewtabscale;
548 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
549 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
550 felec = qq23*rinv23*(rinvsq23-felec);
552 /* Update potential sums from outer loop */
557 /* Calculate temporary vectorial force */
562 /* Update vectorial force */
566 f[j_coord_offset+DIM*3+XX] -= tx;
567 f[j_coord_offset+DIM*3+YY] -= ty;
568 f[j_coord_offset+DIM*3+ZZ] -= tz;
572 /**************************
573 * CALCULATE INTERACTIONS *
574 **************************/
581 /* EWALD ELECTROSTATICS */
583 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
584 ewrt = r31*ewtabscale;
588 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
589 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
590 felec = qq31*rinv31*(rinvsq31-felec);
592 /* Update potential sums from outer loop */
597 /* Calculate temporary vectorial force */
602 /* Update vectorial force */
606 f[j_coord_offset+DIM*1+XX] -= tx;
607 f[j_coord_offset+DIM*1+YY] -= ty;
608 f[j_coord_offset+DIM*1+ZZ] -= tz;
612 /**************************
613 * CALCULATE INTERACTIONS *
614 **************************/
621 /* EWALD ELECTROSTATICS */
623 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
624 ewrt = r32*ewtabscale;
628 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
629 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
630 felec = qq32*rinv32*(rinvsq32-felec);
632 /* Update potential sums from outer loop */
637 /* Calculate temporary vectorial force */
642 /* Update vectorial force */
646 f[j_coord_offset+DIM*2+XX] -= tx;
647 f[j_coord_offset+DIM*2+YY] -= ty;
648 f[j_coord_offset+DIM*2+ZZ] -= tz;
652 /**************************
653 * CALCULATE INTERACTIONS *
654 **************************/
661 /* EWALD ELECTROSTATICS */
663 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
664 ewrt = r33*ewtabscale;
668 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
669 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
670 felec = qq33*rinv33*(rinvsq33-felec);
672 /* Update potential sums from outer loop */
677 /* Calculate temporary vectorial force */
682 /* Update vectorial force */
686 f[j_coord_offset+DIM*3+XX] -= tx;
687 f[j_coord_offset+DIM*3+YY] -= ty;
688 f[j_coord_offset+DIM*3+ZZ] -= tz;
692 /* Inner loop uses 406 flops */
694 /* End of innermost loop */
697 f[i_coord_offset+DIM*0+XX] += fix0;
698 f[i_coord_offset+DIM*0+YY] += fiy0;
699 f[i_coord_offset+DIM*0+ZZ] += fiz0;
703 f[i_coord_offset+DIM*1+XX] += fix1;
704 f[i_coord_offset+DIM*1+YY] += fiy1;
705 f[i_coord_offset+DIM*1+ZZ] += fiz1;
709 f[i_coord_offset+DIM*2+XX] += fix2;
710 f[i_coord_offset+DIM*2+YY] += fiy2;
711 f[i_coord_offset+DIM*2+ZZ] += fiz2;
715 f[i_coord_offset+DIM*3+XX] += fix3;
716 f[i_coord_offset+DIM*3+YY] += fiy3;
717 f[i_coord_offset+DIM*3+ZZ] += fiz3;
721 fshift[i_shift_offset+XX] += tx;
722 fshift[i_shift_offset+YY] += ty;
723 fshift[i_shift_offset+ZZ] += tz;
726 /* Update potential energies */
727 kernel_data->energygrp_elec[ggid] += velecsum;
728 kernel_data->energygrp_vdw[ggid] += vvdwsum;
730 /* Increment number of inner iterations */
731 inneriter += j_index_end - j_index_start;
733 /* Outer loop uses 41 flops */
736 /* Increment number of outer iterations */
739 /* Update outer/inner flops */
741 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*406);
744 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_c
745 * Electrostatics interaction: Ewald
746 * VdW interaction: LennardJones
747 * Geometry: Water4-Water4
748 * Calculate force/pot: Force
751 nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_c
752 (t_nblist * gmx_restrict nlist,
753 rvec * gmx_restrict xx,
754 rvec * gmx_restrict ff,
755 t_forcerec * gmx_restrict fr,
756 t_mdatoms * gmx_restrict mdatoms,
757 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
758 t_nrnb * gmx_restrict nrnb)
760 int i_shift_offset,i_coord_offset,j_coord_offset;
761 int j_index_start,j_index_end;
762 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
763 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
764 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
765 real *shiftvec,*fshift,*x,*f;
767 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
769 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
771 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
773 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
775 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
777 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
779 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
781 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
782 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
783 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
784 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
785 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
786 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
787 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
788 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
789 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
790 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
791 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
792 real velec,felec,velecsum,facel,crf,krf,krf2;
795 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
799 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
807 jindex = nlist->jindex;
809 shiftidx = nlist->shift;
811 shiftvec = fr->shift_vec[0];
812 fshift = fr->fshift[0];
814 charge = mdatoms->chargeA;
815 nvdwtype = fr->ntype;
817 vdwtype = mdatoms->typeA;
819 sh_ewald = fr->ic->sh_ewald;
820 ewtab = fr->ic->tabq_coul_F;
821 ewtabscale = fr->ic->tabq_scale;
822 ewtabhalfspace = 0.5/ewtabscale;
824 /* Setup water-specific parameters */
825 inr = nlist->iinr[0];
826 iq1 = facel*charge[inr+1];
827 iq2 = facel*charge[inr+2];
828 iq3 = facel*charge[inr+3];
829 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
834 vdwjidx0 = 2*vdwtype[inr+0];
835 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
836 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
847 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
848 rcutoff = fr->rcoulomb;
849 rcutoff2 = rcutoff*rcutoff;
851 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
857 /* Start outer loop over neighborlists */
858 for(iidx=0; iidx<nri; iidx++)
860 /* Load shift vector for this list */
861 i_shift_offset = DIM*shiftidx[iidx];
862 shX = shiftvec[i_shift_offset+XX];
863 shY = shiftvec[i_shift_offset+YY];
864 shZ = shiftvec[i_shift_offset+ZZ];
866 /* Load limits for loop over neighbors */
867 j_index_start = jindex[iidx];
868 j_index_end = jindex[iidx+1];
870 /* Get outer coordinate index */
872 i_coord_offset = DIM*inr;
874 /* Load i particle coords and add shift vector */
875 ix0 = shX + x[i_coord_offset+DIM*0+XX];
876 iy0 = shY + x[i_coord_offset+DIM*0+YY];
877 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
878 ix1 = shX + x[i_coord_offset+DIM*1+XX];
879 iy1 = shY + x[i_coord_offset+DIM*1+YY];
880 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
881 ix2 = shX + x[i_coord_offset+DIM*2+XX];
882 iy2 = shY + x[i_coord_offset+DIM*2+YY];
883 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
884 ix3 = shX + x[i_coord_offset+DIM*3+XX];
885 iy3 = shY + x[i_coord_offset+DIM*3+YY];
886 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
901 /* Start inner kernel loop */
902 for(jidx=j_index_start; jidx<j_index_end; jidx++)
904 /* Get j neighbor index, and coordinate index */
906 j_coord_offset = DIM*jnr;
908 /* load j atom coordinates */
909 jx0 = x[j_coord_offset+DIM*0+XX];
910 jy0 = x[j_coord_offset+DIM*0+YY];
911 jz0 = x[j_coord_offset+DIM*0+ZZ];
912 jx1 = x[j_coord_offset+DIM*1+XX];
913 jy1 = x[j_coord_offset+DIM*1+YY];
914 jz1 = x[j_coord_offset+DIM*1+ZZ];
915 jx2 = x[j_coord_offset+DIM*2+XX];
916 jy2 = x[j_coord_offset+DIM*2+YY];
917 jz2 = x[j_coord_offset+DIM*2+ZZ];
918 jx3 = x[j_coord_offset+DIM*3+XX];
919 jy3 = x[j_coord_offset+DIM*3+YY];
920 jz3 = x[j_coord_offset+DIM*3+ZZ];
922 /* Calculate displacement vector */
954 /* Calculate squared distance and things based on it */
955 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
956 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
957 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
958 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
959 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
960 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
961 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
962 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
963 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
964 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
966 rinv11 = gmx_invsqrt(rsq11);
967 rinv12 = gmx_invsqrt(rsq12);
968 rinv13 = gmx_invsqrt(rsq13);
969 rinv21 = gmx_invsqrt(rsq21);
970 rinv22 = gmx_invsqrt(rsq22);
971 rinv23 = gmx_invsqrt(rsq23);
972 rinv31 = gmx_invsqrt(rsq31);
973 rinv32 = gmx_invsqrt(rsq32);
974 rinv33 = gmx_invsqrt(rsq33);
976 rinvsq00 = 1.0/rsq00;
977 rinvsq11 = rinv11*rinv11;
978 rinvsq12 = rinv12*rinv12;
979 rinvsq13 = rinv13*rinv13;
980 rinvsq21 = rinv21*rinv21;
981 rinvsq22 = rinv22*rinv22;
982 rinvsq23 = rinv23*rinv23;
983 rinvsq31 = rinv31*rinv31;
984 rinvsq32 = rinv32*rinv32;
985 rinvsq33 = rinv33*rinv33;
987 /**************************
988 * CALCULATE INTERACTIONS *
989 **************************/
994 /* LENNARD-JONES DISPERSION/REPULSION */
996 rinvsix = rinvsq00*rinvsq00*rinvsq00;
997 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
1001 /* Calculate temporary vectorial force */
1006 /* Update vectorial force */
1010 f[j_coord_offset+DIM*0+XX] -= tx;
1011 f[j_coord_offset+DIM*0+YY] -= ty;
1012 f[j_coord_offset+DIM*0+ZZ] -= tz;
1016 /**************************
1017 * CALCULATE INTERACTIONS *
1018 **************************/
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;
1051 /**************************
1052 * CALCULATE INTERACTIONS *
1053 **************************/
1060 /* EWALD ELECTROSTATICS */
1062 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1063 ewrt = r12*ewtabscale;
1065 eweps = ewrt-ewitab;
1066 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1067 felec = qq12*rinv12*(rinvsq12-felec);
1071 /* Calculate temporary vectorial force */
1076 /* Update vectorial force */
1080 f[j_coord_offset+DIM*2+XX] -= tx;
1081 f[j_coord_offset+DIM*2+YY] -= ty;
1082 f[j_coord_offset+DIM*2+ZZ] -= tz;
1086 /**************************
1087 * CALCULATE INTERACTIONS *
1088 **************************/
1095 /* EWALD ELECTROSTATICS */
1097 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1098 ewrt = r13*ewtabscale;
1100 eweps = ewrt-ewitab;
1101 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1102 felec = qq13*rinv13*(rinvsq13-felec);
1106 /* Calculate temporary vectorial force */
1111 /* Update vectorial force */
1115 f[j_coord_offset+DIM*3+XX] -= tx;
1116 f[j_coord_offset+DIM*3+YY] -= ty;
1117 f[j_coord_offset+DIM*3+ZZ] -= tz;
1121 /**************************
1122 * CALCULATE INTERACTIONS *
1123 **************************/
1130 /* EWALD ELECTROSTATICS */
1132 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1133 ewrt = r21*ewtabscale;
1135 eweps = ewrt-ewitab;
1136 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1137 felec = qq21*rinv21*(rinvsq21-felec);
1141 /* Calculate temporary vectorial force */
1146 /* Update vectorial force */
1150 f[j_coord_offset+DIM*1+XX] -= tx;
1151 f[j_coord_offset+DIM*1+YY] -= ty;
1152 f[j_coord_offset+DIM*1+ZZ] -= tz;
1156 /**************************
1157 * CALCULATE INTERACTIONS *
1158 **************************/
1165 /* EWALD ELECTROSTATICS */
1167 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1168 ewrt = r22*ewtabscale;
1170 eweps = ewrt-ewitab;
1171 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1172 felec = qq22*rinv22*(rinvsq22-felec);
1176 /* Calculate temporary vectorial force */
1181 /* Update vectorial force */
1185 f[j_coord_offset+DIM*2+XX] -= tx;
1186 f[j_coord_offset+DIM*2+YY] -= ty;
1187 f[j_coord_offset+DIM*2+ZZ] -= tz;
1191 /**************************
1192 * CALCULATE INTERACTIONS *
1193 **************************/
1200 /* EWALD ELECTROSTATICS */
1202 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1203 ewrt = r23*ewtabscale;
1205 eweps = ewrt-ewitab;
1206 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1207 felec = qq23*rinv23*(rinvsq23-felec);
1211 /* Calculate temporary vectorial force */
1216 /* Update vectorial force */
1220 f[j_coord_offset+DIM*3+XX] -= tx;
1221 f[j_coord_offset+DIM*3+YY] -= ty;
1222 f[j_coord_offset+DIM*3+ZZ] -= tz;
1226 /**************************
1227 * CALCULATE INTERACTIONS *
1228 **************************/
1235 /* EWALD ELECTROSTATICS */
1237 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1238 ewrt = r31*ewtabscale;
1240 eweps = ewrt-ewitab;
1241 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1242 felec = qq31*rinv31*(rinvsq31-felec);
1246 /* Calculate temporary vectorial force */
1251 /* Update vectorial force */
1255 f[j_coord_offset+DIM*1+XX] -= tx;
1256 f[j_coord_offset+DIM*1+YY] -= ty;
1257 f[j_coord_offset+DIM*1+ZZ] -= tz;
1261 /**************************
1262 * CALCULATE INTERACTIONS *
1263 **************************/
1270 /* EWALD ELECTROSTATICS */
1272 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1273 ewrt = r32*ewtabscale;
1275 eweps = ewrt-ewitab;
1276 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1277 felec = qq32*rinv32*(rinvsq32-felec);
1281 /* Calculate temporary vectorial force */
1286 /* Update vectorial force */
1290 f[j_coord_offset+DIM*2+XX] -= tx;
1291 f[j_coord_offset+DIM*2+YY] -= ty;
1292 f[j_coord_offset+DIM*2+ZZ] -= tz;
1296 /**************************
1297 * CALCULATE INTERACTIONS *
1298 **************************/
1305 /* EWALD ELECTROSTATICS */
1307 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1308 ewrt = r33*ewtabscale;
1310 eweps = ewrt-ewitab;
1311 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1312 felec = qq33*rinv33*(rinvsq33-felec);
1316 /* Calculate temporary vectorial force */
1321 /* Update vectorial force */
1325 f[j_coord_offset+DIM*3+XX] -= tx;
1326 f[j_coord_offset+DIM*3+YY] -= ty;
1327 f[j_coord_offset+DIM*3+ZZ] -= tz;
1331 /* Inner loop uses 324 flops */
1333 /* End of innermost loop */
1336 f[i_coord_offset+DIM*0+XX] += fix0;
1337 f[i_coord_offset+DIM*0+YY] += fiy0;
1338 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1342 f[i_coord_offset+DIM*1+XX] += fix1;
1343 f[i_coord_offset+DIM*1+YY] += fiy1;
1344 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1348 f[i_coord_offset+DIM*2+XX] += fix2;
1349 f[i_coord_offset+DIM*2+YY] += fiy2;
1350 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1354 f[i_coord_offset+DIM*3+XX] += fix3;
1355 f[i_coord_offset+DIM*3+YY] += fiy3;
1356 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1360 fshift[i_shift_offset+XX] += tx;
1361 fshift[i_shift_offset+YY] += ty;
1362 fshift[i_shift_offset+ZZ] += tz;
1364 /* Increment number of inner iterations */
1365 inneriter += j_index_end - j_index_start;
1367 /* Outer loop uses 39 flops */
1370 /* Increment number of outer iterations */
1373 /* Update outer/inner flops */
1375 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*324);