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_ElecEwSh_VdwNone_GeomW4W4_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: None
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_VdwNone_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
73 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
75 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
77 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
79 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
81 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
82 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
83 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
84 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
85 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
86 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
87 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
88 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
89 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
90 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
102 jindex = nlist->jindex;
104 shiftidx = nlist->shift;
106 shiftvec = fr->shift_vec[0];
107 fshift = fr->fshift[0];
109 charge = mdatoms->chargeA;
111 sh_ewald = fr->ic->sh_ewald;
112 ewtab = fr->ic->tabq_coul_FDV0;
113 ewtabscale = fr->ic->tabq_scale;
114 ewtabhalfspace = 0.5/ewtabscale;
116 /* Setup water-specific parameters */
117 inr = nlist->iinr[0];
118 iq1 = facel*charge[inr+1];
119 iq2 = facel*charge[inr+2];
120 iq3 = facel*charge[inr+3];
135 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
136 rcutoff = fr->rcoulomb;
137 rcutoff2 = rcutoff*rcutoff;
142 /* Start outer loop over neighborlists */
143 for(iidx=0; iidx<nri; iidx++)
145 /* Load shift vector for this list */
146 i_shift_offset = DIM*shiftidx[iidx];
147 shX = shiftvec[i_shift_offset+XX];
148 shY = shiftvec[i_shift_offset+YY];
149 shZ = shiftvec[i_shift_offset+ZZ];
151 /* Load limits for loop over neighbors */
152 j_index_start = jindex[iidx];
153 j_index_end = jindex[iidx+1];
155 /* Get outer coordinate index */
157 i_coord_offset = DIM*inr;
159 /* Load i particle coords and add shift vector */
160 ix1 = shX + x[i_coord_offset+DIM*1+XX];
161 iy1 = shY + x[i_coord_offset+DIM*1+YY];
162 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
163 ix2 = shX + x[i_coord_offset+DIM*2+XX];
164 iy2 = shY + x[i_coord_offset+DIM*2+YY];
165 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
166 ix3 = shX + x[i_coord_offset+DIM*3+XX];
167 iy3 = shY + x[i_coord_offset+DIM*3+YY];
168 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
180 /* Reset potential sums */
183 /* Start inner kernel loop */
184 for(jidx=j_index_start; jidx<j_index_end; jidx++)
186 /* Get j neighbor index, and coordinate index */
188 j_coord_offset = DIM*jnr;
190 /* load j atom coordinates */
191 jx1 = x[j_coord_offset+DIM*1+XX];
192 jy1 = x[j_coord_offset+DIM*1+YY];
193 jz1 = x[j_coord_offset+DIM*1+ZZ];
194 jx2 = x[j_coord_offset+DIM*2+XX];
195 jy2 = x[j_coord_offset+DIM*2+YY];
196 jz2 = x[j_coord_offset+DIM*2+ZZ];
197 jx3 = x[j_coord_offset+DIM*3+XX];
198 jy3 = x[j_coord_offset+DIM*3+YY];
199 jz3 = x[j_coord_offset+DIM*3+ZZ];
201 /* Calculate displacement vector */
230 /* Calculate squared distance and things based on it */
231 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
232 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
233 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
234 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
235 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
236 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
237 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
238 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
239 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
241 rinv11 = gmx_invsqrt(rsq11);
242 rinv12 = gmx_invsqrt(rsq12);
243 rinv13 = gmx_invsqrt(rsq13);
244 rinv21 = gmx_invsqrt(rsq21);
245 rinv22 = gmx_invsqrt(rsq22);
246 rinv23 = gmx_invsqrt(rsq23);
247 rinv31 = gmx_invsqrt(rsq31);
248 rinv32 = gmx_invsqrt(rsq32);
249 rinv33 = gmx_invsqrt(rsq33);
251 rinvsq11 = rinv11*rinv11;
252 rinvsq12 = rinv12*rinv12;
253 rinvsq13 = rinv13*rinv13;
254 rinvsq21 = rinv21*rinv21;
255 rinvsq22 = rinv22*rinv22;
256 rinvsq23 = rinv23*rinv23;
257 rinvsq31 = rinv31*rinv31;
258 rinvsq32 = rinv32*rinv32;
259 rinvsq33 = rinv33*rinv33;
261 /**************************
262 * CALCULATE INTERACTIONS *
263 **************************/
270 /* EWALD ELECTROSTATICS */
272 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
273 ewrt = r11*ewtabscale;
277 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
278 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
279 felec = qq11*rinv11*(rinvsq11-felec);
281 /* Update potential sums from outer loop */
286 /* Calculate temporary vectorial force */
291 /* Update vectorial force */
295 f[j_coord_offset+DIM*1+XX] -= tx;
296 f[j_coord_offset+DIM*1+YY] -= ty;
297 f[j_coord_offset+DIM*1+ZZ] -= tz;
301 /**************************
302 * CALCULATE INTERACTIONS *
303 **************************/
310 /* EWALD ELECTROSTATICS */
312 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
313 ewrt = r12*ewtabscale;
317 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
318 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
319 felec = qq12*rinv12*(rinvsq12-felec);
321 /* Update potential sums from outer loop */
326 /* Calculate temporary vectorial force */
331 /* Update vectorial force */
335 f[j_coord_offset+DIM*2+XX] -= tx;
336 f[j_coord_offset+DIM*2+YY] -= ty;
337 f[j_coord_offset+DIM*2+ZZ] -= tz;
341 /**************************
342 * CALCULATE INTERACTIONS *
343 **************************/
350 /* EWALD ELECTROSTATICS */
352 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
353 ewrt = r13*ewtabscale;
357 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
358 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
359 felec = qq13*rinv13*(rinvsq13-felec);
361 /* Update potential sums from outer loop */
366 /* Calculate temporary vectorial force */
371 /* Update vectorial force */
375 f[j_coord_offset+DIM*3+XX] -= tx;
376 f[j_coord_offset+DIM*3+YY] -= ty;
377 f[j_coord_offset+DIM*3+ZZ] -= tz;
381 /**************************
382 * CALCULATE INTERACTIONS *
383 **************************/
390 /* EWALD ELECTROSTATICS */
392 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
393 ewrt = r21*ewtabscale;
397 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
398 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
399 felec = qq21*rinv21*(rinvsq21-felec);
401 /* Update potential sums from outer loop */
406 /* Calculate temporary vectorial force */
411 /* Update vectorial force */
415 f[j_coord_offset+DIM*1+XX] -= tx;
416 f[j_coord_offset+DIM*1+YY] -= ty;
417 f[j_coord_offset+DIM*1+ZZ] -= tz;
421 /**************************
422 * CALCULATE INTERACTIONS *
423 **************************/
430 /* EWALD ELECTROSTATICS */
432 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
433 ewrt = r22*ewtabscale;
437 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
438 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
439 felec = qq22*rinv22*(rinvsq22-felec);
441 /* Update potential sums from outer loop */
446 /* Calculate temporary vectorial force */
451 /* Update vectorial force */
455 f[j_coord_offset+DIM*2+XX] -= tx;
456 f[j_coord_offset+DIM*2+YY] -= ty;
457 f[j_coord_offset+DIM*2+ZZ] -= tz;
461 /**************************
462 * CALCULATE INTERACTIONS *
463 **************************/
470 /* EWALD ELECTROSTATICS */
472 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
473 ewrt = r23*ewtabscale;
477 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
478 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
479 felec = qq23*rinv23*(rinvsq23-felec);
481 /* Update potential sums from outer loop */
486 /* Calculate temporary vectorial force */
491 /* Update vectorial force */
495 f[j_coord_offset+DIM*3+XX] -= tx;
496 f[j_coord_offset+DIM*3+YY] -= ty;
497 f[j_coord_offset+DIM*3+ZZ] -= tz;
501 /**************************
502 * CALCULATE INTERACTIONS *
503 **************************/
510 /* EWALD ELECTROSTATICS */
512 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
513 ewrt = r31*ewtabscale;
517 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
518 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
519 felec = qq31*rinv31*(rinvsq31-felec);
521 /* Update potential sums from outer loop */
526 /* Calculate temporary vectorial force */
531 /* Update vectorial force */
535 f[j_coord_offset+DIM*1+XX] -= tx;
536 f[j_coord_offset+DIM*1+YY] -= ty;
537 f[j_coord_offset+DIM*1+ZZ] -= tz;
541 /**************************
542 * CALCULATE INTERACTIONS *
543 **************************/
550 /* EWALD ELECTROSTATICS */
552 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
553 ewrt = r32*ewtabscale;
557 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
558 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
559 felec = qq32*rinv32*(rinvsq32-felec);
561 /* Update potential sums from outer loop */
566 /* Calculate temporary vectorial force */
571 /* Update vectorial force */
575 f[j_coord_offset+DIM*2+XX] -= tx;
576 f[j_coord_offset+DIM*2+YY] -= ty;
577 f[j_coord_offset+DIM*2+ZZ] -= tz;
581 /**************************
582 * CALCULATE INTERACTIONS *
583 **************************/
590 /* EWALD ELECTROSTATICS */
592 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
593 ewrt = r33*ewtabscale;
597 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
598 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
599 felec = qq33*rinv33*(rinvsq33-felec);
601 /* Update potential sums from outer loop */
606 /* Calculate temporary vectorial force */
611 /* Update vectorial force */
615 f[j_coord_offset+DIM*3+XX] -= tx;
616 f[j_coord_offset+DIM*3+YY] -= ty;
617 f[j_coord_offset+DIM*3+ZZ] -= tz;
621 /* Inner loop uses 369 flops */
623 /* End of innermost loop */
626 f[i_coord_offset+DIM*1+XX] += fix1;
627 f[i_coord_offset+DIM*1+YY] += fiy1;
628 f[i_coord_offset+DIM*1+ZZ] += fiz1;
632 f[i_coord_offset+DIM*2+XX] += fix2;
633 f[i_coord_offset+DIM*2+YY] += fiy2;
634 f[i_coord_offset+DIM*2+ZZ] += fiz2;
638 f[i_coord_offset+DIM*3+XX] += fix3;
639 f[i_coord_offset+DIM*3+YY] += fiy3;
640 f[i_coord_offset+DIM*3+ZZ] += fiz3;
644 fshift[i_shift_offset+XX] += tx;
645 fshift[i_shift_offset+YY] += ty;
646 fshift[i_shift_offset+ZZ] += tz;
649 /* Update potential energies */
650 kernel_data->energygrp_elec[ggid] += velecsum;
652 /* Increment number of inner iterations */
653 inneriter += j_index_end - j_index_start;
655 /* Outer loop uses 31 flops */
658 /* Increment number of outer iterations */
661 /* Update outer/inner flops */
663 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*31 + inneriter*369);
666 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW4W4_F_c
667 * Electrostatics interaction: Ewald
668 * VdW interaction: None
669 * Geometry: Water4-Water4
670 * Calculate force/pot: Force
673 nb_kernel_ElecEwSh_VdwNone_GeomW4W4_F_c
674 (t_nblist * gmx_restrict nlist,
675 rvec * gmx_restrict xx,
676 rvec * gmx_restrict ff,
677 t_forcerec * gmx_restrict fr,
678 t_mdatoms * gmx_restrict mdatoms,
679 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
680 t_nrnb * gmx_restrict nrnb)
682 int i_shift_offset,i_coord_offset,j_coord_offset;
683 int j_index_start,j_index_end;
684 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
685 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
686 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
687 real *shiftvec,*fshift,*x,*f;
689 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
691 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
693 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
701 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
702 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
703 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
704 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
705 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
706 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
707 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
708 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
709 real velec,felec,velecsum,facel,crf,krf,krf2;
712 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
720 jindex = nlist->jindex;
722 shiftidx = nlist->shift;
724 shiftvec = fr->shift_vec[0];
725 fshift = fr->fshift[0];
727 charge = mdatoms->chargeA;
729 sh_ewald = fr->ic->sh_ewald;
730 ewtab = fr->ic->tabq_coul_F;
731 ewtabscale = fr->ic->tabq_scale;
732 ewtabhalfspace = 0.5/ewtabscale;
734 /* Setup water-specific parameters */
735 inr = nlist->iinr[0];
736 iq1 = facel*charge[inr+1];
737 iq2 = facel*charge[inr+2];
738 iq3 = facel*charge[inr+3];
753 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
754 rcutoff = fr->rcoulomb;
755 rcutoff2 = rcutoff*rcutoff;
760 /* Start outer loop over neighborlists */
761 for(iidx=0; iidx<nri; iidx++)
763 /* Load shift vector for this list */
764 i_shift_offset = DIM*shiftidx[iidx];
765 shX = shiftvec[i_shift_offset+XX];
766 shY = shiftvec[i_shift_offset+YY];
767 shZ = shiftvec[i_shift_offset+ZZ];
769 /* Load limits for loop over neighbors */
770 j_index_start = jindex[iidx];
771 j_index_end = jindex[iidx+1];
773 /* Get outer coordinate index */
775 i_coord_offset = DIM*inr;
777 /* Load i particle coords and add shift vector */
778 ix1 = shX + x[i_coord_offset+DIM*1+XX];
779 iy1 = shY + x[i_coord_offset+DIM*1+YY];
780 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
781 ix2 = shX + x[i_coord_offset+DIM*2+XX];
782 iy2 = shY + x[i_coord_offset+DIM*2+YY];
783 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
784 ix3 = shX + x[i_coord_offset+DIM*3+XX];
785 iy3 = shY + x[i_coord_offset+DIM*3+YY];
786 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
798 /* Start inner kernel loop */
799 for(jidx=j_index_start; jidx<j_index_end; jidx++)
801 /* Get j neighbor index, and coordinate index */
803 j_coord_offset = DIM*jnr;
805 /* load j atom coordinates */
806 jx1 = x[j_coord_offset+DIM*1+XX];
807 jy1 = x[j_coord_offset+DIM*1+YY];
808 jz1 = x[j_coord_offset+DIM*1+ZZ];
809 jx2 = x[j_coord_offset+DIM*2+XX];
810 jy2 = x[j_coord_offset+DIM*2+YY];
811 jz2 = x[j_coord_offset+DIM*2+ZZ];
812 jx3 = x[j_coord_offset+DIM*3+XX];
813 jy3 = x[j_coord_offset+DIM*3+YY];
814 jz3 = x[j_coord_offset+DIM*3+ZZ];
816 /* Calculate displacement vector */
845 /* Calculate squared distance and things based on it */
846 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
847 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
848 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
849 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
850 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
851 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
852 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
853 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
854 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
856 rinv11 = gmx_invsqrt(rsq11);
857 rinv12 = gmx_invsqrt(rsq12);
858 rinv13 = gmx_invsqrt(rsq13);
859 rinv21 = gmx_invsqrt(rsq21);
860 rinv22 = gmx_invsqrt(rsq22);
861 rinv23 = gmx_invsqrt(rsq23);
862 rinv31 = gmx_invsqrt(rsq31);
863 rinv32 = gmx_invsqrt(rsq32);
864 rinv33 = gmx_invsqrt(rsq33);
866 rinvsq11 = rinv11*rinv11;
867 rinvsq12 = rinv12*rinv12;
868 rinvsq13 = rinv13*rinv13;
869 rinvsq21 = rinv21*rinv21;
870 rinvsq22 = rinv22*rinv22;
871 rinvsq23 = rinv23*rinv23;
872 rinvsq31 = rinv31*rinv31;
873 rinvsq32 = rinv32*rinv32;
874 rinvsq33 = rinv33*rinv33;
876 /**************************
877 * CALCULATE INTERACTIONS *
878 **************************/
885 /* EWALD ELECTROSTATICS */
887 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
888 ewrt = r11*ewtabscale;
891 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
892 felec = qq11*rinv11*(rinvsq11-felec);
896 /* Calculate temporary vectorial force */
901 /* Update vectorial force */
905 f[j_coord_offset+DIM*1+XX] -= tx;
906 f[j_coord_offset+DIM*1+YY] -= ty;
907 f[j_coord_offset+DIM*1+ZZ] -= tz;
911 /**************************
912 * CALCULATE INTERACTIONS *
913 **************************/
920 /* EWALD ELECTROSTATICS */
922 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
923 ewrt = r12*ewtabscale;
926 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
927 felec = qq12*rinv12*(rinvsq12-felec);
931 /* Calculate temporary vectorial force */
936 /* Update vectorial force */
940 f[j_coord_offset+DIM*2+XX] -= tx;
941 f[j_coord_offset+DIM*2+YY] -= ty;
942 f[j_coord_offset+DIM*2+ZZ] -= tz;
946 /**************************
947 * CALCULATE INTERACTIONS *
948 **************************/
955 /* EWALD ELECTROSTATICS */
957 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
958 ewrt = r13*ewtabscale;
961 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
962 felec = qq13*rinv13*(rinvsq13-felec);
966 /* Calculate temporary vectorial force */
971 /* Update vectorial force */
975 f[j_coord_offset+DIM*3+XX] -= tx;
976 f[j_coord_offset+DIM*3+YY] -= ty;
977 f[j_coord_offset+DIM*3+ZZ] -= tz;
981 /**************************
982 * CALCULATE INTERACTIONS *
983 **************************/
990 /* EWALD ELECTROSTATICS */
992 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
993 ewrt = r21*ewtabscale;
996 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
997 felec = qq21*rinv21*(rinvsq21-felec);
1001 /* Calculate temporary vectorial force */
1006 /* Update vectorial force */
1010 f[j_coord_offset+DIM*1+XX] -= tx;
1011 f[j_coord_offset+DIM*1+YY] -= ty;
1012 f[j_coord_offset+DIM*1+ZZ] -= tz;
1016 /**************************
1017 * CALCULATE INTERACTIONS *
1018 **************************/
1025 /* EWALD ELECTROSTATICS */
1027 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1028 ewrt = r22*ewtabscale;
1030 eweps = ewrt-ewitab;
1031 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1032 felec = qq22*rinv22*(rinvsq22-felec);
1036 /* Calculate temporary vectorial force */
1041 /* Update vectorial force */
1045 f[j_coord_offset+DIM*2+XX] -= tx;
1046 f[j_coord_offset+DIM*2+YY] -= ty;
1047 f[j_coord_offset+DIM*2+ZZ] -= tz;
1051 /**************************
1052 * CALCULATE INTERACTIONS *
1053 **************************/
1060 /* EWALD ELECTROSTATICS */
1062 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1063 ewrt = r23*ewtabscale;
1065 eweps = ewrt-ewitab;
1066 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1067 felec = qq23*rinv23*(rinvsq23-felec);
1071 /* Calculate temporary vectorial force */
1076 /* Update vectorial force */
1080 f[j_coord_offset+DIM*3+XX] -= tx;
1081 f[j_coord_offset+DIM*3+YY] -= ty;
1082 f[j_coord_offset+DIM*3+ZZ] -= tz;
1086 /**************************
1087 * CALCULATE INTERACTIONS *
1088 **************************/
1095 /* EWALD ELECTROSTATICS */
1097 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1098 ewrt = r31*ewtabscale;
1100 eweps = ewrt-ewitab;
1101 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1102 felec = qq31*rinv31*(rinvsq31-felec);
1106 /* Calculate temporary vectorial force */
1111 /* Update vectorial force */
1115 f[j_coord_offset+DIM*1+XX] -= tx;
1116 f[j_coord_offset+DIM*1+YY] -= ty;
1117 f[j_coord_offset+DIM*1+ZZ] -= tz;
1121 /**************************
1122 * CALCULATE INTERACTIONS *
1123 **************************/
1130 /* EWALD ELECTROSTATICS */
1132 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1133 ewrt = r32*ewtabscale;
1135 eweps = ewrt-ewitab;
1136 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1137 felec = qq32*rinv32*(rinvsq32-felec);
1141 /* Calculate temporary vectorial force */
1146 /* Update vectorial force */
1150 f[j_coord_offset+DIM*2+XX] -= tx;
1151 f[j_coord_offset+DIM*2+YY] -= ty;
1152 f[j_coord_offset+DIM*2+ZZ] -= tz;
1156 /**************************
1157 * CALCULATE INTERACTIONS *
1158 **************************/
1165 /* EWALD ELECTROSTATICS */
1167 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1168 ewrt = r33*ewtabscale;
1170 eweps = ewrt-ewitab;
1171 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1172 felec = qq33*rinv33*(rinvsq33-felec);
1176 /* Calculate temporary vectorial force */
1181 /* Update vectorial force */
1185 f[j_coord_offset+DIM*3+XX] -= tx;
1186 f[j_coord_offset+DIM*3+YY] -= ty;
1187 f[j_coord_offset+DIM*3+ZZ] -= tz;
1191 /* Inner loop uses 297 flops */
1193 /* End of innermost loop */
1196 f[i_coord_offset+DIM*1+XX] += fix1;
1197 f[i_coord_offset+DIM*1+YY] += fiy1;
1198 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1202 f[i_coord_offset+DIM*2+XX] += fix2;
1203 f[i_coord_offset+DIM*2+YY] += fiy2;
1204 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1208 f[i_coord_offset+DIM*3+XX] += fix3;
1209 f[i_coord_offset+DIM*3+YY] += fiy3;
1210 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1214 fshift[i_shift_offset+XX] += tx;
1215 fshift[i_shift_offset+YY] += ty;
1216 fshift[i_shift_offset+ZZ] += tz;
1218 /* Increment number of inner iterations */
1219 inneriter += j_index_end - j_index_start;
1221 /* Outer loop uses 30 flops */
1224 /* Increment number of outer iterations */
1227 /* Update outer/inner flops */
1229 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*30 + inneriter*297);