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 "types/simple.h"
46 #include "gromacs/math/vec.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW3W3_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwNone_GeomW3W3_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
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 iq0 = facel*charge[inr+0];
121 iq1 = facel*charge[inr+1];
122 iq2 = facel*charge[inr+2];
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 ix0 = shX + x[i_coord_offset+DIM*0+XX];
163 iy0 = shY + x[i_coord_offset+DIM*0+YY];
164 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
165 ix1 = shX + x[i_coord_offset+DIM*1+XX];
166 iy1 = shY + x[i_coord_offset+DIM*1+YY];
167 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
168 ix2 = shX + x[i_coord_offset+DIM*2+XX];
169 iy2 = shY + x[i_coord_offset+DIM*2+YY];
170 iz2 = shZ + x[i_coord_offset+DIM*2+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 jx0 = x[j_coord_offset+DIM*0+XX];
194 jy0 = x[j_coord_offset+DIM*0+YY];
195 jz0 = x[j_coord_offset+DIM*0+ZZ];
196 jx1 = x[j_coord_offset+DIM*1+XX];
197 jy1 = x[j_coord_offset+DIM*1+YY];
198 jz1 = x[j_coord_offset+DIM*1+ZZ];
199 jx2 = x[j_coord_offset+DIM*2+XX];
200 jy2 = x[j_coord_offset+DIM*2+YY];
201 jz2 = x[j_coord_offset+DIM*2+ZZ];
203 /* Calculate displacement vector */
232 /* Calculate squared distance and things based on it */
233 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
234 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
235 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
236 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
237 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
238 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
239 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
240 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
241 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
243 rinv00 = gmx_invsqrt(rsq00);
244 rinv01 = gmx_invsqrt(rsq01);
245 rinv02 = gmx_invsqrt(rsq02);
246 rinv10 = gmx_invsqrt(rsq10);
247 rinv11 = gmx_invsqrt(rsq11);
248 rinv12 = gmx_invsqrt(rsq12);
249 rinv20 = gmx_invsqrt(rsq20);
250 rinv21 = gmx_invsqrt(rsq21);
251 rinv22 = gmx_invsqrt(rsq22);
253 rinvsq00 = rinv00*rinv00;
254 rinvsq01 = rinv01*rinv01;
255 rinvsq02 = rinv02*rinv02;
256 rinvsq10 = rinv10*rinv10;
257 rinvsq11 = rinv11*rinv11;
258 rinvsq12 = rinv12*rinv12;
259 rinvsq20 = rinv20*rinv20;
260 rinvsq21 = rinv21*rinv21;
261 rinvsq22 = rinv22*rinv22;
263 /**************************
264 * CALCULATE INTERACTIONS *
265 **************************/
272 /* EWALD ELECTROSTATICS */
274 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
275 ewrt = r00*ewtabscale;
279 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
280 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
281 felec = qq00*rinv00*(rinvsq00-felec);
283 /* Update potential sums from outer loop */
288 /* Calculate temporary vectorial force */
293 /* Update vectorial force */
297 f[j_coord_offset+DIM*0+XX] -= tx;
298 f[j_coord_offset+DIM*0+YY] -= ty;
299 f[j_coord_offset+DIM*0+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 = r01*ewtabscale;
319 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
320 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
321 felec = qq01*rinv01*(rinvsq01-felec);
323 /* Update potential sums from outer loop */
328 /* Calculate temporary vectorial force */
333 /* Update vectorial force */
337 f[j_coord_offset+DIM*1+XX] -= tx;
338 f[j_coord_offset+DIM*1+YY] -= ty;
339 f[j_coord_offset+DIM*1+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 = r02*ewtabscale;
359 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
360 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
361 felec = qq02*rinv02*(rinvsq02-felec);
363 /* Update potential sums from outer loop */
368 /* Calculate temporary vectorial force */
373 /* Update vectorial force */
377 f[j_coord_offset+DIM*2+XX] -= tx;
378 f[j_coord_offset+DIM*2+YY] -= ty;
379 f[j_coord_offset+DIM*2+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 = r10*ewtabscale;
399 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
400 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
401 felec = qq10*rinv10*(rinvsq10-felec);
403 /* Update potential sums from outer loop */
408 /* Calculate temporary vectorial force */
413 /* Update vectorial force */
417 f[j_coord_offset+DIM*0+XX] -= tx;
418 f[j_coord_offset+DIM*0+YY] -= ty;
419 f[j_coord_offset+DIM*0+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 = r11*ewtabscale;
439 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
440 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
441 felec = qq11*rinv11*(rinvsq11-felec);
443 /* Update potential sums from outer loop */
448 /* Calculate temporary vectorial force */
453 /* Update vectorial force */
457 f[j_coord_offset+DIM*1+XX] -= tx;
458 f[j_coord_offset+DIM*1+YY] -= ty;
459 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
479 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
480 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
481 felec = qq12*rinv12*(rinvsq12-felec);
483 /* Update potential sums from outer loop */
488 /* Calculate temporary vectorial force */
493 /* Update vectorial force */
497 f[j_coord_offset+DIM*2+XX] -= tx;
498 f[j_coord_offset+DIM*2+YY] -= ty;
499 f[j_coord_offset+DIM*2+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 = r20*ewtabscale;
519 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
520 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
521 felec = qq20*rinv20*(rinvsq20-felec);
523 /* Update potential sums from outer loop */
528 /* Calculate temporary vectorial force */
533 /* Update vectorial force */
537 f[j_coord_offset+DIM*0+XX] -= tx;
538 f[j_coord_offset+DIM*0+YY] -= ty;
539 f[j_coord_offset+DIM*0+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 = r21*ewtabscale;
559 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
560 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
561 felec = qq21*rinv21*(rinvsq21-felec);
563 /* Update potential sums from outer loop */
568 /* Calculate temporary vectorial force */
573 /* Update vectorial force */
577 f[j_coord_offset+DIM*1+XX] -= tx;
578 f[j_coord_offset+DIM*1+YY] -= ty;
579 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
599 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
600 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
601 felec = qq22*rinv22*(rinvsq22-felec);
603 /* Update potential sums from outer loop */
608 /* Calculate temporary vectorial force */
613 /* Update vectorial force */
617 f[j_coord_offset+DIM*2+XX] -= tx;
618 f[j_coord_offset+DIM*2+YY] -= ty;
619 f[j_coord_offset+DIM*2+ZZ] -= tz;
623 /* Inner loop uses 369 flops */
625 /* End of innermost loop */
628 f[i_coord_offset+DIM*0+XX] += fix0;
629 f[i_coord_offset+DIM*0+YY] += fiy0;
630 f[i_coord_offset+DIM*0+ZZ] += fiz0;
634 f[i_coord_offset+DIM*1+XX] += fix1;
635 f[i_coord_offset+DIM*1+YY] += fiy1;
636 f[i_coord_offset+DIM*1+ZZ] += fiz1;
640 f[i_coord_offset+DIM*2+XX] += fix2;
641 f[i_coord_offset+DIM*2+YY] += fiy2;
642 f[i_coord_offset+DIM*2+ZZ] += fiz2;
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_W3W3_VF,outeriter*31 + inneriter*369);
668 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW3W3_F_c
669 * Electrostatics interaction: Ewald
670 * VdW interaction: None
671 * Geometry: Water3-Water3
672 * Calculate force/pot: Force
675 nb_kernel_ElecEwSh_VdwNone_GeomW3W3_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
693 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
695 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
697 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
699 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
701 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
702 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
703 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
704 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
705 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
706 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
707 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
708 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
709 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
710 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
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 iq0 = facel*charge[inr+0];
739 iq1 = facel*charge[inr+1];
740 iq2 = facel*charge[inr+2];
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 ix0 = shX + x[i_coord_offset+DIM*0+XX];
781 iy0 = shY + x[i_coord_offset+DIM*0+YY];
782 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
783 ix1 = shX + x[i_coord_offset+DIM*1+XX];
784 iy1 = shY + x[i_coord_offset+DIM*1+YY];
785 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
786 ix2 = shX + x[i_coord_offset+DIM*2+XX];
787 iy2 = shY + x[i_coord_offset+DIM*2+YY];
788 iz2 = shZ + x[i_coord_offset+DIM*2+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 jx0 = x[j_coord_offset+DIM*0+XX];
809 jy0 = x[j_coord_offset+DIM*0+YY];
810 jz0 = x[j_coord_offset+DIM*0+ZZ];
811 jx1 = x[j_coord_offset+DIM*1+XX];
812 jy1 = x[j_coord_offset+DIM*1+YY];
813 jz1 = x[j_coord_offset+DIM*1+ZZ];
814 jx2 = x[j_coord_offset+DIM*2+XX];
815 jy2 = x[j_coord_offset+DIM*2+YY];
816 jz2 = x[j_coord_offset+DIM*2+ZZ];
818 /* Calculate displacement vector */
847 /* Calculate squared distance and things based on it */
848 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
849 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
850 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
851 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
852 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
853 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
854 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
855 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
856 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
858 rinv00 = gmx_invsqrt(rsq00);
859 rinv01 = gmx_invsqrt(rsq01);
860 rinv02 = gmx_invsqrt(rsq02);
861 rinv10 = gmx_invsqrt(rsq10);
862 rinv11 = gmx_invsqrt(rsq11);
863 rinv12 = gmx_invsqrt(rsq12);
864 rinv20 = gmx_invsqrt(rsq20);
865 rinv21 = gmx_invsqrt(rsq21);
866 rinv22 = gmx_invsqrt(rsq22);
868 rinvsq00 = rinv00*rinv00;
869 rinvsq01 = rinv01*rinv01;
870 rinvsq02 = rinv02*rinv02;
871 rinvsq10 = rinv10*rinv10;
872 rinvsq11 = rinv11*rinv11;
873 rinvsq12 = rinv12*rinv12;
874 rinvsq20 = rinv20*rinv20;
875 rinvsq21 = rinv21*rinv21;
876 rinvsq22 = rinv22*rinv22;
878 /**************************
879 * CALCULATE INTERACTIONS *
880 **************************/
887 /* EWALD ELECTROSTATICS */
889 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
890 ewrt = r00*ewtabscale;
893 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
894 felec = qq00*rinv00*(rinvsq00-felec);
898 /* Calculate temporary vectorial force */
903 /* Update vectorial force */
907 f[j_coord_offset+DIM*0+XX] -= tx;
908 f[j_coord_offset+DIM*0+YY] -= ty;
909 f[j_coord_offset+DIM*0+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 = r01*ewtabscale;
928 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
929 felec = qq01*rinv01*(rinvsq01-felec);
933 /* Calculate temporary vectorial force */
938 /* Update vectorial force */
942 f[j_coord_offset+DIM*1+XX] -= tx;
943 f[j_coord_offset+DIM*1+YY] -= ty;
944 f[j_coord_offset+DIM*1+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 = r02*ewtabscale;
963 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
964 felec = qq02*rinv02*(rinvsq02-felec);
968 /* Calculate temporary vectorial force */
973 /* Update vectorial force */
977 f[j_coord_offset+DIM*2+XX] -= tx;
978 f[j_coord_offset+DIM*2+YY] -= ty;
979 f[j_coord_offset+DIM*2+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 = r10*ewtabscale;
998 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
999 felec = qq10*rinv10*(rinvsq10-felec);
1003 /* Calculate temporary vectorial force */
1008 /* Update vectorial force */
1012 f[j_coord_offset+DIM*0+XX] -= tx;
1013 f[j_coord_offset+DIM*0+YY] -= ty;
1014 f[j_coord_offset+DIM*0+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 = r11*ewtabscale;
1032 eweps = ewrt-ewitab;
1033 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1034 felec = qq11*rinv11*(rinvsq11-felec);
1038 /* Calculate temporary vectorial force */
1043 /* Update vectorial force */
1047 f[j_coord_offset+DIM*1+XX] -= tx;
1048 f[j_coord_offset+DIM*1+YY] -= ty;
1049 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
1067 eweps = ewrt-ewitab;
1068 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1069 felec = qq12*rinv12*(rinvsq12-felec);
1073 /* Calculate temporary vectorial force */
1078 /* Update vectorial force */
1082 f[j_coord_offset+DIM*2+XX] -= tx;
1083 f[j_coord_offset+DIM*2+YY] -= ty;
1084 f[j_coord_offset+DIM*2+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 = r20*ewtabscale;
1102 eweps = ewrt-ewitab;
1103 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1104 felec = qq20*rinv20*(rinvsq20-felec);
1108 /* Calculate temporary vectorial force */
1113 /* Update vectorial force */
1117 f[j_coord_offset+DIM*0+XX] -= tx;
1118 f[j_coord_offset+DIM*0+YY] -= ty;
1119 f[j_coord_offset+DIM*0+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 = r21*ewtabscale;
1137 eweps = ewrt-ewitab;
1138 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1139 felec = qq21*rinv21*(rinvsq21-felec);
1143 /* Calculate temporary vectorial force */
1148 /* Update vectorial force */
1152 f[j_coord_offset+DIM*1+XX] -= tx;
1153 f[j_coord_offset+DIM*1+YY] -= ty;
1154 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
1172 eweps = ewrt-ewitab;
1173 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1174 felec = qq22*rinv22*(rinvsq22-felec);
1178 /* Calculate temporary vectorial force */
1183 /* Update vectorial force */
1187 f[j_coord_offset+DIM*2+XX] -= tx;
1188 f[j_coord_offset+DIM*2+YY] -= ty;
1189 f[j_coord_offset+DIM*2+ZZ] -= tz;
1193 /* Inner loop uses 297 flops */
1195 /* End of innermost loop */
1198 f[i_coord_offset+DIM*0+XX] += fix0;
1199 f[i_coord_offset+DIM*0+YY] += fiy0;
1200 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1204 f[i_coord_offset+DIM*1+XX] += fix1;
1205 f[i_coord_offset+DIM*1+YY] += fiy1;
1206 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1210 f[i_coord_offset+DIM*2+XX] += fix2;
1211 f[i_coord_offset+DIM*2+YY] += fiy2;
1212 f[i_coord_offset+DIM*2+ZZ] += fiz2;
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_W3W3_F,outeriter*30 + inneriter*297);