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_VdwBham_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwBham_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 = 3*nvdwtype*vdwtype[inr+0];
140 vdwjidx0 = 3*vdwtype[inr+0];
141 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
142 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
143 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
157 /* Start outer loop over neighborlists */
158 for(iidx=0; iidx<nri; iidx++)
160 /* Load shift vector for this list */
161 i_shift_offset = DIM*shiftidx[iidx];
162 shX = shiftvec[i_shift_offset+XX];
163 shY = shiftvec[i_shift_offset+YY];
164 shZ = shiftvec[i_shift_offset+ZZ];
166 /* Load limits for loop over neighbors */
167 j_index_start = jindex[iidx];
168 j_index_end = jindex[iidx+1];
170 /* Get outer coordinate index */
172 i_coord_offset = DIM*inr;
174 /* Load i particle coords and add shift vector */
175 ix0 = shX + x[i_coord_offset+DIM*0+XX];
176 iy0 = shY + x[i_coord_offset+DIM*0+YY];
177 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
178 ix1 = shX + x[i_coord_offset+DIM*1+XX];
179 iy1 = shY + x[i_coord_offset+DIM*1+YY];
180 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
181 ix2 = shX + x[i_coord_offset+DIM*2+XX];
182 iy2 = shY + x[i_coord_offset+DIM*2+YY];
183 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
184 ix3 = shX + x[i_coord_offset+DIM*3+XX];
185 iy3 = shY + x[i_coord_offset+DIM*3+YY];
186 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
201 /* Reset potential sums */
205 /* Start inner kernel loop */
206 for(jidx=j_index_start; jidx<j_index_end; jidx++)
208 /* Get j neighbor index, and coordinate index */
210 j_coord_offset = DIM*jnr;
212 /* load j atom coordinates */
213 jx0 = x[j_coord_offset+DIM*0+XX];
214 jy0 = x[j_coord_offset+DIM*0+YY];
215 jz0 = x[j_coord_offset+DIM*0+ZZ];
216 jx1 = x[j_coord_offset+DIM*1+XX];
217 jy1 = x[j_coord_offset+DIM*1+YY];
218 jz1 = x[j_coord_offset+DIM*1+ZZ];
219 jx2 = x[j_coord_offset+DIM*2+XX];
220 jy2 = x[j_coord_offset+DIM*2+YY];
221 jz2 = x[j_coord_offset+DIM*2+ZZ];
222 jx3 = x[j_coord_offset+DIM*3+XX];
223 jy3 = x[j_coord_offset+DIM*3+YY];
224 jz3 = x[j_coord_offset+DIM*3+ZZ];
226 /* Calculate displacement vector */
258 /* Calculate squared distance and things based on it */
259 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
260 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
261 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
262 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
263 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
264 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
265 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
266 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
267 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
268 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
270 rinv00 = gmx_invsqrt(rsq00);
271 rinv11 = gmx_invsqrt(rsq11);
272 rinv12 = gmx_invsqrt(rsq12);
273 rinv13 = gmx_invsqrt(rsq13);
274 rinv21 = gmx_invsqrt(rsq21);
275 rinv22 = gmx_invsqrt(rsq22);
276 rinv23 = gmx_invsqrt(rsq23);
277 rinv31 = gmx_invsqrt(rsq31);
278 rinv32 = gmx_invsqrt(rsq32);
279 rinv33 = gmx_invsqrt(rsq33);
281 rinvsq00 = rinv00*rinv00;
282 rinvsq11 = rinv11*rinv11;
283 rinvsq12 = rinv12*rinv12;
284 rinvsq13 = rinv13*rinv13;
285 rinvsq21 = rinv21*rinv21;
286 rinvsq22 = rinv22*rinv22;
287 rinvsq23 = rinv23*rinv23;
288 rinvsq31 = rinv31*rinv31;
289 rinvsq32 = rinv32*rinv32;
290 rinvsq33 = rinv33*rinv33;
292 /**************************
293 * CALCULATE INTERACTIONS *
294 **************************/
298 /* BUCKINGHAM DISPERSION/REPULSION */
299 rinvsix = rinvsq00*rinvsq00*rinvsq00;
300 vvdw6 = c6_00*rinvsix;
302 vvdwexp = cexp1_00*exp(-br);
303 vvdw = vvdwexp - vvdw6*(1.0/6.0);
304 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
306 /* Update potential sums from outer loop */
311 /* Calculate temporary vectorial force */
316 /* Update vectorial force */
320 f[j_coord_offset+DIM*0+XX] -= tx;
321 f[j_coord_offset+DIM*0+YY] -= ty;
322 f[j_coord_offset+DIM*0+ZZ] -= tz;
324 /**************************
325 * CALCULATE INTERACTIONS *
326 **************************/
330 /* EWALD ELECTROSTATICS */
332 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
333 ewrt = r11*ewtabscale;
337 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
338 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
339 felec = qq11*rinv11*(rinvsq11-felec);
341 /* Update potential sums from outer loop */
346 /* Calculate temporary vectorial force */
351 /* Update vectorial force */
355 f[j_coord_offset+DIM*1+XX] -= tx;
356 f[j_coord_offset+DIM*1+YY] -= ty;
357 f[j_coord_offset+DIM*1+ZZ] -= tz;
359 /**************************
360 * CALCULATE INTERACTIONS *
361 **************************/
365 /* EWALD ELECTROSTATICS */
367 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
368 ewrt = r12*ewtabscale;
372 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
373 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
374 felec = qq12*rinv12*(rinvsq12-felec);
376 /* Update potential sums from outer loop */
381 /* Calculate temporary vectorial force */
386 /* Update vectorial force */
390 f[j_coord_offset+DIM*2+XX] -= tx;
391 f[j_coord_offset+DIM*2+YY] -= ty;
392 f[j_coord_offset+DIM*2+ZZ] -= tz;
394 /**************************
395 * CALCULATE INTERACTIONS *
396 **************************/
400 /* EWALD ELECTROSTATICS */
402 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
403 ewrt = r13*ewtabscale;
407 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
408 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
409 felec = qq13*rinv13*(rinvsq13-felec);
411 /* Update potential sums from outer loop */
416 /* Calculate temporary vectorial force */
421 /* Update vectorial force */
425 f[j_coord_offset+DIM*3+XX] -= tx;
426 f[j_coord_offset+DIM*3+YY] -= ty;
427 f[j_coord_offset+DIM*3+ZZ] -= tz;
429 /**************************
430 * CALCULATE INTERACTIONS *
431 **************************/
435 /* EWALD ELECTROSTATICS */
437 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
438 ewrt = r21*ewtabscale;
442 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
443 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
444 felec = qq21*rinv21*(rinvsq21-felec);
446 /* Update potential sums from outer loop */
451 /* Calculate temporary vectorial force */
456 /* Update vectorial force */
460 f[j_coord_offset+DIM*1+XX] -= tx;
461 f[j_coord_offset+DIM*1+YY] -= ty;
462 f[j_coord_offset+DIM*1+ZZ] -= tz;
464 /**************************
465 * CALCULATE INTERACTIONS *
466 **************************/
470 /* EWALD ELECTROSTATICS */
472 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
473 ewrt = r22*ewtabscale;
477 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
478 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
479 felec = qq22*rinv22*(rinvsq22-felec);
481 /* Update potential sums from outer loop */
486 /* Calculate temporary vectorial force */
491 /* Update vectorial force */
495 f[j_coord_offset+DIM*2+XX] -= tx;
496 f[j_coord_offset+DIM*2+YY] -= ty;
497 f[j_coord_offset+DIM*2+ZZ] -= tz;
499 /**************************
500 * CALCULATE INTERACTIONS *
501 **************************/
505 /* EWALD ELECTROSTATICS */
507 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
508 ewrt = r23*ewtabscale;
512 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
513 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
514 felec = qq23*rinv23*(rinvsq23-felec);
516 /* Update potential sums from outer loop */
521 /* Calculate temporary vectorial force */
526 /* Update vectorial force */
530 f[j_coord_offset+DIM*3+XX] -= tx;
531 f[j_coord_offset+DIM*3+YY] -= ty;
532 f[j_coord_offset+DIM*3+ZZ] -= tz;
534 /**************************
535 * CALCULATE INTERACTIONS *
536 **************************/
540 /* EWALD ELECTROSTATICS */
542 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
543 ewrt = r31*ewtabscale;
547 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
548 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
549 felec = qq31*rinv31*(rinvsq31-felec);
551 /* Update potential sums from outer loop */
556 /* Calculate temporary vectorial force */
561 /* Update vectorial force */
565 f[j_coord_offset+DIM*1+XX] -= tx;
566 f[j_coord_offset+DIM*1+YY] -= ty;
567 f[j_coord_offset+DIM*1+ZZ] -= tz;
569 /**************************
570 * CALCULATE INTERACTIONS *
571 **************************/
575 /* EWALD ELECTROSTATICS */
577 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
578 ewrt = r32*ewtabscale;
582 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
583 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
584 felec = qq32*rinv32*(rinvsq32-felec);
586 /* Update potential sums from outer loop */
591 /* Calculate temporary vectorial force */
596 /* Update vectorial force */
600 f[j_coord_offset+DIM*2+XX] -= tx;
601 f[j_coord_offset+DIM*2+YY] -= ty;
602 f[j_coord_offset+DIM*2+ZZ] -= tz;
604 /**************************
605 * CALCULATE INTERACTIONS *
606 **************************/
610 /* EWALD ELECTROSTATICS */
612 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
613 ewrt = r33*ewtabscale;
617 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
618 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
619 felec = qq33*rinv33*(rinvsq33-felec);
621 /* Update potential sums from outer loop */
626 /* Calculate temporary vectorial force */
631 /* Update vectorial force */
635 f[j_coord_offset+DIM*3+XX] -= tx;
636 f[j_coord_offset+DIM*3+YY] -= ty;
637 f[j_coord_offset+DIM*3+ZZ] -= tz;
639 /* Inner loop uses 421 flops */
641 /* End of innermost loop */
644 f[i_coord_offset+DIM*0+XX] += fix0;
645 f[i_coord_offset+DIM*0+YY] += fiy0;
646 f[i_coord_offset+DIM*0+ZZ] += fiz0;
650 f[i_coord_offset+DIM*1+XX] += fix1;
651 f[i_coord_offset+DIM*1+YY] += fiy1;
652 f[i_coord_offset+DIM*1+ZZ] += fiz1;
656 f[i_coord_offset+DIM*2+XX] += fix2;
657 f[i_coord_offset+DIM*2+YY] += fiy2;
658 f[i_coord_offset+DIM*2+ZZ] += fiz2;
662 f[i_coord_offset+DIM*3+XX] += fix3;
663 f[i_coord_offset+DIM*3+YY] += fiy3;
664 f[i_coord_offset+DIM*3+ZZ] += fiz3;
668 fshift[i_shift_offset+XX] += tx;
669 fshift[i_shift_offset+YY] += ty;
670 fshift[i_shift_offset+ZZ] += tz;
673 /* Update potential energies */
674 kernel_data->energygrp_elec[ggid] += velecsum;
675 kernel_data->energygrp_vdw[ggid] += vvdwsum;
677 /* Increment number of inner iterations */
678 inneriter += j_index_end - j_index_start;
680 /* Outer loop uses 41 flops */
683 /* Increment number of outer iterations */
686 /* Update outer/inner flops */
688 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*421);
691 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW4W4_F_c
692 * Electrostatics interaction: Ewald
693 * VdW interaction: Buckingham
694 * Geometry: Water4-Water4
695 * Calculate force/pot: Force
698 nb_kernel_ElecEw_VdwBham_GeomW4W4_F_c
699 (t_nblist * gmx_restrict nlist,
700 rvec * gmx_restrict xx,
701 rvec * gmx_restrict ff,
702 t_forcerec * gmx_restrict fr,
703 t_mdatoms * gmx_restrict mdatoms,
704 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
705 t_nrnb * gmx_restrict nrnb)
707 int i_shift_offset,i_coord_offset,j_coord_offset;
708 int j_index_start,j_index_end;
709 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
710 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
711 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
712 real *shiftvec,*fshift,*x,*f;
714 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
716 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
718 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
720 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
722 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
724 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
726 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
728 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
729 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
730 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
731 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
732 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
733 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
734 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
735 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
736 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
737 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
738 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
739 real velec,felec,velecsum,facel,crf,krf,krf2;
742 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
746 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
754 jindex = nlist->jindex;
756 shiftidx = nlist->shift;
758 shiftvec = fr->shift_vec[0];
759 fshift = fr->fshift[0];
761 charge = mdatoms->chargeA;
762 nvdwtype = fr->ntype;
764 vdwtype = mdatoms->typeA;
766 sh_ewald = fr->ic->sh_ewald;
767 ewtab = fr->ic->tabq_coul_F;
768 ewtabscale = fr->ic->tabq_scale;
769 ewtabhalfspace = 0.5/ewtabscale;
771 /* Setup water-specific parameters */
772 inr = nlist->iinr[0];
773 iq1 = facel*charge[inr+1];
774 iq2 = facel*charge[inr+2];
775 iq3 = facel*charge[inr+3];
776 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
781 vdwjidx0 = 3*vdwtype[inr+0];
782 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
783 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
784 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
798 /* Start outer loop over neighborlists */
799 for(iidx=0; iidx<nri; iidx++)
801 /* Load shift vector for this list */
802 i_shift_offset = DIM*shiftidx[iidx];
803 shX = shiftvec[i_shift_offset+XX];
804 shY = shiftvec[i_shift_offset+YY];
805 shZ = shiftvec[i_shift_offset+ZZ];
807 /* Load limits for loop over neighbors */
808 j_index_start = jindex[iidx];
809 j_index_end = jindex[iidx+1];
811 /* Get outer coordinate index */
813 i_coord_offset = DIM*inr;
815 /* Load i particle coords and add shift vector */
816 ix0 = shX + x[i_coord_offset+DIM*0+XX];
817 iy0 = shY + x[i_coord_offset+DIM*0+YY];
818 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
819 ix1 = shX + x[i_coord_offset+DIM*1+XX];
820 iy1 = shY + x[i_coord_offset+DIM*1+YY];
821 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
822 ix2 = shX + x[i_coord_offset+DIM*2+XX];
823 iy2 = shY + x[i_coord_offset+DIM*2+YY];
824 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
825 ix3 = shX + x[i_coord_offset+DIM*3+XX];
826 iy3 = shY + x[i_coord_offset+DIM*3+YY];
827 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
842 /* Start inner kernel loop */
843 for(jidx=j_index_start; jidx<j_index_end; jidx++)
845 /* Get j neighbor index, and coordinate index */
847 j_coord_offset = DIM*jnr;
849 /* load j atom coordinates */
850 jx0 = x[j_coord_offset+DIM*0+XX];
851 jy0 = x[j_coord_offset+DIM*0+YY];
852 jz0 = x[j_coord_offset+DIM*0+ZZ];
853 jx1 = x[j_coord_offset+DIM*1+XX];
854 jy1 = x[j_coord_offset+DIM*1+YY];
855 jz1 = x[j_coord_offset+DIM*1+ZZ];
856 jx2 = x[j_coord_offset+DIM*2+XX];
857 jy2 = x[j_coord_offset+DIM*2+YY];
858 jz2 = x[j_coord_offset+DIM*2+ZZ];
859 jx3 = x[j_coord_offset+DIM*3+XX];
860 jy3 = x[j_coord_offset+DIM*3+YY];
861 jz3 = x[j_coord_offset+DIM*3+ZZ];
863 /* Calculate displacement vector */
895 /* Calculate squared distance and things based on it */
896 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
897 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
898 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
899 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
900 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
901 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
902 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
903 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
904 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
905 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
907 rinv00 = gmx_invsqrt(rsq00);
908 rinv11 = gmx_invsqrt(rsq11);
909 rinv12 = gmx_invsqrt(rsq12);
910 rinv13 = gmx_invsqrt(rsq13);
911 rinv21 = gmx_invsqrt(rsq21);
912 rinv22 = gmx_invsqrt(rsq22);
913 rinv23 = gmx_invsqrt(rsq23);
914 rinv31 = gmx_invsqrt(rsq31);
915 rinv32 = gmx_invsqrt(rsq32);
916 rinv33 = gmx_invsqrt(rsq33);
918 rinvsq00 = rinv00*rinv00;
919 rinvsq11 = rinv11*rinv11;
920 rinvsq12 = rinv12*rinv12;
921 rinvsq13 = rinv13*rinv13;
922 rinvsq21 = rinv21*rinv21;
923 rinvsq22 = rinv22*rinv22;
924 rinvsq23 = rinv23*rinv23;
925 rinvsq31 = rinv31*rinv31;
926 rinvsq32 = rinv32*rinv32;
927 rinvsq33 = rinv33*rinv33;
929 /**************************
930 * CALCULATE INTERACTIONS *
931 **************************/
935 /* BUCKINGHAM DISPERSION/REPULSION */
936 rinvsix = rinvsq00*rinvsq00*rinvsq00;
937 vvdw6 = c6_00*rinvsix;
939 vvdwexp = cexp1_00*exp(-br);
940 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
944 /* Calculate temporary vectorial force */
949 /* Update vectorial force */
953 f[j_coord_offset+DIM*0+XX] -= tx;
954 f[j_coord_offset+DIM*0+YY] -= ty;
955 f[j_coord_offset+DIM*0+ZZ] -= tz;
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
963 /* EWALD ELECTROSTATICS */
965 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
966 ewrt = r11*ewtabscale;
969 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
970 felec = qq11*rinv11*(rinvsq11-felec);
974 /* Calculate temporary vectorial force */
979 /* Update vectorial force */
983 f[j_coord_offset+DIM*1+XX] -= tx;
984 f[j_coord_offset+DIM*1+YY] -= ty;
985 f[j_coord_offset+DIM*1+ZZ] -= tz;
987 /**************************
988 * CALCULATE INTERACTIONS *
989 **************************/
993 /* EWALD ELECTROSTATICS */
995 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
996 ewrt = r12*ewtabscale;
999 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1000 felec = qq12*rinv12*(rinvsq12-felec);
1004 /* Calculate temporary vectorial force */
1009 /* Update vectorial force */
1013 f[j_coord_offset+DIM*2+XX] -= tx;
1014 f[j_coord_offset+DIM*2+YY] -= ty;
1015 f[j_coord_offset+DIM*2+ZZ] -= tz;
1017 /**************************
1018 * CALCULATE INTERACTIONS *
1019 **************************/
1023 /* EWALD ELECTROSTATICS */
1025 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1026 ewrt = r13*ewtabscale;
1028 eweps = ewrt-ewitab;
1029 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1030 felec = qq13*rinv13*(rinvsq13-felec);
1034 /* Calculate temporary vectorial force */
1039 /* Update vectorial force */
1043 f[j_coord_offset+DIM*3+XX] -= tx;
1044 f[j_coord_offset+DIM*3+YY] -= ty;
1045 f[j_coord_offset+DIM*3+ZZ] -= tz;
1047 /**************************
1048 * CALCULATE INTERACTIONS *
1049 **************************/
1053 /* EWALD ELECTROSTATICS */
1055 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1056 ewrt = r21*ewtabscale;
1058 eweps = ewrt-ewitab;
1059 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1060 felec = qq21*rinv21*(rinvsq21-felec);
1064 /* Calculate temporary vectorial force */
1069 /* Update vectorial force */
1073 f[j_coord_offset+DIM*1+XX] -= tx;
1074 f[j_coord_offset+DIM*1+YY] -= ty;
1075 f[j_coord_offset+DIM*1+ZZ] -= tz;
1077 /**************************
1078 * CALCULATE INTERACTIONS *
1079 **************************/
1083 /* EWALD ELECTROSTATICS */
1085 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1086 ewrt = r22*ewtabscale;
1088 eweps = ewrt-ewitab;
1089 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1090 felec = qq22*rinv22*(rinvsq22-felec);
1094 /* Calculate temporary vectorial force */
1099 /* Update vectorial force */
1103 f[j_coord_offset+DIM*2+XX] -= tx;
1104 f[j_coord_offset+DIM*2+YY] -= ty;
1105 f[j_coord_offset+DIM*2+ZZ] -= tz;
1107 /**************************
1108 * CALCULATE INTERACTIONS *
1109 **************************/
1113 /* EWALD ELECTROSTATICS */
1115 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1116 ewrt = r23*ewtabscale;
1118 eweps = ewrt-ewitab;
1119 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1120 felec = qq23*rinv23*(rinvsq23-felec);
1124 /* Calculate temporary vectorial force */
1129 /* Update vectorial force */
1133 f[j_coord_offset+DIM*3+XX] -= tx;
1134 f[j_coord_offset+DIM*3+YY] -= ty;
1135 f[j_coord_offset+DIM*3+ZZ] -= tz;
1137 /**************************
1138 * CALCULATE INTERACTIONS *
1139 **************************/
1143 /* EWALD ELECTROSTATICS */
1145 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1146 ewrt = r31*ewtabscale;
1148 eweps = ewrt-ewitab;
1149 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1150 felec = qq31*rinv31*(rinvsq31-felec);
1154 /* Calculate temporary vectorial force */
1159 /* Update vectorial force */
1163 f[j_coord_offset+DIM*1+XX] -= tx;
1164 f[j_coord_offset+DIM*1+YY] -= ty;
1165 f[j_coord_offset+DIM*1+ZZ] -= tz;
1167 /**************************
1168 * CALCULATE INTERACTIONS *
1169 **************************/
1173 /* EWALD ELECTROSTATICS */
1175 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1176 ewrt = r32*ewtabscale;
1178 eweps = ewrt-ewitab;
1179 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1180 felec = qq32*rinv32*(rinvsq32-felec);
1184 /* Calculate temporary vectorial force */
1189 /* Update vectorial force */
1193 f[j_coord_offset+DIM*2+XX] -= tx;
1194 f[j_coord_offset+DIM*2+YY] -= ty;
1195 f[j_coord_offset+DIM*2+ZZ] -= tz;
1197 /**************************
1198 * CALCULATE INTERACTIONS *
1199 **************************/
1203 /* EWALD ELECTROSTATICS */
1205 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1206 ewrt = r33*ewtabscale;
1208 eweps = ewrt-ewitab;
1209 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1210 felec = qq33*rinv33*(rinvsq33-felec);
1214 /* Calculate temporary vectorial force */
1219 /* Update vectorial force */
1223 f[j_coord_offset+DIM*3+XX] -= tx;
1224 f[j_coord_offset+DIM*3+YY] -= ty;
1225 f[j_coord_offset+DIM*3+ZZ] -= tz;
1227 /* Inner loop uses 355 flops */
1229 /* End of innermost loop */
1232 f[i_coord_offset+DIM*0+XX] += fix0;
1233 f[i_coord_offset+DIM*0+YY] += fiy0;
1234 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1238 f[i_coord_offset+DIM*1+XX] += fix1;
1239 f[i_coord_offset+DIM*1+YY] += fiy1;
1240 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1244 f[i_coord_offset+DIM*2+XX] += fix2;
1245 f[i_coord_offset+DIM*2+YY] += fiy2;
1246 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1250 f[i_coord_offset+DIM*3+XX] += fix3;
1251 f[i_coord_offset+DIM*3+YY] += fiy3;
1252 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1256 fshift[i_shift_offset+XX] += tx;
1257 fshift[i_shift_offset+YY] += ty;
1258 fshift[i_shift_offset+ZZ] += tz;
1260 /* Increment number of inner iterations */
1261 inneriter += j_index_end - j_index_start;
1263 /* Outer loop uses 39 flops */
1266 /* Increment number of outer iterations */
1269 /* Update outer/inner flops */
1271 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*355);