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_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: None
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_VdwNone_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
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 iq0 = facel*charge[inr+0];
119 iq1 = facel*charge[inr+1];
120 iq2 = facel*charge[inr+2];
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 ix0 = shX + x[i_coord_offset+DIM*0+XX];
161 iy0 = shY + x[i_coord_offset+DIM*0+YY];
162 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
163 ix1 = shX + x[i_coord_offset+DIM*1+XX];
164 iy1 = shY + x[i_coord_offset+DIM*1+YY];
165 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
166 ix2 = shX + x[i_coord_offset+DIM*2+XX];
167 iy2 = shY + x[i_coord_offset+DIM*2+YY];
168 iz2 = shZ + x[i_coord_offset+DIM*2+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 jx0 = x[j_coord_offset+DIM*0+XX];
192 jy0 = x[j_coord_offset+DIM*0+YY];
193 jz0 = x[j_coord_offset+DIM*0+ZZ];
194 jx1 = x[j_coord_offset+DIM*1+XX];
195 jy1 = x[j_coord_offset+DIM*1+YY];
196 jz1 = x[j_coord_offset+DIM*1+ZZ];
197 jx2 = x[j_coord_offset+DIM*2+XX];
198 jy2 = x[j_coord_offset+DIM*2+YY];
199 jz2 = x[j_coord_offset+DIM*2+ZZ];
201 /* Calculate displacement vector */
230 /* Calculate squared distance and things based on it */
231 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
232 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
233 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
234 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
235 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
236 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
237 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
238 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
239 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
241 rinv00 = gmx_invsqrt(rsq00);
242 rinv01 = gmx_invsqrt(rsq01);
243 rinv02 = gmx_invsqrt(rsq02);
244 rinv10 = gmx_invsqrt(rsq10);
245 rinv11 = gmx_invsqrt(rsq11);
246 rinv12 = gmx_invsqrt(rsq12);
247 rinv20 = gmx_invsqrt(rsq20);
248 rinv21 = gmx_invsqrt(rsq21);
249 rinv22 = gmx_invsqrt(rsq22);
251 rinvsq00 = rinv00*rinv00;
252 rinvsq01 = rinv01*rinv01;
253 rinvsq02 = rinv02*rinv02;
254 rinvsq10 = rinv10*rinv10;
255 rinvsq11 = rinv11*rinv11;
256 rinvsq12 = rinv12*rinv12;
257 rinvsq20 = rinv20*rinv20;
258 rinvsq21 = rinv21*rinv21;
259 rinvsq22 = rinv22*rinv22;
261 /**************************
262 * CALCULATE INTERACTIONS *
263 **************************/
270 /* EWALD ELECTROSTATICS */
272 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
273 ewrt = r00*ewtabscale;
277 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
278 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
279 felec = qq00*rinv00*(rinvsq00-felec);
281 /* Update potential sums from outer loop */
286 /* Calculate temporary vectorial force */
291 /* Update vectorial force */
295 f[j_coord_offset+DIM*0+XX] -= tx;
296 f[j_coord_offset+DIM*0+YY] -= ty;
297 f[j_coord_offset+DIM*0+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 = r01*ewtabscale;
317 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
318 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
319 felec = qq01*rinv01*(rinvsq01-felec);
321 /* Update potential sums from outer loop */
326 /* Calculate temporary vectorial force */
331 /* Update vectorial force */
335 f[j_coord_offset+DIM*1+XX] -= tx;
336 f[j_coord_offset+DIM*1+YY] -= ty;
337 f[j_coord_offset+DIM*1+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 = r02*ewtabscale;
357 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
358 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
359 felec = qq02*rinv02*(rinvsq02-felec);
361 /* Update potential sums from outer loop */
366 /* Calculate temporary vectorial force */
371 /* Update vectorial force */
375 f[j_coord_offset+DIM*2+XX] -= tx;
376 f[j_coord_offset+DIM*2+YY] -= ty;
377 f[j_coord_offset+DIM*2+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 = r10*ewtabscale;
397 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
398 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
399 felec = qq10*rinv10*(rinvsq10-felec);
401 /* Update potential sums from outer loop */
406 /* Calculate temporary vectorial force */
411 /* Update vectorial force */
415 f[j_coord_offset+DIM*0+XX] -= tx;
416 f[j_coord_offset+DIM*0+YY] -= ty;
417 f[j_coord_offset+DIM*0+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 = r11*ewtabscale;
437 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
438 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
439 felec = qq11*rinv11*(rinvsq11-felec);
441 /* Update potential sums from outer loop */
446 /* Calculate temporary vectorial force */
451 /* Update vectorial force */
455 f[j_coord_offset+DIM*1+XX] -= tx;
456 f[j_coord_offset+DIM*1+YY] -= ty;
457 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
477 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
478 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
479 felec = qq12*rinv12*(rinvsq12-felec);
481 /* Update potential sums from outer loop */
486 /* Calculate temporary vectorial force */
491 /* Update vectorial force */
495 f[j_coord_offset+DIM*2+XX] -= tx;
496 f[j_coord_offset+DIM*2+YY] -= ty;
497 f[j_coord_offset+DIM*2+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 = r20*ewtabscale;
517 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
518 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
519 felec = qq20*rinv20*(rinvsq20-felec);
521 /* Update potential sums from outer loop */
526 /* Calculate temporary vectorial force */
531 /* Update vectorial force */
535 f[j_coord_offset+DIM*0+XX] -= tx;
536 f[j_coord_offset+DIM*0+YY] -= ty;
537 f[j_coord_offset+DIM*0+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 = r21*ewtabscale;
557 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
558 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
559 felec = qq21*rinv21*(rinvsq21-felec);
561 /* Update potential sums from outer loop */
566 /* Calculate temporary vectorial force */
571 /* Update vectorial force */
575 f[j_coord_offset+DIM*1+XX] -= tx;
576 f[j_coord_offset+DIM*1+YY] -= ty;
577 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
597 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
598 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
599 felec = qq22*rinv22*(rinvsq22-felec);
601 /* Update potential sums from outer loop */
606 /* Calculate temporary vectorial force */
611 /* Update vectorial force */
615 f[j_coord_offset+DIM*2+XX] -= tx;
616 f[j_coord_offset+DIM*2+YY] -= ty;
617 f[j_coord_offset+DIM*2+ZZ] -= tz;
621 /* Inner loop uses 369 flops */
623 /* End of innermost loop */
626 f[i_coord_offset+DIM*0+XX] += fix0;
627 f[i_coord_offset+DIM*0+YY] += fiy0;
628 f[i_coord_offset+DIM*0+ZZ] += fiz0;
632 f[i_coord_offset+DIM*1+XX] += fix1;
633 f[i_coord_offset+DIM*1+YY] += fiy1;
634 f[i_coord_offset+DIM*1+ZZ] += fiz1;
638 f[i_coord_offset+DIM*2+XX] += fix2;
639 f[i_coord_offset+DIM*2+YY] += fiy2;
640 f[i_coord_offset+DIM*2+ZZ] += fiz2;
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_W3W3_VF,outeriter*31 + inneriter*369);
666 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW3W3_F_c
667 * Electrostatics interaction: Ewald
668 * VdW interaction: None
669 * Geometry: Water3-Water3
670 * Calculate force/pot: Force
673 nb_kernel_ElecEwSh_VdwNone_GeomW3W3_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
691 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
693 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
695 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
697 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
699 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
700 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
701 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
702 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
703 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
704 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
705 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
706 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
707 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
708 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
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 iq0 = facel*charge[inr+0];
737 iq1 = facel*charge[inr+1];
738 iq2 = facel*charge[inr+2];
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 ix0 = shX + x[i_coord_offset+DIM*0+XX];
779 iy0 = shY + x[i_coord_offset+DIM*0+YY];
780 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
781 ix1 = shX + x[i_coord_offset+DIM*1+XX];
782 iy1 = shY + x[i_coord_offset+DIM*1+YY];
783 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
784 ix2 = shX + x[i_coord_offset+DIM*2+XX];
785 iy2 = shY + x[i_coord_offset+DIM*2+YY];
786 iz2 = shZ + x[i_coord_offset+DIM*2+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 jx0 = x[j_coord_offset+DIM*0+XX];
807 jy0 = x[j_coord_offset+DIM*0+YY];
808 jz0 = x[j_coord_offset+DIM*0+ZZ];
809 jx1 = x[j_coord_offset+DIM*1+XX];
810 jy1 = x[j_coord_offset+DIM*1+YY];
811 jz1 = x[j_coord_offset+DIM*1+ZZ];
812 jx2 = x[j_coord_offset+DIM*2+XX];
813 jy2 = x[j_coord_offset+DIM*2+YY];
814 jz2 = x[j_coord_offset+DIM*2+ZZ];
816 /* Calculate displacement vector */
845 /* Calculate squared distance and things based on it */
846 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
847 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
848 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
849 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
850 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
851 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
852 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
853 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
854 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
856 rinv00 = gmx_invsqrt(rsq00);
857 rinv01 = gmx_invsqrt(rsq01);
858 rinv02 = gmx_invsqrt(rsq02);
859 rinv10 = gmx_invsqrt(rsq10);
860 rinv11 = gmx_invsqrt(rsq11);
861 rinv12 = gmx_invsqrt(rsq12);
862 rinv20 = gmx_invsqrt(rsq20);
863 rinv21 = gmx_invsqrt(rsq21);
864 rinv22 = gmx_invsqrt(rsq22);
866 rinvsq00 = rinv00*rinv00;
867 rinvsq01 = rinv01*rinv01;
868 rinvsq02 = rinv02*rinv02;
869 rinvsq10 = rinv10*rinv10;
870 rinvsq11 = rinv11*rinv11;
871 rinvsq12 = rinv12*rinv12;
872 rinvsq20 = rinv20*rinv20;
873 rinvsq21 = rinv21*rinv21;
874 rinvsq22 = rinv22*rinv22;
876 /**************************
877 * CALCULATE INTERACTIONS *
878 **************************/
885 /* EWALD ELECTROSTATICS */
887 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
888 ewrt = r00*ewtabscale;
891 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
892 felec = qq00*rinv00*(rinvsq00-felec);
896 /* Calculate temporary vectorial force */
901 /* Update vectorial force */
905 f[j_coord_offset+DIM*0+XX] -= tx;
906 f[j_coord_offset+DIM*0+YY] -= ty;
907 f[j_coord_offset+DIM*0+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 = r01*ewtabscale;
926 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
927 felec = qq01*rinv01*(rinvsq01-felec);
931 /* Calculate temporary vectorial force */
936 /* Update vectorial force */
940 f[j_coord_offset+DIM*1+XX] -= tx;
941 f[j_coord_offset+DIM*1+YY] -= ty;
942 f[j_coord_offset+DIM*1+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 = r02*ewtabscale;
961 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
962 felec = qq02*rinv02*(rinvsq02-felec);
966 /* Calculate temporary vectorial force */
971 /* Update vectorial force */
975 f[j_coord_offset+DIM*2+XX] -= tx;
976 f[j_coord_offset+DIM*2+YY] -= ty;
977 f[j_coord_offset+DIM*2+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 = r10*ewtabscale;
996 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
997 felec = qq10*rinv10*(rinvsq10-felec);
1001 /* Calculate temporary vectorial force */
1006 /* Update vectorial force */
1010 f[j_coord_offset+DIM*0+XX] -= tx;
1011 f[j_coord_offset+DIM*0+YY] -= ty;
1012 f[j_coord_offset+DIM*0+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 = r11*ewtabscale;
1030 eweps = ewrt-ewitab;
1031 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1032 felec = qq11*rinv11*(rinvsq11-felec);
1036 /* Calculate temporary vectorial force */
1041 /* Update vectorial force */
1045 f[j_coord_offset+DIM*1+XX] -= tx;
1046 f[j_coord_offset+DIM*1+YY] -= ty;
1047 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
1065 eweps = ewrt-ewitab;
1066 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1067 felec = qq12*rinv12*(rinvsq12-felec);
1071 /* Calculate temporary vectorial force */
1076 /* Update vectorial force */
1080 f[j_coord_offset+DIM*2+XX] -= tx;
1081 f[j_coord_offset+DIM*2+YY] -= ty;
1082 f[j_coord_offset+DIM*2+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 = r20*ewtabscale;
1100 eweps = ewrt-ewitab;
1101 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1102 felec = qq20*rinv20*(rinvsq20-felec);
1106 /* Calculate temporary vectorial force */
1111 /* Update vectorial force */
1115 f[j_coord_offset+DIM*0+XX] -= tx;
1116 f[j_coord_offset+DIM*0+YY] -= ty;
1117 f[j_coord_offset+DIM*0+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 = r21*ewtabscale;
1135 eweps = ewrt-ewitab;
1136 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1137 felec = qq21*rinv21*(rinvsq21-felec);
1141 /* Calculate temporary vectorial force */
1146 /* Update vectorial force */
1150 f[j_coord_offset+DIM*1+XX] -= tx;
1151 f[j_coord_offset+DIM*1+YY] -= ty;
1152 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
1170 eweps = ewrt-ewitab;
1171 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1172 felec = qq22*rinv22*(rinvsq22-felec);
1176 /* Calculate temporary vectorial force */
1181 /* Update vectorial force */
1185 f[j_coord_offset+DIM*2+XX] -= tx;
1186 f[j_coord_offset+DIM*2+YY] -= ty;
1187 f[j_coord_offset+DIM*2+ZZ] -= tz;
1191 /* Inner loop uses 297 flops */
1193 /* End of innermost loop */
1196 f[i_coord_offset+DIM*0+XX] += fix0;
1197 f[i_coord_offset+DIM*0+YY] += fiy0;
1198 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1202 f[i_coord_offset+DIM*1+XX] += fix1;
1203 f[i_coord_offset+DIM*1+YY] += fiy1;
1204 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1208 f[i_coord_offset+DIM*2+XX] += fix2;
1209 f[i_coord_offset+DIM*2+YY] += fiy2;
1210 f[i_coord_offset+DIM*2+ZZ] += fiz2;
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_W3W3_F,outeriter*30 + inneriter*297);