2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW4W4_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: None
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwNone_GeomW4W4_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
59 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
61 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
63 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
65 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
67 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
68 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
69 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
70 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
71 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
72 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
73 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
74 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
75 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
76 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
77 real velec,felec,velecsum,facel,crf,krf,krf2;
80 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
88 jindex = nlist->jindex;
90 shiftidx = nlist->shift;
92 shiftvec = fr->shift_vec[0];
93 fshift = fr->fshift[0];
95 charge = mdatoms->chargeA;
97 sh_ewald = fr->ic->sh_ewald;
98 ewtab = fr->ic->tabq_coul_FDV0;
99 ewtabscale = fr->ic->tabq_scale;
100 ewtabhalfspace = 0.5/ewtabscale;
102 /* Setup water-specific parameters */
103 inr = nlist->iinr[0];
104 iq1 = facel*charge[inr+1];
105 iq2 = facel*charge[inr+2];
106 iq3 = facel*charge[inr+3];
124 /* Start outer loop over neighborlists */
125 for(iidx=0; iidx<nri; iidx++)
127 /* Load shift vector for this list */
128 i_shift_offset = DIM*shiftidx[iidx];
129 shX = shiftvec[i_shift_offset+XX];
130 shY = shiftvec[i_shift_offset+YY];
131 shZ = shiftvec[i_shift_offset+ZZ];
133 /* Load limits for loop over neighbors */
134 j_index_start = jindex[iidx];
135 j_index_end = jindex[iidx+1];
137 /* Get outer coordinate index */
139 i_coord_offset = DIM*inr;
141 /* Load i particle coords and add shift vector */
142 ix1 = shX + x[i_coord_offset+DIM*1+XX];
143 iy1 = shY + x[i_coord_offset+DIM*1+YY];
144 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
145 ix2 = shX + x[i_coord_offset+DIM*2+XX];
146 iy2 = shY + x[i_coord_offset+DIM*2+YY];
147 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
148 ix3 = shX + x[i_coord_offset+DIM*3+XX];
149 iy3 = shY + x[i_coord_offset+DIM*3+YY];
150 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
162 /* Reset potential sums */
165 /* Start inner kernel loop */
166 for(jidx=j_index_start; jidx<j_index_end; jidx++)
168 /* Get j neighbor index, and coordinate index */
170 j_coord_offset = DIM*jnr;
172 /* load j atom coordinates */
173 jx1 = x[j_coord_offset+DIM*1+XX];
174 jy1 = x[j_coord_offset+DIM*1+YY];
175 jz1 = x[j_coord_offset+DIM*1+ZZ];
176 jx2 = x[j_coord_offset+DIM*2+XX];
177 jy2 = x[j_coord_offset+DIM*2+YY];
178 jz2 = x[j_coord_offset+DIM*2+ZZ];
179 jx3 = x[j_coord_offset+DIM*3+XX];
180 jy3 = x[j_coord_offset+DIM*3+YY];
181 jz3 = x[j_coord_offset+DIM*3+ZZ];
183 /* Calculate displacement vector */
212 /* Calculate squared distance and things based on it */
213 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
214 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
215 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
216 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
217 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
218 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
219 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
220 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
221 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
223 rinv11 = gmx_invsqrt(rsq11);
224 rinv12 = gmx_invsqrt(rsq12);
225 rinv13 = gmx_invsqrt(rsq13);
226 rinv21 = gmx_invsqrt(rsq21);
227 rinv22 = gmx_invsqrt(rsq22);
228 rinv23 = gmx_invsqrt(rsq23);
229 rinv31 = gmx_invsqrt(rsq31);
230 rinv32 = gmx_invsqrt(rsq32);
231 rinv33 = gmx_invsqrt(rsq33);
233 rinvsq11 = rinv11*rinv11;
234 rinvsq12 = rinv12*rinv12;
235 rinvsq13 = rinv13*rinv13;
236 rinvsq21 = rinv21*rinv21;
237 rinvsq22 = rinv22*rinv22;
238 rinvsq23 = rinv23*rinv23;
239 rinvsq31 = rinv31*rinv31;
240 rinvsq32 = rinv32*rinv32;
241 rinvsq33 = rinv33*rinv33;
243 /**************************
244 * CALCULATE INTERACTIONS *
245 **************************/
249 /* EWALD ELECTROSTATICS */
251 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
252 ewrt = r11*ewtabscale;
256 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
257 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
258 felec = qq11*rinv11*(rinvsq11-felec);
260 /* Update potential sums from outer loop */
265 /* Calculate temporary vectorial force */
270 /* Update vectorial force */
274 f[j_coord_offset+DIM*1+XX] -= tx;
275 f[j_coord_offset+DIM*1+YY] -= ty;
276 f[j_coord_offset+DIM*1+ZZ] -= tz;
278 /**************************
279 * CALCULATE INTERACTIONS *
280 **************************/
284 /* EWALD ELECTROSTATICS */
286 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
287 ewrt = r12*ewtabscale;
291 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
292 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
293 felec = qq12*rinv12*(rinvsq12-felec);
295 /* Update potential sums from outer loop */
300 /* Calculate temporary vectorial force */
305 /* Update vectorial force */
309 f[j_coord_offset+DIM*2+XX] -= tx;
310 f[j_coord_offset+DIM*2+YY] -= ty;
311 f[j_coord_offset+DIM*2+ZZ] -= tz;
313 /**************************
314 * CALCULATE INTERACTIONS *
315 **************************/
319 /* EWALD ELECTROSTATICS */
321 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
322 ewrt = r13*ewtabscale;
326 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
327 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
328 felec = qq13*rinv13*(rinvsq13-felec);
330 /* Update potential sums from outer loop */
335 /* Calculate temporary vectorial force */
340 /* Update vectorial force */
344 f[j_coord_offset+DIM*3+XX] -= tx;
345 f[j_coord_offset+DIM*3+YY] -= ty;
346 f[j_coord_offset+DIM*3+ZZ] -= tz;
348 /**************************
349 * CALCULATE INTERACTIONS *
350 **************************/
354 /* EWALD ELECTROSTATICS */
356 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
357 ewrt = r21*ewtabscale;
361 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
362 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
363 felec = qq21*rinv21*(rinvsq21-felec);
365 /* Update potential sums from outer loop */
370 /* Calculate temporary vectorial force */
375 /* Update vectorial force */
379 f[j_coord_offset+DIM*1+XX] -= tx;
380 f[j_coord_offset+DIM*1+YY] -= ty;
381 f[j_coord_offset+DIM*1+ZZ] -= tz;
383 /**************************
384 * CALCULATE INTERACTIONS *
385 **************************/
389 /* EWALD ELECTROSTATICS */
391 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
392 ewrt = r22*ewtabscale;
396 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
397 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
398 felec = qq22*rinv22*(rinvsq22-felec);
400 /* Update potential sums from outer loop */
405 /* Calculate temporary vectorial force */
410 /* Update vectorial force */
414 f[j_coord_offset+DIM*2+XX] -= tx;
415 f[j_coord_offset+DIM*2+YY] -= ty;
416 f[j_coord_offset+DIM*2+ZZ] -= tz;
418 /**************************
419 * CALCULATE INTERACTIONS *
420 **************************/
424 /* EWALD ELECTROSTATICS */
426 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
427 ewrt = r23*ewtabscale;
431 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
432 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
433 felec = qq23*rinv23*(rinvsq23-felec);
435 /* Update potential sums from outer loop */
440 /* Calculate temporary vectorial force */
445 /* Update vectorial force */
449 f[j_coord_offset+DIM*3+XX] -= tx;
450 f[j_coord_offset+DIM*3+YY] -= ty;
451 f[j_coord_offset+DIM*3+ZZ] -= tz;
453 /**************************
454 * CALCULATE INTERACTIONS *
455 **************************/
459 /* EWALD ELECTROSTATICS */
461 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
462 ewrt = r31*ewtabscale;
466 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
467 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
468 felec = qq31*rinv31*(rinvsq31-felec);
470 /* Update potential sums from outer loop */
475 /* Calculate temporary vectorial force */
480 /* Update vectorial force */
484 f[j_coord_offset+DIM*1+XX] -= tx;
485 f[j_coord_offset+DIM*1+YY] -= ty;
486 f[j_coord_offset+DIM*1+ZZ] -= tz;
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
494 /* EWALD ELECTROSTATICS */
496 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
497 ewrt = r32*ewtabscale;
501 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
502 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
503 felec = qq32*rinv32*(rinvsq32-felec);
505 /* Update potential sums from outer loop */
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*2+XX] -= tx;
520 f[j_coord_offset+DIM*2+YY] -= ty;
521 f[j_coord_offset+DIM*2+ZZ] -= tz;
523 /**************************
524 * CALCULATE INTERACTIONS *
525 **************************/
529 /* EWALD ELECTROSTATICS */
531 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
532 ewrt = r33*ewtabscale;
536 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
537 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
538 felec = qq33*rinv33*(rinvsq33-felec);
540 /* Update potential sums from outer loop */
545 /* Calculate temporary vectorial force */
550 /* Update vectorial force */
554 f[j_coord_offset+DIM*3+XX] -= tx;
555 f[j_coord_offset+DIM*3+YY] -= ty;
556 f[j_coord_offset+DIM*3+ZZ] -= tz;
558 /* Inner loop uses 360 flops */
560 /* End of innermost loop */
563 f[i_coord_offset+DIM*1+XX] += fix1;
564 f[i_coord_offset+DIM*1+YY] += fiy1;
565 f[i_coord_offset+DIM*1+ZZ] += fiz1;
569 f[i_coord_offset+DIM*2+XX] += fix2;
570 f[i_coord_offset+DIM*2+YY] += fiy2;
571 f[i_coord_offset+DIM*2+ZZ] += fiz2;
575 f[i_coord_offset+DIM*3+XX] += fix3;
576 f[i_coord_offset+DIM*3+YY] += fiy3;
577 f[i_coord_offset+DIM*3+ZZ] += fiz3;
581 fshift[i_shift_offset+XX] += tx;
582 fshift[i_shift_offset+YY] += ty;
583 fshift[i_shift_offset+ZZ] += tz;
586 /* Update potential energies */
587 kernel_data->energygrp_elec[ggid] += velecsum;
589 /* Increment number of inner iterations */
590 inneriter += j_index_end - j_index_start;
592 /* Outer loop uses 31 flops */
595 /* Increment number of outer iterations */
598 /* Update outer/inner flops */
600 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*31 + inneriter*360);
603 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW4W4_F_c
604 * Electrostatics interaction: Ewald
605 * VdW interaction: None
606 * Geometry: Water4-Water4
607 * Calculate force/pot: Force
610 nb_kernel_ElecEw_VdwNone_GeomW4W4_F_c
611 (t_nblist * gmx_restrict nlist,
612 rvec * gmx_restrict xx,
613 rvec * gmx_restrict ff,
614 t_forcerec * gmx_restrict fr,
615 t_mdatoms * gmx_restrict mdatoms,
616 nb_kernel_data_t * gmx_restrict kernel_data,
617 t_nrnb * gmx_restrict nrnb)
619 int i_shift_offset,i_coord_offset,j_coord_offset;
620 int j_index_start,j_index_end;
621 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
622 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
623 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
624 real *shiftvec,*fshift,*x,*f;
626 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
628 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
630 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
632 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
634 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
636 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
637 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
638 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
639 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
640 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
641 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
642 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
643 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
644 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
645 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
646 real velec,felec,velecsum,facel,crf,krf,krf2;
649 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
657 jindex = nlist->jindex;
659 shiftidx = nlist->shift;
661 shiftvec = fr->shift_vec[0];
662 fshift = fr->fshift[0];
664 charge = mdatoms->chargeA;
666 sh_ewald = fr->ic->sh_ewald;
667 ewtab = fr->ic->tabq_coul_F;
668 ewtabscale = fr->ic->tabq_scale;
669 ewtabhalfspace = 0.5/ewtabscale;
671 /* Setup water-specific parameters */
672 inr = nlist->iinr[0];
673 iq1 = facel*charge[inr+1];
674 iq2 = facel*charge[inr+2];
675 iq3 = facel*charge[inr+3];
693 /* Start outer loop over neighborlists */
694 for(iidx=0; iidx<nri; iidx++)
696 /* Load shift vector for this list */
697 i_shift_offset = DIM*shiftidx[iidx];
698 shX = shiftvec[i_shift_offset+XX];
699 shY = shiftvec[i_shift_offset+YY];
700 shZ = shiftvec[i_shift_offset+ZZ];
702 /* Load limits for loop over neighbors */
703 j_index_start = jindex[iidx];
704 j_index_end = jindex[iidx+1];
706 /* Get outer coordinate index */
708 i_coord_offset = DIM*inr;
710 /* Load i particle coords and add shift vector */
711 ix1 = shX + x[i_coord_offset+DIM*1+XX];
712 iy1 = shY + x[i_coord_offset+DIM*1+YY];
713 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
714 ix2 = shX + x[i_coord_offset+DIM*2+XX];
715 iy2 = shY + x[i_coord_offset+DIM*2+YY];
716 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
717 ix3 = shX + x[i_coord_offset+DIM*3+XX];
718 iy3 = shY + x[i_coord_offset+DIM*3+YY];
719 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
731 /* Start inner kernel loop */
732 for(jidx=j_index_start; jidx<j_index_end; jidx++)
734 /* Get j neighbor index, and coordinate index */
736 j_coord_offset = DIM*jnr;
738 /* load j atom coordinates */
739 jx1 = x[j_coord_offset+DIM*1+XX];
740 jy1 = x[j_coord_offset+DIM*1+YY];
741 jz1 = x[j_coord_offset+DIM*1+ZZ];
742 jx2 = x[j_coord_offset+DIM*2+XX];
743 jy2 = x[j_coord_offset+DIM*2+YY];
744 jz2 = x[j_coord_offset+DIM*2+ZZ];
745 jx3 = x[j_coord_offset+DIM*3+XX];
746 jy3 = x[j_coord_offset+DIM*3+YY];
747 jz3 = x[j_coord_offset+DIM*3+ZZ];
749 /* Calculate displacement vector */
778 /* Calculate squared distance and things based on it */
779 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
780 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
781 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
782 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
783 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
784 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
785 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
786 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
787 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
789 rinv11 = gmx_invsqrt(rsq11);
790 rinv12 = gmx_invsqrt(rsq12);
791 rinv13 = gmx_invsqrt(rsq13);
792 rinv21 = gmx_invsqrt(rsq21);
793 rinv22 = gmx_invsqrt(rsq22);
794 rinv23 = gmx_invsqrt(rsq23);
795 rinv31 = gmx_invsqrt(rsq31);
796 rinv32 = gmx_invsqrt(rsq32);
797 rinv33 = gmx_invsqrt(rsq33);
799 rinvsq11 = rinv11*rinv11;
800 rinvsq12 = rinv12*rinv12;
801 rinvsq13 = rinv13*rinv13;
802 rinvsq21 = rinv21*rinv21;
803 rinvsq22 = rinv22*rinv22;
804 rinvsq23 = rinv23*rinv23;
805 rinvsq31 = rinv31*rinv31;
806 rinvsq32 = rinv32*rinv32;
807 rinvsq33 = rinv33*rinv33;
809 /**************************
810 * CALCULATE INTERACTIONS *
811 **************************/
815 /* EWALD ELECTROSTATICS */
817 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
818 ewrt = r11*ewtabscale;
821 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
822 felec = qq11*rinv11*(rinvsq11-felec);
826 /* Calculate temporary vectorial force */
831 /* Update vectorial force */
835 f[j_coord_offset+DIM*1+XX] -= tx;
836 f[j_coord_offset+DIM*1+YY] -= ty;
837 f[j_coord_offset+DIM*1+ZZ] -= tz;
839 /**************************
840 * CALCULATE INTERACTIONS *
841 **************************/
845 /* EWALD ELECTROSTATICS */
847 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
848 ewrt = r12*ewtabscale;
851 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
852 felec = qq12*rinv12*(rinvsq12-felec);
856 /* Calculate temporary vectorial force */
861 /* Update vectorial force */
865 f[j_coord_offset+DIM*2+XX] -= tx;
866 f[j_coord_offset+DIM*2+YY] -= ty;
867 f[j_coord_offset+DIM*2+ZZ] -= tz;
869 /**************************
870 * CALCULATE INTERACTIONS *
871 **************************/
875 /* EWALD ELECTROSTATICS */
877 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
878 ewrt = r13*ewtabscale;
881 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
882 felec = qq13*rinv13*(rinvsq13-felec);
886 /* Calculate temporary vectorial force */
891 /* Update vectorial force */
895 f[j_coord_offset+DIM*3+XX] -= tx;
896 f[j_coord_offset+DIM*3+YY] -= ty;
897 f[j_coord_offset+DIM*3+ZZ] -= tz;
899 /**************************
900 * CALCULATE INTERACTIONS *
901 **************************/
905 /* EWALD ELECTROSTATICS */
907 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
908 ewrt = r21*ewtabscale;
911 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
912 felec = qq21*rinv21*(rinvsq21-felec);
916 /* Calculate temporary vectorial force */
921 /* Update vectorial force */
925 f[j_coord_offset+DIM*1+XX] -= tx;
926 f[j_coord_offset+DIM*1+YY] -= ty;
927 f[j_coord_offset+DIM*1+ZZ] -= tz;
929 /**************************
930 * CALCULATE INTERACTIONS *
931 **************************/
935 /* EWALD ELECTROSTATICS */
937 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
938 ewrt = r22*ewtabscale;
941 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
942 felec = qq22*rinv22*(rinvsq22-felec);
946 /* Calculate temporary vectorial force */
951 /* Update vectorial force */
955 f[j_coord_offset+DIM*2+XX] -= tx;
956 f[j_coord_offset+DIM*2+YY] -= ty;
957 f[j_coord_offset+DIM*2+ZZ] -= tz;
959 /**************************
960 * CALCULATE INTERACTIONS *
961 **************************/
965 /* EWALD ELECTROSTATICS */
967 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
968 ewrt = r23*ewtabscale;
971 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
972 felec = qq23*rinv23*(rinvsq23-felec);
976 /* Calculate temporary vectorial force */
981 /* Update vectorial force */
985 f[j_coord_offset+DIM*3+XX] -= tx;
986 f[j_coord_offset+DIM*3+YY] -= ty;
987 f[j_coord_offset+DIM*3+ZZ] -= tz;
989 /**************************
990 * CALCULATE INTERACTIONS *
991 **************************/
995 /* EWALD ELECTROSTATICS */
997 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
998 ewrt = r31*ewtabscale;
1000 eweps = ewrt-ewitab;
1001 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1002 felec = qq31*rinv31*(rinvsq31-felec);
1006 /* Calculate temporary vectorial force */
1011 /* Update vectorial force */
1015 f[j_coord_offset+DIM*1+XX] -= tx;
1016 f[j_coord_offset+DIM*1+YY] -= ty;
1017 f[j_coord_offset+DIM*1+ZZ] -= tz;
1019 /**************************
1020 * CALCULATE INTERACTIONS *
1021 **************************/
1025 /* EWALD ELECTROSTATICS */
1027 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1028 ewrt = r32*ewtabscale;
1030 eweps = ewrt-ewitab;
1031 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1032 felec = qq32*rinv32*(rinvsq32-felec);
1036 /* Calculate temporary vectorial force */
1041 /* Update vectorial force */
1045 f[j_coord_offset+DIM*2+XX] -= tx;
1046 f[j_coord_offset+DIM*2+YY] -= ty;
1047 f[j_coord_offset+DIM*2+ZZ] -= tz;
1049 /**************************
1050 * CALCULATE INTERACTIONS *
1051 **************************/
1055 /* EWALD ELECTROSTATICS */
1057 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1058 ewrt = r33*ewtabscale;
1060 eweps = ewrt-ewitab;
1061 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1062 felec = qq33*rinv33*(rinvsq33-felec);
1066 /* Calculate temporary vectorial force */
1071 /* Update vectorial force */
1075 f[j_coord_offset+DIM*3+XX] -= tx;
1076 f[j_coord_offset+DIM*3+YY] -= ty;
1077 f[j_coord_offset+DIM*3+ZZ] -= tz;
1079 /* Inner loop uses 297 flops */
1081 /* End of innermost loop */
1084 f[i_coord_offset+DIM*1+XX] += fix1;
1085 f[i_coord_offset+DIM*1+YY] += fiy1;
1086 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1090 f[i_coord_offset+DIM*2+XX] += fix2;
1091 f[i_coord_offset+DIM*2+YY] += fiy2;
1092 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1096 f[i_coord_offset+DIM*3+XX] += fix3;
1097 f[i_coord_offset+DIM*3+YY] += fiy3;
1098 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1102 fshift[i_shift_offset+XX] += tx;
1103 fshift[i_shift_offset+YY] += ty;
1104 fshift[i_shift_offset+ZZ] += tz;
1106 /* Increment number of inner iterations */
1107 inneriter += j_index_end - j_index_start;
1109 /* Outer loop uses 30 flops */
1112 /* Increment number of outer iterations */
1115 /* Update outer/inner flops */
1117 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*30 + inneriter*297);