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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJEw_GeomW4W4_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LJEwald
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwLJEw_GeomW4W4_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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;
85 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
86 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
87 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
88 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
89 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
90 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
91 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
92 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
93 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
94 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
95 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
96 real velec,felec,velecsum,facel,crf,krf,krf2;
99 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
112 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
115 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
123 jindex = nlist->jindex;
125 shiftidx = nlist->shift;
127 shiftvec = fr->shift_vec[0];
128 fshift = fr->fshift[0];
130 charge = mdatoms->chargeA;
131 nvdwtype = fr->ntype;
133 vdwtype = mdatoms->typeA;
134 vdwgridparam = fr->ljpme_c6grid;
135 ewclj = fr->ewaldcoeff_lj;
136 sh_lj_ewald = fr->ic->sh_lj_ewald;
137 ewclj2 = ewclj*ewclj;
138 ewclj6 = ewclj2*ewclj2*ewclj2;
140 sh_ewald = fr->ic->sh_ewald;
141 ewtab = fr->ic->tabq_coul_FDV0;
142 ewtabscale = fr->ic->tabq_scale;
143 ewtabhalfspace = 0.5/ewtabscale;
145 /* Setup water-specific parameters */
146 inr = nlist->iinr[0];
147 iq1 = facel*charge[inr+1];
148 iq2 = facel*charge[inr+2];
149 iq3 = facel*charge[inr+3];
150 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
155 vdwjidx0 = 2*vdwtype[inr+0];
156 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
157 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
158 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
172 /* Start outer loop over neighborlists */
173 for(iidx=0; iidx<nri; iidx++)
175 /* Load shift vector for this list */
176 i_shift_offset = DIM*shiftidx[iidx];
177 shX = shiftvec[i_shift_offset+XX];
178 shY = shiftvec[i_shift_offset+YY];
179 shZ = shiftvec[i_shift_offset+ZZ];
181 /* Load limits for loop over neighbors */
182 j_index_start = jindex[iidx];
183 j_index_end = jindex[iidx+1];
185 /* Get outer coordinate index */
187 i_coord_offset = DIM*inr;
189 /* Load i particle coords and add shift vector */
190 ix0 = shX + x[i_coord_offset+DIM*0+XX];
191 iy0 = shY + x[i_coord_offset+DIM*0+YY];
192 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
193 ix1 = shX + x[i_coord_offset+DIM*1+XX];
194 iy1 = shY + x[i_coord_offset+DIM*1+YY];
195 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
196 ix2 = shX + x[i_coord_offset+DIM*2+XX];
197 iy2 = shY + x[i_coord_offset+DIM*2+YY];
198 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
199 ix3 = shX + x[i_coord_offset+DIM*3+XX];
200 iy3 = shY + x[i_coord_offset+DIM*3+YY];
201 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
216 /* Reset potential sums */
220 /* Start inner kernel loop */
221 for(jidx=j_index_start; jidx<j_index_end; jidx++)
223 /* Get j neighbor index, and coordinate index */
225 j_coord_offset = DIM*jnr;
227 /* load j atom coordinates */
228 jx0 = x[j_coord_offset+DIM*0+XX];
229 jy0 = x[j_coord_offset+DIM*0+YY];
230 jz0 = x[j_coord_offset+DIM*0+ZZ];
231 jx1 = x[j_coord_offset+DIM*1+XX];
232 jy1 = x[j_coord_offset+DIM*1+YY];
233 jz1 = x[j_coord_offset+DIM*1+ZZ];
234 jx2 = x[j_coord_offset+DIM*2+XX];
235 jy2 = x[j_coord_offset+DIM*2+YY];
236 jz2 = x[j_coord_offset+DIM*2+ZZ];
237 jx3 = x[j_coord_offset+DIM*3+XX];
238 jy3 = x[j_coord_offset+DIM*3+YY];
239 jz3 = x[j_coord_offset+DIM*3+ZZ];
241 /* Calculate displacement vector */
273 /* Calculate squared distance and things based on it */
274 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
275 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
276 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
277 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
278 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
279 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
280 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
281 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
282 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
283 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
285 rinv00 = gmx_invsqrt(rsq00);
286 rinv11 = gmx_invsqrt(rsq11);
287 rinv12 = gmx_invsqrt(rsq12);
288 rinv13 = gmx_invsqrt(rsq13);
289 rinv21 = gmx_invsqrt(rsq21);
290 rinv22 = gmx_invsqrt(rsq22);
291 rinv23 = gmx_invsqrt(rsq23);
292 rinv31 = gmx_invsqrt(rsq31);
293 rinv32 = gmx_invsqrt(rsq32);
294 rinv33 = gmx_invsqrt(rsq33);
296 rinvsq00 = rinv00*rinv00;
297 rinvsq11 = rinv11*rinv11;
298 rinvsq12 = rinv12*rinv12;
299 rinvsq13 = rinv13*rinv13;
300 rinvsq21 = rinv21*rinv21;
301 rinvsq22 = rinv22*rinv22;
302 rinvsq23 = rinv23*rinv23;
303 rinvsq31 = rinv31*rinv31;
304 rinvsq32 = rinv32*rinv32;
305 rinvsq33 = rinv33*rinv33;
307 /**************************
308 * CALCULATE INTERACTIONS *
309 **************************/
313 rinvsix = rinvsq00*rinvsq00*rinvsq00;
314 ewcljrsq = ewclj2*rsq00;
315 exponent = exp(-ewcljrsq);
316 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
317 vvdw6 = (c6_00-c6grid_00*(1.0-poly))*rinvsix;
318 vvdw12 = c12_00*rinvsix*rinvsix;
319 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
320 fvdw = (vvdw12 - vvdw6 - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
322 /* Update potential sums from outer loop */
327 /* Calculate temporary vectorial force */
332 /* Update vectorial force */
336 f[j_coord_offset+DIM*0+XX] -= tx;
337 f[j_coord_offset+DIM*0+YY] -= ty;
338 f[j_coord_offset+DIM*0+ZZ] -= tz;
340 /**************************
341 * CALCULATE INTERACTIONS *
342 **************************/
346 /* EWALD ELECTROSTATICS */
348 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
349 ewrt = r11*ewtabscale;
353 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
354 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
355 felec = qq11*rinv11*(rinvsq11-felec);
357 /* Update potential sums from outer loop */
362 /* Calculate temporary vectorial force */
367 /* Update vectorial force */
371 f[j_coord_offset+DIM*1+XX] -= tx;
372 f[j_coord_offset+DIM*1+YY] -= ty;
373 f[j_coord_offset+DIM*1+ZZ] -= tz;
375 /**************************
376 * CALCULATE INTERACTIONS *
377 **************************/
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-(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;
410 /**************************
411 * CALCULATE INTERACTIONS *
412 **************************/
416 /* EWALD ELECTROSTATICS */
418 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
419 ewrt = r13*ewtabscale;
423 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
424 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
425 felec = qq13*rinv13*(rinvsq13-felec);
427 /* Update potential sums from outer loop */
432 /* Calculate temporary vectorial force */
437 /* Update vectorial force */
441 f[j_coord_offset+DIM*3+XX] -= tx;
442 f[j_coord_offset+DIM*3+YY] -= ty;
443 f[j_coord_offset+DIM*3+ZZ] -= tz;
445 /**************************
446 * CALCULATE INTERACTIONS *
447 **************************/
451 /* EWALD ELECTROSTATICS */
453 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
454 ewrt = r21*ewtabscale;
458 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
459 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
460 felec = qq21*rinv21*(rinvsq21-felec);
462 /* Update potential sums from outer loop */
467 /* Calculate temporary vectorial force */
472 /* Update vectorial force */
476 f[j_coord_offset+DIM*1+XX] -= tx;
477 f[j_coord_offset+DIM*1+YY] -= ty;
478 f[j_coord_offset+DIM*1+ZZ] -= tz;
480 /**************************
481 * CALCULATE INTERACTIONS *
482 **************************/
486 /* EWALD ELECTROSTATICS */
488 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
489 ewrt = r22*ewtabscale;
493 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
494 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
495 felec = qq22*rinv22*(rinvsq22-felec);
497 /* Update potential sums from outer loop */
502 /* Calculate temporary vectorial force */
507 /* Update vectorial force */
511 f[j_coord_offset+DIM*2+XX] -= tx;
512 f[j_coord_offset+DIM*2+YY] -= ty;
513 f[j_coord_offset+DIM*2+ZZ] -= tz;
515 /**************************
516 * CALCULATE INTERACTIONS *
517 **************************/
521 /* EWALD ELECTROSTATICS */
523 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
524 ewrt = r23*ewtabscale;
528 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
529 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
530 felec = qq23*rinv23*(rinvsq23-felec);
532 /* Update potential sums from outer loop */
537 /* Calculate temporary vectorial force */
542 /* Update vectorial force */
546 f[j_coord_offset+DIM*3+XX] -= tx;
547 f[j_coord_offset+DIM*3+YY] -= ty;
548 f[j_coord_offset+DIM*3+ZZ] -= tz;
550 /**************************
551 * CALCULATE INTERACTIONS *
552 **************************/
556 /* EWALD ELECTROSTATICS */
558 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
559 ewrt = r31*ewtabscale;
563 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
564 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
565 felec = qq31*rinv31*(rinvsq31-felec);
567 /* Update potential sums from outer loop */
572 /* Calculate temporary vectorial force */
577 /* Update vectorial force */
581 f[j_coord_offset+DIM*1+XX] -= tx;
582 f[j_coord_offset+DIM*1+YY] -= ty;
583 f[j_coord_offset+DIM*1+ZZ] -= tz;
585 /**************************
586 * CALCULATE INTERACTIONS *
587 **************************/
591 /* EWALD ELECTROSTATICS */
593 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
594 ewrt = r32*ewtabscale;
598 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
599 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
600 felec = qq32*rinv32*(rinvsq32-felec);
602 /* Update potential sums from outer loop */
607 /* Calculate temporary vectorial force */
612 /* Update vectorial force */
616 f[j_coord_offset+DIM*2+XX] -= tx;
617 f[j_coord_offset+DIM*2+YY] -= ty;
618 f[j_coord_offset+DIM*2+ZZ] -= tz;
620 /**************************
621 * CALCULATE INTERACTIONS *
622 **************************/
626 /* EWALD ELECTROSTATICS */
628 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
629 ewrt = r33*ewtabscale;
633 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
634 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
635 felec = qq33*rinv33*(rinvsq33-felec);
637 /* Update potential sums from outer loop */
642 /* Calculate temporary vectorial force */
647 /* Update vectorial force */
651 f[j_coord_offset+DIM*3+XX] -= tx;
652 f[j_coord_offset+DIM*3+YY] -= ty;
653 f[j_coord_offset+DIM*3+ZZ] -= tz;
655 /* Inner loop uses 409 flops */
657 /* End of innermost loop */
660 f[i_coord_offset+DIM*0+XX] += fix0;
661 f[i_coord_offset+DIM*0+YY] += fiy0;
662 f[i_coord_offset+DIM*0+ZZ] += fiz0;
666 f[i_coord_offset+DIM*1+XX] += fix1;
667 f[i_coord_offset+DIM*1+YY] += fiy1;
668 f[i_coord_offset+DIM*1+ZZ] += fiz1;
672 f[i_coord_offset+DIM*2+XX] += fix2;
673 f[i_coord_offset+DIM*2+YY] += fiy2;
674 f[i_coord_offset+DIM*2+ZZ] += fiz2;
678 f[i_coord_offset+DIM*3+XX] += fix3;
679 f[i_coord_offset+DIM*3+YY] += fiy3;
680 f[i_coord_offset+DIM*3+ZZ] += fiz3;
684 fshift[i_shift_offset+XX] += tx;
685 fshift[i_shift_offset+YY] += ty;
686 fshift[i_shift_offset+ZZ] += tz;
689 /* Update potential energies */
690 kernel_data->energygrp_elec[ggid] += velecsum;
691 kernel_data->energygrp_vdw[ggid] += vvdwsum;
693 /* Increment number of inner iterations */
694 inneriter += j_index_end - j_index_start;
696 /* Outer loop uses 41 flops */
699 /* Increment number of outer iterations */
702 /* Update outer/inner flops */
704 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*409);
707 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJEw_GeomW4W4_F_c
708 * Electrostatics interaction: Ewald
709 * VdW interaction: LJEwald
710 * Geometry: Water4-Water4
711 * Calculate force/pot: Force
714 nb_kernel_ElecEw_VdwLJEw_GeomW4W4_F_c
715 (t_nblist * gmx_restrict nlist,
716 rvec * gmx_restrict xx,
717 rvec * gmx_restrict ff,
718 t_forcerec * gmx_restrict fr,
719 t_mdatoms * gmx_restrict mdatoms,
720 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
721 t_nrnb * gmx_restrict nrnb)
723 int i_shift_offset,i_coord_offset,j_coord_offset;
724 int j_index_start,j_index_end;
725 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
726 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
727 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
728 real *shiftvec,*fshift,*x,*f;
730 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
732 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
734 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
736 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
738 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
740 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
742 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
744 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
745 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
746 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
747 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
748 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
749 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
750 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
751 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
752 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
753 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
754 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
755 real velec,felec,velecsum,facel,crf,krf,krf2;
758 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
771 real ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,sh_lj_ewald;
774 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
782 jindex = nlist->jindex;
784 shiftidx = nlist->shift;
786 shiftvec = fr->shift_vec[0];
787 fshift = fr->fshift[0];
789 charge = mdatoms->chargeA;
790 nvdwtype = fr->ntype;
792 vdwtype = mdatoms->typeA;
793 vdwgridparam = fr->ljpme_c6grid;
794 ewclj = fr->ewaldcoeff_lj;
795 sh_lj_ewald = fr->ic->sh_lj_ewald;
796 ewclj2 = ewclj*ewclj;
797 ewclj6 = ewclj2*ewclj2*ewclj2;
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];
817 c6grid_00 = vdwgridparam[vdwioffset0+vdwjidx0];
831 /* Start outer loop over neighborlists */
832 for(iidx=0; iidx<nri; iidx++)
834 /* Load shift vector for this list */
835 i_shift_offset = DIM*shiftidx[iidx];
836 shX = shiftvec[i_shift_offset+XX];
837 shY = shiftvec[i_shift_offset+YY];
838 shZ = shiftvec[i_shift_offset+ZZ];
840 /* Load limits for loop over neighbors */
841 j_index_start = jindex[iidx];
842 j_index_end = jindex[iidx+1];
844 /* Get outer coordinate index */
846 i_coord_offset = DIM*inr;
848 /* Load i particle coords and add shift vector */
849 ix0 = shX + x[i_coord_offset+DIM*0+XX];
850 iy0 = shY + x[i_coord_offset+DIM*0+YY];
851 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
852 ix1 = shX + x[i_coord_offset+DIM*1+XX];
853 iy1 = shY + x[i_coord_offset+DIM*1+YY];
854 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
855 ix2 = shX + x[i_coord_offset+DIM*2+XX];
856 iy2 = shY + x[i_coord_offset+DIM*2+YY];
857 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
858 ix3 = shX + x[i_coord_offset+DIM*3+XX];
859 iy3 = shY + x[i_coord_offset+DIM*3+YY];
860 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
875 /* Start inner kernel loop */
876 for(jidx=j_index_start; jidx<j_index_end; jidx++)
878 /* Get j neighbor index, and coordinate index */
880 j_coord_offset = DIM*jnr;
882 /* load j atom coordinates */
883 jx0 = x[j_coord_offset+DIM*0+XX];
884 jy0 = x[j_coord_offset+DIM*0+YY];
885 jz0 = x[j_coord_offset+DIM*0+ZZ];
886 jx1 = x[j_coord_offset+DIM*1+XX];
887 jy1 = x[j_coord_offset+DIM*1+YY];
888 jz1 = x[j_coord_offset+DIM*1+ZZ];
889 jx2 = x[j_coord_offset+DIM*2+XX];
890 jy2 = x[j_coord_offset+DIM*2+YY];
891 jz2 = x[j_coord_offset+DIM*2+ZZ];
892 jx3 = x[j_coord_offset+DIM*3+XX];
893 jy3 = x[j_coord_offset+DIM*3+YY];
894 jz3 = x[j_coord_offset+DIM*3+ZZ];
896 /* Calculate displacement vector */
928 /* Calculate squared distance and things based on it */
929 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
930 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
931 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
932 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
933 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
934 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
935 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
936 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
937 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
938 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
940 rinv00 = gmx_invsqrt(rsq00);
941 rinv11 = gmx_invsqrt(rsq11);
942 rinv12 = gmx_invsqrt(rsq12);
943 rinv13 = gmx_invsqrt(rsq13);
944 rinv21 = gmx_invsqrt(rsq21);
945 rinv22 = gmx_invsqrt(rsq22);
946 rinv23 = gmx_invsqrt(rsq23);
947 rinv31 = gmx_invsqrt(rsq31);
948 rinv32 = gmx_invsqrt(rsq32);
949 rinv33 = gmx_invsqrt(rsq33);
951 rinvsq00 = rinv00*rinv00;
952 rinvsq11 = rinv11*rinv11;
953 rinvsq12 = rinv12*rinv12;
954 rinvsq13 = rinv13*rinv13;
955 rinvsq21 = rinv21*rinv21;
956 rinvsq22 = rinv22*rinv22;
957 rinvsq23 = rinv23*rinv23;
958 rinvsq31 = rinv31*rinv31;
959 rinvsq32 = rinv32*rinv32;
960 rinvsq33 = rinv33*rinv33;
962 /**************************
963 * CALCULATE INTERACTIONS *
964 **************************/
968 rinvsix = rinvsq00*rinvsq00*rinvsq00;
969 ewcljrsq = ewclj2*rsq00;
970 exponent = exp(-ewcljrsq);
971 poly = exponent*(1.0 + ewcljrsq + ewcljrsq*ewcljrsq*0.5);
972 fvdw = (((c12_00*rinvsix - c6_00 + c6grid_00*(1.0-poly))*rinvsix) - c6grid_00*(1.0/6.0)*exponent*ewclj6)*rinvsq00;
976 /* Calculate temporary vectorial force */
981 /* Update vectorial force */
985 f[j_coord_offset+DIM*0+XX] -= tx;
986 f[j_coord_offset+DIM*0+YY] -= ty;
987 f[j_coord_offset+DIM*0+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 = r11*ewtabscale;
1000 eweps = ewrt-ewitab;
1001 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1002 felec = qq11*rinv11*(rinvsq11-felec);
1006 /* Calculate temporary vectorial force */
1011 /* Update vectorial force */
1015 f[j_coord_offset+DIM*1+XX] -= tx;
1016 f[j_coord_offset+DIM*1+YY] -= ty;
1017 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
1030 eweps = ewrt-ewitab;
1031 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1032 felec = qq12*rinv12*(rinvsq12-felec);
1036 /* Calculate temporary vectorial force */
1041 /* Update vectorial force */
1045 f[j_coord_offset+DIM*2+XX] -= tx;
1046 f[j_coord_offset+DIM*2+YY] -= ty;
1047 f[j_coord_offset+DIM*2+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 = r13*ewtabscale;
1060 eweps = ewrt-ewitab;
1061 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1062 felec = qq13*rinv13*(rinvsq13-felec);
1066 /* Calculate temporary vectorial force */
1071 /* Update vectorial force */
1075 f[j_coord_offset+DIM*3+XX] -= tx;
1076 f[j_coord_offset+DIM*3+YY] -= ty;
1077 f[j_coord_offset+DIM*3+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 = r21*ewtabscale;
1090 eweps = ewrt-ewitab;
1091 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1092 felec = qq21*rinv21*(rinvsq21-felec);
1096 /* Calculate temporary vectorial force */
1101 /* Update vectorial force */
1105 f[j_coord_offset+DIM*1+XX] -= tx;
1106 f[j_coord_offset+DIM*1+YY] -= ty;
1107 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
1120 eweps = ewrt-ewitab;
1121 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1122 felec = qq22*rinv22*(rinvsq22-felec);
1126 /* Calculate temporary vectorial force */
1131 /* Update vectorial force */
1135 f[j_coord_offset+DIM*2+XX] -= tx;
1136 f[j_coord_offset+DIM*2+YY] -= ty;
1137 f[j_coord_offset+DIM*2+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 = r23*ewtabscale;
1150 eweps = ewrt-ewitab;
1151 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1152 felec = qq23*rinv23*(rinvsq23-felec);
1156 /* Calculate temporary vectorial force */
1161 /* Update vectorial force */
1165 f[j_coord_offset+DIM*3+XX] -= tx;
1166 f[j_coord_offset+DIM*3+YY] -= ty;
1167 f[j_coord_offset+DIM*3+ZZ] -= tz;
1169 /**************************
1170 * CALCULATE INTERACTIONS *
1171 **************************/
1175 /* EWALD ELECTROSTATICS */
1177 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1178 ewrt = r31*ewtabscale;
1180 eweps = ewrt-ewitab;
1181 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1182 felec = qq31*rinv31*(rinvsq31-felec);
1186 /* Calculate temporary vectorial force */
1191 /* Update vectorial force */
1195 f[j_coord_offset+DIM*1+XX] -= tx;
1196 f[j_coord_offset+DIM*1+YY] -= ty;
1197 f[j_coord_offset+DIM*1+ZZ] -= tz;
1199 /**************************
1200 * CALCULATE INTERACTIONS *
1201 **************************/
1205 /* EWALD ELECTROSTATICS */
1207 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1208 ewrt = r32*ewtabscale;
1210 eweps = ewrt-ewitab;
1211 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1212 felec = qq32*rinv32*(rinvsq32-felec);
1216 /* Calculate temporary vectorial force */
1221 /* Update vectorial force */
1225 f[j_coord_offset+DIM*2+XX] -= tx;
1226 f[j_coord_offset+DIM*2+YY] -= ty;
1227 f[j_coord_offset+DIM*2+ZZ] -= tz;
1229 /**************************
1230 * CALCULATE INTERACTIONS *
1231 **************************/
1235 /* EWALD ELECTROSTATICS */
1237 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1238 ewrt = r33*ewtabscale;
1240 eweps = ewrt-ewitab;
1241 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1242 felec = qq33*rinv33*(rinvsq33-felec);
1246 /* Calculate temporary vectorial force */
1251 /* Update vectorial force */
1255 f[j_coord_offset+DIM*3+XX] -= tx;
1256 f[j_coord_offset+DIM*3+YY] -= ty;
1257 f[j_coord_offset+DIM*3+ZZ] -= tz;
1259 /* Inner loop uses 341 flops */
1261 /* End of innermost loop */
1264 f[i_coord_offset+DIM*0+XX] += fix0;
1265 f[i_coord_offset+DIM*0+YY] += fiy0;
1266 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1270 f[i_coord_offset+DIM*1+XX] += fix1;
1271 f[i_coord_offset+DIM*1+YY] += fiy1;
1272 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1276 f[i_coord_offset+DIM*2+XX] += fix2;
1277 f[i_coord_offset+DIM*2+YY] += fiy2;
1278 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1282 f[i_coord_offset+DIM*3+XX] += fix3;
1283 f[i_coord_offset+DIM*3+YY] += fiy3;
1284 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1288 fshift[i_shift_offset+XX] += tx;
1289 fshift[i_shift_offset+YY] += ty;
1290 fshift[i_shift_offset+ZZ] += tz;
1292 /* Increment number of inner iterations */
1293 inneriter += j_index_end - j_index_start;
1295 /* Outer loop uses 39 flops */
1298 /* Increment number of outer iterations */
1301 /* Update outer/inner flops */
1303 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*341);