2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW4W4_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_VdwBhamSh_GeomW4W4_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
65 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
67 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
69 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
71 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
72 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
73 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
74 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
75 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
76 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
77 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
78 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
79 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
80 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
81 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
82 real velec,felec,velecsum,facel,crf,krf,krf2;
85 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
89 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
97 jindex = nlist->jindex;
99 shiftidx = nlist->shift;
101 shiftvec = fr->shift_vec[0];
102 fshift = fr->fshift[0];
104 charge = mdatoms->chargeA;
105 nvdwtype = fr->ntype;
107 vdwtype = mdatoms->typeA;
109 sh_ewald = fr->ic->sh_ewald;
110 ewtab = fr->ic->tabq_coul_FDV0;
111 ewtabscale = fr->ic->tabq_scale;
112 ewtabhalfspace = 0.5/ewtabscale;
114 /* Setup water-specific parameters */
115 inr = nlist->iinr[0];
116 iq1 = facel*charge[inr+1];
117 iq2 = facel*charge[inr+2];
118 iq3 = facel*charge[inr+3];
119 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
124 vdwjidx0 = 3*vdwtype[inr+0];
125 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
126 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
127 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
138 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
139 rcutoff = fr->rcoulomb;
140 rcutoff2 = rcutoff*rcutoff;
142 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
148 /* Start outer loop over neighborlists */
149 for(iidx=0; iidx<nri; iidx++)
151 /* Load shift vector for this list */
152 i_shift_offset = DIM*shiftidx[iidx];
153 shX = shiftvec[i_shift_offset+XX];
154 shY = shiftvec[i_shift_offset+YY];
155 shZ = shiftvec[i_shift_offset+ZZ];
157 /* Load limits for loop over neighbors */
158 j_index_start = jindex[iidx];
159 j_index_end = jindex[iidx+1];
161 /* Get outer coordinate index */
163 i_coord_offset = DIM*inr;
165 /* Load i particle coords and add shift vector */
166 ix0 = shX + x[i_coord_offset+DIM*0+XX];
167 iy0 = shY + x[i_coord_offset+DIM*0+YY];
168 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
169 ix1 = shX + x[i_coord_offset+DIM*1+XX];
170 iy1 = shY + x[i_coord_offset+DIM*1+YY];
171 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
172 ix2 = shX + x[i_coord_offset+DIM*2+XX];
173 iy2 = shY + x[i_coord_offset+DIM*2+YY];
174 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
175 ix3 = shX + x[i_coord_offset+DIM*3+XX];
176 iy3 = shY + x[i_coord_offset+DIM*3+YY];
177 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
192 /* Reset potential sums */
196 /* Start inner kernel loop */
197 for(jidx=j_index_start; jidx<j_index_end; jidx++)
199 /* Get j neighbor index, and coordinate index */
201 j_coord_offset = DIM*jnr;
203 /* load j atom coordinates */
204 jx0 = x[j_coord_offset+DIM*0+XX];
205 jy0 = x[j_coord_offset+DIM*0+YY];
206 jz0 = x[j_coord_offset+DIM*0+ZZ];
207 jx1 = x[j_coord_offset+DIM*1+XX];
208 jy1 = x[j_coord_offset+DIM*1+YY];
209 jz1 = x[j_coord_offset+DIM*1+ZZ];
210 jx2 = x[j_coord_offset+DIM*2+XX];
211 jy2 = x[j_coord_offset+DIM*2+YY];
212 jz2 = x[j_coord_offset+DIM*2+ZZ];
213 jx3 = x[j_coord_offset+DIM*3+XX];
214 jy3 = x[j_coord_offset+DIM*3+YY];
215 jz3 = x[j_coord_offset+DIM*3+ZZ];
217 /* Calculate displacement vector */
249 /* Calculate squared distance and things based on it */
250 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
251 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
252 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
253 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
254 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
255 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
256 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
257 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
258 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
259 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
261 rinv00 = gmx_invsqrt(rsq00);
262 rinv11 = gmx_invsqrt(rsq11);
263 rinv12 = gmx_invsqrt(rsq12);
264 rinv13 = gmx_invsqrt(rsq13);
265 rinv21 = gmx_invsqrt(rsq21);
266 rinv22 = gmx_invsqrt(rsq22);
267 rinv23 = gmx_invsqrt(rsq23);
268 rinv31 = gmx_invsqrt(rsq31);
269 rinv32 = gmx_invsqrt(rsq32);
270 rinv33 = gmx_invsqrt(rsq33);
272 rinvsq00 = rinv00*rinv00;
273 rinvsq11 = rinv11*rinv11;
274 rinvsq12 = rinv12*rinv12;
275 rinvsq13 = rinv13*rinv13;
276 rinvsq21 = rinv21*rinv21;
277 rinvsq22 = rinv22*rinv22;
278 rinvsq23 = rinv23*rinv23;
279 rinvsq31 = rinv31*rinv31;
280 rinvsq32 = rinv32*rinv32;
281 rinvsq33 = rinv33*rinv33;
283 /**************************
284 * CALCULATE INTERACTIONS *
285 **************************/
292 /* BUCKINGHAM DISPERSION/REPULSION */
293 rinvsix = rinvsq00*rinvsq00*rinvsq00;
294 vvdw6 = c6_00*rinvsix;
296 vvdwexp = cexp1_00*exp(-br);
297 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
298 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
300 /* Update potential sums from outer loop */
305 /* Calculate temporary vectorial force */
310 /* Update vectorial force */
314 f[j_coord_offset+DIM*0+XX] -= tx;
315 f[j_coord_offset+DIM*0+YY] -= ty;
316 f[j_coord_offset+DIM*0+ZZ] -= tz;
320 /**************************
321 * CALCULATE INTERACTIONS *
322 **************************/
329 /* EWALD ELECTROSTATICS */
331 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
332 ewrt = r11*ewtabscale;
336 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
337 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
338 felec = qq11*rinv11*(rinvsq11-felec);
340 /* Update potential sums from outer loop */
345 /* Calculate temporary vectorial force */
350 /* Update vectorial force */
354 f[j_coord_offset+DIM*1+XX] -= tx;
355 f[j_coord_offset+DIM*1+YY] -= ty;
356 f[j_coord_offset+DIM*1+ZZ] -= tz;
360 /**************************
361 * CALCULATE INTERACTIONS *
362 **************************/
369 /* EWALD ELECTROSTATICS */
371 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
372 ewrt = r12*ewtabscale;
376 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
377 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
378 felec = qq12*rinv12*(rinvsq12-felec);
380 /* Update potential sums from outer loop */
385 /* Calculate temporary vectorial force */
390 /* Update vectorial force */
394 f[j_coord_offset+DIM*2+XX] -= tx;
395 f[j_coord_offset+DIM*2+YY] -= ty;
396 f[j_coord_offset+DIM*2+ZZ] -= tz;
400 /**************************
401 * CALCULATE INTERACTIONS *
402 **************************/
409 /* EWALD ELECTROSTATICS */
411 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
412 ewrt = r13*ewtabscale;
416 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
417 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
418 felec = qq13*rinv13*(rinvsq13-felec);
420 /* Update potential sums from outer loop */
425 /* Calculate temporary vectorial force */
430 /* Update vectorial force */
434 f[j_coord_offset+DIM*3+XX] -= tx;
435 f[j_coord_offset+DIM*3+YY] -= ty;
436 f[j_coord_offset+DIM*3+ZZ] -= tz;
440 /**************************
441 * CALCULATE INTERACTIONS *
442 **************************/
449 /* EWALD ELECTROSTATICS */
451 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
452 ewrt = r21*ewtabscale;
456 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
457 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
458 felec = qq21*rinv21*(rinvsq21-felec);
460 /* Update potential sums from outer loop */
465 /* Calculate temporary vectorial force */
470 /* Update vectorial force */
474 f[j_coord_offset+DIM*1+XX] -= tx;
475 f[j_coord_offset+DIM*1+YY] -= ty;
476 f[j_coord_offset+DIM*1+ZZ] -= tz;
480 /**************************
481 * CALCULATE INTERACTIONS *
482 **************************/
489 /* EWALD ELECTROSTATICS */
491 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
492 ewrt = r22*ewtabscale;
496 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
497 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
498 felec = qq22*rinv22*(rinvsq22-felec);
500 /* Update potential sums from outer loop */
505 /* Calculate temporary vectorial force */
510 /* Update vectorial force */
514 f[j_coord_offset+DIM*2+XX] -= tx;
515 f[j_coord_offset+DIM*2+YY] -= ty;
516 f[j_coord_offset+DIM*2+ZZ] -= tz;
520 /**************************
521 * CALCULATE INTERACTIONS *
522 **************************/
529 /* EWALD ELECTROSTATICS */
531 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
532 ewrt = r23*ewtabscale;
536 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
537 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
538 felec = qq23*rinv23*(rinvsq23-felec);
540 /* Update potential sums from outer loop */
545 /* Calculate temporary vectorial force */
550 /* Update vectorial force */
554 f[j_coord_offset+DIM*3+XX] -= tx;
555 f[j_coord_offset+DIM*3+YY] -= ty;
556 f[j_coord_offset+DIM*3+ZZ] -= tz;
560 /**************************
561 * CALCULATE INTERACTIONS *
562 **************************/
569 /* EWALD ELECTROSTATICS */
571 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
572 ewrt = r31*ewtabscale;
576 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
577 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
578 felec = qq31*rinv31*(rinvsq31-felec);
580 /* Update potential sums from outer loop */
585 /* Calculate temporary vectorial force */
590 /* Update vectorial force */
594 f[j_coord_offset+DIM*1+XX] -= tx;
595 f[j_coord_offset+DIM*1+YY] -= ty;
596 f[j_coord_offset+DIM*1+ZZ] -= tz;
600 /**************************
601 * CALCULATE INTERACTIONS *
602 **************************/
609 /* EWALD ELECTROSTATICS */
611 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
612 ewrt = r32*ewtabscale;
616 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
617 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
618 felec = qq32*rinv32*(rinvsq32-felec);
620 /* Update potential sums from outer loop */
625 /* Calculate temporary vectorial force */
630 /* Update vectorial force */
634 f[j_coord_offset+DIM*2+XX] -= tx;
635 f[j_coord_offset+DIM*2+YY] -= ty;
636 f[j_coord_offset+DIM*2+ZZ] -= tz;
640 /**************************
641 * CALCULATE INTERACTIONS *
642 **************************/
649 /* EWALD ELECTROSTATICS */
651 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
652 ewrt = r33*ewtabscale;
656 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
657 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
658 felec = qq33*rinv33*(rinvsq33-felec);
660 /* Update potential sums from outer loop */
665 /* Calculate temporary vectorial force */
670 /* Update vectorial force */
674 f[j_coord_offset+DIM*3+XX] -= tx;
675 f[j_coord_offset+DIM*3+YY] -= ty;
676 f[j_coord_offset+DIM*3+ZZ] -= tz;
680 /* Inner loop uses 461 flops */
682 /* End of innermost loop */
685 f[i_coord_offset+DIM*0+XX] += fix0;
686 f[i_coord_offset+DIM*0+YY] += fiy0;
687 f[i_coord_offset+DIM*0+ZZ] += fiz0;
691 f[i_coord_offset+DIM*1+XX] += fix1;
692 f[i_coord_offset+DIM*1+YY] += fiy1;
693 f[i_coord_offset+DIM*1+ZZ] += fiz1;
697 f[i_coord_offset+DIM*2+XX] += fix2;
698 f[i_coord_offset+DIM*2+YY] += fiy2;
699 f[i_coord_offset+DIM*2+ZZ] += fiz2;
703 f[i_coord_offset+DIM*3+XX] += fix3;
704 f[i_coord_offset+DIM*3+YY] += fiy3;
705 f[i_coord_offset+DIM*3+ZZ] += fiz3;
709 fshift[i_shift_offset+XX] += tx;
710 fshift[i_shift_offset+YY] += ty;
711 fshift[i_shift_offset+ZZ] += tz;
714 /* Update potential energies */
715 kernel_data->energygrp_elec[ggid] += velecsum;
716 kernel_data->energygrp_vdw[ggid] += vvdwsum;
718 /* Increment number of inner iterations */
719 inneriter += j_index_end - j_index_start;
721 /* Outer loop uses 41 flops */
724 /* Increment number of outer iterations */
727 /* Update outer/inner flops */
729 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*461);
732 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW4W4_F_c
733 * Electrostatics interaction: Ewald
734 * VdW interaction: Buckingham
735 * Geometry: Water4-Water4
736 * Calculate force/pot: Force
739 nb_kernel_ElecEwSh_VdwBhamSh_GeomW4W4_F_c
740 (t_nblist * gmx_restrict nlist,
741 rvec * gmx_restrict xx,
742 rvec * gmx_restrict ff,
743 t_forcerec * gmx_restrict fr,
744 t_mdatoms * gmx_restrict mdatoms,
745 nb_kernel_data_t * gmx_restrict kernel_data,
746 t_nrnb * gmx_restrict nrnb)
748 int i_shift_offset,i_coord_offset,j_coord_offset;
749 int j_index_start,j_index_end;
750 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
751 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
752 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
753 real *shiftvec,*fshift,*x,*f;
755 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
757 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
759 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
761 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
763 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
765 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
767 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
769 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
770 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
771 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
772 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
773 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
774 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
775 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
776 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
777 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
778 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
779 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
780 real velec,felec,velecsum,facel,crf,krf,krf2;
783 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
787 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
795 jindex = nlist->jindex;
797 shiftidx = nlist->shift;
799 shiftvec = fr->shift_vec[0];
800 fshift = fr->fshift[0];
802 charge = mdatoms->chargeA;
803 nvdwtype = fr->ntype;
805 vdwtype = mdatoms->typeA;
807 sh_ewald = fr->ic->sh_ewald;
808 ewtab = fr->ic->tabq_coul_F;
809 ewtabscale = fr->ic->tabq_scale;
810 ewtabhalfspace = 0.5/ewtabscale;
812 /* Setup water-specific parameters */
813 inr = nlist->iinr[0];
814 iq1 = facel*charge[inr+1];
815 iq2 = facel*charge[inr+2];
816 iq3 = facel*charge[inr+3];
817 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
822 vdwjidx0 = 3*vdwtype[inr+0];
823 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
824 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
825 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
836 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
837 rcutoff = fr->rcoulomb;
838 rcutoff2 = rcutoff*rcutoff;
840 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
846 /* Start outer loop over neighborlists */
847 for(iidx=0; iidx<nri; iidx++)
849 /* Load shift vector for this list */
850 i_shift_offset = DIM*shiftidx[iidx];
851 shX = shiftvec[i_shift_offset+XX];
852 shY = shiftvec[i_shift_offset+YY];
853 shZ = shiftvec[i_shift_offset+ZZ];
855 /* Load limits for loop over neighbors */
856 j_index_start = jindex[iidx];
857 j_index_end = jindex[iidx+1];
859 /* Get outer coordinate index */
861 i_coord_offset = DIM*inr;
863 /* Load i particle coords and add shift vector */
864 ix0 = shX + x[i_coord_offset+DIM*0+XX];
865 iy0 = shY + x[i_coord_offset+DIM*0+YY];
866 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
867 ix1 = shX + x[i_coord_offset+DIM*1+XX];
868 iy1 = shY + x[i_coord_offset+DIM*1+YY];
869 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
870 ix2 = shX + x[i_coord_offset+DIM*2+XX];
871 iy2 = shY + x[i_coord_offset+DIM*2+YY];
872 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
873 ix3 = shX + x[i_coord_offset+DIM*3+XX];
874 iy3 = shY + x[i_coord_offset+DIM*3+YY];
875 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
890 /* Start inner kernel loop */
891 for(jidx=j_index_start; jidx<j_index_end; jidx++)
893 /* Get j neighbor index, and coordinate index */
895 j_coord_offset = DIM*jnr;
897 /* load j atom coordinates */
898 jx0 = x[j_coord_offset+DIM*0+XX];
899 jy0 = x[j_coord_offset+DIM*0+YY];
900 jz0 = x[j_coord_offset+DIM*0+ZZ];
901 jx1 = x[j_coord_offset+DIM*1+XX];
902 jy1 = x[j_coord_offset+DIM*1+YY];
903 jz1 = x[j_coord_offset+DIM*1+ZZ];
904 jx2 = x[j_coord_offset+DIM*2+XX];
905 jy2 = x[j_coord_offset+DIM*2+YY];
906 jz2 = x[j_coord_offset+DIM*2+ZZ];
907 jx3 = x[j_coord_offset+DIM*3+XX];
908 jy3 = x[j_coord_offset+DIM*3+YY];
909 jz3 = x[j_coord_offset+DIM*3+ZZ];
911 /* Calculate displacement vector */
943 /* Calculate squared distance and things based on it */
944 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
945 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
946 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
947 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
948 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
949 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
950 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
951 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
952 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
953 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
955 rinv00 = gmx_invsqrt(rsq00);
956 rinv11 = gmx_invsqrt(rsq11);
957 rinv12 = gmx_invsqrt(rsq12);
958 rinv13 = gmx_invsqrt(rsq13);
959 rinv21 = gmx_invsqrt(rsq21);
960 rinv22 = gmx_invsqrt(rsq22);
961 rinv23 = gmx_invsqrt(rsq23);
962 rinv31 = gmx_invsqrt(rsq31);
963 rinv32 = gmx_invsqrt(rsq32);
964 rinv33 = gmx_invsqrt(rsq33);
966 rinvsq00 = rinv00*rinv00;
967 rinvsq11 = rinv11*rinv11;
968 rinvsq12 = rinv12*rinv12;
969 rinvsq13 = rinv13*rinv13;
970 rinvsq21 = rinv21*rinv21;
971 rinvsq22 = rinv22*rinv22;
972 rinvsq23 = rinv23*rinv23;
973 rinvsq31 = rinv31*rinv31;
974 rinvsq32 = rinv32*rinv32;
975 rinvsq33 = rinv33*rinv33;
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
986 /* BUCKINGHAM DISPERSION/REPULSION */
987 rinvsix = rinvsq00*rinvsq00*rinvsq00;
988 vvdw6 = c6_00*rinvsix;
990 vvdwexp = cexp1_00*exp(-br);
991 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
995 /* Calculate temporary vectorial force */
1000 /* Update vectorial force */
1004 f[j_coord_offset+DIM*0+XX] -= tx;
1005 f[j_coord_offset+DIM*0+YY] -= ty;
1006 f[j_coord_offset+DIM*0+ZZ] -= tz;
1010 /**************************
1011 * CALCULATE INTERACTIONS *
1012 **************************/
1019 /* EWALD ELECTROSTATICS */
1021 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1022 ewrt = r11*ewtabscale;
1024 eweps = ewrt-ewitab;
1025 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1026 felec = qq11*rinv11*(rinvsq11-felec);
1030 /* Calculate temporary vectorial force */
1035 /* Update vectorial force */
1039 f[j_coord_offset+DIM*1+XX] -= tx;
1040 f[j_coord_offset+DIM*1+YY] -= ty;
1041 f[j_coord_offset+DIM*1+ZZ] -= tz;
1045 /**************************
1046 * CALCULATE INTERACTIONS *
1047 **************************/
1054 /* EWALD ELECTROSTATICS */
1056 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1057 ewrt = r12*ewtabscale;
1059 eweps = ewrt-ewitab;
1060 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1061 felec = qq12*rinv12*(rinvsq12-felec);
1065 /* Calculate temporary vectorial force */
1070 /* Update vectorial force */
1074 f[j_coord_offset+DIM*2+XX] -= tx;
1075 f[j_coord_offset+DIM*2+YY] -= ty;
1076 f[j_coord_offset+DIM*2+ZZ] -= tz;
1080 /**************************
1081 * CALCULATE INTERACTIONS *
1082 **************************/
1089 /* EWALD ELECTROSTATICS */
1091 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1092 ewrt = r13*ewtabscale;
1094 eweps = ewrt-ewitab;
1095 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1096 felec = qq13*rinv13*(rinvsq13-felec);
1100 /* Calculate temporary vectorial force */
1105 /* Update vectorial force */
1109 f[j_coord_offset+DIM*3+XX] -= tx;
1110 f[j_coord_offset+DIM*3+YY] -= ty;
1111 f[j_coord_offset+DIM*3+ZZ] -= tz;
1115 /**************************
1116 * CALCULATE INTERACTIONS *
1117 **************************/
1124 /* EWALD ELECTROSTATICS */
1126 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1127 ewrt = r21*ewtabscale;
1129 eweps = ewrt-ewitab;
1130 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1131 felec = qq21*rinv21*(rinvsq21-felec);
1135 /* Calculate temporary vectorial force */
1140 /* Update vectorial force */
1144 f[j_coord_offset+DIM*1+XX] -= tx;
1145 f[j_coord_offset+DIM*1+YY] -= ty;
1146 f[j_coord_offset+DIM*1+ZZ] -= tz;
1150 /**************************
1151 * CALCULATE INTERACTIONS *
1152 **************************/
1159 /* EWALD ELECTROSTATICS */
1161 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1162 ewrt = r22*ewtabscale;
1164 eweps = ewrt-ewitab;
1165 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1166 felec = qq22*rinv22*(rinvsq22-felec);
1170 /* Calculate temporary vectorial force */
1175 /* Update vectorial force */
1179 f[j_coord_offset+DIM*2+XX] -= tx;
1180 f[j_coord_offset+DIM*2+YY] -= ty;
1181 f[j_coord_offset+DIM*2+ZZ] -= tz;
1185 /**************************
1186 * CALCULATE INTERACTIONS *
1187 **************************/
1194 /* EWALD ELECTROSTATICS */
1196 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1197 ewrt = r23*ewtabscale;
1199 eweps = ewrt-ewitab;
1200 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1201 felec = qq23*rinv23*(rinvsq23-felec);
1205 /* Calculate temporary vectorial force */
1210 /* Update vectorial force */
1214 f[j_coord_offset+DIM*3+XX] -= tx;
1215 f[j_coord_offset+DIM*3+YY] -= ty;
1216 f[j_coord_offset+DIM*3+ZZ] -= tz;
1220 /**************************
1221 * CALCULATE INTERACTIONS *
1222 **************************/
1229 /* EWALD ELECTROSTATICS */
1231 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1232 ewrt = r31*ewtabscale;
1234 eweps = ewrt-ewitab;
1235 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1236 felec = qq31*rinv31*(rinvsq31-felec);
1240 /* Calculate temporary vectorial force */
1245 /* Update vectorial force */
1249 f[j_coord_offset+DIM*1+XX] -= tx;
1250 f[j_coord_offset+DIM*1+YY] -= ty;
1251 f[j_coord_offset+DIM*1+ZZ] -= tz;
1255 /**************************
1256 * CALCULATE INTERACTIONS *
1257 **************************/
1264 /* EWALD ELECTROSTATICS */
1266 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1267 ewrt = r32*ewtabscale;
1269 eweps = ewrt-ewitab;
1270 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1271 felec = qq32*rinv32*(rinvsq32-felec);
1275 /* Calculate temporary vectorial force */
1280 /* Update vectorial force */
1284 f[j_coord_offset+DIM*2+XX] -= tx;
1285 f[j_coord_offset+DIM*2+YY] -= ty;
1286 f[j_coord_offset+DIM*2+ZZ] -= tz;
1290 /**************************
1291 * CALCULATE INTERACTIONS *
1292 **************************/
1299 /* EWALD ELECTROSTATICS */
1301 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1302 ewrt = r33*ewtabscale;
1304 eweps = ewrt-ewitab;
1305 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1306 felec = qq33*rinv33*(rinvsq33-felec);
1310 /* Calculate temporary vectorial force */
1315 /* Update vectorial force */
1319 f[j_coord_offset+DIM*3+XX] -= tx;
1320 f[j_coord_offset+DIM*3+YY] -= ty;
1321 f[j_coord_offset+DIM*3+ZZ] -= tz;
1325 /* Inner loop uses 355 flops */
1327 /* End of innermost loop */
1330 f[i_coord_offset+DIM*0+XX] += fix0;
1331 f[i_coord_offset+DIM*0+YY] += fiy0;
1332 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1336 f[i_coord_offset+DIM*1+XX] += fix1;
1337 f[i_coord_offset+DIM*1+YY] += fiy1;
1338 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1342 f[i_coord_offset+DIM*2+XX] += fix2;
1343 f[i_coord_offset+DIM*2+YY] += fiy2;
1344 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1348 f[i_coord_offset+DIM*3+XX] += fix3;
1349 f[i_coord_offset+DIM*3+YY] += fiy3;
1350 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1354 fshift[i_shift_offset+XX] += tx;
1355 fshift[i_shift_offset+YY] += ty;
1356 fshift[i_shift_offset+ZZ] += tz;
1358 /* Increment number of inner iterations */
1359 inneriter += j_index_end - j_index_start;
1361 /* Outer loop uses 39 flops */
1364 /* Increment number of outer iterations */
1367 /* Update outer/inner flops */
1369 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*355);