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_ElecEwSh_VdwNone_GeomW3W3_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: None
37 * Geometry: Water3-Water3
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_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];
121 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
122 rcutoff = fr->rcoulomb;
123 rcutoff2 = rcutoff*rcutoff;
128 /* Start outer loop over neighborlists */
129 for(iidx=0; iidx<nri; iidx++)
131 /* Load shift vector for this list */
132 i_shift_offset = DIM*shiftidx[iidx];
133 shX = shiftvec[i_shift_offset+XX];
134 shY = shiftvec[i_shift_offset+YY];
135 shZ = shiftvec[i_shift_offset+ZZ];
137 /* Load limits for loop over neighbors */
138 j_index_start = jindex[iidx];
139 j_index_end = jindex[iidx+1];
141 /* Get outer coordinate index */
143 i_coord_offset = DIM*inr;
145 /* Load i particle coords and add shift vector */
146 ix0 = shX + x[i_coord_offset+DIM*0+XX];
147 iy0 = shY + x[i_coord_offset+DIM*0+YY];
148 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
149 ix1 = shX + x[i_coord_offset+DIM*1+XX];
150 iy1 = shY + x[i_coord_offset+DIM*1+YY];
151 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
152 ix2 = shX + x[i_coord_offset+DIM*2+XX];
153 iy2 = shY + x[i_coord_offset+DIM*2+YY];
154 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
166 /* Reset potential sums */
169 /* Start inner kernel loop */
170 for(jidx=j_index_start; jidx<j_index_end; jidx++)
172 /* Get j neighbor index, and coordinate index */
174 j_coord_offset = DIM*jnr;
176 /* load j atom coordinates */
177 jx0 = x[j_coord_offset+DIM*0+XX];
178 jy0 = x[j_coord_offset+DIM*0+YY];
179 jz0 = x[j_coord_offset+DIM*0+ZZ];
180 jx1 = x[j_coord_offset+DIM*1+XX];
181 jy1 = x[j_coord_offset+DIM*1+YY];
182 jz1 = x[j_coord_offset+DIM*1+ZZ];
183 jx2 = x[j_coord_offset+DIM*2+XX];
184 jy2 = x[j_coord_offset+DIM*2+YY];
185 jz2 = x[j_coord_offset+DIM*2+ZZ];
187 /* Calculate displacement vector */
216 /* Calculate squared distance and things based on it */
217 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
218 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
219 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
220 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
221 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
222 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
223 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
224 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
225 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
227 rinv00 = gmx_invsqrt(rsq00);
228 rinv01 = gmx_invsqrt(rsq01);
229 rinv02 = gmx_invsqrt(rsq02);
230 rinv10 = gmx_invsqrt(rsq10);
231 rinv11 = gmx_invsqrt(rsq11);
232 rinv12 = gmx_invsqrt(rsq12);
233 rinv20 = gmx_invsqrt(rsq20);
234 rinv21 = gmx_invsqrt(rsq21);
235 rinv22 = gmx_invsqrt(rsq22);
237 rinvsq00 = rinv00*rinv00;
238 rinvsq01 = rinv01*rinv01;
239 rinvsq02 = rinv02*rinv02;
240 rinvsq10 = rinv10*rinv10;
241 rinvsq11 = rinv11*rinv11;
242 rinvsq12 = rinv12*rinv12;
243 rinvsq20 = rinv20*rinv20;
244 rinvsq21 = rinv21*rinv21;
245 rinvsq22 = rinv22*rinv22;
247 /**************************
248 * CALCULATE INTERACTIONS *
249 **************************/
256 /* EWALD ELECTROSTATICS */
258 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
259 ewrt = r00*ewtabscale;
263 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
264 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
265 felec = qq00*rinv00*(rinvsq00-felec);
267 /* Update potential sums from outer loop */
272 /* Calculate temporary vectorial force */
277 /* Update vectorial force */
281 f[j_coord_offset+DIM*0+XX] -= tx;
282 f[j_coord_offset+DIM*0+YY] -= ty;
283 f[j_coord_offset+DIM*0+ZZ] -= tz;
287 /**************************
288 * CALCULATE INTERACTIONS *
289 **************************/
296 /* EWALD ELECTROSTATICS */
298 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
299 ewrt = r01*ewtabscale;
303 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
304 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
305 felec = qq01*rinv01*(rinvsq01-felec);
307 /* Update potential sums from outer loop */
312 /* Calculate temporary vectorial force */
317 /* Update vectorial force */
321 f[j_coord_offset+DIM*1+XX] -= tx;
322 f[j_coord_offset+DIM*1+YY] -= ty;
323 f[j_coord_offset+DIM*1+ZZ] -= tz;
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
336 /* EWALD ELECTROSTATICS */
338 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
339 ewrt = r02*ewtabscale;
343 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
344 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
345 felec = qq02*rinv02*(rinvsq02-felec);
347 /* Update potential sums from outer loop */
352 /* Calculate temporary vectorial force */
357 /* Update vectorial force */
361 f[j_coord_offset+DIM*2+XX] -= tx;
362 f[j_coord_offset+DIM*2+YY] -= ty;
363 f[j_coord_offset+DIM*2+ZZ] -= tz;
367 /**************************
368 * CALCULATE INTERACTIONS *
369 **************************/
376 /* EWALD ELECTROSTATICS */
378 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
379 ewrt = r10*ewtabscale;
383 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
384 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
385 felec = qq10*rinv10*(rinvsq10-felec);
387 /* Update potential sums from outer loop */
392 /* Calculate temporary vectorial force */
397 /* Update vectorial force */
401 f[j_coord_offset+DIM*0+XX] -= tx;
402 f[j_coord_offset+DIM*0+YY] -= ty;
403 f[j_coord_offset+DIM*0+ZZ] -= tz;
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
416 /* EWALD ELECTROSTATICS */
418 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
419 ewrt = r11*ewtabscale;
423 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
424 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
425 felec = qq11*rinv11*(rinvsq11-felec);
427 /* Update potential sums from outer loop */
432 /* Calculate temporary vectorial force */
437 /* Update vectorial force */
441 f[j_coord_offset+DIM*1+XX] -= tx;
442 f[j_coord_offset+DIM*1+YY] -= ty;
443 f[j_coord_offset+DIM*1+ZZ] -= tz;
447 /**************************
448 * CALCULATE INTERACTIONS *
449 **************************/
456 /* EWALD ELECTROSTATICS */
458 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
459 ewrt = r12*ewtabscale;
463 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
464 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
465 felec = qq12*rinv12*(rinvsq12-felec);
467 /* Update potential sums from outer loop */
472 /* Calculate temporary vectorial force */
477 /* Update vectorial force */
481 f[j_coord_offset+DIM*2+XX] -= tx;
482 f[j_coord_offset+DIM*2+YY] -= ty;
483 f[j_coord_offset+DIM*2+ZZ] -= tz;
487 /**************************
488 * CALCULATE INTERACTIONS *
489 **************************/
496 /* EWALD ELECTROSTATICS */
498 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
499 ewrt = r20*ewtabscale;
503 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
504 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
505 felec = qq20*rinv20*(rinvsq20-felec);
507 /* Update potential sums from outer loop */
512 /* Calculate temporary vectorial force */
517 /* Update vectorial force */
521 f[j_coord_offset+DIM*0+XX] -= tx;
522 f[j_coord_offset+DIM*0+YY] -= ty;
523 f[j_coord_offset+DIM*0+ZZ] -= tz;
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
536 /* EWALD ELECTROSTATICS */
538 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
539 ewrt = r21*ewtabscale;
543 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
544 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
545 felec = qq21*rinv21*(rinvsq21-felec);
547 /* Update potential sums from outer loop */
552 /* Calculate temporary vectorial force */
557 /* Update vectorial force */
561 f[j_coord_offset+DIM*1+XX] -= tx;
562 f[j_coord_offset+DIM*1+YY] -= ty;
563 f[j_coord_offset+DIM*1+ZZ] -= tz;
567 /**************************
568 * CALCULATE INTERACTIONS *
569 **************************/
576 /* EWALD ELECTROSTATICS */
578 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
579 ewrt = r22*ewtabscale;
583 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
584 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
585 felec = qq22*rinv22*(rinvsq22-felec);
587 /* Update potential sums from outer loop */
592 /* Calculate temporary vectorial force */
597 /* Update vectorial force */
601 f[j_coord_offset+DIM*2+XX] -= tx;
602 f[j_coord_offset+DIM*2+YY] -= ty;
603 f[j_coord_offset+DIM*2+ZZ] -= tz;
607 /* Inner loop uses 369 flops */
609 /* End of innermost loop */
612 f[i_coord_offset+DIM*0+XX] += fix0;
613 f[i_coord_offset+DIM*0+YY] += fiy0;
614 f[i_coord_offset+DIM*0+ZZ] += fiz0;
618 f[i_coord_offset+DIM*1+XX] += fix1;
619 f[i_coord_offset+DIM*1+YY] += fiy1;
620 f[i_coord_offset+DIM*1+ZZ] += fiz1;
624 f[i_coord_offset+DIM*2+XX] += fix2;
625 f[i_coord_offset+DIM*2+YY] += fiy2;
626 f[i_coord_offset+DIM*2+ZZ] += fiz2;
630 fshift[i_shift_offset+XX] += tx;
631 fshift[i_shift_offset+YY] += ty;
632 fshift[i_shift_offset+ZZ] += tz;
635 /* Update potential energies */
636 kernel_data->energygrp_elec[ggid] += velecsum;
638 /* Increment number of inner iterations */
639 inneriter += j_index_end - j_index_start;
641 /* Outer loop uses 31 flops */
644 /* Increment number of outer iterations */
647 /* Update outer/inner flops */
649 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*31 + inneriter*369);
652 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW3W3_F_c
653 * Electrostatics interaction: Ewald
654 * VdW interaction: None
655 * Geometry: Water3-Water3
656 * Calculate force/pot: Force
659 nb_kernel_ElecEwSh_VdwNone_GeomW3W3_F_c
660 (t_nblist * gmx_restrict nlist,
661 rvec * gmx_restrict xx,
662 rvec * gmx_restrict ff,
663 t_forcerec * gmx_restrict fr,
664 t_mdatoms * gmx_restrict mdatoms,
665 nb_kernel_data_t * gmx_restrict kernel_data,
666 t_nrnb * gmx_restrict nrnb)
668 int i_shift_offset,i_coord_offset,j_coord_offset;
669 int j_index_start,j_index_end;
670 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
671 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
672 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
673 real *shiftvec,*fshift,*x,*f;
675 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
677 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
679 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
681 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
683 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
685 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
686 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
687 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
688 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
689 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
690 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
691 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
692 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
693 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
694 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
695 real velec,felec,velecsum,facel,crf,krf,krf2;
698 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
706 jindex = nlist->jindex;
708 shiftidx = nlist->shift;
710 shiftvec = fr->shift_vec[0];
711 fshift = fr->fshift[0];
713 charge = mdatoms->chargeA;
715 sh_ewald = fr->ic->sh_ewald;
716 ewtab = fr->ic->tabq_coul_F;
717 ewtabscale = fr->ic->tabq_scale;
718 ewtabhalfspace = 0.5/ewtabscale;
720 /* Setup water-specific parameters */
721 inr = nlist->iinr[0];
722 iq0 = facel*charge[inr+0];
723 iq1 = facel*charge[inr+1];
724 iq2 = facel*charge[inr+2];
739 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
740 rcutoff = fr->rcoulomb;
741 rcutoff2 = rcutoff*rcutoff;
746 /* Start outer loop over neighborlists */
747 for(iidx=0; iidx<nri; iidx++)
749 /* Load shift vector for this list */
750 i_shift_offset = DIM*shiftidx[iidx];
751 shX = shiftvec[i_shift_offset+XX];
752 shY = shiftvec[i_shift_offset+YY];
753 shZ = shiftvec[i_shift_offset+ZZ];
755 /* Load limits for loop over neighbors */
756 j_index_start = jindex[iidx];
757 j_index_end = jindex[iidx+1];
759 /* Get outer coordinate index */
761 i_coord_offset = DIM*inr;
763 /* Load i particle coords and add shift vector */
764 ix0 = shX + x[i_coord_offset+DIM*0+XX];
765 iy0 = shY + x[i_coord_offset+DIM*0+YY];
766 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
767 ix1 = shX + x[i_coord_offset+DIM*1+XX];
768 iy1 = shY + x[i_coord_offset+DIM*1+YY];
769 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
770 ix2 = shX + x[i_coord_offset+DIM*2+XX];
771 iy2 = shY + x[i_coord_offset+DIM*2+YY];
772 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
784 /* Start inner kernel loop */
785 for(jidx=j_index_start; jidx<j_index_end; jidx++)
787 /* Get j neighbor index, and coordinate index */
789 j_coord_offset = DIM*jnr;
791 /* load j atom coordinates */
792 jx0 = x[j_coord_offset+DIM*0+XX];
793 jy0 = x[j_coord_offset+DIM*0+YY];
794 jz0 = x[j_coord_offset+DIM*0+ZZ];
795 jx1 = x[j_coord_offset+DIM*1+XX];
796 jy1 = x[j_coord_offset+DIM*1+YY];
797 jz1 = x[j_coord_offset+DIM*1+ZZ];
798 jx2 = x[j_coord_offset+DIM*2+XX];
799 jy2 = x[j_coord_offset+DIM*2+YY];
800 jz2 = x[j_coord_offset+DIM*2+ZZ];
802 /* Calculate displacement vector */
831 /* Calculate squared distance and things based on it */
832 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
833 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
834 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
835 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
836 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
837 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
838 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
839 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
840 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
842 rinv00 = gmx_invsqrt(rsq00);
843 rinv01 = gmx_invsqrt(rsq01);
844 rinv02 = gmx_invsqrt(rsq02);
845 rinv10 = gmx_invsqrt(rsq10);
846 rinv11 = gmx_invsqrt(rsq11);
847 rinv12 = gmx_invsqrt(rsq12);
848 rinv20 = gmx_invsqrt(rsq20);
849 rinv21 = gmx_invsqrt(rsq21);
850 rinv22 = gmx_invsqrt(rsq22);
852 rinvsq00 = rinv00*rinv00;
853 rinvsq01 = rinv01*rinv01;
854 rinvsq02 = rinv02*rinv02;
855 rinvsq10 = rinv10*rinv10;
856 rinvsq11 = rinv11*rinv11;
857 rinvsq12 = rinv12*rinv12;
858 rinvsq20 = rinv20*rinv20;
859 rinvsq21 = rinv21*rinv21;
860 rinvsq22 = rinv22*rinv22;
862 /**************************
863 * CALCULATE INTERACTIONS *
864 **************************/
871 /* EWALD ELECTROSTATICS */
873 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
874 ewrt = r00*ewtabscale;
877 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
878 felec = qq00*rinv00*(rinvsq00-felec);
882 /* Calculate temporary vectorial force */
887 /* Update vectorial force */
891 f[j_coord_offset+DIM*0+XX] -= tx;
892 f[j_coord_offset+DIM*0+YY] -= ty;
893 f[j_coord_offset+DIM*0+ZZ] -= tz;
897 /**************************
898 * CALCULATE INTERACTIONS *
899 **************************/
906 /* EWALD ELECTROSTATICS */
908 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
909 ewrt = r01*ewtabscale;
912 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
913 felec = qq01*rinv01*(rinvsq01-felec);
917 /* Calculate temporary vectorial force */
922 /* Update vectorial force */
926 f[j_coord_offset+DIM*1+XX] -= tx;
927 f[j_coord_offset+DIM*1+YY] -= ty;
928 f[j_coord_offset+DIM*1+ZZ] -= tz;
932 /**************************
933 * CALCULATE INTERACTIONS *
934 **************************/
941 /* EWALD ELECTROSTATICS */
943 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
944 ewrt = r02*ewtabscale;
947 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
948 felec = qq02*rinv02*(rinvsq02-felec);
952 /* Calculate temporary vectorial force */
957 /* Update vectorial force */
961 f[j_coord_offset+DIM*2+XX] -= tx;
962 f[j_coord_offset+DIM*2+YY] -= ty;
963 f[j_coord_offset+DIM*2+ZZ] -= tz;
967 /**************************
968 * CALCULATE INTERACTIONS *
969 **************************/
976 /* EWALD ELECTROSTATICS */
978 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
979 ewrt = r10*ewtabscale;
982 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
983 felec = qq10*rinv10*(rinvsq10-felec);
987 /* Calculate temporary vectorial force */
992 /* Update vectorial force */
996 f[j_coord_offset+DIM*0+XX] -= tx;
997 f[j_coord_offset+DIM*0+YY] -= ty;
998 f[j_coord_offset+DIM*0+ZZ] -= tz;
1002 /**************************
1003 * CALCULATE INTERACTIONS *
1004 **************************/
1011 /* EWALD ELECTROSTATICS */
1013 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1014 ewrt = r11*ewtabscale;
1016 eweps = ewrt-ewitab;
1017 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1018 felec = qq11*rinv11*(rinvsq11-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;
1037 /**************************
1038 * CALCULATE INTERACTIONS *
1039 **************************/
1046 /* EWALD ELECTROSTATICS */
1048 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1049 ewrt = r12*ewtabscale;
1051 eweps = ewrt-ewitab;
1052 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1053 felec = qq12*rinv12*(rinvsq12-felec);
1057 /* Calculate temporary vectorial force */
1062 /* Update vectorial force */
1066 f[j_coord_offset+DIM*2+XX] -= tx;
1067 f[j_coord_offset+DIM*2+YY] -= ty;
1068 f[j_coord_offset+DIM*2+ZZ] -= tz;
1072 /**************************
1073 * CALCULATE INTERACTIONS *
1074 **************************/
1081 /* EWALD ELECTROSTATICS */
1083 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1084 ewrt = r20*ewtabscale;
1086 eweps = ewrt-ewitab;
1087 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1088 felec = qq20*rinv20*(rinvsq20-felec);
1092 /* Calculate temporary vectorial force */
1097 /* Update vectorial force */
1101 f[j_coord_offset+DIM*0+XX] -= tx;
1102 f[j_coord_offset+DIM*0+YY] -= ty;
1103 f[j_coord_offset+DIM*0+ZZ] -= tz;
1107 /**************************
1108 * CALCULATE INTERACTIONS *
1109 **************************/
1116 /* EWALD ELECTROSTATICS */
1118 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1119 ewrt = r21*ewtabscale;
1121 eweps = ewrt-ewitab;
1122 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1123 felec = qq21*rinv21*(rinvsq21-felec);
1127 /* Calculate temporary vectorial force */
1132 /* Update vectorial force */
1136 f[j_coord_offset+DIM*1+XX] -= tx;
1137 f[j_coord_offset+DIM*1+YY] -= ty;
1138 f[j_coord_offset+DIM*1+ZZ] -= tz;
1142 /**************************
1143 * CALCULATE INTERACTIONS *
1144 **************************/
1151 /* EWALD ELECTROSTATICS */
1153 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1154 ewrt = r22*ewtabscale;
1156 eweps = ewrt-ewitab;
1157 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1158 felec = qq22*rinv22*(rinvsq22-felec);
1162 /* Calculate temporary vectorial force */
1167 /* Update vectorial force */
1171 f[j_coord_offset+DIM*2+XX] -= tx;
1172 f[j_coord_offset+DIM*2+YY] -= ty;
1173 f[j_coord_offset+DIM*2+ZZ] -= tz;
1177 /* Inner loop uses 297 flops */
1179 /* End of innermost loop */
1182 f[i_coord_offset+DIM*0+XX] += fix0;
1183 f[i_coord_offset+DIM*0+YY] += fiy0;
1184 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1188 f[i_coord_offset+DIM*1+XX] += fix1;
1189 f[i_coord_offset+DIM*1+YY] += fiy1;
1190 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1194 f[i_coord_offset+DIM*2+XX] += fix2;
1195 f[i_coord_offset+DIM*2+YY] += fiy2;
1196 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1200 fshift[i_shift_offset+XX] += tx;
1201 fshift[i_shift_offset+YY] += ty;
1202 fshift[i_shift_offset+ZZ] += tz;
1204 /* Increment number of inner iterations */
1205 inneriter += j_index_end - j_index_start;
1207 /* Outer loop uses 30 flops */
1210 /* Increment number of outer iterations */
1213 /* Update outer/inner flops */
1215 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*30 + inneriter*297);