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_ElecEw_VdwNone_GeomW4W4_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: None
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_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];
138 /* Start outer loop over neighborlists */
139 for(iidx=0; iidx<nri; iidx++)
141 /* Load shift vector for this list */
142 i_shift_offset = DIM*shiftidx[iidx];
143 shX = shiftvec[i_shift_offset+XX];
144 shY = shiftvec[i_shift_offset+YY];
145 shZ = shiftvec[i_shift_offset+ZZ];
147 /* Load limits for loop over neighbors */
148 j_index_start = jindex[iidx];
149 j_index_end = jindex[iidx+1];
151 /* Get outer coordinate index */
153 i_coord_offset = DIM*inr;
155 /* Load i particle coords and add shift vector */
156 ix1 = shX + x[i_coord_offset+DIM*1+XX];
157 iy1 = shY + x[i_coord_offset+DIM*1+YY];
158 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
159 ix2 = shX + x[i_coord_offset+DIM*2+XX];
160 iy2 = shY + x[i_coord_offset+DIM*2+YY];
161 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
162 ix3 = shX + x[i_coord_offset+DIM*3+XX];
163 iy3 = shY + x[i_coord_offset+DIM*3+YY];
164 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
176 /* Reset potential sums */
179 /* Start inner kernel loop */
180 for(jidx=j_index_start; jidx<j_index_end; jidx++)
182 /* Get j neighbor index, and coordinate index */
184 j_coord_offset = DIM*jnr;
186 /* load j atom coordinates */
187 jx1 = x[j_coord_offset+DIM*1+XX];
188 jy1 = x[j_coord_offset+DIM*1+YY];
189 jz1 = x[j_coord_offset+DIM*1+ZZ];
190 jx2 = x[j_coord_offset+DIM*2+XX];
191 jy2 = x[j_coord_offset+DIM*2+YY];
192 jz2 = x[j_coord_offset+DIM*2+ZZ];
193 jx3 = x[j_coord_offset+DIM*3+XX];
194 jy3 = x[j_coord_offset+DIM*3+YY];
195 jz3 = x[j_coord_offset+DIM*3+ZZ];
197 /* Calculate displacement vector */
226 /* Calculate squared distance and things based on it */
227 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
228 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
229 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
230 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
231 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
232 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
233 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
234 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
235 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
237 rinv11 = gmx_invsqrt(rsq11);
238 rinv12 = gmx_invsqrt(rsq12);
239 rinv13 = gmx_invsqrt(rsq13);
240 rinv21 = gmx_invsqrt(rsq21);
241 rinv22 = gmx_invsqrt(rsq22);
242 rinv23 = gmx_invsqrt(rsq23);
243 rinv31 = gmx_invsqrt(rsq31);
244 rinv32 = gmx_invsqrt(rsq32);
245 rinv33 = gmx_invsqrt(rsq33);
247 rinvsq11 = rinv11*rinv11;
248 rinvsq12 = rinv12*rinv12;
249 rinvsq13 = rinv13*rinv13;
250 rinvsq21 = rinv21*rinv21;
251 rinvsq22 = rinv22*rinv22;
252 rinvsq23 = rinv23*rinv23;
253 rinvsq31 = rinv31*rinv31;
254 rinvsq32 = rinv32*rinv32;
255 rinvsq33 = rinv33*rinv33;
257 /**************************
258 * CALCULATE INTERACTIONS *
259 **************************/
263 /* EWALD ELECTROSTATICS */
265 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
266 ewrt = r11*ewtabscale;
270 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
271 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
272 felec = qq11*rinv11*(rinvsq11-felec);
274 /* Update potential sums from outer loop */
279 /* Calculate temporary vectorial force */
284 /* Update vectorial force */
288 f[j_coord_offset+DIM*1+XX] -= tx;
289 f[j_coord_offset+DIM*1+YY] -= ty;
290 f[j_coord_offset+DIM*1+ZZ] -= tz;
292 /**************************
293 * CALCULATE INTERACTIONS *
294 **************************/
298 /* EWALD ELECTROSTATICS */
300 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
301 ewrt = r12*ewtabscale;
305 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
306 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
307 felec = qq12*rinv12*(rinvsq12-felec);
309 /* Update potential sums from outer loop */
314 /* Calculate temporary vectorial force */
319 /* Update vectorial force */
323 f[j_coord_offset+DIM*2+XX] -= tx;
324 f[j_coord_offset+DIM*2+YY] -= ty;
325 f[j_coord_offset+DIM*2+ZZ] -= tz;
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
333 /* EWALD ELECTROSTATICS */
335 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
336 ewrt = r13*ewtabscale;
340 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
341 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
342 felec = qq13*rinv13*(rinvsq13-felec);
344 /* Update potential sums from outer loop */
349 /* Calculate temporary vectorial force */
354 /* Update vectorial force */
358 f[j_coord_offset+DIM*3+XX] -= tx;
359 f[j_coord_offset+DIM*3+YY] -= ty;
360 f[j_coord_offset+DIM*3+ZZ] -= tz;
362 /**************************
363 * CALCULATE INTERACTIONS *
364 **************************/
368 /* EWALD ELECTROSTATICS */
370 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
371 ewrt = r21*ewtabscale;
375 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
376 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
377 felec = qq21*rinv21*(rinvsq21-felec);
379 /* Update potential sums from outer loop */
384 /* Calculate temporary vectorial force */
389 /* Update vectorial force */
393 f[j_coord_offset+DIM*1+XX] -= tx;
394 f[j_coord_offset+DIM*1+YY] -= ty;
395 f[j_coord_offset+DIM*1+ZZ] -= tz;
397 /**************************
398 * CALCULATE INTERACTIONS *
399 **************************/
403 /* EWALD ELECTROSTATICS */
405 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
406 ewrt = r22*ewtabscale;
410 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
411 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
412 felec = qq22*rinv22*(rinvsq22-felec);
414 /* Update potential sums from outer loop */
419 /* Calculate temporary vectorial force */
424 /* Update vectorial force */
428 f[j_coord_offset+DIM*2+XX] -= tx;
429 f[j_coord_offset+DIM*2+YY] -= ty;
430 f[j_coord_offset+DIM*2+ZZ] -= tz;
432 /**************************
433 * CALCULATE INTERACTIONS *
434 **************************/
438 /* EWALD ELECTROSTATICS */
440 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
441 ewrt = r23*ewtabscale;
445 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
446 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
447 felec = qq23*rinv23*(rinvsq23-felec);
449 /* Update potential sums from outer loop */
454 /* Calculate temporary vectorial force */
459 /* Update vectorial force */
463 f[j_coord_offset+DIM*3+XX] -= tx;
464 f[j_coord_offset+DIM*3+YY] -= ty;
465 f[j_coord_offset+DIM*3+ZZ] -= tz;
467 /**************************
468 * CALCULATE INTERACTIONS *
469 **************************/
473 /* EWALD ELECTROSTATICS */
475 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
476 ewrt = r31*ewtabscale;
480 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
481 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
482 felec = qq31*rinv31*(rinvsq31-felec);
484 /* Update potential sums from outer loop */
489 /* Calculate temporary vectorial force */
494 /* Update vectorial force */
498 f[j_coord_offset+DIM*1+XX] -= tx;
499 f[j_coord_offset+DIM*1+YY] -= ty;
500 f[j_coord_offset+DIM*1+ZZ] -= tz;
502 /**************************
503 * CALCULATE INTERACTIONS *
504 **************************/
508 /* EWALD ELECTROSTATICS */
510 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
511 ewrt = r32*ewtabscale;
515 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
516 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
517 felec = qq32*rinv32*(rinvsq32-felec);
519 /* Update potential sums from outer loop */
524 /* Calculate temporary vectorial force */
529 /* Update vectorial force */
533 f[j_coord_offset+DIM*2+XX] -= tx;
534 f[j_coord_offset+DIM*2+YY] -= ty;
535 f[j_coord_offset+DIM*2+ZZ] -= tz;
537 /**************************
538 * CALCULATE INTERACTIONS *
539 **************************/
543 /* EWALD ELECTROSTATICS */
545 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
546 ewrt = r33*ewtabscale;
550 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
551 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
552 felec = qq33*rinv33*(rinvsq33-felec);
554 /* Update potential sums from outer loop */
559 /* Calculate temporary vectorial force */
564 /* Update vectorial force */
568 f[j_coord_offset+DIM*3+XX] -= tx;
569 f[j_coord_offset+DIM*3+YY] -= ty;
570 f[j_coord_offset+DIM*3+ZZ] -= tz;
572 /* Inner loop uses 360 flops */
574 /* End of innermost loop */
577 f[i_coord_offset+DIM*1+XX] += fix1;
578 f[i_coord_offset+DIM*1+YY] += fiy1;
579 f[i_coord_offset+DIM*1+ZZ] += fiz1;
583 f[i_coord_offset+DIM*2+XX] += fix2;
584 f[i_coord_offset+DIM*2+YY] += fiy2;
585 f[i_coord_offset+DIM*2+ZZ] += fiz2;
589 f[i_coord_offset+DIM*3+XX] += fix3;
590 f[i_coord_offset+DIM*3+YY] += fiy3;
591 f[i_coord_offset+DIM*3+ZZ] += fiz3;
595 fshift[i_shift_offset+XX] += tx;
596 fshift[i_shift_offset+YY] += ty;
597 fshift[i_shift_offset+ZZ] += tz;
600 /* Update potential energies */
601 kernel_data->energygrp_elec[ggid] += velecsum;
603 /* Increment number of inner iterations */
604 inneriter += j_index_end - j_index_start;
606 /* Outer loop uses 31 flops */
609 /* Increment number of outer iterations */
612 /* Update outer/inner flops */
614 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*31 + inneriter*360);
617 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW4W4_F_c
618 * Electrostatics interaction: Ewald
619 * VdW interaction: None
620 * Geometry: Water4-Water4
621 * Calculate force/pot: Force
624 nb_kernel_ElecEw_VdwNone_GeomW4W4_F_c
625 (t_nblist * gmx_restrict nlist,
626 rvec * gmx_restrict xx,
627 rvec * gmx_restrict ff,
628 t_forcerec * gmx_restrict fr,
629 t_mdatoms * gmx_restrict mdatoms,
630 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
631 t_nrnb * gmx_restrict nrnb)
633 int i_shift_offset,i_coord_offset,j_coord_offset;
634 int j_index_start,j_index_end;
635 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
636 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
637 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
638 real *shiftvec,*fshift,*x,*f;
640 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
642 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
644 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
646 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
648 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
650 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
651 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
652 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
653 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
654 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
655 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
656 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
657 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
658 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
659 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
660 real velec,felec,velecsum,facel,crf,krf,krf2;
663 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
671 jindex = nlist->jindex;
673 shiftidx = nlist->shift;
675 shiftvec = fr->shift_vec[0];
676 fshift = fr->fshift[0];
678 charge = mdatoms->chargeA;
680 sh_ewald = fr->ic->sh_ewald;
681 ewtab = fr->ic->tabq_coul_F;
682 ewtabscale = fr->ic->tabq_scale;
683 ewtabhalfspace = 0.5/ewtabscale;
685 /* Setup water-specific parameters */
686 inr = nlist->iinr[0];
687 iq1 = facel*charge[inr+1];
688 iq2 = facel*charge[inr+2];
689 iq3 = facel*charge[inr+3];
707 /* Start outer loop over neighborlists */
708 for(iidx=0; iidx<nri; iidx++)
710 /* Load shift vector for this list */
711 i_shift_offset = DIM*shiftidx[iidx];
712 shX = shiftvec[i_shift_offset+XX];
713 shY = shiftvec[i_shift_offset+YY];
714 shZ = shiftvec[i_shift_offset+ZZ];
716 /* Load limits for loop over neighbors */
717 j_index_start = jindex[iidx];
718 j_index_end = jindex[iidx+1];
720 /* Get outer coordinate index */
722 i_coord_offset = DIM*inr;
724 /* Load i particle coords and add shift vector */
725 ix1 = shX + x[i_coord_offset+DIM*1+XX];
726 iy1 = shY + x[i_coord_offset+DIM*1+YY];
727 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
728 ix2 = shX + x[i_coord_offset+DIM*2+XX];
729 iy2 = shY + x[i_coord_offset+DIM*2+YY];
730 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
731 ix3 = shX + x[i_coord_offset+DIM*3+XX];
732 iy3 = shY + x[i_coord_offset+DIM*3+YY];
733 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
745 /* Start inner kernel loop */
746 for(jidx=j_index_start; jidx<j_index_end; jidx++)
748 /* Get j neighbor index, and coordinate index */
750 j_coord_offset = DIM*jnr;
752 /* load j atom coordinates */
753 jx1 = x[j_coord_offset+DIM*1+XX];
754 jy1 = x[j_coord_offset+DIM*1+YY];
755 jz1 = x[j_coord_offset+DIM*1+ZZ];
756 jx2 = x[j_coord_offset+DIM*2+XX];
757 jy2 = x[j_coord_offset+DIM*2+YY];
758 jz2 = x[j_coord_offset+DIM*2+ZZ];
759 jx3 = x[j_coord_offset+DIM*3+XX];
760 jy3 = x[j_coord_offset+DIM*3+YY];
761 jz3 = x[j_coord_offset+DIM*3+ZZ];
763 /* Calculate displacement vector */
792 /* Calculate squared distance and things based on it */
793 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
794 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
795 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
796 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
797 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
798 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
799 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
800 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
801 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
803 rinv11 = gmx_invsqrt(rsq11);
804 rinv12 = gmx_invsqrt(rsq12);
805 rinv13 = gmx_invsqrt(rsq13);
806 rinv21 = gmx_invsqrt(rsq21);
807 rinv22 = gmx_invsqrt(rsq22);
808 rinv23 = gmx_invsqrt(rsq23);
809 rinv31 = gmx_invsqrt(rsq31);
810 rinv32 = gmx_invsqrt(rsq32);
811 rinv33 = gmx_invsqrt(rsq33);
813 rinvsq11 = rinv11*rinv11;
814 rinvsq12 = rinv12*rinv12;
815 rinvsq13 = rinv13*rinv13;
816 rinvsq21 = rinv21*rinv21;
817 rinvsq22 = rinv22*rinv22;
818 rinvsq23 = rinv23*rinv23;
819 rinvsq31 = rinv31*rinv31;
820 rinvsq32 = rinv32*rinv32;
821 rinvsq33 = rinv33*rinv33;
823 /**************************
824 * CALCULATE INTERACTIONS *
825 **************************/
829 /* EWALD ELECTROSTATICS */
831 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
832 ewrt = r11*ewtabscale;
835 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
836 felec = qq11*rinv11*(rinvsq11-felec);
840 /* Calculate temporary vectorial force */
845 /* Update vectorial force */
849 f[j_coord_offset+DIM*1+XX] -= tx;
850 f[j_coord_offset+DIM*1+YY] -= ty;
851 f[j_coord_offset+DIM*1+ZZ] -= tz;
853 /**************************
854 * CALCULATE INTERACTIONS *
855 **************************/
859 /* EWALD ELECTROSTATICS */
861 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
862 ewrt = r12*ewtabscale;
865 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
866 felec = qq12*rinv12*(rinvsq12-felec);
870 /* Calculate temporary vectorial force */
875 /* Update vectorial force */
879 f[j_coord_offset+DIM*2+XX] -= tx;
880 f[j_coord_offset+DIM*2+YY] -= ty;
881 f[j_coord_offset+DIM*2+ZZ] -= tz;
883 /**************************
884 * CALCULATE INTERACTIONS *
885 **************************/
889 /* EWALD ELECTROSTATICS */
891 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
892 ewrt = r13*ewtabscale;
895 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
896 felec = qq13*rinv13*(rinvsq13-felec);
900 /* Calculate temporary vectorial force */
905 /* Update vectorial force */
909 f[j_coord_offset+DIM*3+XX] -= tx;
910 f[j_coord_offset+DIM*3+YY] -= ty;
911 f[j_coord_offset+DIM*3+ZZ] -= tz;
913 /**************************
914 * CALCULATE INTERACTIONS *
915 **************************/
919 /* EWALD ELECTROSTATICS */
921 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
922 ewrt = r21*ewtabscale;
925 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
926 felec = qq21*rinv21*(rinvsq21-felec);
930 /* Calculate temporary vectorial force */
935 /* Update vectorial force */
939 f[j_coord_offset+DIM*1+XX] -= tx;
940 f[j_coord_offset+DIM*1+YY] -= ty;
941 f[j_coord_offset+DIM*1+ZZ] -= tz;
943 /**************************
944 * CALCULATE INTERACTIONS *
945 **************************/
949 /* EWALD ELECTROSTATICS */
951 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
952 ewrt = r22*ewtabscale;
955 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
956 felec = qq22*rinv22*(rinvsq22-felec);
960 /* Calculate temporary vectorial force */
965 /* Update vectorial force */
969 f[j_coord_offset+DIM*2+XX] -= tx;
970 f[j_coord_offset+DIM*2+YY] -= ty;
971 f[j_coord_offset+DIM*2+ZZ] -= tz;
973 /**************************
974 * CALCULATE INTERACTIONS *
975 **************************/
979 /* EWALD ELECTROSTATICS */
981 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
982 ewrt = r23*ewtabscale;
985 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
986 felec = qq23*rinv23*(rinvsq23-felec);
990 /* Calculate temporary vectorial force */
995 /* Update vectorial force */
999 f[j_coord_offset+DIM*3+XX] -= tx;
1000 f[j_coord_offset+DIM*3+YY] -= ty;
1001 f[j_coord_offset+DIM*3+ZZ] -= tz;
1003 /**************************
1004 * CALCULATE INTERACTIONS *
1005 **************************/
1009 /* EWALD ELECTROSTATICS */
1011 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1012 ewrt = r31*ewtabscale;
1014 eweps = ewrt-ewitab;
1015 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1016 felec = qq31*rinv31*(rinvsq31-felec);
1020 /* Calculate temporary vectorial force */
1025 /* Update vectorial force */
1029 f[j_coord_offset+DIM*1+XX] -= tx;
1030 f[j_coord_offset+DIM*1+YY] -= ty;
1031 f[j_coord_offset+DIM*1+ZZ] -= tz;
1033 /**************************
1034 * CALCULATE INTERACTIONS *
1035 **************************/
1039 /* EWALD ELECTROSTATICS */
1041 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1042 ewrt = r32*ewtabscale;
1044 eweps = ewrt-ewitab;
1045 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1046 felec = qq32*rinv32*(rinvsq32-felec);
1050 /* Calculate temporary vectorial force */
1055 /* Update vectorial force */
1059 f[j_coord_offset+DIM*2+XX] -= tx;
1060 f[j_coord_offset+DIM*2+YY] -= ty;
1061 f[j_coord_offset+DIM*2+ZZ] -= tz;
1063 /**************************
1064 * CALCULATE INTERACTIONS *
1065 **************************/
1069 /* EWALD ELECTROSTATICS */
1071 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1072 ewrt = r33*ewtabscale;
1074 eweps = ewrt-ewitab;
1075 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1076 felec = qq33*rinv33*(rinvsq33-felec);
1080 /* Calculate temporary vectorial force */
1085 /* Update vectorial force */
1089 f[j_coord_offset+DIM*3+XX] -= tx;
1090 f[j_coord_offset+DIM*3+YY] -= ty;
1091 f[j_coord_offset+DIM*3+ZZ] -= tz;
1093 /* Inner loop uses 297 flops */
1095 /* End of innermost loop */
1098 f[i_coord_offset+DIM*1+XX] += fix1;
1099 f[i_coord_offset+DIM*1+YY] += fiy1;
1100 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1104 f[i_coord_offset+DIM*2+XX] += fix2;
1105 f[i_coord_offset+DIM*2+YY] += fiy2;
1106 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1110 f[i_coord_offset+DIM*3+XX] += fix3;
1111 f[i_coord_offset+DIM*3+YY] += fiy3;
1112 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1116 fshift[i_shift_offset+XX] += tx;
1117 fshift[i_shift_offset+YY] += ty;
1118 fshift[i_shift_offset+ZZ] += tz;
1120 /* Increment number of inner iterations */
1121 inneriter += j_index_end - j_index_start;
1123 /* Outer loop uses 30 flops */
1126 /* Increment number of outer iterations */
1129 /* Update outer/inner flops */
1131 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*30 + inneriter*297);