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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW4W4_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwLJ_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;
103 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
118 charge = mdatoms->chargeA;
119 nvdwtype = fr->ntype;
121 vdwtype = mdatoms->typeA;
123 sh_ewald = fr->ic->sh_ewald;
124 ewtab = fr->ic->tabq_coul_FDV0;
125 ewtabscale = fr->ic->tabq_scale;
126 ewtabhalfspace = 0.5/ewtabscale;
128 /* Setup water-specific parameters */
129 inr = nlist->iinr[0];
130 iq1 = facel*charge[inr+1];
131 iq2 = facel*charge[inr+2];
132 iq3 = facel*charge[inr+3];
133 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
138 vdwjidx0 = 2*vdwtype[inr+0];
139 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
140 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
154 /* Start outer loop over neighborlists */
155 for(iidx=0; iidx<nri; iidx++)
157 /* Load shift vector for this list */
158 i_shift_offset = DIM*shiftidx[iidx];
159 shX = shiftvec[i_shift_offset+XX];
160 shY = shiftvec[i_shift_offset+YY];
161 shZ = shiftvec[i_shift_offset+ZZ];
163 /* Load limits for loop over neighbors */
164 j_index_start = jindex[iidx];
165 j_index_end = jindex[iidx+1];
167 /* Get outer coordinate index */
169 i_coord_offset = DIM*inr;
171 /* Load i particle coords and add shift vector */
172 ix0 = shX + x[i_coord_offset+DIM*0+XX];
173 iy0 = shY + x[i_coord_offset+DIM*0+YY];
174 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
175 ix1 = shX + x[i_coord_offset+DIM*1+XX];
176 iy1 = shY + x[i_coord_offset+DIM*1+YY];
177 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
178 ix2 = shX + x[i_coord_offset+DIM*2+XX];
179 iy2 = shY + x[i_coord_offset+DIM*2+YY];
180 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
181 ix3 = shX + x[i_coord_offset+DIM*3+XX];
182 iy3 = shY + x[i_coord_offset+DIM*3+YY];
183 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
198 /* Reset potential sums */
202 /* Start inner kernel loop */
203 for(jidx=j_index_start; jidx<j_index_end; jidx++)
205 /* Get j neighbor index, and coordinate index */
207 j_coord_offset = DIM*jnr;
209 /* load j atom coordinates */
210 jx0 = x[j_coord_offset+DIM*0+XX];
211 jy0 = x[j_coord_offset+DIM*0+YY];
212 jz0 = x[j_coord_offset+DIM*0+ZZ];
213 jx1 = x[j_coord_offset+DIM*1+XX];
214 jy1 = x[j_coord_offset+DIM*1+YY];
215 jz1 = x[j_coord_offset+DIM*1+ZZ];
216 jx2 = x[j_coord_offset+DIM*2+XX];
217 jy2 = x[j_coord_offset+DIM*2+YY];
218 jz2 = x[j_coord_offset+DIM*2+ZZ];
219 jx3 = x[j_coord_offset+DIM*3+XX];
220 jy3 = x[j_coord_offset+DIM*3+YY];
221 jz3 = x[j_coord_offset+DIM*3+ZZ];
223 /* Calculate displacement vector */
255 /* Calculate squared distance and things based on it */
256 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
257 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
258 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
259 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
260 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
261 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
262 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
263 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
264 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
265 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
267 rinv11 = gmx_invsqrt(rsq11);
268 rinv12 = gmx_invsqrt(rsq12);
269 rinv13 = gmx_invsqrt(rsq13);
270 rinv21 = gmx_invsqrt(rsq21);
271 rinv22 = gmx_invsqrt(rsq22);
272 rinv23 = gmx_invsqrt(rsq23);
273 rinv31 = gmx_invsqrt(rsq31);
274 rinv32 = gmx_invsqrt(rsq32);
275 rinv33 = gmx_invsqrt(rsq33);
277 rinvsq00 = 1.0/rsq00;
278 rinvsq11 = rinv11*rinv11;
279 rinvsq12 = rinv12*rinv12;
280 rinvsq13 = rinv13*rinv13;
281 rinvsq21 = rinv21*rinv21;
282 rinvsq22 = rinv22*rinv22;
283 rinvsq23 = rinv23*rinv23;
284 rinvsq31 = rinv31*rinv31;
285 rinvsq32 = rinv32*rinv32;
286 rinvsq33 = rinv33*rinv33;
288 /**************************
289 * CALCULATE INTERACTIONS *
290 **************************/
292 /* LENNARD-JONES DISPERSION/REPULSION */
294 rinvsix = rinvsq00*rinvsq00*rinvsq00;
295 vvdw6 = c6_00*rinvsix;
296 vvdw12 = c12_00*rinvsix*rinvsix;
297 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
298 fvdw = (vvdw12-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;
318 /**************************
319 * CALCULATE INTERACTIONS *
320 **************************/
324 /* EWALD ELECTROSTATICS */
326 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
327 ewrt = r11*ewtabscale;
331 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
332 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
333 felec = qq11*rinv11*(rinvsq11-felec);
335 /* Update potential sums from outer loop */
340 /* Calculate temporary vectorial force */
345 /* Update vectorial force */
349 f[j_coord_offset+DIM*1+XX] -= tx;
350 f[j_coord_offset+DIM*1+YY] -= ty;
351 f[j_coord_offset+DIM*1+ZZ] -= tz;
353 /**************************
354 * CALCULATE INTERACTIONS *
355 **************************/
359 /* EWALD ELECTROSTATICS */
361 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
362 ewrt = r12*ewtabscale;
366 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
367 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
368 felec = qq12*rinv12*(rinvsq12-felec);
370 /* Update potential sums from outer loop */
375 /* Calculate temporary vectorial force */
380 /* Update vectorial force */
384 f[j_coord_offset+DIM*2+XX] -= tx;
385 f[j_coord_offset+DIM*2+YY] -= ty;
386 f[j_coord_offset+DIM*2+ZZ] -= tz;
388 /**************************
389 * CALCULATE INTERACTIONS *
390 **************************/
394 /* EWALD ELECTROSTATICS */
396 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
397 ewrt = r13*ewtabscale;
401 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
402 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
403 felec = qq13*rinv13*(rinvsq13-felec);
405 /* Update potential sums from outer loop */
410 /* Calculate temporary vectorial force */
415 /* Update vectorial force */
419 f[j_coord_offset+DIM*3+XX] -= tx;
420 f[j_coord_offset+DIM*3+YY] -= ty;
421 f[j_coord_offset+DIM*3+ZZ] -= tz;
423 /**************************
424 * CALCULATE INTERACTIONS *
425 **************************/
429 /* EWALD ELECTROSTATICS */
431 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
432 ewrt = r21*ewtabscale;
436 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
437 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
438 felec = qq21*rinv21*(rinvsq21-felec);
440 /* Update potential sums from outer loop */
445 /* Calculate temporary vectorial force */
450 /* Update vectorial force */
454 f[j_coord_offset+DIM*1+XX] -= tx;
455 f[j_coord_offset+DIM*1+YY] -= ty;
456 f[j_coord_offset+DIM*1+ZZ] -= tz;
458 /**************************
459 * CALCULATE INTERACTIONS *
460 **************************/
464 /* EWALD ELECTROSTATICS */
466 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
467 ewrt = r22*ewtabscale;
471 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
472 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
473 felec = qq22*rinv22*(rinvsq22-felec);
475 /* Update potential sums from outer loop */
480 /* Calculate temporary vectorial force */
485 /* Update vectorial force */
489 f[j_coord_offset+DIM*2+XX] -= tx;
490 f[j_coord_offset+DIM*2+YY] -= ty;
491 f[j_coord_offset+DIM*2+ZZ] -= tz;
493 /**************************
494 * CALCULATE INTERACTIONS *
495 **************************/
499 /* EWALD ELECTROSTATICS */
501 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
502 ewrt = r23*ewtabscale;
506 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
507 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
508 felec = qq23*rinv23*(rinvsq23-felec);
510 /* Update potential sums from outer loop */
515 /* Calculate temporary vectorial force */
520 /* Update vectorial force */
524 f[j_coord_offset+DIM*3+XX] -= tx;
525 f[j_coord_offset+DIM*3+YY] -= ty;
526 f[j_coord_offset+DIM*3+ZZ] -= tz;
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
534 /* EWALD ELECTROSTATICS */
536 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
537 ewrt = r31*ewtabscale;
541 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
542 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
543 felec = qq31*rinv31*(rinvsq31-felec);
545 /* Update potential sums from outer loop */
550 /* Calculate temporary vectorial force */
555 /* Update vectorial force */
559 f[j_coord_offset+DIM*1+XX] -= tx;
560 f[j_coord_offset+DIM*1+YY] -= ty;
561 f[j_coord_offset+DIM*1+ZZ] -= tz;
563 /**************************
564 * CALCULATE INTERACTIONS *
565 **************************/
569 /* EWALD ELECTROSTATICS */
571 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
572 ewrt = r32*ewtabscale;
576 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
577 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
578 felec = qq32*rinv32*(rinvsq32-felec);
580 /* Update potential sums from outer loop */
585 /* Calculate temporary vectorial force */
590 /* Update vectorial force */
594 f[j_coord_offset+DIM*2+XX] -= tx;
595 f[j_coord_offset+DIM*2+YY] -= ty;
596 f[j_coord_offset+DIM*2+ZZ] -= tz;
598 /**************************
599 * CALCULATE INTERACTIONS *
600 **************************/
604 /* EWALD ELECTROSTATICS */
606 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
607 ewrt = r33*ewtabscale;
611 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
612 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
613 felec = qq33*rinv33*(rinvsq33-felec);
615 /* Update potential sums from outer loop */
620 /* Calculate temporary vectorial force */
625 /* Update vectorial force */
629 f[j_coord_offset+DIM*3+XX] -= tx;
630 f[j_coord_offset+DIM*3+YY] -= ty;
631 f[j_coord_offset+DIM*3+ZZ] -= tz;
633 /* Inner loop uses 392 flops */
635 /* End of innermost loop */
638 f[i_coord_offset+DIM*0+XX] += fix0;
639 f[i_coord_offset+DIM*0+YY] += fiy0;
640 f[i_coord_offset+DIM*0+ZZ] += fiz0;
644 f[i_coord_offset+DIM*1+XX] += fix1;
645 f[i_coord_offset+DIM*1+YY] += fiy1;
646 f[i_coord_offset+DIM*1+ZZ] += fiz1;
650 f[i_coord_offset+DIM*2+XX] += fix2;
651 f[i_coord_offset+DIM*2+YY] += fiy2;
652 f[i_coord_offset+DIM*2+ZZ] += fiz2;
656 f[i_coord_offset+DIM*3+XX] += fix3;
657 f[i_coord_offset+DIM*3+YY] += fiy3;
658 f[i_coord_offset+DIM*3+ZZ] += fiz3;
662 fshift[i_shift_offset+XX] += tx;
663 fshift[i_shift_offset+YY] += ty;
664 fshift[i_shift_offset+ZZ] += tz;
667 /* Update potential energies */
668 kernel_data->energygrp_elec[ggid] += velecsum;
669 kernel_data->energygrp_vdw[ggid] += vvdwsum;
671 /* Increment number of inner iterations */
672 inneriter += j_index_end - j_index_start;
674 /* Outer loop uses 41 flops */
677 /* Increment number of outer iterations */
680 /* Update outer/inner flops */
682 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*392);
685 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW4W4_F_c
686 * Electrostatics interaction: Ewald
687 * VdW interaction: LennardJones
688 * Geometry: Water4-Water4
689 * Calculate force/pot: Force
692 nb_kernel_ElecEw_VdwLJ_GeomW4W4_F_c
693 (t_nblist * gmx_restrict nlist,
694 rvec * gmx_restrict xx,
695 rvec * gmx_restrict ff,
696 t_forcerec * gmx_restrict fr,
697 t_mdatoms * gmx_restrict mdatoms,
698 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
699 t_nrnb * gmx_restrict nrnb)
701 int i_shift_offset,i_coord_offset,j_coord_offset;
702 int j_index_start,j_index_end;
703 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
704 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
705 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
706 real *shiftvec,*fshift,*x,*f;
708 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
710 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
712 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
714 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
716 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
718 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
720 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
722 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
723 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
724 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
725 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
726 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
727 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
728 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
729 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
730 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
731 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
732 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
733 real velec,felec,velecsum,facel,crf,krf,krf2;
736 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
740 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
748 jindex = nlist->jindex;
750 shiftidx = nlist->shift;
752 shiftvec = fr->shift_vec[0];
753 fshift = fr->fshift[0];
755 charge = mdatoms->chargeA;
756 nvdwtype = fr->ntype;
758 vdwtype = mdatoms->typeA;
760 sh_ewald = fr->ic->sh_ewald;
761 ewtab = fr->ic->tabq_coul_F;
762 ewtabscale = fr->ic->tabq_scale;
763 ewtabhalfspace = 0.5/ewtabscale;
765 /* Setup water-specific parameters */
766 inr = nlist->iinr[0];
767 iq1 = facel*charge[inr+1];
768 iq2 = facel*charge[inr+2];
769 iq3 = facel*charge[inr+3];
770 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
775 vdwjidx0 = 2*vdwtype[inr+0];
776 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
777 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
791 /* Start outer loop over neighborlists */
792 for(iidx=0; iidx<nri; iidx++)
794 /* Load shift vector for this list */
795 i_shift_offset = DIM*shiftidx[iidx];
796 shX = shiftvec[i_shift_offset+XX];
797 shY = shiftvec[i_shift_offset+YY];
798 shZ = shiftvec[i_shift_offset+ZZ];
800 /* Load limits for loop over neighbors */
801 j_index_start = jindex[iidx];
802 j_index_end = jindex[iidx+1];
804 /* Get outer coordinate index */
806 i_coord_offset = DIM*inr;
808 /* Load i particle coords and add shift vector */
809 ix0 = shX + x[i_coord_offset+DIM*0+XX];
810 iy0 = shY + x[i_coord_offset+DIM*0+YY];
811 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
812 ix1 = shX + x[i_coord_offset+DIM*1+XX];
813 iy1 = shY + x[i_coord_offset+DIM*1+YY];
814 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
815 ix2 = shX + x[i_coord_offset+DIM*2+XX];
816 iy2 = shY + x[i_coord_offset+DIM*2+YY];
817 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
818 ix3 = shX + x[i_coord_offset+DIM*3+XX];
819 iy3 = shY + x[i_coord_offset+DIM*3+YY];
820 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
835 /* Start inner kernel loop */
836 for(jidx=j_index_start; jidx<j_index_end; jidx++)
838 /* Get j neighbor index, and coordinate index */
840 j_coord_offset = DIM*jnr;
842 /* load j atom coordinates */
843 jx0 = x[j_coord_offset+DIM*0+XX];
844 jy0 = x[j_coord_offset+DIM*0+YY];
845 jz0 = x[j_coord_offset+DIM*0+ZZ];
846 jx1 = x[j_coord_offset+DIM*1+XX];
847 jy1 = x[j_coord_offset+DIM*1+YY];
848 jz1 = x[j_coord_offset+DIM*1+ZZ];
849 jx2 = x[j_coord_offset+DIM*2+XX];
850 jy2 = x[j_coord_offset+DIM*2+YY];
851 jz2 = x[j_coord_offset+DIM*2+ZZ];
852 jx3 = x[j_coord_offset+DIM*3+XX];
853 jy3 = x[j_coord_offset+DIM*3+YY];
854 jz3 = x[j_coord_offset+DIM*3+ZZ];
856 /* Calculate displacement vector */
888 /* Calculate squared distance and things based on it */
889 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
890 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
891 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
892 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
893 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
894 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
895 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
896 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
897 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
898 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
900 rinv11 = gmx_invsqrt(rsq11);
901 rinv12 = gmx_invsqrt(rsq12);
902 rinv13 = gmx_invsqrt(rsq13);
903 rinv21 = gmx_invsqrt(rsq21);
904 rinv22 = gmx_invsqrt(rsq22);
905 rinv23 = gmx_invsqrt(rsq23);
906 rinv31 = gmx_invsqrt(rsq31);
907 rinv32 = gmx_invsqrt(rsq32);
908 rinv33 = gmx_invsqrt(rsq33);
910 rinvsq00 = 1.0/rsq00;
911 rinvsq11 = rinv11*rinv11;
912 rinvsq12 = rinv12*rinv12;
913 rinvsq13 = rinv13*rinv13;
914 rinvsq21 = rinv21*rinv21;
915 rinvsq22 = rinv22*rinv22;
916 rinvsq23 = rinv23*rinv23;
917 rinvsq31 = rinv31*rinv31;
918 rinvsq32 = rinv32*rinv32;
919 rinvsq33 = rinv33*rinv33;
921 /**************************
922 * CALCULATE INTERACTIONS *
923 **************************/
925 /* LENNARD-JONES DISPERSION/REPULSION */
927 rinvsix = rinvsq00*rinvsq00*rinvsq00;
928 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
932 /* Calculate temporary vectorial force */
937 /* Update vectorial force */
941 f[j_coord_offset+DIM*0+XX] -= tx;
942 f[j_coord_offset+DIM*0+YY] -= ty;
943 f[j_coord_offset+DIM*0+ZZ] -= tz;
945 /**************************
946 * CALCULATE INTERACTIONS *
947 **************************/
951 /* EWALD ELECTROSTATICS */
953 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
954 ewrt = r11*ewtabscale;
957 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
958 felec = qq11*rinv11*(rinvsq11-felec);
962 /* Calculate temporary vectorial force */
967 /* Update vectorial force */
971 f[j_coord_offset+DIM*1+XX] -= tx;
972 f[j_coord_offset+DIM*1+YY] -= ty;
973 f[j_coord_offset+DIM*1+ZZ] -= tz;
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
981 /* EWALD ELECTROSTATICS */
983 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
984 ewrt = r12*ewtabscale;
987 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
988 felec = qq12*rinv12*(rinvsq12-felec);
992 /* Calculate temporary vectorial force */
997 /* Update vectorial force */
1001 f[j_coord_offset+DIM*2+XX] -= tx;
1002 f[j_coord_offset+DIM*2+YY] -= ty;
1003 f[j_coord_offset+DIM*2+ZZ] -= tz;
1005 /**************************
1006 * CALCULATE INTERACTIONS *
1007 **************************/
1011 /* EWALD ELECTROSTATICS */
1013 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1014 ewrt = r13*ewtabscale;
1016 eweps = ewrt-ewitab;
1017 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1018 felec = qq13*rinv13*(rinvsq13-felec);
1022 /* Calculate temporary vectorial force */
1027 /* Update vectorial force */
1031 f[j_coord_offset+DIM*3+XX] -= tx;
1032 f[j_coord_offset+DIM*3+YY] -= ty;
1033 f[j_coord_offset+DIM*3+ZZ] -= tz;
1035 /**************************
1036 * CALCULATE INTERACTIONS *
1037 **************************/
1041 /* EWALD ELECTROSTATICS */
1043 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1044 ewrt = r21*ewtabscale;
1046 eweps = ewrt-ewitab;
1047 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1048 felec = qq21*rinv21*(rinvsq21-felec);
1052 /* Calculate temporary vectorial force */
1057 /* Update vectorial force */
1061 f[j_coord_offset+DIM*1+XX] -= tx;
1062 f[j_coord_offset+DIM*1+YY] -= ty;
1063 f[j_coord_offset+DIM*1+ZZ] -= tz;
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1071 /* EWALD ELECTROSTATICS */
1073 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1074 ewrt = r22*ewtabscale;
1076 eweps = ewrt-ewitab;
1077 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1078 felec = qq22*rinv22*(rinvsq22-felec);
1082 /* Calculate temporary vectorial force */
1087 /* Update vectorial force */
1091 f[j_coord_offset+DIM*2+XX] -= tx;
1092 f[j_coord_offset+DIM*2+YY] -= ty;
1093 f[j_coord_offset+DIM*2+ZZ] -= tz;
1095 /**************************
1096 * CALCULATE INTERACTIONS *
1097 **************************/
1101 /* EWALD ELECTROSTATICS */
1103 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1104 ewrt = r23*ewtabscale;
1106 eweps = ewrt-ewitab;
1107 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1108 felec = qq23*rinv23*(rinvsq23-felec);
1112 /* Calculate temporary vectorial force */
1117 /* Update vectorial force */
1121 f[j_coord_offset+DIM*3+XX] -= tx;
1122 f[j_coord_offset+DIM*3+YY] -= ty;
1123 f[j_coord_offset+DIM*3+ZZ] -= tz;
1125 /**************************
1126 * CALCULATE INTERACTIONS *
1127 **************************/
1131 /* EWALD ELECTROSTATICS */
1133 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1134 ewrt = r31*ewtabscale;
1136 eweps = ewrt-ewitab;
1137 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1138 felec = qq31*rinv31*(rinvsq31-felec);
1142 /* Calculate temporary vectorial force */
1147 /* Update vectorial force */
1151 f[j_coord_offset+DIM*1+XX] -= tx;
1152 f[j_coord_offset+DIM*1+YY] -= ty;
1153 f[j_coord_offset+DIM*1+ZZ] -= tz;
1155 /**************************
1156 * CALCULATE INTERACTIONS *
1157 **************************/
1161 /* EWALD ELECTROSTATICS */
1163 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1164 ewrt = r32*ewtabscale;
1166 eweps = ewrt-ewitab;
1167 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1168 felec = qq32*rinv32*(rinvsq32-felec);
1172 /* Calculate temporary vectorial force */
1177 /* Update vectorial force */
1181 f[j_coord_offset+DIM*2+XX] -= tx;
1182 f[j_coord_offset+DIM*2+YY] -= ty;
1183 f[j_coord_offset+DIM*2+ZZ] -= tz;
1185 /**************************
1186 * CALCULATE INTERACTIONS *
1187 **************************/
1191 /* EWALD ELECTROSTATICS */
1193 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1194 ewrt = r33*ewtabscale;
1196 eweps = ewrt-ewitab;
1197 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1198 felec = qq33*rinv33*(rinvsq33-felec);
1202 /* Calculate temporary vectorial force */
1207 /* Update vectorial force */
1211 f[j_coord_offset+DIM*3+XX] -= tx;
1212 f[j_coord_offset+DIM*3+YY] -= ty;
1213 f[j_coord_offset+DIM*3+ZZ] -= tz;
1215 /* Inner loop uses 324 flops */
1217 /* End of innermost loop */
1220 f[i_coord_offset+DIM*0+XX] += fix0;
1221 f[i_coord_offset+DIM*0+YY] += fiy0;
1222 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1226 f[i_coord_offset+DIM*1+XX] += fix1;
1227 f[i_coord_offset+DIM*1+YY] += fiy1;
1228 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1232 f[i_coord_offset+DIM*2+XX] += fix2;
1233 f[i_coord_offset+DIM*2+YY] += fiy2;
1234 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1238 f[i_coord_offset+DIM*3+XX] += fix3;
1239 f[i_coord_offset+DIM*3+YY] += fiy3;
1240 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1244 fshift[i_shift_offset+XX] += tx;
1245 fshift[i_shift_offset+YY] += ty;
1246 fshift[i_shift_offset+ZZ] += tz;
1248 /* Increment number of inner iterations */
1249 inneriter += j_index_end - j_index_start;
1251 /* Outer loop uses 39 flops */
1254 /* Increment number of outer iterations */
1257 /* Update outer/inner flops */
1259 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*324);