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_GeomW3W3_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: None
37 * Geometry: Water3-Water3
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwNone_GeomW3W3_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
65 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
67 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
68 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
69 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
70 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
71 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
72 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
73 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
74 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
75 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
76 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
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 iq0 = facel*charge[inr+0];
105 iq1 = facel*charge[inr+1];
106 iq2 = facel*charge[inr+2];
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 ix0 = shX + x[i_coord_offset+DIM*0+XX];
143 iy0 = shY + x[i_coord_offset+DIM*0+YY];
144 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
145 ix1 = shX + x[i_coord_offset+DIM*1+XX];
146 iy1 = shY + x[i_coord_offset+DIM*1+YY];
147 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
148 ix2 = shX + x[i_coord_offset+DIM*2+XX];
149 iy2 = shY + x[i_coord_offset+DIM*2+YY];
150 iz2 = shZ + x[i_coord_offset+DIM*2+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 jx0 = x[j_coord_offset+DIM*0+XX];
174 jy0 = x[j_coord_offset+DIM*0+YY];
175 jz0 = x[j_coord_offset+DIM*0+ZZ];
176 jx1 = x[j_coord_offset+DIM*1+XX];
177 jy1 = x[j_coord_offset+DIM*1+YY];
178 jz1 = x[j_coord_offset+DIM*1+ZZ];
179 jx2 = x[j_coord_offset+DIM*2+XX];
180 jy2 = x[j_coord_offset+DIM*2+YY];
181 jz2 = x[j_coord_offset+DIM*2+ZZ];
183 /* Calculate displacement vector */
212 /* Calculate squared distance and things based on it */
213 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
214 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
215 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
216 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
217 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
218 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
219 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
220 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
221 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
223 rinv00 = gmx_invsqrt(rsq00);
224 rinv01 = gmx_invsqrt(rsq01);
225 rinv02 = gmx_invsqrt(rsq02);
226 rinv10 = gmx_invsqrt(rsq10);
227 rinv11 = gmx_invsqrt(rsq11);
228 rinv12 = gmx_invsqrt(rsq12);
229 rinv20 = gmx_invsqrt(rsq20);
230 rinv21 = gmx_invsqrt(rsq21);
231 rinv22 = gmx_invsqrt(rsq22);
233 rinvsq00 = rinv00*rinv00;
234 rinvsq01 = rinv01*rinv01;
235 rinvsq02 = rinv02*rinv02;
236 rinvsq10 = rinv10*rinv10;
237 rinvsq11 = rinv11*rinv11;
238 rinvsq12 = rinv12*rinv12;
239 rinvsq20 = rinv20*rinv20;
240 rinvsq21 = rinv21*rinv21;
241 rinvsq22 = rinv22*rinv22;
243 /**************************
244 * CALCULATE INTERACTIONS *
245 **************************/
249 /* EWALD ELECTROSTATICS */
251 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
252 ewrt = r00*ewtabscale;
256 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
257 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
258 felec = qq00*rinv00*(rinvsq00-felec);
260 /* Update potential sums from outer loop */
265 /* Calculate temporary vectorial force */
270 /* Update vectorial force */
274 f[j_coord_offset+DIM*0+XX] -= tx;
275 f[j_coord_offset+DIM*0+YY] -= ty;
276 f[j_coord_offset+DIM*0+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 = r01*ewtabscale;
291 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
292 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
293 felec = qq01*rinv01*(rinvsq01-felec);
295 /* Update potential sums from outer loop */
300 /* Calculate temporary vectorial force */
305 /* Update vectorial force */
309 f[j_coord_offset+DIM*1+XX] -= tx;
310 f[j_coord_offset+DIM*1+YY] -= ty;
311 f[j_coord_offset+DIM*1+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 = r02*ewtabscale;
326 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
327 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
328 felec = qq02*rinv02*(rinvsq02-felec);
330 /* Update potential sums from outer loop */
335 /* Calculate temporary vectorial force */
340 /* Update vectorial force */
344 f[j_coord_offset+DIM*2+XX] -= tx;
345 f[j_coord_offset+DIM*2+YY] -= ty;
346 f[j_coord_offset+DIM*2+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 = r10*ewtabscale;
361 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
362 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
363 felec = qq10*rinv10*(rinvsq10-felec);
365 /* Update potential sums from outer loop */
370 /* Calculate temporary vectorial force */
375 /* Update vectorial force */
379 f[j_coord_offset+DIM*0+XX] -= tx;
380 f[j_coord_offset+DIM*0+YY] -= ty;
381 f[j_coord_offset+DIM*0+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 = r11*ewtabscale;
396 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
397 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
398 felec = qq11*rinv11*(rinvsq11-felec);
400 /* Update potential sums from outer loop */
405 /* Calculate temporary vectorial force */
410 /* Update vectorial force */
414 f[j_coord_offset+DIM*1+XX] -= tx;
415 f[j_coord_offset+DIM*1+YY] -= ty;
416 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
431 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
432 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
433 felec = qq12*rinv12*(rinvsq12-felec);
435 /* Update potential sums from outer loop */
440 /* Calculate temporary vectorial force */
445 /* Update vectorial force */
449 f[j_coord_offset+DIM*2+XX] -= tx;
450 f[j_coord_offset+DIM*2+YY] -= ty;
451 f[j_coord_offset+DIM*2+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 = r20*ewtabscale;
466 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
467 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
468 felec = qq20*rinv20*(rinvsq20-felec);
470 /* Update potential sums from outer loop */
475 /* Calculate temporary vectorial force */
480 /* Update vectorial force */
484 f[j_coord_offset+DIM*0+XX] -= tx;
485 f[j_coord_offset+DIM*0+YY] -= ty;
486 f[j_coord_offset+DIM*0+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 = r21*ewtabscale;
501 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
502 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
503 felec = qq21*rinv21*(rinvsq21-felec);
505 /* Update potential sums from outer loop */
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*1+XX] -= tx;
520 f[j_coord_offset+DIM*1+YY] -= ty;
521 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
536 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
537 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
538 felec = qq22*rinv22*(rinvsq22-felec);
540 /* Update potential sums from outer loop */
545 /* Calculate temporary vectorial force */
550 /* Update vectorial force */
554 f[j_coord_offset+DIM*2+XX] -= tx;
555 f[j_coord_offset+DIM*2+YY] -= ty;
556 f[j_coord_offset+DIM*2+ZZ] -= tz;
558 /* Inner loop uses 360 flops */
560 /* End of innermost loop */
563 f[i_coord_offset+DIM*0+XX] += fix0;
564 f[i_coord_offset+DIM*0+YY] += fiy0;
565 f[i_coord_offset+DIM*0+ZZ] += fiz0;
569 f[i_coord_offset+DIM*1+XX] += fix1;
570 f[i_coord_offset+DIM*1+YY] += fiy1;
571 f[i_coord_offset+DIM*1+ZZ] += fiz1;
575 f[i_coord_offset+DIM*2+XX] += fix2;
576 f[i_coord_offset+DIM*2+YY] += fiy2;
577 f[i_coord_offset+DIM*2+ZZ] += fiz2;
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_W3W3_VF,outeriter*31 + inneriter*360);
603 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW3W3_F_c
604 * Electrostatics interaction: Ewald
605 * VdW interaction: None
606 * Geometry: Water3-Water3
607 * Calculate force/pot: Force
610 nb_kernel_ElecEw_VdwNone_GeomW3W3_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
628 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
630 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
632 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
634 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
636 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
637 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
638 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
639 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
640 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
641 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
642 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
643 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
644 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
645 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
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 iq0 = facel*charge[inr+0];
674 iq1 = facel*charge[inr+1];
675 iq2 = facel*charge[inr+2];
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 ix0 = shX + x[i_coord_offset+DIM*0+XX];
712 iy0 = shY + x[i_coord_offset+DIM*0+YY];
713 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
714 ix1 = shX + x[i_coord_offset+DIM*1+XX];
715 iy1 = shY + x[i_coord_offset+DIM*1+YY];
716 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
717 ix2 = shX + x[i_coord_offset+DIM*2+XX];
718 iy2 = shY + x[i_coord_offset+DIM*2+YY];
719 iz2 = shZ + x[i_coord_offset+DIM*2+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 jx0 = x[j_coord_offset+DIM*0+XX];
740 jy0 = x[j_coord_offset+DIM*0+YY];
741 jz0 = x[j_coord_offset+DIM*0+ZZ];
742 jx1 = x[j_coord_offset+DIM*1+XX];
743 jy1 = x[j_coord_offset+DIM*1+YY];
744 jz1 = x[j_coord_offset+DIM*1+ZZ];
745 jx2 = x[j_coord_offset+DIM*2+XX];
746 jy2 = x[j_coord_offset+DIM*2+YY];
747 jz2 = x[j_coord_offset+DIM*2+ZZ];
749 /* Calculate displacement vector */
778 /* Calculate squared distance and things based on it */
779 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
780 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
781 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
782 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
783 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
784 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
785 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
786 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
787 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
789 rinv00 = gmx_invsqrt(rsq00);
790 rinv01 = gmx_invsqrt(rsq01);
791 rinv02 = gmx_invsqrt(rsq02);
792 rinv10 = gmx_invsqrt(rsq10);
793 rinv11 = gmx_invsqrt(rsq11);
794 rinv12 = gmx_invsqrt(rsq12);
795 rinv20 = gmx_invsqrt(rsq20);
796 rinv21 = gmx_invsqrt(rsq21);
797 rinv22 = gmx_invsqrt(rsq22);
799 rinvsq00 = rinv00*rinv00;
800 rinvsq01 = rinv01*rinv01;
801 rinvsq02 = rinv02*rinv02;
802 rinvsq10 = rinv10*rinv10;
803 rinvsq11 = rinv11*rinv11;
804 rinvsq12 = rinv12*rinv12;
805 rinvsq20 = rinv20*rinv20;
806 rinvsq21 = rinv21*rinv21;
807 rinvsq22 = rinv22*rinv22;
809 /**************************
810 * CALCULATE INTERACTIONS *
811 **************************/
815 /* EWALD ELECTROSTATICS */
817 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
818 ewrt = r00*ewtabscale;
821 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
822 felec = qq00*rinv00*(rinvsq00-felec);
826 /* Calculate temporary vectorial force */
831 /* Update vectorial force */
835 f[j_coord_offset+DIM*0+XX] -= tx;
836 f[j_coord_offset+DIM*0+YY] -= ty;
837 f[j_coord_offset+DIM*0+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 = r01*ewtabscale;
851 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
852 felec = qq01*rinv01*(rinvsq01-felec);
856 /* Calculate temporary vectorial force */
861 /* Update vectorial force */
865 f[j_coord_offset+DIM*1+XX] -= tx;
866 f[j_coord_offset+DIM*1+YY] -= ty;
867 f[j_coord_offset+DIM*1+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 = r02*ewtabscale;
881 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
882 felec = qq02*rinv02*(rinvsq02-felec);
886 /* Calculate temporary vectorial force */
891 /* Update vectorial force */
895 f[j_coord_offset+DIM*2+XX] -= tx;
896 f[j_coord_offset+DIM*2+YY] -= ty;
897 f[j_coord_offset+DIM*2+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 = r10*ewtabscale;
911 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
912 felec = qq10*rinv10*(rinvsq10-felec);
916 /* Calculate temporary vectorial force */
921 /* Update vectorial force */
925 f[j_coord_offset+DIM*0+XX] -= tx;
926 f[j_coord_offset+DIM*0+YY] -= ty;
927 f[j_coord_offset+DIM*0+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 = r11*ewtabscale;
941 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
942 felec = qq11*rinv11*(rinvsq11-felec);
946 /* Calculate temporary vectorial force */
951 /* Update vectorial force */
955 f[j_coord_offset+DIM*1+XX] -= tx;
956 f[j_coord_offset+DIM*1+YY] -= ty;
957 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
971 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
972 felec = qq12*rinv12*(rinvsq12-felec);
976 /* Calculate temporary vectorial force */
981 /* Update vectorial force */
985 f[j_coord_offset+DIM*2+XX] -= tx;
986 f[j_coord_offset+DIM*2+YY] -= ty;
987 f[j_coord_offset+DIM*2+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 = r20*ewtabscale;
1000 eweps = ewrt-ewitab;
1001 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1002 felec = qq20*rinv20*(rinvsq20-felec);
1006 /* Calculate temporary vectorial force */
1011 /* Update vectorial force */
1015 f[j_coord_offset+DIM*0+XX] -= tx;
1016 f[j_coord_offset+DIM*0+YY] -= ty;
1017 f[j_coord_offset+DIM*0+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 = r21*ewtabscale;
1030 eweps = ewrt-ewitab;
1031 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1032 felec = qq21*rinv21*(rinvsq21-felec);
1036 /* Calculate temporary vectorial force */
1041 /* Update vectorial force */
1045 f[j_coord_offset+DIM*1+XX] -= tx;
1046 f[j_coord_offset+DIM*1+YY] -= ty;
1047 f[j_coord_offset+DIM*1+ZZ] -= tz;
1049 /**************************
1050 * CALCULATE INTERACTIONS *
1051 **************************/
1055 /* EWALD ELECTROSTATICS */
1057 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1058 ewrt = r22*ewtabscale;
1060 eweps = ewrt-ewitab;
1061 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1062 felec = qq22*rinv22*(rinvsq22-felec);
1066 /* Calculate temporary vectorial force */
1071 /* Update vectorial force */
1075 f[j_coord_offset+DIM*2+XX] -= tx;
1076 f[j_coord_offset+DIM*2+YY] -= ty;
1077 f[j_coord_offset+DIM*2+ZZ] -= tz;
1079 /* Inner loop uses 297 flops */
1081 /* End of innermost loop */
1084 f[i_coord_offset+DIM*0+XX] += fix0;
1085 f[i_coord_offset+DIM*0+YY] += fiy0;
1086 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1090 f[i_coord_offset+DIM*1+XX] += fix1;
1091 f[i_coord_offset+DIM*1+YY] += fiy1;
1092 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1096 f[i_coord_offset+DIM*2+XX] += fix2;
1097 f[i_coord_offset+DIM*2+YY] += fiy2;
1098 f[i_coord_offset+DIM*2+ZZ] += fiz2;
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_W3W3_F,outeriter*30 + inneriter*297);