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_ElecRFCut_VdwLJSh_GeomW4W4_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwLJSh_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;
110 jindex = nlist->jindex;
112 shiftidx = nlist->shift;
114 shiftvec = fr->shift_vec[0];
115 fshift = fr->fshift[0];
117 charge = mdatoms->chargeA;
121 nvdwtype = fr->ntype;
123 vdwtype = mdatoms->typeA;
125 /* Setup water-specific parameters */
126 inr = nlist->iinr[0];
127 iq1 = facel*charge[inr+1];
128 iq2 = facel*charge[inr+2];
129 iq3 = facel*charge[inr+3];
130 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
135 vdwjidx0 = 2*vdwtype[inr+0];
136 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
137 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
148 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
149 rcutoff = fr->rcoulomb;
150 rcutoff2 = rcutoff*rcutoff;
152 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
158 /* Start outer loop over neighborlists */
159 for(iidx=0; iidx<nri; iidx++)
161 /* Load shift vector for this list */
162 i_shift_offset = DIM*shiftidx[iidx];
163 shX = shiftvec[i_shift_offset+XX];
164 shY = shiftvec[i_shift_offset+YY];
165 shZ = shiftvec[i_shift_offset+ZZ];
167 /* Load limits for loop over neighbors */
168 j_index_start = jindex[iidx];
169 j_index_end = jindex[iidx+1];
171 /* Get outer coordinate index */
173 i_coord_offset = DIM*inr;
175 /* Load i particle coords and add shift vector */
176 ix0 = shX + x[i_coord_offset+DIM*0+XX];
177 iy0 = shY + x[i_coord_offset+DIM*0+YY];
178 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
179 ix1 = shX + x[i_coord_offset+DIM*1+XX];
180 iy1 = shY + x[i_coord_offset+DIM*1+YY];
181 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
182 ix2 = shX + x[i_coord_offset+DIM*2+XX];
183 iy2 = shY + x[i_coord_offset+DIM*2+YY];
184 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
185 ix3 = shX + x[i_coord_offset+DIM*3+XX];
186 iy3 = shY + x[i_coord_offset+DIM*3+YY];
187 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
202 /* Reset potential sums */
206 /* Start inner kernel loop */
207 for(jidx=j_index_start; jidx<j_index_end; jidx++)
209 /* Get j neighbor index, and coordinate index */
211 j_coord_offset = DIM*jnr;
213 /* load j atom coordinates */
214 jx0 = x[j_coord_offset+DIM*0+XX];
215 jy0 = x[j_coord_offset+DIM*0+YY];
216 jz0 = x[j_coord_offset+DIM*0+ZZ];
217 jx1 = x[j_coord_offset+DIM*1+XX];
218 jy1 = x[j_coord_offset+DIM*1+YY];
219 jz1 = x[j_coord_offset+DIM*1+ZZ];
220 jx2 = x[j_coord_offset+DIM*2+XX];
221 jy2 = x[j_coord_offset+DIM*2+YY];
222 jz2 = x[j_coord_offset+DIM*2+ZZ];
223 jx3 = x[j_coord_offset+DIM*3+XX];
224 jy3 = x[j_coord_offset+DIM*3+YY];
225 jz3 = x[j_coord_offset+DIM*3+ZZ];
227 /* Calculate displacement vector */
259 /* Calculate squared distance and things based on it */
260 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
261 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
262 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
263 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
264 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
265 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
266 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
267 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
268 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
269 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
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 = 1.0/rsq00;
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 **************************/
299 /* LENNARD-JONES DISPERSION/REPULSION */
301 rinvsix = rinvsq00*rinvsq00*rinvsq00;
302 vvdw6 = c6_00*rinvsix;
303 vvdw12 = c12_00*rinvsix*rinvsix;
304 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
305 fvdw = (vvdw12-vvdw6)*rinvsq00;
307 /* Update potential sums from outer loop */
312 /* Calculate temporary vectorial force */
317 /* Update vectorial force */
321 f[j_coord_offset+DIM*0+XX] -= tx;
322 f[j_coord_offset+DIM*0+YY] -= ty;
323 f[j_coord_offset+DIM*0+ZZ] -= tz;
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
334 /* REACTION-FIELD ELECTROSTATICS */
335 velec = qq11*(rinv11+krf*rsq11-crf);
336 felec = qq11*(rinv11*rinvsq11-krf2);
338 /* Update potential sums from outer loop */
343 /* Calculate temporary vectorial force */
348 /* Update vectorial force */
352 f[j_coord_offset+DIM*1+XX] -= tx;
353 f[j_coord_offset+DIM*1+YY] -= ty;
354 f[j_coord_offset+DIM*1+ZZ] -= tz;
358 /**************************
359 * CALCULATE INTERACTIONS *
360 **************************/
365 /* REACTION-FIELD ELECTROSTATICS */
366 velec = qq12*(rinv12+krf*rsq12-crf);
367 felec = qq12*(rinv12*rinvsq12-krf2);
369 /* Update potential sums from outer loop */
374 /* Calculate temporary vectorial force */
379 /* Update vectorial force */
383 f[j_coord_offset+DIM*2+XX] -= tx;
384 f[j_coord_offset+DIM*2+YY] -= ty;
385 f[j_coord_offset+DIM*2+ZZ] -= tz;
389 /**************************
390 * CALCULATE INTERACTIONS *
391 **************************/
396 /* REACTION-FIELD ELECTROSTATICS */
397 velec = qq13*(rinv13+krf*rsq13-crf);
398 felec = qq13*(rinv13*rinvsq13-krf2);
400 /* Update potential sums from outer loop */
405 /* Calculate temporary vectorial force */
410 /* Update vectorial force */
414 f[j_coord_offset+DIM*3+XX] -= tx;
415 f[j_coord_offset+DIM*3+YY] -= ty;
416 f[j_coord_offset+DIM*3+ZZ] -= tz;
420 /**************************
421 * CALCULATE INTERACTIONS *
422 **************************/
427 /* REACTION-FIELD ELECTROSTATICS */
428 velec = qq21*(rinv21+krf*rsq21-crf);
429 felec = qq21*(rinv21*rinvsq21-krf2);
431 /* Update potential sums from outer loop */
436 /* Calculate temporary vectorial force */
441 /* Update vectorial force */
445 f[j_coord_offset+DIM*1+XX] -= tx;
446 f[j_coord_offset+DIM*1+YY] -= ty;
447 f[j_coord_offset+DIM*1+ZZ] -= tz;
451 /**************************
452 * CALCULATE INTERACTIONS *
453 **************************/
458 /* REACTION-FIELD ELECTROSTATICS */
459 velec = qq22*(rinv22+krf*rsq22-crf);
460 felec = qq22*(rinv22*rinvsq22-krf2);
462 /* Update potential sums from outer loop */
467 /* Calculate temporary vectorial force */
472 /* Update vectorial force */
476 f[j_coord_offset+DIM*2+XX] -= tx;
477 f[j_coord_offset+DIM*2+YY] -= ty;
478 f[j_coord_offset+DIM*2+ZZ] -= tz;
482 /**************************
483 * CALCULATE INTERACTIONS *
484 **************************/
489 /* REACTION-FIELD ELECTROSTATICS */
490 velec = qq23*(rinv23+krf*rsq23-crf);
491 felec = qq23*(rinv23*rinvsq23-krf2);
493 /* Update potential sums from outer loop */
498 /* Calculate temporary vectorial force */
503 /* Update vectorial force */
507 f[j_coord_offset+DIM*3+XX] -= tx;
508 f[j_coord_offset+DIM*3+YY] -= ty;
509 f[j_coord_offset+DIM*3+ZZ] -= tz;
513 /**************************
514 * CALCULATE INTERACTIONS *
515 **************************/
520 /* REACTION-FIELD ELECTROSTATICS */
521 velec = qq31*(rinv31+krf*rsq31-crf);
522 felec = qq31*(rinv31*rinvsq31-krf2);
524 /* Update potential sums from outer loop */
529 /* Calculate temporary vectorial force */
534 /* Update vectorial force */
538 f[j_coord_offset+DIM*1+XX] -= tx;
539 f[j_coord_offset+DIM*1+YY] -= ty;
540 f[j_coord_offset+DIM*1+ZZ] -= tz;
544 /**************************
545 * CALCULATE INTERACTIONS *
546 **************************/
551 /* REACTION-FIELD ELECTROSTATICS */
552 velec = qq32*(rinv32+krf*rsq32-crf);
553 felec = qq32*(rinv32*rinvsq32-krf2);
555 /* Update potential sums from outer loop */
560 /* Calculate temporary vectorial force */
565 /* Update vectorial force */
569 f[j_coord_offset+DIM*2+XX] -= tx;
570 f[j_coord_offset+DIM*2+YY] -= ty;
571 f[j_coord_offset+DIM*2+ZZ] -= tz;
575 /**************************
576 * CALCULATE INTERACTIONS *
577 **************************/
582 /* REACTION-FIELD ELECTROSTATICS */
583 velec = qq33*(rinv33+krf*rsq33-crf);
584 felec = qq33*(rinv33*rinvsq33-krf2);
586 /* Update potential sums from outer loop */
591 /* Calculate temporary vectorial force */
596 /* Update vectorial force */
600 f[j_coord_offset+DIM*3+XX] -= tx;
601 f[j_coord_offset+DIM*3+YY] -= ty;
602 f[j_coord_offset+DIM*3+ZZ] -= tz;
606 /* Inner loop uses 316 flops */
608 /* End of innermost loop */
611 f[i_coord_offset+DIM*0+XX] += fix0;
612 f[i_coord_offset+DIM*0+YY] += fiy0;
613 f[i_coord_offset+DIM*0+ZZ] += fiz0;
617 f[i_coord_offset+DIM*1+XX] += fix1;
618 f[i_coord_offset+DIM*1+YY] += fiy1;
619 f[i_coord_offset+DIM*1+ZZ] += fiz1;
623 f[i_coord_offset+DIM*2+XX] += fix2;
624 f[i_coord_offset+DIM*2+YY] += fiy2;
625 f[i_coord_offset+DIM*2+ZZ] += fiz2;
629 f[i_coord_offset+DIM*3+XX] += fix3;
630 f[i_coord_offset+DIM*3+YY] += fiy3;
631 f[i_coord_offset+DIM*3+ZZ] += fiz3;
635 fshift[i_shift_offset+XX] += tx;
636 fshift[i_shift_offset+YY] += ty;
637 fshift[i_shift_offset+ZZ] += tz;
640 /* Update potential energies */
641 kernel_data->energygrp_elec[ggid] += velecsum;
642 kernel_data->energygrp_vdw[ggid] += vvdwsum;
644 /* Increment number of inner iterations */
645 inneriter += j_index_end - j_index_start;
647 /* Outer loop uses 41 flops */
650 /* Increment number of outer iterations */
653 /* Update outer/inner flops */
655 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*316);
658 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_c
659 * Electrostatics interaction: ReactionField
660 * VdW interaction: LennardJones
661 * Geometry: Water4-Water4
662 * Calculate force/pot: Force
665 nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_c
666 (t_nblist * gmx_restrict nlist,
667 rvec * gmx_restrict xx,
668 rvec * gmx_restrict ff,
669 t_forcerec * gmx_restrict fr,
670 t_mdatoms * gmx_restrict mdatoms,
671 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
672 t_nrnb * gmx_restrict nrnb)
674 int i_shift_offset,i_coord_offset,j_coord_offset;
675 int j_index_start,j_index_end;
676 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
677 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
678 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
679 real *shiftvec,*fshift,*x,*f;
681 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
683 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
685 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
687 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
689 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
691 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
693 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
695 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
696 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
697 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
698 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
699 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
700 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
701 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
702 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
703 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
704 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
705 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
706 real velec,felec,velecsum,facel,crf,krf,krf2;
709 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
718 jindex = nlist->jindex;
720 shiftidx = nlist->shift;
722 shiftvec = fr->shift_vec[0];
723 fshift = fr->fshift[0];
725 charge = mdatoms->chargeA;
729 nvdwtype = fr->ntype;
731 vdwtype = mdatoms->typeA;
733 /* Setup water-specific parameters */
734 inr = nlist->iinr[0];
735 iq1 = facel*charge[inr+1];
736 iq2 = facel*charge[inr+2];
737 iq3 = facel*charge[inr+3];
738 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
743 vdwjidx0 = 2*vdwtype[inr+0];
744 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
745 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
756 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
757 rcutoff = fr->rcoulomb;
758 rcutoff2 = rcutoff*rcutoff;
760 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
766 /* Start outer loop over neighborlists */
767 for(iidx=0; iidx<nri; iidx++)
769 /* Load shift vector for this list */
770 i_shift_offset = DIM*shiftidx[iidx];
771 shX = shiftvec[i_shift_offset+XX];
772 shY = shiftvec[i_shift_offset+YY];
773 shZ = shiftvec[i_shift_offset+ZZ];
775 /* Load limits for loop over neighbors */
776 j_index_start = jindex[iidx];
777 j_index_end = jindex[iidx+1];
779 /* Get outer coordinate index */
781 i_coord_offset = DIM*inr;
783 /* Load i particle coords and add shift vector */
784 ix0 = shX + x[i_coord_offset+DIM*0+XX];
785 iy0 = shY + x[i_coord_offset+DIM*0+YY];
786 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
787 ix1 = shX + x[i_coord_offset+DIM*1+XX];
788 iy1 = shY + x[i_coord_offset+DIM*1+YY];
789 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
790 ix2 = shX + x[i_coord_offset+DIM*2+XX];
791 iy2 = shY + x[i_coord_offset+DIM*2+YY];
792 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
793 ix3 = shX + x[i_coord_offset+DIM*3+XX];
794 iy3 = shY + x[i_coord_offset+DIM*3+YY];
795 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
810 /* Start inner kernel loop */
811 for(jidx=j_index_start; jidx<j_index_end; jidx++)
813 /* Get j neighbor index, and coordinate index */
815 j_coord_offset = DIM*jnr;
817 /* load j atom coordinates */
818 jx0 = x[j_coord_offset+DIM*0+XX];
819 jy0 = x[j_coord_offset+DIM*0+YY];
820 jz0 = x[j_coord_offset+DIM*0+ZZ];
821 jx1 = x[j_coord_offset+DIM*1+XX];
822 jy1 = x[j_coord_offset+DIM*1+YY];
823 jz1 = x[j_coord_offset+DIM*1+ZZ];
824 jx2 = x[j_coord_offset+DIM*2+XX];
825 jy2 = x[j_coord_offset+DIM*2+YY];
826 jz2 = x[j_coord_offset+DIM*2+ZZ];
827 jx3 = x[j_coord_offset+DIM*3+XX];
828 jy3 = x[j_coord_offset+DIM*3+YY];
829 jz3 = x[j_coord_offset+DIM*3+ZZ];
831 /* Calculate displacement vector */
863 /* Calculate squared distance and things based on it */
864 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
865 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
866 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
867 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
868 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
869 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
870 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
871 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
872 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
873 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
875 rinv11 = gmx_invsqrt(rsq11);
876 rinv12 = gmx_invsqrt(rsq12);
877 rinv13 = gmx_invsqrt(rsq13);
878 rinv21 = gmx_invsqrt(rsq21);
879 rinv22 = gmx_invsqrt(rsq22);
880 rinv23 = gmx_invsqrt(rsq23);
881 rinv31 = gmx_invsqrt(rsq31);
882 rinv32 = gmx_invsqrt(rsq32);
883 rinv33 = gmx_invsqrt(rsq33);
885 rinvsq00 = 1.0/rsq00;
886 rinvsq11 = rinv11*rinv11;
887 rinvsq12 = rinv12*rinv12;
888 rinvsq13 = rinv13*rinv13;
889 rinvsq21 = rinv21*rinv21;
890 rinvsq22 = rinv22*rinv22;
891 rinvsq23 = rinv23*rinv23;
892 rinvsq31 = rinv31*rinv31;
893 rinvsq32 = rinv32*rinv32;
894 rinvsq33 = rinv33*rinv33;
896 /**************************
897 * CALCULATE INTERACTIONS *
898 **************************/
903 /* LENNARD-JONES DISPERSION/REPULSION */
905 rinvsix = rinvsq00*rinvsq00*rinvsq00;
906 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
910 /* Calculate temporary vectorial force */
915 /* Update vectorial force */
919 f[j_coord_offset+DIM*0+XX] -= tx;
920 f[j_coord_offset+DIM*0+YY] -= ty;
921 f[j_coord_offset+DIM*0+ZZ] -= tz;
925 /**************************
926 * CALCULATE INTERACTIONS *
927 **************************/
932 /* REACTION-FIELD ELECTROSTATICS */
933 felec = qq11*(rinv11*rinvsq11-krf2);
937 /* Calculate temporary vectorial force */
942 /* Update vectorial force */
946 f[j_coord_offset+DIM*1+XX] -= tx;
947 f[j_coord_offset+DIM*1+YY] -= ty;
948 f[j_coord_offset+DIM*1+ZZ] -= tz;
952 /**************************
953 * CALCULATE INTERACTIONS *
954 **************************/
959 /* REACTION-FIELD ELECTROSTATICS */
960 felec = qq12*(rinv12*rinvsq12-krf2);
964 /* Calculate temporary vectorial force */
969 /* Update vectorial force */
973 f[j_coord_offset+DIM*2+XX] -= tx;
974 f[j_coord_offset+DIM*2+YY] -= ty;
975 f[j_coord_offset+DIM*2+ZZ] -= tz;
979 /**************************
980 * CALCULATE INTERACTIONS *
981 **************************/
986 /* REACTION-FIELD ELECTROSTATICS */
987 felec = qq13*(rinv13*rinvsq13-krf2);
991 /* Calculate temporary vectorial force */
996 /* Update vectorial force */
1000 f[j_coord_offset+DIM*3+XX] -= tx;
1001 f[j_coord_offset+DIM*3+YY] -= ty;
1002 f[j_coord_offset+DIM*3+ZZ] -= tz;
1006 /**************************
1007 * CALCULATE INTERACTIONS *
1008 **************************/
1013 /* REACTION-FIELD ELECTROSTATICS */
1014 felec = qq21*(rinv21*rinvsq21-krf2);
1018 /* Calculate temporary vectorial force */
1023 /* Update vectorial force */
1027 f[j_coord_offset+DIM*1+XX] -= tx;
1028 f[j_coord_offset+DIM*1+YY] -= ty;
1029 f[j_coord_offset+DIM*1+ZZ] -= tz;
1033 /**************************
1034 * CALCULATE INTERACTIONS *
1035 **************************/
1040 /* REACTION-FIELD ELECTROSTATICS */
1041 felec = qq22*(rinv22*rinvsq22-krf2);
1045 /* Calculate temporary vectorial force */
1050 /* Update vectorial force */
1054 f[j_coord_offset+DIM*2+XX] -= tx;
1055 f[j_coord_offset+DIM*2+YY] -= ty;
1056 f[j_coord_offset+DIM*2+ZZ] -= tz;
1060 /**************************
1061 * CALCULATE INTERACTIONS *
1062 **************************/
1067 /* REACTION-FIELD ELECTROSTATICS */
1068 felec = qq23*(rinv23*rinvsq23-krf2);
1072 /* Calculate temporary vectorial force */
1077 /* Update vectorial force */
1081 f[j_coord_offset+DIM*3+XX] -= tx;
1082 f[j_coord_offset+DIM*3+YY] -= ty;
1083 f[j_coord_offset+DIM*3+ZZ] -= tz;
1087 /**************************
1088 * CALCULATE INTERACTIONS *
1089 **************************/
1094 /* REACTION-FIELD ELECTROSTATICS */
1095 felec = qq31*(rinv31*rinvsq31-krf2);
1099 /* Calculate temporary vectorial force */
1104 /* Update vectorial force */
1108 f[j_coord_offset+DIM*1+XX] -= tx;
1109 f[j_coord_offset+DIM*1+YY] -= ty;
1110 f[j_coord_offset+DIM*1+ZZ] -= tz;
1114 /**************************
1115 * CALCULATE INTERACTIONS *
1116 **************************/
1121 /* REACTION-FIELD ELECTROSTATICS */
1122 felec = qq32*(rinv32*rinvsq32-krf2);
1126 /* Calculate temporary vectorial force */
1131 /* Update vectorial force */
1135 f[j_coord_offset+DIM*2+XX] -= tx;
1136 f[j_coord_offset+DIM*2+YY] -= ty;
1137 f[j_coord_offset+DIM*2+ZZ] -= tz;
1141 /**************************
1142 * CALCULATE INTERACTIONS *
1143 **************************/
1148 /* REACTION-FIELD ELECTROSTATICS */
1149 felec = qq33*(rinv33*rinvsq33-krf2);
1153 /* Calculate temporary vectorial force */
1158 /* Update vectorial force */
1162 f[j_coord_offset+DIM*3+XX] -= tx;
1163 f[j_coord_offset+DIM*3+YY] -= ty;
1164 f[j_coord_offset+DIM*3+ZZ] -= tz;
1168 /* Inner loop uses 261 flops */
1170 /* End of innermost loop */
1173 f[i_coord_offset+DIM*0+XX] += fix0;
1174 f[i_coord_offset+DIM*0+YY] += fiy0;
1175 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1179 f[i_coord_offset+DIM*1+XX] += fix1;
1180 f[i_coord_offset+DIM*1+YY] += fiy1;
1181 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1185 f[i_coord_offset+DIM*2+XX] += fix2;
1186 f[i_coord_offset+DIM*2+YY] += fiy2;
1187 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1191 f[i_coord_offset+DIM*3+XX] += fix3;
1192 f[i_coord_offset+DIM*3+YY] += fiy3;
1193 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1197 fshift[i_shift_offset+XX] += tx;
1198 fshift[i_shift_offset+YY] += ty;
1199 fshift[i_shift_offset+ZZ] += tz;
1201 /* Increment number of inner iterations */
1202 inneriter += j_index_end - j_index_start;
1204 /* Outer loop uses 39 flops */
1207 /* Increment number of outer iterations */
1210 /* Update outer/inner flops */
1212 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*261);