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_VdwBhamSh_GeomW4W4_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwBhamSh_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 = 3*nvdwtype*vdwtype[inr+0];
135 vdwjidx0 = 3*vdwtype[inr+0];
136 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
137 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
138 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
149 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
150 rcutoff = fr->rcoulomb;
151 rcutoff2 = rcutoff*rcutoff;
153 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
159 /* Start outer loop over neighborlists */
160 for(iidx=0; iidx<nri; iidx++)
162 /* Load shift vector for this list */
163 i_shift_offset = DIM*shiftidx[iidx];
164 shX = shiftvec[i_shift_offset+XX];
165 shY = shiftvec[i_shift_offset+YY];
166 shZ = shiftvec[i_shift_offset+ZZ];
168 /* Load limits for loop over neighbors */
169 j_index_start = jindex[iidx];
170 j_index_end = jindex[iidx+1];
172 /* Get outer coordinate index */
174 i_coord_offset = DIM*inr;
176 /* Load i particle coords and add shift vector */
177 ix0 = shX + x[i_coord_offset+DIM*0+XX];
178 iy0 = shY + x[i_coord_offset+DIM*0+YY];
179 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
180 ix1 = shX + x[i_coord_offset+DIM*1+XX];
181 iy1 = shY + x[i_coord_offset+DIM*1+YY];
182 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
183 ix2 = shX + x[i_coord_offset+DIM*2+XX];
184 iy2 = shY + x[i_coord_offset+DIM*2+YY];
185 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
186 ix3 = shX + x[i_coord_offset+DIM*3+XX];
187 iy3 = shY + x[i_coord_offset+DIM*3+YY];
188 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
203 /* Reset potential sums */
207 /* Start inner kernel loop */
208 for(jidx=j_index_start; jidx<j_index_end; jidx++)
210 /* Get j neighbor index, and coordinate index */
212 j_coord_offset = DIM*jnr;
214 /* load j atom coordinates */
215 jx0 = x[j_coord_offset+DIM*0+XX];
216 jy0 = x[j_coord_offset+DIM*0+YY];
217 jz0 = x[j_coord_offset+DIM*0+ZZ];
218 jx1 = x[j_coord_offset+DIM*1+XX];
219 jy1 = x[j_coord_offset+DIM*1+YY];
220 jz1 = x[j_coord_offset+DIM*1+ZZ];
221 jx2 = x[j_coord_offset+DIM*2+XX];
222 jy2 = x[j_coord_offset+DIM*2+YY];
223 jz2 = x[j_coord_offset+DIM*2+ZZ];
224 jx3 = x[j_coord_offset+DIM*3+XX];
225 jy3 = x[j_coord_offset+DIM*3+YY];
226 jz3 = x[j_coord_offset+DIM*3+ZZ];
228 /* Calculate displacement vector */
260 /* Calculate squared distance and things based on it */
261 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
262 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
263 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
264 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
265 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
266 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
267 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
268 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
269 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
270 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
272 rinv00 = gmx_invsqrt(rsq00);
273 rinv11 = gmx_invsqrt(rsq11);
274 rinv12 = gmx_invsqrt(rsq12);
275 rinv13 = gmx_invsqrt(rsq13);
276 rinv21 = gmx_invsqrt(rsq21);
277 rinv22 = gmx_invsqrt(rsq22);
278 rinv23 = gmx_invsqrt(rsq23);
279 rinv31 = gmx_invsqrt(rsq31);
280 rinv32 = gmx_invsqrt(rsq32);
281 rinv33 = gmx_invsqrt(rsq33);
283 rinvsq00 = rinv00*rinv00;
284 rinvsq11 = rinv11*rinv11;
285 rinvsq12 = rinv12*rinv12;
286 rinvsq13 = rinv13*rinv13;
287 rinvsq21 = rinv21*rinv21;
288 rinvsq22 = rinv22*rinv22;
289 rinvsq23 = rinv23*rinv23;
290 rinvsq31 = rinv31*rinv31;
291 rinvsq32 = rinv32*rinv32;
292 rinvsq33 = rinv33*rinv33;
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
303 /* BUCKINGHAM DISPERSION/REPULSION */
304 rinvsix = rinvsq00*rinvsq00*rinvsq00;
305 vvdw6 = c6_00*rinvsix;
307 vvdwexp = cexp1_00*exp(-br);
308 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
309 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
311 /* Update potential sums from outer loop */
316 /* Calculate temporary vectorial force */
321 /* Update vectorial force */
325 f[j_coord_offset+DIM*0+XX] -= tx;
326 f[j_coord_offset+DIM*0+YY] -= ty;
327 f[j_coord_offset+DIM*0+ZZ] -= tz;
331 /**************************
332 * CALCULATE INTERACTIONS *
333 **************************/
338 /* REACTION-FIELD ELECTROSTATICS */
339 velec = qq11*(rinv11+krf*rsq11-crf);
340 felec = qq11*(rinv11*rinvsq11-krf2);
342 /* Update potential sums from outer loop */
347 /* Calculate temporary vectorial force */
352 /* Update vectorial force */
356 f[j_coord_offset+DIM*1+XX] -= tx;
357 f[j_coord_offset+DIM*1+YY] -= ty;
358 f[j_coord_offset+DIM*1+ZZ] -= tz;
362 /**************************
363 * CALCULATE INTERACTIONS *
364 **************************/
369 /* REACTION-FIELD ELECTROSTATICS */
370 velec = qq12*(rinv12+krf*rsq12-crf);
371 felec = qq12*(rinv12*rinvsq12-krf2);
373 /* Update potential sums from outer loop */
378 /* Calculate temporary vectorial force */
383 /* Update vectorial force */
387 f[j_coord_offset+DIM*2+XX] -= tx;
388 f[j_coord_offset+DIM*2+YY] -= ty;
389 f[j_coord_offset+DIM*2+ZZ] -= tz;
393 /**************************
394 * CALCULATE INTERACTIONS *
395 **************************/
400 /* REACTION-FIELD ELECTROSTATICS */
401 velec = qq13*(rinv13+krf*rsq13-crf);
402 felec = qq13*(rinv13*rinvsq13-krf2);
404 /* Update potential sums from outer loop */
409 /* Calculate temporary vectorial force */
414 /* Update vectorial force */
418 f[j_coord_offset+DIM*3+XX] -= tx;
419 f[j_coord_offset+DIM*3+YY] -= ty;
420 f[j_coord_offset+DIM*3+ZZ] -= tz;
424 /**************************
425 * CALCULATE INTERACTIONS *
426 **************************/
431 /* REACTION-FIELD ELECTROSTATICS */
432 velec = qq21*(rinv21+krf*rsq21-crf);
433 felec = qq21*(rinv21*rinvsq21-krf2);
435 /* Update potential sums from outer loop */
440 /* Calculate temporary vectorial force */
445 /* Update vectorial force */
449 f[j_coord_offset+DIM*1+XX] -= tx;
450 f[j_coord_offset+DIM*1+YY] -= ty;
451 f[j_coord_offset+DIM*1+ZZ] -= tz;
455 /**************************
456 * CALCULATE INTERACTIONS *
457 **************************/
462 /* REACTION-FIELD ELECTROSTATICS */
463 velec = qq22*(rinv22+krf*rsq22-crf);
464 felec = qq22*(rinv22*rinvsq22-krf2);
466 /* Update potential sums from outer loop */
471 /* Calculate temporary vectorial force */
476 /* Update vectorial force */
480 f[j_coord_offset+DIM*2+XX] -= tx;
481 f[j_coord_offset+DIM*2+YY] -= ty;
482 f[j_coord_offset+DIM*2+ZZ] -= tz;
486 /**************************
487 * CALCULATE INTERACTIONS *
488 **************************/
493 /* REACTION-FIELD ELECTROSTATICS */
494 velec = qq23*(rinv23+krf*rsq23-crf);
495 felec = qq23*(rinv23*rinvsq23-krf2);
497 /* Update potential sums from outer loop */
502 /* Calculate temporary vectorial force */
507 /* Update vectorial force */
511 f[j_coord_offset+DIM*3+XX] -= tx;
512 f[j_coord_offset+DIM*3+YY] -= ty;
513 f[j_coord_offset+DIM*3+ZZ] -= tz;
517 /**************************
518 * CALCULATE INTERACTIONS *
519 **************************/
524 /* REACTION-FIELD ELECTROSTATICS */
525 velec = qq31*(rinv31+krf*rsq31-crf);
526 felec = qq31*(rinv31*rinvsq31-krf2);
528 /* Update potential sums from outer loop */
533 /* Calculate temporary vectorial force */
538 /* Update vectorial force */
542 f[j_coord_offset+DIM*1+XX] -= tx;
543 f[j_coord_offset+DIM*1+YY] -= ty;
544 f[j_coord_offset+DIM*1+ZZ] -= tz;
548 /**************************
549 * CALCULATE INTERACTIONS *
550 **************************/
555 /* REACTION-FIELD ELECTROSTATICS */
556 velec = qq32*(rinv32+krf*rsq32-crf);
557 felec = qq32*(rinv32*rinvsq32-krf2);
559 /* Update potential sums from outer loop */
564 /* Calculate temporary vectorial force */
569 /* Update vectorial force */
573 f[j_coord_offset+DIM*2+XX] -= tx;
574 f[j_coord_offset+DIM*2+YY] -= ty;
575 f[j_coord_offset+DIM*2+ZZ] -= tz;
579 /**************************
580 * CALCULATE INTERACTIONS *
581 **************************/
586 /* REACTION-FIELD ELECTROSTATICS */
587 velec = qq33*(rinv33+krf*rsq33-crf);
588 felec = qq33*(rinv33*rinvsq33-krf2);
590 /* Update potential sums from outer loop */
595 /* Calculate temporary vectorial force */
600 /* Update vectorial force */
604 f[j_coord_offset+DIM*3+XX] -= tx;
605 f[j_coord_offset+DIM*3+YY] -= ty;
606 f[j_coord_offset+DIM*3+ZZ] -= tz;
610 /* Inner loop uses 371 flops */
612 /* End of innermost loop */
615 f[i_coord_offset+DIM*0+XX] += fix0;
616 f[i_coord_offset+DIM*0+YY] += fiy0;
617 f[i_coord_offset+DIM*0+ZZ] += fiz0;
621 f[i_coord_offset+DIM*1+XX] += fix1;
622 f[i_coord_offset+DIM*1+YY] += fiy1;
623 f[i_coord_offset+DIM*1+ZZ] += fiz1;
627 f[i_coord_offset+DIM*2+XX] += fix2;
628 f[i_coord_offset+DIM*2+YY] += fiy2;
629 f[i_coord_offset+DIM*2+ZZ] += fiz2;
633 f[i_coord_offset+DIM*3+XX] += fix3;
634 f[i_coord_offset+DIM*3+YY] += fiy3;
635 f[i_coord_offset+DIM*3+ZZ] += fiz3;
639 fshift[i_shift_offset+XX] += tx;
640 fshift[i_shift_offset+YY] += ty;
641 fshift[i_shift_offset+ZZ] += tz;
644 /* Update potential energies */
645 kernel_data->energygrp_elec[ggid] += velecsum;
646 kernel_data->energygrp_vdw[ggid] += vvdwsum;
648 /* Increment number of inner iterations */
649 inneriter += j_index_end - j_index_start;
651 /* Outer loop uses 41 flops */
654 /* Increment number of outer iterations */
657 /* Update outer/inner flops */
659 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*371);
662 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW4W4_F_c
663 * Electrostatics interaction: ReactionField
664 * VdW interaction: Buckingham
665 * Geometry: Water4-Water4
666 * Calculate force/pot: Force
669 nb_kernel_ElecRFCut_VdwBhamSh_GeomW4W4_F_c
670 (t_nblist * gmx_restrict nlist,
671 rvec * gmx_restrict xx,
672 rvec * gmx_restrict ff,
673 t_forcerec * gmx_restrict fr,
674 t_mdatoms * gmx_restrict mdatoms,
675 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
676 t_nrnb * gmx_restrict nrnb)
678 int i_shift_offset,i_coord_offset,j_coord_offset;
679 int j_index_start,j_index_end;
680 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
681 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
682 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
683 real *shiftvec,*fshift,*x,*f;
685 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
687 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
689 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
691 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
693 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
695 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
697 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
699 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
700 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
701 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
702 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
703 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
704 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
705 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
706 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
707 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
708 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
709 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
710 real velec,felec,velecsum,facel,crf,krf,krf2;
713 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
722 jindex = nlist->jindex;
724 shiftidx = nlist->shift;
726 shiftvec = fr->shift_vec[0];
727 fshift = fr->fshift[0];
729 charge = mdatoms->chargeA;
733 nvdwtype = fr->ntype;
735 vdwtype = mdatoms->typeA;
737 /* Setup water-specific parameters */
738 inr = nlist->iinr[0];
739 iq1 = facel*charge[inr+1];
740 iq2 = facel*charge[inr+2];
741 iq3 = facel*charge[inr+3];
742 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
747 vdwjidx0 = 3*vdwtype[inr+0];
748 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
749 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
750 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
761 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
762 rcutoff = fr->rcoulomb;
763 rcutoff2 = rcutoff*rcutoff;
765 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
771 /* Start outer loop over neighborlists */
772 for(iidx=0; iidx<nri; iidx++)
774 /* Load shift vector for this list */
775 i_shift_offset = DIM*shiftidx[iidx];
776 shX = shiftvec[i_shift_offset+XX];
777 shY = shiftvec[i_shift_offset+YY];
778 shZ = shiftvec[i_shift_offset+ZZ];
780 /* Load limits for loop over neighbors */
781 j_index_start = jindex[iidx];
782 j_index_end = jindex[iidx+1];
784 /* Get outer coordinate index */
786 i_coord_offset = DIM*inr;
788 /* Load i particle coords and add shift vector */
789 ix0 = shX + x[i_coord_offset+DIM*0+XX];
790 iy0 = shY + x[i_coord_offset+DIM*0+YY];
791 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
792 ix1 = shX + x[i_coord_offset+DIM*1+XX];
793 iy1 = shY + x[i_coord_offset+DIM*1+YY];
794 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
795 ix2 = shX + x[i_coord_offset+DIM*2+XX];
796 iy2 = shY + x[i_coord_offset+DIM*2+YY];
797 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
798 ix3 = shX + x[i_coord_offset+DIM*3+XX];
799 iy3 = shY + x[i_coord_offset+DIM*3+YY];
800 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
815 /* Start inner kernel loop */
816 for(jidx=j_index_start; jidx<j_index_end; jidx++)
818 /* Get j neighbor index, and coordinate index */
820 j_coord_offset = DIM*jnr;
822 /* load j atom coordinates */
823 jx0 = x[j_coord_offset+DIM*0+XX];
824 jy0 = x[j_coord_offset+DIM*0+YY];
825 jz0 = x[j_coord_offset+DIM*0+ZZ];
826 jx1 = x[j_coord_offset+DIM*1+XX];
827 jy1 = x[j_coord_offset+DIM*1+YY];
828 jz1 = x[j_coord_offset+DIM*1+ZZ];
829 jx2 = x[j_coord_offset+DIM*2+XX];
830 jy2 = x[j_coord_offset+DIM*2+YY];
831 jz2 = x[j_coord_offset+DIM*2+ZZ];
832 jx3 = x[j_coord_offset+DIM*3+XX];
833 jy3 = x[j_coord_offset+DIM*3+YY];
834 jz3 = x[j_coord_offset+DIM*3+ZZ];
836 /* Calculate displacement vector */
868 /* Calculate squared distance and things based on it */
869 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
870 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
871 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
872 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
873 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
874 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
875 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
876 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
877 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
878 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
880 rinv00 = gmx_invsqrt(rsq00);
881 rinv11 = gmx_invsqrt(rsq11);
882 rinv12 = gmx_invsqrt(rsq12);
883 rinv13 = gmx_invsqrt(rsq13);
884 rinv21 = gmx_invsqrt(rsq21);
885 rinv22 = gmx_invsqrt(rsq22);
886 rinv23 = gmx_invsqrt(rsq23);
887 rinv31 = gmx_invsqrt(rsq31);
888 rinv32 = gmx_invsqrt(rsq32);
889 rinv33 = gmx_invsqrt(rsq33);
891 rinvsq00 = rinv00*rinv00;
892 rinvsq11 = rinv11*rinv11;
893 rinvsq12 = rinv12*rinv12;
894 rinvsq13 = rinv13*rinv13;
895 rinvsq21 = rinv21*rinv21;
896 rinvsq22 = rinv22*rinv22;
897 rinvsq23 = rinv23*rinv23;
898 rinvsq31 = rinv31*rinv31;
899 rinvsq32 = rinv32*rinv32;
900 rinvsq33 = rinv33*rinv33;
902 /**************************
903 * CALCULATE INTERACTIONS *
904 **************************/
911 /* BUCKINGHAM DISPERSION/REPULSION */
912 rinvsix = rinvsq00*rinvsq00*rinvsq00;
913 vvdw6 = c6_00*rinvsix;
915 vvdwexp = cexp1_00*exp(-br);
916 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
920 /* Calculate temporary vectorial force */
925 /* Update vectorial force */
929 f[j_coord_offset+DIM*0+XX] -= tx;
930 f[j_coord_offset+DIM*0+YY] -= ty;
931 f[j_coord_offset+DIM*0+ZZ] -= tz;
935 /**************************
936 * CALCULATE INTERACTIONS *
937 **************************/
942 /* REACTION-FIELD ELECTROSTATICS */
943 felec = qq11*(rinv11*rinvsq11-krf2);
947 /* Calculate temporary vectorial force */
952 /* Update vectorial force */
956 f[j_coord_offset+DIM*1+XX] -= tx;
957 f[j_coord_offset+DIM*1+YY] -= ty;
958 f[j_coord_offset+DIM*1+ZZ] -= tz;
962 /**************************
963 * CALCULATE INTERACTIONS *
964 **************************/
969 /* REACTION-FIELD ELECTROSTATICS */
970 felec = qq12*(rinv12*rinvsq12-krf2);
974 /* Calculate temporary vectorial force */
979 /* Update vectorial force */
983 f[j_coord_offset+DIM*2+XX] -= tx;
984 f[j_coord_offset+DIM*2+YY] -= ty;
985 f[j_coord_offset+DIM*2+ZZ] -= tz;
989 /**************************
990 * CALCULATE INTERACTIONS *
991 **************************/
996 /* REACTION-FIELD ELECTROSTATICS */
997 felec = qq13*(rinv13*rinvsq13-krf2);
1001 /* Calculate temporary vectorial force */
1006 /* Update vectorial force */
1010 f[j_coord_offset+DIM*3+XX] -= tx;
1011 f[j_coord_offset+DIM*3+YY] -= ty;
1012 f[j_coord_offset+DIM*3+ZZ] -= tz;
1016 /**************************
1017 * CALCULATE INTERACTIONS *
1018 **************************/
1023 /* REACTION-FIELD ELECTROSTATICS */
1024 felec = qq21*(rinv21*rinvsq21-krf2);
1028 /* Calculate temporary vectorial force */
1033 /* Update vectorial force */
1037 f[j_coord_offset+DIM*1+XX] -= tx;
1038 f[j_coord_offset+DIM*1+YY] -= ty;
1039 f[j_coord_offset+DIM*1+ZZ] -= tz;
1043 /**************************
1044 * CALCULATE INTERACTIONS *
1045 **************************/
1050 /* REACTION-FIELD ELECTROSTATICS */
1051 felec = qq22*(rinv22*rinvsq22-krf2);
1055 /* Calculate temporary vectorial force */
1060 /* Update vectorial force */
1064 f[j_coord_offset+DIM*2+XX] -= tx;
1065 f[j_coord_offset+DIM*2+YY] -= ty;
1066 f[j_coord_offset+DIM*2+ZZ] -= tz;
1070 /**************************
1071 * CALCULATE INTERACTIONS *
1072 **************************/
1077 /* REACTION-FIELD ELECTROSTATICS */
1078 felec = qq23*(rinv23*rinvsq23-krf2);
1082 /* Calculate temporary vectorial force */
1087 /* Update vectorial force */
1091 f[j_coord_offset+DIM*3+XX] -= tx;
1092 f[j_coord_offset+DIM*3+YY] -= ty;
1093 f[j_coord_offset+DIM*3+ZZ] -= tz;
1097 /**************************
1098 * CALCULATE INTERACTIONS *
1099 **************************/
1104 /* REACTION-FIELD ELECTROSTATICS */
1105 felec = qq31*(rinv31*rinvsq31-krf2);
1109 /* Calculate temporary vectorial force */
1114 /* Update vectorial force */
1118 f[j_coord_offset+DIM*1+XX] -= tx;
1119 f[j_coord_offset+DIM*1+YY] -= ty;
1120 f[j_coord_offset+DIM*1+ZZ] -= tz;
1124 /**************************
1125 * CALCULATE INTERACTIONS *
1126 **************************/
1131 /* REACTION-FIELD ELECTROSTATICS */
1132 felec = qq32*(rinv32*rinvsq32-krf2);
1136 /* Calculate temporary vectorial force */
1141 /* Update vectorial force */
1145 f[j_coord_offset+DIM*2+XX] -= tx;
1146 f[j_coord_offset+DIM*2+YY] -= ty;
1147 f[j_coord_offset+DIM*2+ZZ] -= tz;
1151 /**************************
1152 * CALCULATE INTERACTIONS *
1153 **************************/
1158 /* REACTION-FIELD ELECTROSTATICS */
1159 felec = qq33*(rinv33*rinvsq33-krf2);
1163 /* Calculate temporary vectorial force */
1168 /* Update vectorial force */
1172 f[j_coord_offset+DIM*3+XX] -= tx;
1173 f[j_coord_offset+DIM*3+YY] -= ty;
1174 f[j_coord_offset+DIM*3+ZZ] -= tz;
1178 /* Inner loop uses 292 flops */
1180 /* End of innermost loop */
1183 f[i_coord_offset+DIM*0+XX] += fix0;
1184 f[i_coord_offset+DIM*0+YY] += fiy0;
1185 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1189 f[i_coord_offset+DIM*1+XX] += fix1;
1190 f[i_coord_offset+DIM*1+YY] += fiy1;
1191 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1195 f[i_coord_offset+DIM*2+XX] += fix2;
1196 f[i_coord_offset+DIM*2+YY] += fiy2;
1197 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1201 f[i_coord_offset+DIM*3+XX] += fix3;
1202 f[i_coord_offset+DIM*3+YY] += fiy3;
1203 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1207 fshift[i_shift_offset+XX] += tx;
1208 fshift[i_shift_offset+YY] += ty;
1209 fshift[i_shift_offset+ZZ] += tz;
1211 /* Increment number of inner iterations */
1212 inneriter += j_index_end - j_index_start;
1214 /* Outer loop uses 39 flops */
1217 /* Increment number of outer iterations */
1220 /* Update outer/inner flops */
1222 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*292);