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_ElecEwSh_VdwNone_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwNone_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 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 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
83 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
84 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
85 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
86 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
87 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
88 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
89 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
90 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
91 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
92 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
111 charge = mdatoms->chargeA;
113 sh_ewald = fr->ic->sh_ewald;
114 ewtab = fr->ic->tabq_coul_FDV0;
115 ewtabscale = fr->ic->tabq_scale;
116 ewtabhalfspace = 0.5/ewtabscale;
118 /* Setup water-specific parameters */
119 inr = nlist->iinr[0];
120 iq1 = facel*charge[inr+1];
121 iq2 = facel*charge[inr+2];
122 iq3 = facel*charge[inr+3];
137 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
138 rcutoff = fr->rcoulomb;
139 rcutoff2 = rcutoff*rcutoff;
144 /* Start outer loop over neighborlists */
145 for(iidx=0; iidx<nri; iidx++)
147 /* Load shift vector for this list */
148 i_shift_offset = DIM*shiftidx[iidx];
149 shX = shiftvec[i_shift_offset+XX];
150 shY = shiftvec[i_shift_offset+YY];
151 shZ = shiftvec[i_shift_offset+ZZ];
153 /* Load limits for loop over neighbors */
154 j_index_start = jindex[iidx];
155 j_index_end = jindex[iidx+1];
157 /* Get outer coordinate index */
159 i_coord_offset = DIM*inr;
161 /* Load i particle coords and add shift vector */
162 ix1 = shX + x[i_coord_offset+DIM*1+XX];
163 iy1 = shY + x[i_coord_offset+DIM*1+YY];
164 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
165 ix2 = shX + x[i_coord_offset+DIM*2+XX];
166 iy2 = shY + x[i_coord_offset+DIM*2+YY];
167 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
168 ix3 = shX + x[i_coord_offset+DIM*3+XX];
169 iy3 = shY + x[i_coord_offset+DIM*3+YY];
170 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
182 /* Reset potential sums */
185 /* Start inner kernel loop */
186 for(jidx=j_index_start; jidx<j_index_end; jidx++)
188 /* Get j neighbor index, and coordinate index */
190 j_coord_offset = DIM*jnr;
192 /* load j atom coordinates */
193 jx1 = x[j_coord_offset+DIM*1+XX];
194 jy1 = x[j_coord_offset+DIM*1+YY];
195 jz1 = x[j_coord_offset+DIM*1+ZZ];
196 jx2 = x[j_coord_offset+DIM*2+XX];
197 jy2 = x[j_coord_offset+DIM*2+YY];
198 jz2 = x[j_coord_offset+DIM*2+ZZ];
199 jx3 = x[j_coord_offset+DIM*3+XX];
200 jy3 = x[j_coord_offset+DIM*3+YY];
201 jz3 = x[j_coord_offset+DIM*3+ZZ];
203 /* Calculate displacement vector */
232 /* Calculate squared distance and things based on it */
233 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
234 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
235 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
236 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
237 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
238 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
239 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
240 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
241 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
243 rinv11 = gmx_invsqrt(rsq11);
244 rinv12 = gmx_invsqrt(rsq12);
245 rinv13 = gmx_invsqrt(rsq13);
246 rinv21 = gmx_invsqrt(rsq21);
247 rinv22 = gmx_invsqrt(rsq22);
248 rinv23 = gmx_invsqrt(rsq23);
249 rinv31 = gmx_invsqrt(rsq31);
250 rinv32 = gmx_invsqrt(rsq32);
251 rinv33 = gmx_invsqrt(rsq33);
253 rinvsq11 = rinv11*rinv11;
254 rinvsq12 = rinv12*rinv12;
255 rinvsq13 = rinv13*rinv13;
256 rinvsq21 = rinv21*rinv21;
257 rinvsq22 = rinv22*rinv22;
258 rinvsq23 = rinv23*rinv23;
259 rinvsq31 = rinv31*rinv31;
260 rinvsq32 = rinv32*rinv32;
261 rinvsq33 = rinv33*rinv33;
263 /**************************
264 * CALCULATE INTERACTIONS *
265 **************************/
272 /* EWALD ELECTROSTATICS */
274 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
275 ewrt = r11*ewtabscale;
279 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
280 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
281 felec = qq11*rinv11*(rinvsq11-felec);
283 /* Update potential sums from outer loop */
288 /* Calculate temporary vectorial force */
293 /* Update vectorial force */
297 f[j_coord_offset+DIM*1+XX] -= tx;
298 f[j_coord_offset+DIM*1+YY] -= ty;
299 f[j_coord_offset+DIM*1+ZZ] -= tz;
303 /**************************
304 * CALCULATE INTERACTIONS *
305 **************************/
312 /* EWALD ELECTROSTATICS */
314 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
315 ewrt = r12*ewtabscale;
319 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
320 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
321 felec = qq12*rinv12*(rinvsq12-felec);
323 /* Update potential sums from outer loop */
328 /* Calculate temporary vectorial force */
333 /* Update vectorial force */
337 f[j_coord_offset+DIM*2+XX] -= tx;
338 f[j_coord_offset+DIM*2+YY] -= ty;
339 f[j_coord_offset+DIM*2+ZZ] -= tz;
343 /**************************
344 * CALCULATE INTERACTIONS *
345 **************************/
352 /* EWALD ELECTROSTATICS */
354 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
355 ewrt = r13*ewtabscale;
359 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
360 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
361 felec = qq13*rinv13*(rinvsq13-felec);
363 /* Update potential sums from outer loop */
368 /* Calculate temporary vectorial force */
373 /* Update vectorial force */
377 f[j_coord_offset+DIM*3+XX] -= tx;
378 f[j_coord_offset+DIM*3+YY] -= ty;
379 f[j_coord_offset+DIM*3+ZZ] -= tz;
383 /**************************
384 * CALCULATE INTERACTIONS *
385 **************************/
392 /* EWALD ELECTROSTATICS */
394 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
395 ewrt = r21*ewtabscale;
399 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
400 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
401 felec = qq21*rinv21*(rinvsq21-felec);
403 /* Update potential sums from outer loop */
408 /* Calculate temporary vectorial force */
413 /* Update vectorial force */
417 f[j_coord_offset+DIM*1+XX] -= tx;
418 f[j_coord_offset+DIM*1+YY] -= ty;
419 f[j_coord_offset+DIM*1+ZZ] -= tz;
423 /**************************
424 * CALCULATE INTERACTIONS *
425 **************************/
432 /* EWALD ELECTROSTATICS */
434 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
435 ewrt = r22*ewtabscale;
439 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
440 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
441 felec = qq22*rinv22*(rinvsq22-felec);
443 /* Update potential sums from outer loop */
448 /* Calculate temporary vectorial force */
453 /* Update vectorial force */
457 f[j_coord_offset+DIM*2+XX] -= tx;
458 f[j_coord_offset+DIM*2+YY] -= ty;
459 f[j_coord_offset+DIM*2+ZZ] -= tz;
463 /**************************
464 * CALCULATE INTERACTIONS *
465 **************************/
472 /* EWALD ELECTROSTATICS */
474 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
475 ewrt = r23*ewtabscale;
479 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
480 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
481 felec = qq23*rinv23*(rinvsq23-felec);
483 /* Update potential sums from outer loop */
488 /* Calculate temporary vectorial force */
493 /* Update vectorial force */
497 f[j_coord_offset+DIM*3+XX] -= tx;
498 f[j_coord_offset+DIM*3+YY] -= ty;
499 f[j_coord_offset+DIM*3+ZZ] -= tz;
503 /**************************
504 * CALCULATE INTERACTIONS *
505 **************************/
512 /* EWALD ELECTROSTATICS */
514 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
515 ewrt = r31*ewtabscale;
519 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
520 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
521 felec = qq31*rinv31*(rinvsq31-felec);
523 /* Update potential sums from outer loop */
528 /* Calculate temporary vectorial force */
533 /* Update vectorial force */
537 f[j_coord_offset+DIM*1+XX] -= tx;
538 f[j_coord_offset+DIM*1+YY] -= ty;
539 f[j_coord_offset+DIM*1+ZZ] -= tz;
543 /**************************
544 * CALCULATE INTERACTIONS *
545 **************************/
552 /* EWALD ELECTROSTATICS */
554 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
555 ewrt = r32*ewtabscale;
559 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
560 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
561 felec = qq32*rinv32*(rinvsq32-felec);
563 /* Update potential sums from outer loop */
568 /* Calculate temporary vectorial force */
573 /* Update vectorial force */
577 f[j_coord_offset+DIM*2+XX] -= tx;
578 f[j_coord_offset+DIM*2+YY] -= ty;
579 f[j_coord_offset+DIM*2+ZZ] -= tz;
583 /**************************
584 * CALCULATE INTERACTIONS *
585 **************************/
592 /* EWALD ELECTROSTATICS */
594 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
595 ewrt = r33*ewtabscale;
599 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
600 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
601 felec = qq33*rinv33*(rinvsq33-felec);
603 /* Update potential sums from outer loop */
608 /* Calculate temporary vectorial force */
613 /* Update vectorial force */
617 f[j_coord_offset+DIM*3+XX] -= tx;
618 f[j_coord_offset+DIM*3+YY] -= ty;
619 f[j_coord_offset+DIM*3+ZZ] -= tz;
623 /* Inner loop uses 369 flops */
625 /* End of innermost loop */
628 f[i_coord_offset+DIM*1+XX] += fix1;
629 f[i_coord_offset+DIM*1+YY] += fiy1;
630 f[i_coord_offset+DIM*1+ZZ] += fiz1;
634 f[i_coord_offset+DIM*2+XX] += fix2;
635 f[i_coord_offset+DIM*2+YY] += fiy2;
636 f[i_coord_offset+DIM*2+ZZ] += fiz2;
640 f[i_coord_offset+DIM*3+XX] += fix3;
641 f[i_coord_offset+DIM*3+YY] += fiy3;
642 f[i_coord_offset+DIM*3+ZZ] += fiz3;
646 fshift[i_shift_offset+XX] += tx;
647 fshift[i_shift_offset+YY] += ty;
648 fshift[i_shift_offset+ZZ] += tz;
651 /* Update potential energies */
652 kernel_data->energygrp_elec[ggid] += velecsum;
654 /* Increment number of inner iterations */
655 inneriter += j_index_end - j_index_start;
657 /* Outer loop uses 31 flops */
660 /* Increment number of outer iterations */
663 /* Update outer/inner flops */
665 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*31 + inneriter*369);
668 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW4W4_F_c
669 * Electrostatics interaction: Ewald
670 * VdW interaction: None
671 * Geometry: Water4-Water4
672 * Calculate force/pot: Force
675 nb_kernel_ElecEwSh_VdwNone_GeomW4W4_F_c
676 (t_nblist * gmx_restrict nlist,
677 rvec * gmx_restrict xx,
678 rvec * gmx_restrict ff,
679 t_forcerec * gmx_restrict fr,
680 t_mdatoms * gmx_restrict mdatoms,
681 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
682 t_nrnb * gmx_restrict nrnb)
684 int i_shift_offset,i_coord_offset,j_coord_offset;
685 int j_index_start,j_index_end;
686 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
687 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
688 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
689 real *shiftvec,*fshift,*x,*f;
691 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
693 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
695 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
697 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
699 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
701 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
702 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
703 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
704 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
705 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
706 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
707 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
708 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
709 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
710 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
711 real velec,felec,velecsum,facel,crf,krf,krf2;
714 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
722 jindex = nlist->jindex;
724 shiftidx = nlist->shift;
726 shiftvec = fr->shift_vec[0];
727 fshift = fr->fshift[0];
729 charge = mdatoms->chargeA;
731 sh_ewald = fr->ic->sh_ewald;
732 ewtab = fr->ic->tabq_coul_F;
733 ewtabscale = fr->ic->tabq_scale;
734 ewtabhalfspace = 0.5/ewtabscale;
736 /* Setup water-specific parameters */
737 inr = nlist->iinr[0];
738 iq1 = facel*charge[inr+1];
739 iq2 = facel*charge[inr+2];
740 iq3 = facel*charge[inr+3];
755 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
756 rcutoff = fr->rcoulomb;
757 rcutoff2 = rcutoff*rcutoff;
762 /* Start outer loop over neighborlists */
763 for(iidx=0; iidx<nri; iidx++)
765 /* Load shift vector for this list */
766 i_shift_offset = DIM*shiftidx[iidx];
767 shX = shiftvec[i_shift_offset+XX];
768 shY = shiftvec[i_shift_offset+YY];
769 shZ = shiftvec[i_shift_offset+ZZ];
771 /* Load limits for loop over neighbors */
772 j_index_start = jindex[iidx];
773 j_index_end = jindex[iidx+1];
775 /* Get outer coordinate index */
777 i_coord_offset = DIM*inr;
779 /* Load i particle coords and add shift vector */
780 ix1 = shX + x[i_coord_offset+DIM*1+XX];
781 iy1 = shY + x[i_coord_offset+DIM*1+YY];
782 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
783 ix2 = shX + x[i_coord_offset+DIM*2+XX];
784 iy2 = shY + x[i_coord_offset+DIM*2+YY];
785 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
786 ix3 = shX + x[i_coord_offset+DIM*3+XX];
787 iy3 = shY + x[i_coord_offset+DIM*3+YY];
788 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
800 /* Start inner kernel loop */
801 for(jidx=j_index_start; jidx<j_index_end; jidx++)
803 /* Get j neighbor index, and coordinate index */
805 j_coord_offset = DIM*jnr;
807 /* load j atom coordinates */
808 jx1 = x[j_coord_offset+DIM*1+XX];
809 jy1 = x[j_coord_offset+DIM*1+YY];
810 jz1 = x[j_coord_offset+DIM*1+ZZ];
811 jx2 = x[j_coord_offset+DIM*2+XX];
812 jy2 = x[j_coord_offset+DIM*2+YY];
813 jz2 = x[j_coord_offset+DIM*2+ZZ];
814 jx3 = x[j_coord_offset+DIM*3+XX];
815 jy3 = x[j_coord_offset+DIM*3+YY];
816 jz3 = x[j_coord_offset+DIM*3+ZZ];
818 /* Calculate displacement vector */
847 /* Calculate squared distance and things based on it */
848 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
849 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
850 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
851 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
852 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
853 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
854 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
855 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
856 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
858 rinv11 = gmx_invsqrt(rsq11);
859 rinv12 = gmx_invsqrt(rsq12);
860 rinv13 = gmx_invsqrt(rsq13);
861 rinv21 = gmx_invsqrt(rsq21);
862 rinv22 = gmx_invsqrt(rsq22);
863 rinv23 = gmx_invsqrt(rsq23);
864 rinv31 = gmx_invsqrt(rsq31);
865 rinv32 = gmx_invsqrt(rsq32);
866 rinv33 = gmx_invsqrt(rsq33);
868 rinvsq11 = rinv11*rinv11;
869 rinvsq12 = rinv12*rinv12;
870 rinvsq13 = rinv13*rinv13;
871 rinvsq21 = rinv21*rinv21;
872 rinvsq22 = rinv22*rinv22;
873 rinvsq23 = rinv23*rinv23;
874 rinvsq31 = rinv31*rinv31;
875 rinvsq32 = rinv32*rinv32;
876 rinvsq33 = rinv33*rinv33;
878 /**************************
879 * CALCULATE INTERACTIONS *
880 **************************/
887 /* EWALD ELECTROSTATICS */
889 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
890 ewrt = r11*ewtabscale;
893 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
894 felec = qq11*rinv11*(rinvsq11-felec);
898 /* Calculate temporary vectorial force */
903 /* Update vectorial force */
907 f[j_coord_offset+DIM*1+XX] -= tx;
908 f[j_coord_offset+DIM*1+YY] -= ty;
909 f[j_coord_offset+DIM*1+ZZ] -= tz;
913 /**************************
914 * CALCULATE INTERACTIONS *
915 **************************/
922 /* EWALD ELECTROSTATICS */
924 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
925 ewrt = r12*ewtabscale;
928 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
929 felec = qq12*rinv12*(rinvsq12-felec);
933 /* Calculate temporary vectorial force */
938 /* Update vectorial force */
942 f[j_coord_offset+DIM*2+XX] -= tx;
943 f[j_coord_offset+DIM*2+YY] -= ty;
944 f[j_coord_offset+DIM*2+ZZ] -= tz;
948 /**************************
949 * CALCULATE INTERACTIONS *
950 **************************/
957 /* EWALD ELECTROSTATICS */
959 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
960 ewrt = r13*ewtabscale;
963 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
964 felec = qq13*rinv13*(rinvsq13-felec);
968 /* Calculate temporary vectorial force */
973 /* Update vectorial force */
977 f[j_coord_offset+DIM*3+XX] -= tx;
978 f[j_coord_offset+DIM*3+YY] -= ty;
979 f[j_coord_offset+DIM*3+ZZ] -= tz;
983 /**************************
984 * CALCULATE INTERACTIONS *
985 **************************/
992 /* EWALD ELECTROSTATICS */
994 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
995 ewrt = r21*ewtabscale;
998 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
999 felec = qq21*rinv21*(rinvsq21-felec);
1003 /* Calculate temporary vectorial force */
1008 /* Update vectorial force */
1012 f[j_coord_offset+DIM*1+XX] -= tx;
1013 f[j_coord_offset+DIM*1+YY] -= ty;
1014 f[j_coord_offset+DIM*1+ZZ] -= tz;
1018 /**************************
1019 * CALCULATE INTERACTIONS *
1020 **************************/
1027 /* EWALD ELECTROSTATICS */
1029 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1030 ewrt = r22*ewtabscale;
1032 eweps = ewrt-ewitab;
1033 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1034 felec = qq22*rinv22*(rinvsq22-felec);
1038 /* Calculate temporary vectorial force */
1043 /* Update vectorial force */
1047 f[j_coord_offset+DIM*2+XX] -= tx;
1048 f[j_coord_offset+DIM*2+YY] -= ty;
1049 f[j_coord_offset+DIM*2+ZZ] -= tz;
1053 /**************************
1054 * CALCULATE INTERACTIONS *
1055 **************************/
1062 /* EWALD ELECTROSTATICS */
1064 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1065 ewrt = r23*ewtabscale;
1067 eweps = ewrt-ewitab;
1068 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1069 felec = qq23*rinv23*(rinvsq23-felec);
1073 /* Calculate temporary vectorial force */
1078 /* Update vectorial force */
1082 f[j_coord_offset+DIM*3+XX] -= tx;
1083 f[j_coord_offset+DIM*3+YY] -= ty;
1084 f[j_coord_offset+DIM*3+ZZ] -= tz;
1088 /**************************
1089 * CALCULATE INTERACTIONS *
1090 **************************/
1097 /* EWALD ELECTROSTATICS */
1099 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1100 ewrt = r31*ewtabscale;
1102 eweps = ewrt-ewitab;
1103 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1104 felec = qq31*rinv31*(rinvsq31-felec);
1108 /* Calculate temporary vectorial force */
1113 /* Update vectorial force */
1117 f[j_coord_offset+DIM*1+XX] -= tx;
1118 f[j_coord_offset+DIM*1+YY] -= ty;
1119 f[j_coord_offset+DIM*1+ZZ] -= tz;
1123 /**************************
1124 * CALCULATE INTERACTIONS *
1125 **************************/
1132 /* EWALD ELECTROSTATICS */
1134 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1135 ewrt = r32*ewtabscale;
1137 eweps = ewrt-ewitab;
1138 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1139 felec = qq32*rinv32*(rinvsq32-felec);
1143 /* Calculate temporary vectorial force */
1148 /* Update vectorial force */
1152 f[j_coord_offset+DIM*2+XX] -= tx;
1153 f[j_coord_offset+DIM*2+YY] -= ty;
1154 f[j_coord_offset+DIM*2+ZZ] -= tz;
1158 /**************************
1159 * CALCULATE INTERACTIONS *
1160 **************************/
1167 /* EWALD ELECTROSTATICS */
1169 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1170 ewrt = r33*ewtabscale;
1172 eweps = ewrt-ewitab;
1173 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1174 felec = qq33*rinv33*(rinvsq33-felec);
1178 /* Calculate temporary vectorial force */
1183 /* Update vectorial force */
1187 f[j_coord_offset+DIM*3+XX] -= tx;
1188 f[j_coord_offset+DIM*3+YY] -= ty;
1189 f[j_coord_offset+DIM*3+ZZ] -= tz;
1193 /* Inner loop uses 297 flops */
1195 /* End of innermost loop */
1198 f[i_coord_offset+DIM*1+XX] += fix1;
1199 f[i_coord_offset+DIM*1+YY] += fiy1;
1200 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1204 f[i_coord_offset+DIM*2+XX] += fix2;
1205 f[i_coord_offset+DIM*2+YY] += fiy2;
1206 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1210 f[i_coord_offset+DIM*3+XX] += fix3;
1211 f[i_coord_offset+DIM*3+YY] += fiy3;
1212 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1216 fshift[i_shift_offset+XX] += tx;
1217 fshift[i_shift_offset+YY] += ty;
1218 fshift[i_shift_offset+ZZ] += tz;
1220 /* Increment number of inner iterations */
1221 inneriter += j_index_end - j_index_start;
1223 /* Outer loop uses 30 flops */
1226 /* Increment number of outer iterations */
1229 /* Update outer/inner flops */
1231 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*30 + inneriter*297);