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_ElecEw_VdwNone_GeomW4W4_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_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];
140 /* Start outer loop over neighborlists */
141 for(iidx=0; iidx<nri; iidx++)
143 /* Load shift vector for this list */
144 i_shift_offset = DIM*shiftidx[iidx];
145 shX = shiftvec[i_shift_offset+XX];
146 shY = shiftvec[i_shift_offset+YY];
147 shZ = shiftvec[i_shift_offset+ZZ];
149 /* Load limits for loop over neighbors */
150 j_index_start = jindex[iidx];
151 j_index_end = jindex[iidx+1];
153 /* Get outer coordinate index */
155 i_coord_offset = DIM*inr;
157 /* Load i particle coords and add shift vector */
158 ix1 = shX + x[i_coord_offset+DIM*1+XX];
159 iy1 = shY + x[i_coord_offset+DIM*1+YY];
160 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
161 ix2 = shX + x[i_coord_offset+DIM*2+XX];
162 iy2 = shY + x[i_coord_offset+DIM*2+YY];
163 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
164 ix3 = shX + x[i_coord_offset+DIM*3+XX];
165 iy3 = shY + x[i_coord_offset+DIM*3+YY];
166 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
178 /* Reset potential sums */
181 /* Start inner kernel loop */
182 for(jidx=j_index_start; jidx<j_index_end; jidx++)
184 /* Get j neighbor index, and coordinate index */
186 j_coord_offset = DIM*jnr;
188 /* load j atom coordinates */
189 jx1 = x[j_coord_offset+DIM*1+XX];
190 jy1 = x[j_coord_offset+DIM*1+YY];
191 jz1 = x[j_coord_offset+DIM*1+ZZ];
192 jx2 = x[j_coord_offset+DIM*2+XX];
193 jy2 = x[j_coord_offset+DIM*2+YY];
194 jz2 = x[j_coord_offset+DIM*2+ZZ];
195 jx3 = x[j_coord_offset+DIM*3+XX];
196 jy3 = x[j_coord_offset+DIM*3+YY];
197 jz3 = x[j_coord_offset+DIM*3+ZZ];
199 /* Calculate displacement vector */
228 /* Calculate squared distance and things based on it */
229 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
230 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
231 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
232 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
233 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
234 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
235 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
236 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
237 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
239 rinv11 = gmx_invsqrt(rsq11);
240 rinv12 = gmx_invsqrt(rsq12);
241 rinv13 = gmx_invsqrt(rsq13);
242 rinv21 = gmx_invsqrt(rsq21);
243 rinv22 = gmx_invsqrt(rsq22);
244 rinv23 = gmx_invsqrt(rsq23);
245 rinv31 = gmx_invsqrt(rsq31);
246 rinv32 = gmx_invsqrt(rsq32);
247 rinv33 = gmx_invsqrt(rsq33);
249 rinvsq11 = rinv11*rinv11;
250 rinvsq12 = rinv12*rinv12;
251 rinvsq13 = rinv13*rinv13;
252 rinvsq21 = rinv21*rinv21;
253 rinvsq22 = rinv22*rinv22;
254 rinvsq23 = rinv23*rinv23;
255 rinvsq31 = rinv31*rinv31;
256 rinvsq32 = rinv32*rinv32;
257 rinvsq33 = rinv33*rinv33;
259 /**************************
260 * CALCULATE INTERACTIONS *
261 **************************/
265 /* EWALD ELECTROSTATICS */
267 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
268 ewrt = r11*ewtabscale;
272 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
273 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
274 felec = qq11*rinv11*(rinvsq11-felec);
276 /* Update potential sums from outer loop */
281 /* Calculate temporary vectorial force */
286 /* Update vectorial force */
290 f[j_coord_offset+DIM*1+XX] -= tx;
291 f[j_coord_offset+DIM*1+YY] -= ty;
292 f[j_coord_offset+DIM*1+ZZ] -= tz;
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
300 /* EWALD ELECTROSTATICS */
302 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
303 ewrt = r12*ewtabscale;
307 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
308 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
309 felec = qq12*rinv12*(rinvsq12-felec);
311 /* Update potential sums from outer loop */
316 /* Calculate temporary vectorial force */
321 /* Update vectorial force */
325 f[j_coord_offset+DIM*2+XX] -= tx;
326 f[j_coord_offset+DIM*2+YY] -= ty;
327 f[j_coord_offset+DIM*2+ZZ] -= tz;
329 /**************************
330 * CALCULATE INTERACTIONS *
331 **************************/
335 /* EWALD ELECTROSTATICS */
337 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
338 ewrt = r13*ewtabscale;
342 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
343 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
344 felec = qq13*rinv13*(rinvsq13-felec);
346 /* Update potential sums from outer loop */
351 /* Calculate temporary vectorial force */
356 /* Update vectorial force */
360 f[j_coord_offset+DIM*3+XX] -= tx;
361 f[j_coord_offset+DIM*3+YY] -= ty;
362 f[j_coord_offset+DIM*3+ZZ] -= tz;
364 /**************************
365 * CALCULATE INTERACTIONS *
366 **************************/
370 /* EWALD ELECTROSTATICS */
372 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
373 ewrt = r21*ewtabscale;
377 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
378 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
379 felec = qq21*rinv21*(rinvsq21-felec);
381 /* Update potential sums from outer loop */
386 /* Calculate temporary vectorial force */
391 /* Update vectorial force */
395 f[j_coord_offset+DIM*1+XX] -= tx;
396 f[j_coord_offset+DIM*1+YY] -= ty;
397 f[j_coord_offset+DIM*1+ZZ] -= tz;
399 /**************************
400 * CALCULATE INTERACTIONS *
401 **************************/
405 /* EWALD ELECTROSTATICS */
407 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
408 ewrt = r22*ewtabscale;
412 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
413 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
414 felec = qq22*rinv22*(rinvsq22-felec);
416 /* Update potential sums from outer loop */
421 /* Calculate temporary vectorial force */
426 /* Update vectorial force */
430 f[j_coord_offset+DIM*2+XX] -= tx;
431 f[j_coord_offset+DIM*2+YY] -= ty;
432 f[j_coord_offset+DIM*2+ZZ] -= tz;
434 /**************************
435 * CALCULATE INTERACTIONS *
436 **************************/
440 /* EWALD ELECTROSTATICS */
442 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
443 ewrt = r23*ewtabscale;
447 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
448 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
449 felec = qq23*rinv23*(rinvsq23-felec);
451 /* Update potential sums from outer loop */
456 /* Calculate temporary vectorial force */
461 /* Update vectorial force */
465 f[j_coord_offset+DIM*3+XX] -= tx;
466 f[j_coord_offset+DIM*3+YY] -= ty;
467 f[j_coord_offset+DIM*3+ZZ] -= tz;
469 /**************************
470 * CALCULATE INTERACTIONS *
471 **************************/
475 /* EWALD ELECTROSTATICS */
477 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
478 ewrt = r31*ewtabscale;
482 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
483 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
484 felec = qq31*rinv31*(rinvsq31-felec);
486 /* Update potential sums from outer loop */
491 /* Calculate temporary vectorial force */
496 /* Update vectorial force */
500 f[j_coord_offset+DIM*1+XX] -= tx;
501 f[j_coord_offset+DIM*1+YY] -= ty;
502 f[j_coord_offset+DIM*1+ZZ] -= tz;
504 /**************************
505 * CALCULATE INTERACTIONS *
506 **************************/
510 /* EWALD ELECTROSTATICS */
512 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
513 ewrt = r32*ewtabscale;
517 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
518 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
519 felec = qq32*rinv32*(rinvsq32-felec);
521 /* Update potential sums from outer loop */
526 /* Calculate temporary vectorial force */
531 /* Update vectorial force */
535 f[j_coord_offset+DIM*2+XX] -= tx;
536 f[j_coord_offset+DIM*2+YY] -= ty;
537 f[j_coord_offset+DIM*2+ZZ] -= tz;
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
545 /* EWALD ELECTROSTATICS */
547 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
548 ewrt = r33*ewtabscale;
552 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
553 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
554 felec = qq33*rinv33*(rinvsq33-felec);
556 /* Update potential sums from outer loop */
561 /* Calculate temporary vectorial force */
566 /* Update vectorial force */
570 f[j_coord_offset+DIM*3+XX] -= tx;
571 f[j_coord_offset+DIM*3+YY] -= ty;
572 f[j_coord_offset+DIM*3+ZZ] -= tz;
574 /* Inner loop uses 360 flops */
576 /* End of innermost loop */
579 f[i_coord_offset+DIM*1+XX] += fix1;
580 f[i_coord_offset+DIM*1+YY] += fiy1;
581 f[i_coord_offset+DIM*1+ZZ] += fiz1;
585 f[i_coord_offset+DIM*2+XX] += fix2;
586 f[i_coord_offset+DIM*2+YY] += fiy2;
587 f[i_coord_offset+DIM*2+ZZ] += fiz2;
591 f[i_coord_offset+DIM*3+XX] += fix3;
592 f[i_coord_offset+DIM*3+YY] += fiy3;
593 f[i_coord_offset+DIM*3+ZZ] += fiz3;
597 fshift[i_shift_offset+XX] += tx;
598 fshift[i_shift_offset+YY] += ty;
599 fshift[i_shift_offset+ZZ] += tz;
602 /* Update potential energies */
603 kernel_data->energygrp_elec[ggid] += velecsum;
605 /* Increment number of inner iterations */
606 inneriter += j_index_end - j_index_start;
608 /* Outer loop uses 31 flops */
611 /* Increment number of outer iterations */
614 /* Update outer/inner flops */
616 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*31 + inneriter*360);
619 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW4W4_F_c
620 * Electrostatics interaction: Ewald
621 * VdW interaction: None
622 * Geometry: Water4-Water4
623 * Calculate force/pot: Force
626 nb_kernel_ElecEw_VdwNone_GeomW4W4_F_c
627 (t_nblist * gmx_restrict nlist,
628 rvec * gmx_restrict xx,
629 rvec * gmx_restrict ff,
630 t_forcerec * gmx_restrict fr,
631 t_mdatoms * gmx_restrict mdatoms,
632 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
633 t_nrnb * gmx_restrict nrnb)
635 int i_shift_offset,i_coord_offset,j_coord_offset;
636 int j_index_start,j_index_end;
637 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
638 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
639 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
640 real *shiftvec,*fshift,*x,*f;
642 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
644 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
646 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
648 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
650 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
652 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
653 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
654 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
655 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
656 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
657 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
658 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
659 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
660 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
661 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
662 real velec,felec,velecsum,facel,crf,krf,krf2;
665 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
673 jindex = nlist->jindex;
675 shiftidx = nlist->shift;
677 shiftvec = fr->shift_vec[0];
678 fshift = fr->fshift[0];
680 charge = mdatoms->chargeA;
682 sh_ewald = fr->ic->sh_ewald;
683 ewtab = fr->ic->tabq_coul_F;
684 ewtabscale = fr->ic->tabq_scale;
685 ewtabhalfspace = 0.5/ewtabscale;
687 /* Setup water-specific parameters */
688 inr = nlist->iinr[0];
689 iq1 = facel*charge[inr+1];
690 iq2 = facel*charge[inr+2];
691 iq3 = facel*charge[inr+3];
709 /* Start outer loop over neighborlists */
710 for(iidx=0; iidx<nri; iidx++)
712 /* Load shift vector for this list */
713 i_shift_offset = DIM*shiftidx[iidx];
714 shX = shiftvec[i_shift_offset+XX];
715 shY = shiftvec[i_shift_offset+YY];
716 shZ = shiftvec[i_shift_offset+ZZ];
718 /* Load limits for loop over neighbors */
719 j_index_start = jindex[iidx];
720 j_index_end = jindex[iidx+1];
722 /* Get outer coordinate index */
724 i_coord_offset = DIM*inr;
726 /* Load i particle coords and add shift vector */
727 ix1 = shX + x[i_coord_offset+DIM*1+XX];
728 iy1 = shY + x[i_coord_offset+DIM*1+YY];
729 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
730 ix2 = shX + x[i_coord_offset+DIM*2+XX];
731 iy2 = shY + x[i_coord_offset+DIM*2+YY];
732 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
733 ix3 = shX + x[i_coord_offset+DIM*3+XX];
734 iy3 = shY + x[i_coord_offset+DIM*3+YY];
735 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
747 /* Start inner kernel loop */
748 for(jidx=j_index_start; jidx<j_index_end; jidx++)
750 /* Get j neighbor index, and coordinate index */
752 j_coord_offset = DIM*jnr;
754 /* load j atom coordinates */
755 jx1 = x[j_coord_offset+DIM*1+XX];
756 jy1 = x[j_coord_offset+DIM*1+YY];
757 jz1 = x[j_coord_offset+DIM*1+ZZ];
758 jx2 = x[j_coord_offset+DIM*2+XX];
759 jy2 = x[j_coord_offset+DIM*2+YY];
760 jz2 = x[j_coord_offset+DIM*2+ZZ];
761 jx3 = x[j_coord_offset+DIM*3+XX];
762 jy3 = x[j_coord_offset+DIM*3+YY];
763 jz3 = x[j_coord_offset+DIM*3+ZZ];
765 /* Calculate displacement vector */
794 /* Calculate squared distance and things based on it */
795 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
796 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
797 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
798 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
799 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
800 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
801 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
802 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
803 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
805 rinv11 = gmx_invsqrt(rsq11);
806 rinv12 = gmx_invsqrt(rsq12);
807 rinv13 = gmx_invsqrt(rsq13);
808 rinv21 = gmx_invsqrt(rsq21);
809 rinv22 = gmx_invsqrt(rsq22);
810 rinv23 = gmx_invsqrt(rsq23);
811 rinv31 = gmx_invsqrt(rsq31);
812 rinv32 = gmx_invsqrt(rsq32);
813 rinv33 = gmx_invsqrt(rsq33);
815 rinvsq11 = rinv11*rinv11;
816 rinvsq12 = rinv12*rinv12;
817 rinvsq13 = rinv13*rinv13;
818 rinvsq21 = rinv21*rinv21;
819 rinvsq22 = rinv22*rinv22;
820 rinvsq23 = rinv23*rinv23;
821 rinvsq31 = rinv31*rinv31;
822 rinvsq32 = rinv32*rinv32;
823 rinvsq33 = rinv33*rinv33;
825 /**************************
826 * CALCULATE INTERACTIONS *
827 **************************/
831 /* EWALD ELECTROSTATICS */
833 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
834 ewrt = r11*ewtabscale;
837 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
838 felec = qq11*rinv11*(rinvsq11-felec);
842 /* Calculate temporary vectorial force */
847 /* Update vectorial force */
851 f[j_coord_offset+DIM*1+XX] -= tx;
852 f[j_coord_offset+DIM*1+YY] -= ty;
853 f[j_coord_offset+DIM*1+ZZ] -= tz;
855 /**************************
856 * CALCULATE INTERACTIONS *
857 **************************/
861 /* EWALD ELECTROSTATICS */
863 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
864 ewrt = r12*ewtabscale;
867 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
868 felec = qq12*rinv12*(rinvsq12-felec);
872 /* Calculate temporary vectorial force */
877 /* Update vectorial force */
881 f[j_coord_offset+DIM*2+XX] -= tx;
882 f[j_coord_offset+DIM*2+YY] -= ty;
883 f[j_coord_offset+DIM*2+ZZ] -= tz;
885 /**************************
886 * CALCULATE INTERACTIONS *
887 **************************/
891 /* EWALD ELECTROSTATICS */
893 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
894 ewrt = r13*ewtabscale;
897 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
898 felec = qq13*rinv13*(rinvsq13-felec);
902 /* Calculate temporary vectorial force */
907 /* Update vectorial force */
911 f[j_coord_offset+DIM*3+XX] -= tx;
912 f[j_coord_offset+DIM*3+YY] -= ty;
913 f[j_coord_offset+DIM*3+ZZ] -= tz;
915 /**************************
916 * CALCULATE INTERACTIONS *
917 **************************/
921 /* EWALD ELECTROSTATICS */
923 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
924 ewrt = r21*ewtabscale;
927 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
928 felec = qq21*rinv21*(rinvsq21-felec);
932 /* Calculate temporary vectorial force */
937 /* Update vectorial force */
941 f[j_coord_offset+DIM*1+XX] -= tx;
942 f[j_coord_offset+DIM*1+YY] -= ty;
943 f[j_coord_offset+DIM*1+ZZ] -= tz;
945 /**************************
946 * CALCULATE INTERACTIONS *
947 **************************/
951 /* EWALD ELECTROSTATICS */
953 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
954 ewrt = r22*ewtabscale;
957 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
958 felec = qq22*rinv22*(rinvsq22-felec);
962 /* Calculate temporary vectorial force */
967 /* Update vectorial force */
971 f[j_coord_offset+DIM*2+XX] -= tx;
972 f[j_coord_offset+DIM*2+YY] -= ty;
973 f[j_coord_offset+DIM*2+ZZ] -= tz;
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
981 /* EWALD ELECTROSTATICS */
983 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
984 ewrt = r23*ewtabscale;
987 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
988 felec = qq23*rinv23*(rinvsq23-felec);
992 /* Calculate temporary vectorial force */
997 /* Update vectorial force */
1001 f[j_coord_offset+DIM*3+XX] -= tx;
1002 f[j_coord_offset+DIM*3+YY] -= ty;
1003 f[j_coord_offset+DIM*3+ZZ] -= tz;
1005 /**************************
1006 * CALCULATE INTERACTIONS *
1007 **************************/
1011 /* EWALD ELECTROSTATICS */
1013 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1014 ewrt = r31*ewtabscale;
1016 eweps = ewrt-ewitab;
1017 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1018 felec = qq31*rinv31*(rinvsq31-felec);
1022 /* Calculate temporary vectorial force */
1027 /* Update vectorial force */
1031 f[j_coord_offset+DIM*1+XX] -= tx;
1032 f[j_coord_offset+DIM*1+YY] -= ty;
1033 f[j_coord_offset+DIM*1+ZZ] -= tz;
1035 /**************************
1036 * CALCULATE INTERACTIONS *
1037 **************************/
1041 /* EWALD ELECTROSTATICS */
1043 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1044 ewrt = r32*ewtabscale;
1046 eweps = ewrt-ewitab;
1047 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1048 felec = qq32*rinv32*(rinvsq32-felec);
1052 /* Calculate temporary vectorial force */
1057 /* Update vectorial force */
1061 f[j_coord_offset+DIM*2+XX] -= tx;
1062 f[j_coord_offset+DIM*2+YY] -= ty;
1063 f[j_coord_offset+DIM*2+ZZ] -= tz;
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1071 /* EWALD ELECTROSTATICS */
1073 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1074 ewrt = r33*ewtabscale;
1076 eweps = ewrt-ewitab;
1077 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1078 felec = qq33*rinv33*(rinvsq33-felec);
1082 /* Calculate temporary vectorial force */
1087 /* Update vectorial force */
1091 f[j_coord_offset+DIM*3+XX] -= tx;
1092 f[j_coord_offset+DIM*3+YY] -= ty;
1093 f[j_coord_offset+DIM*3+ZZ] -= tz;
1095 /* Inner loop uses 297 flops */
1097 /* End of innermost loop */
1100 f[i_coord_offset+DIM*1+XX] += fix1;
1101 f[i_coord_offset+DIM*1+YY] += fiy1;
1102 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1106 f[i_coord_offset+DIM*2+XX] += fix2;
1107 f[i_coord_offset+DIM*2+YY] += fiy2;
1108 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1112 f[i_coord_offset+DIM*3+XX] += fix3;
1113 f[i_coord_offset+DIM*3+YY] += fiy3;
1114 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1118 fshift[i_shift_offset+XX] += tx;
1119 fshift[i_shift_offset+YY] += ty;
1120 fshift[i_shift_offset+ZZ] += tz;
1122 /* Increment number of inner iterations */
1123 inneriter += j_index_end - j_index_start;
1125 /* Outer loop uses 30 flops */
1128 /* Increment number of outer iterations */
1131 /* Update outer/inner flops */
1133 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*30 + inneriter*297);