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_ElecRFCut_VdwLJSh_GeomW4W4_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwLJSh_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;
108 jindex = nlist->jindex;
110 shiftidx = nlist->shift;
112 shiftvec = fr->shift_vec[0];
113 fshift = fr->fshift[0];
115 charge = mdatoms->chargeA;
119 nvdwtype = fr->ntype;
121 vdwtype = mdatoms->typeA;
123 /* Setup water-specific parameters */
124 inr = nlist->iinr[0];
125 iq1 = facel*charge[inr+1];
126 iq2 = facel*charge[inr+2];
127 iq3 = facel*charge[inr+3];
128 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
133 vdwjidx0 = 2*vdwtype[inr+0];
134 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
135 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
146 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
147 rcutoff = fr->rcoulomb;
148 rcutoff2 = rcutoff*rcutoff;
150 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
156 /* Start outer loop over neighborlists */
157 for(iidx=0; iidx<nri; iidx++)
159 /* Load shift vector for this list */
160 i_shift_offset = DIM*shiftidx[iidx];
161 shX = shiftvec[i_shift_offset+XX];
162 shY = shiftvec[i_shift_offset+YY];
163 shZ = shiftvec[i_shift_offset+ZZ];
165 /* Load limits for loop over neighbors */
166 j_index_start = jindex[iidx];
167 j_index_end = jindex[iidx+1];
169 /* Get outer coordinate index */
171 i_coord_offset = DIM*inr;
173 /* Load i particle coords and add shift vector */
174 ix0 = shX + x[i_coord_offset+DIM*0+XX];
175 iy0 = shY + x[i_coord_offset+DIM*0+YY];
176 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
177 ix1 = shX + x[i_coord_offset+DIM*1+XX];
178 iy1 = shY + x[i_coord_offset+DIM*1+YY];
179 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
180 ix2 = shX + x[i_coord_offset+DIM*2+XX];
181 iy2 = shY + x[i_coord_offset+DIM*2+YY];
182 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
183 ix3 = shX + x[i_coord_offset+DIM*3+XX];
184 iy3 = shY + x[i_coord_offset+DIM*3+YY];
185 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
200 /* Reset potential sums */
204 /* Start inner kernel loop */
205 for(jidx=j_index_start; jidx<j_index_end; jidx++)
207 /* Get j neighbor index, and coordinate index */
209 j_coord_offset = DIM*jnr;
211 /* load j atom coordinates */
212 jx0 = x[j_coord_offset+DIM*0+XX];
213 jy0 = x[j_coord_offset+DIM*0+YY];
214 jz0 = x[j_coord_offset+DIM*0+ZZ];
215 jx1 = x[j_coord_offset+DIM*1+XX];
216 jy1 = x[j_coord_offset+DIM*1+YY];
217 jz1 = x[j_coord_offset+DIM*1+ZZ];
218 jx2 = x[j_coord_offset+DIM*2+XX];
219 jy2 = x[j_coord_offset+DIM*2+YY];
220 jz2 = x[j_coord_offset+DIM*2+ZZ];
221 jx3 = x[j_coord_offset+DIM*3+XX];
222 jy3 = x[j_coord_offset+DIM*3+YY];
223 jz3 = x[j_coord_offset+DIM*3+ZZ];
225 /* Calculate displacement vector */
257 /* Calculate squared distance and things based on it */
258 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
259 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
260 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
261 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
262 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
263 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
264 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
265 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
266 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
267 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
269 rinv11 = gmx_invsqrt(rsq11);
270 rinv12 = gmx_invsqrt(rsq12);
271 rinv13 = gmx_invsqrt(rsq13);
272 rinv21 = gmx_invsqrt(rsq21);
273 rinv22 = gmx_invsqrt(rsq22);
274 rinv23 = gmx_invsqrt(rsq23);
275 rinv31 = gmx_invsqrt(rsq31);
276 rinv32 = gmx_invsqrt(rsq32);
277 rinv33 = gmx_invsqrt(rsq33);
279 rinvsq00 = 1.0/rsq00;
280 rinvsq11 = rinv11*rinv11;
281 rinvsq12 = rinv12*rinv12;
282 rinvsq13 = rinv13*rinv13;
283 rinvsq21 = rinv21*rinv21;
284 rinvsq22 = rinv22*rinv22;
285 rinvsq23 = rinv23*rinv23;
286 rinvsq31 = rinv31*rinv31;
287 rinvsq32 = rinv32*rinv32;
288 rinvsq33 = rinv33*rinv33;
290 /**************************
291 * CALCULATE INTERACTIONS *
292 **************************/
297 /* LENNARD-JONES DISPERSION/REPULSION */
299 rinvsix = rinvsq00*rinvsq00*rinvsq00;
300 vvdw6 = c6_00*rinvsix;
301 vvdw12 = c12_00*rinvsix*rinvsix;
302 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
303 fvdw = (vvdw12-vvdw6)*rinvsq00;
305 /* Update potential sums from outer loop */
310 /* Calculate temporary vectorial force */
315 /* Update vectorial force */
319 f[j_coord_offset+DIM*0+XX] -= tx;
320 f[j_coord_offset+DIM*0+YY] -= ty;
321 f[j_coord_offset+DIM*0+ZZ] -= tz;
325 /**************************
326 * CALCULATE INTERACTIONS *
327 **************************/
332 /* REACTION-FIELD ELECTROSTATICS */
333 velec = qq11*(rinv11+krf*rsq11-crf);
334 felec = qq11*(rinv11*rinvsq11-krf2);
336 /* Update potential sums from outer loop */
341 /* Calculate temporary vectorial force */
346 /* Update vectorial force */
350 f[j_coord_offset+DIM*1+XX] -= tx;
351 f[j_coord_offset+DIM*1+YY] -= ty;
352 f[j_coord_offset+DIM*1+ZZ] -= tz;
356 /**************************
357 * CALCULATE INTERACTIONS *
358 **************************/
363 /* REACTION-FIELD ELECTROSTATICS */
364 velec = qq12*(rinv12+krf*rsq12-crf);
365 felec = qq12*(rinv12*rinvsq12-krf2);
367 /* Update potential sums from outer loop */
372 /* Calculate temporary vectorial force */
377 /* Update vectorial force */
381 f[j_coord_offset+DIM*2+XX] -= tx;
382 f[j_coord_offset+DIM*2+YY] -= ty;
383 f[j_coord_offset+DIM*2+ZZ] -= tz;
387 /**************************
388 * CALCULATE INTERACTIONS *
389 **************************/
394 /* REACTION-FIELD ELECTROSTATICS */
395 velec = qq13*(rinv13+krf*rsq13-crf);
396 felec = qq13*(rinv13*rinvsq13-krf2);
398 /* Update potential sums from outer loop */
403 /* Calculate temporary vectorial force */
408 /* Update vectorial force */
412 f[j_coord_offset+DIM*3+XX] -= tx;
413 f[j_coord_offset+DIM*3+YY] -= ty;
414 f[j_coord_offset+DIM*3+ZZ] -= tz;
418 /**************************
419 * CALCULATE INTERACTIONS *
420 **************************/
425 /* REACTION-FIELD ELECTROSTATICS */
426 velec = qq21*(rinv21+krf*rsq21-crf);
427 felec = qq21*(rinv21*rinvsq21-krf2);
429 /* Update potential sums from outer loop */
434 /* Calculate temporary vectorial force */
439 /* Update vectorial force */
443 f[j_coord_offset+DIM*1+XX] -= tx;
444 f[j_coord_offset+DIM*1+YY] -= ty;
445 f[j_coord_offset+DIM*1+ZZ] -= tz;
449 /**************************
450 * CALCULATE INTERACTIONS *
451 **************************/
456 /* REACTION-FIELD ELECTROSTATICS */
457 velec = qq22*(rinv22+krf*rsq22-crf);
458 felec = qq22*(rinv22*rinvsq22-krf2);
460 /* Update potential sums from outer loop */
465 /* Calculate temporary vectorial force */
470 /* Update vectorial force */
474 f[j_coord_offset+DIM*2+XX] -= tx;
475 f[j_coord_offset+DIM*2+YY] -= ty;
476 f[j_coord_offset+DIM*2+ZZ] -= tz;
480 /**************************
481 * CALCULATE INTERACTIONS *
482 **************************/
487 /* REACTION-FIELD ELECTROSTATICS */
488 velec = qq23*(rinv23+krf*rsq23-crf);
489 felec = qq23*(rinv23*rinvsq23-krf2);
491 /* Update potential sums from outer loop */
496 /* Calculate temporary vectorial force */
501 /* Update vectorial force */
505 f[j_coord_offset+DIM*3+XX] -= tx;
506 f[j_coord_offset+DIM*3+YY] -= ty;
507 f[j_coord_offset+DIM*3+ZZ] -= tz;
511 /**************************
512 * CALCULATE INTERACTIONS *
513 **************************/
518 /* REACTION-FIELD ELECTROSTATICS */
519 velec = qq31*(rinv31+krf*rsq31-crf);
520 felec = qq31*(rinv31*rinvsq31-krf2);
522 /* Update potential sums from outer loop */
527 /* Calculate temporary vectorial force */
532 /* Update vectorial force */
536 f[j_coord_offset+DIM*1+XX] -= tx;
537 f[j_coord_offset+DIM*1+YY] -= ty;
538 f[j_coord_offset+DIM*1+ZZ] -= tz;
542 /**************************
543 * CALCULATE INTERACTIONS *
544 **************************/
549 /* REACTION-FIELD ELECTROSTATICS */
550 velec = qq32*(rinv32+krf*rsq32-crf);
551 felec = qq32*(rinv32*rinvsq32-krf2);
553 /* Update potential sums from outer loop */
558 /* Calculate temporary vectorial force */
563 /* Update vectorial force */
567 f[j_coord_offset+DIM*2+XX] -= tx;
568 f[j_coord_offset+DIM*2+YY] -= ty;
569 f[j_coord_offset+DIM*2+ZZ] -= tz;
573 /**************************
574 * CALCULATE INTERACTIONS *
575 **************************/
580 /* REACTION-FIELD ELECTROSTATICS */
581 velec = qq33*(rinv33+krf*rsq33-crf);
582 felec = qq33*(rinv33*rinvsq33-krf2);
584 /* Update potential sums from outer loop */
589 /* Calculate temporary vectorial force */
594 /* Update vectorial force */
598 f[j_coord_offset+DIM*3+XX] -= tx;
599 f[j_coord_offset+DIM*3+YY] -= ty;
600 f[j_coord_offset+DIM*3+ZZ] -= tz;
604 /* Inner loop uses 316 flops */
606 /* End of innermost loop */
609 f[i_coord_offset+DIM*0+XX] += fix0;
610 f[i_coord_offset+DIM*0+YY] += fiy0;
611 f[i_coord_offset+DIM*0+ZZ] += fiz0;
615 f[i_coord_offset+DIM*1+XX] += fix1;
616 f[i_coord_offset+DIM*1+YY] += fiy1;
617 f[i_coord_offset+DIM*1+ZZ] += fiz1;
621 f[i_coord_offset+DIM*2+XX] += fix2;
622 f[i_coord_offset+DIM*2+YY] += fiy2;
623 f[i_coord_offset+DIM*2+ZZ] += fiz2;
627 f[i_coord_offset+DIM*3+XX] += fix3;
628 f[i_coord_offset+DIM*3+YY] += fiy3;
629 f[i_coord_offset+DIM*3+ZZ] += fiz3;
633 fshift[i_shift_offset+XX] += tx;
634 fshift[i_shift_offset+YY] += ty;
635 fshift[i_shift_offset+ZZ] += tz;
638 /* Update potential energies */
639 kernel_data->energygrp_elec[ggid] += velecsum;
640 kernel_data->energygrp_vdw[ggid] += vvdwsum;
642 /* Increment number of inner iterations */
643 inneriter += j_index_end - j_index_start;
645 /* Outer loop uses 41 flops */
648 /* Increment number of outer iterations */
651 /* Update outer/inner flops */
653 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*316);
656 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_c
657 * Electrostatics interaction: ReactionField
658 * VdW interaction: LennardJones
659 * Geometry: Water4-Water4
660 * Calculate force/pot: Force
663 nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_c
664 (t_nblist * gmx_restrict nlist,
665 rvec * gmx_restrict xx,
666 rvec * gmx_restrict ff,
667 t_forcerec * gmx_restrict fr,
668 t_mdatoms * gmx_restrict mdatoms,
669 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
670 t_nrnb * gmx_restrict nrnb)
672 int i_shift_offset,i_coord_offset,j_coord_offset;
673 int j_index_start,j_index_end;
674 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
675 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
676 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
677 real *shiftvec,*fshift,*x,*f;
679 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
681 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
683 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
685 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
687 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
689 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
691 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
693 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
694 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
695 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
696 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
697 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
698 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
699 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
700 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
701 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
702 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
703 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
704 real velec,felec,velecsum,facel,crf,krf,krf2;
707 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
716 jindex = nlist->jindex;
718 shiftidx = nlist->shift;
720 shiftvec = fr->shift_vec[0];
721 fshift = fr->fshift[0];
723 charge = mdatoms->chargeA;
727 nvdwtype = fr->ntype;
729 vdwtype = mdatoms->typeA;
731 /* Setup water-specific parameters */
732 inr = nlist->iinr[0];
733 iq1 = facel*charge[inr+1];
734 iq2 = facel*charge[inr+2];
735 iq3 = facel*charge[inr+3];
736 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
741 vdwjidx0 = 2*vdwtype[inr+0];
742 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
743 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
754 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
755 rcutoff = fr->rcoulomb;
756 rcutoff2 = rcutoff*rcutoff;
758 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
764 /* Start outer loop over neighborlists */
765 for(iidx=0; iidx<nri; iidx++)
767 /* Load shift vector for this list */
768 i_shift_offset = DIM*shiftidx[iidx];
769 shX = shiftvec[i_shift_offset+XX];
770 shY = shiftvec[i_shift_offset+YY];
771 shZ = shiftvec[i_shift_offset+ZZ];
773 /* Load limits for loop over neighbors */
774 j_index_start = jindex[iidx];
775 j_index_end = jindex[iidx+1];
777 /* Get outer coordinate index */
779 i_coord_offset = DIM*inr;
781 /* Load i particle coords and add shift vector */
782 ix0 = shX + x[i_coord_offset+DIM*0+XX];
783 iy0 = shY + x[i_coord_offset+DIM*0+YY];
784 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
785 ix1 = shX + x[i_coord_offset+DIM*1+XX];
786 iy1 = shY + x[i_coord_offset+DIM*1+YY];
787 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
788 ix2 = shX + x[i_coord_offset+DIM*2+XX];
789 iy2 = shY + x[i_coord_offset+DIM*2+YY];
790 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
791 ix3 = shX + x[i_coord_offset+DIM*3+XX];
792 iy3 = shY + x[i_coord_offset+DIM*3+YY];
793 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
808 /* Start inner kernel loop */
809 for(jidx=j_index_start; jidx<j_index_end; jidx++)
811 /* Get j neighbor index, and coordinate index */
813 j_coord_offset = DIM*jnr;
815 /* load j atom coordinates */
816 jx0 = x[j_coord_offset+DIM*0+XX];
817 jy0 = x[j_coord_offset+DIM*0+YY];
818 jz0 = x[j_coord_offset+DIM*0+ZZ];
819 jx1 = x[j_coord_offset+DIM*1+XX];
820 jy1 = x[j_coord_offset+DIM*1+YY];
821 jz1 = x[j_coord_offset+DIM*1+ZZ];
822 jx2 = x[j_coord_offset+DIM*2+XX];
823 jy2 = x[j_coord_offset+DIM*2+YY];
824 jz2 = x[j_coord_offset+DIM*2+ZZ];
825 jx3 = x[j_coord_offset+DIM*3+XX];
826 jy3 = x[j_coord_offset+DIM*3+YY];
827 jz3 = x[j_coord_offset+DIM*3+ZZ];
829 /* Calculate displacement vector */
861 /* Calculate squared distance and things based on it */
862 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
863 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
864 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
865 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
866 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
867 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
868 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
869 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
870 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
871 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
873 rinv11 = gmx_invsqrt(rsq11);
874 rinv12 = gmx_invsqrt(rsq12);
875 rinv13 = gmx_invsqrt(rsq13);
876 rinv21 = gmx_invsqrt(rsq21);
877 rinv22 = gmx_invsqrt(rsq22);
878 rinv23 = gmx_invsqrt(rsq23);
879 rinv31 = gmx_invsqrt(rsq31);
880 rinv32 = gmx_invsqrt(rsq32);
881 rinv33 = gmx_invsqrt(rsq33);
883 rinvsq00 = 1.0/rsq00;
884 rinvsq11 = rinv11*rinv11;
885 rinvsq12 = rinv12*rinv12;
886 rinvsq13 = rinv13*rinv13;
887 rinvsq21 = rinv21*rinv21;
888 rinvsq22 = rinv22*rinv22;
889 rinvsq23 = rinv23*rinv23;
890 rinvsq31 = rinv31*rinv31;
891 rinvsq32 = rinv32*rinv32;
892 rinvsq33 = rinv33*rinv33;
894 /**************************
895 * CALCULATE INTERACTIONS *
896 **************************/
901 /* LENNARD-JONES DISPERSION/REPULSION */
903 rinvsix = rinvsq00*rinvsq00*rinvsq00;
904 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
908 /* Calculate temporary vectorial force */
913 /* Update vectorial force */
917 f[j_coord_offset+DIM*0+XX] -= tx;
918 f[j_coord_offset+DIM*0+YY] -= ty;
919 f[j_coord_offset+DIM*0+ZZ] -= tz;
923 /**************************
924 * CALCULATE INTERACTIONS *
925 **************************/
930 /* REACTION-FIELD ELECTROSTATICS */
931 felec = qq11*(rinv11*rinvsq11-krf2);
935 /* Calculate temporary vectorial force */
940 /* Update vectorial force */
944 f[j_coord_offset+DIM*1+XX] -= tx;
945 f[j_coord_offset+DIM*1+YY] -= ty;
946 f[j_coord_offset+DIM*1+ZZ] -= tz;
950 /**************************
951 * CALCULATE INTERACTIONS *
952 **************************/
957 /* REACTION-FIELD ELECTROSTATICS */
958 felec = qq12*(rinv12*rinvsq12-krf2);
962 /* Calculate temporary vectorial force */
967 /* Update vectorial force */
971 f[j_coord_offset+DIM*2+XX] -= tx;
972 f[j_coord_offset+DIM*2+YY] -= ty;
973 f[j_coord_offset+DIM*2+ZZ] -= tz;
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
984 /* REACTION-FIELD ELECTROSTATICS */
985 felec = qq13*(rinv13*rinvsq13-krf2);
989 /* Calculate temporary vectorial force */
994 /* Update vectorial force */
998 f[j_coord_offset+DIM*3+XX] -= tx;
999 f[j_coord_offset+DIM*3+YY] -= ty;
1000 f[j_coord_offset+DIM*3+ZZ] -= tz;
1004 /**************************
1005 * CALCULATE INTERACTIONS *
1006 **************************/
1011 /* REACTION-FIELD ELECTROSTATICS */
1012 felec = qq21*(rinv21*rinvsq21-krf2);
1016 /* Calculate temporary vectorial force */
1021 /* Update vectorial force */
1025 f[j_coord_offset+DIM*1+XX] -= tx;
1026 f[j_coord_offset+DIM*1+YY] -= ty;
1027 f[j_coord_offset+DIM*1+ZZ] -= tz;
1031 /**************************
1032 * CALCULATE INTERACTIONS *
1033 **************************/
1038 /* REACTION-FIELD ELECTROSTATICS */
1039 felec = qq22*(rinv22*rinvsq22-krf2);
1043 /* Calculate temporary vectorial force */
1048 /* Update vectorial force */
1052 f[j_coord_offset+DIM*2+XX] -= tx;
1053 f[j_coord_offset+DIM*2+YY] -= ty;
1054 f[j_coord_offset+DIM*2+ZZ] -= tz;
1058 /**************************
1059 * CALCULATE INTERACTIONS *
1060 **************************/
1065 /* REACTION-FIELD ELECTROSTATICS */
1066 felec = qq23*(rinv23*rinvsq23-krf2);
1070 /* Calculate temporary vectorial force */
1075 /* Update vectorial force */
1079 f[j_coord_offset+DIM*3+XX] -= tx;
1080 f[j_coord_offset+DIM*3+YY] -= ty;
1081 f[j_coord_offset+DIM*3+ZZ] -= tz;
1085 /**************************
1086 * CALCULATE INTERACTIONS *
1087 **************************/
1092 /* REACTION-FIELD ELECTROSTATICS */
1093 felec = qq31*(rinv31*rinvsq31-krf2);
1097 /* Calculate temporary vectorial force */
1102 /* Update vectorial force */
1106 f[j_coord_offset+DIM*1+XX] -= tx;
1107 f[j_coord_offset+DIM*1+YY] -= ty;
1108 f[j_coord_offset+DIM*1+ZZ] -= tz;
1112 /**************************
1113 * CALCULATE INTERACTIONS *
1114 **************************/
1119 /* REACTION-FIELD ELECTROSTATICS */
1120 felec = qq32*(rinv32*rinvsq32-krf2);
1124 /* Calculate temporary vectorial force */
1129 /* Update vectorial force */
1133 f[j_coord_offset+DIM*2+XX] -= tx;
1134 f[j_coord_offset+DIM*2+YY] -= ty;
1135 f[j_coord_offset+DIM*2+ZZ] -= tz;
1139 /**************************
1140 * CALCULATE INTERACTIONS *
1141 **************************/
1146 /* REACTION-FIELD ELECTROSTATICS */
1147 felec = qq33*(rinv33*rinvsq33-krf2);
1151 /* Calculate temporary vectorial force */
1156 /* Update vectorial force */
1160 f[j_coord_offset+DIM*3+XX] -= tx;
1161 f[j_coord_offset+DIM*3+YY] -= ty;
1162 f[j_coord_offset+DIM*3+ZZ] -= tz;
1166 /* Inner loop uses 261 flops */
1168 /* End of innermost loop */
1171 f[i_coord_offset+DIM*0+XX] += fix0;
1172 f[i_coord_offset+DIM*0+YY] += fiy0;
1173 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1177 f[i_coord_offset+DIM*1+XX] += fix1;
1178 f[i_coord_offset+DIM*1+YY] += fiy1;
1179 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1183 f[i_coord_offset+DIM*2+XX] += fix2;
1184 f[i_coord_offset+DIM*2+YY] += fiy2;
1185 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1189 f[i_coord_offset+DIM*3+XX] += fix3;
1190 f[i_coord_offset+DIM*3+YY] += fiy3;
1191 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1195 fshift[i_shift_offset+XX] += tx;
1196 fshift[i_shift_offset+YY] += ty;
1197 fshift[i_shift_offset+ZZ] += tz;
1199 /* Increment number of inner iterations */
1200 inneriter += j_index_end - j_index_start;
1202 /* Outer loop uses 39 flops */
1205 /* Increment number of outer iterations */
1208 /* Update outer/inner flops */
1210 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*261);