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_GeomW4W4_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: None
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_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];
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 ix1 = shX + x[i_coord_offset+DIM*1+XX];
147 iy1 = shY + x[i_coord_offset+DIM*1+YY];
148 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
149 ix2 = shX + x[i_coord_offset+DIM*2+XX];
150 iy2 = shY + x[i_coord_offset+DIM*2+YY];
151 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
152 ix3 = shX + x[i_coord_offset+DIM*3+XX];
153 iy3 = shY + x[i_coord_offset+DIM*3+YY];
154 iz3 = shZ + x[i_coord_offset+DIM*3+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 jx1 = x[j_coord_offset+DIM*1+XX];
178 jy1 = x[j_coord_offset+DIM*1+YY];
179 jz1 = x[j_coord_offset+DIM*1+ZZ];
180 jx2 = x[j_coord_offset+DIM*2+XX];
181 jy2 = x[j_coord_offset+DIM*2+YY];
182 jz2 = x[j_coord_offset+DIM*2+ZZ];
183 jx3 = x[j_coord_offset+DIM*3+XX];
184 jy3 = x[j_coord_offset+DIM*3+YY];
185 jz3 = x[j_coord_offset+DIM*3+ZZ];
187 /* Calculate displacement vector */
216 /* Calculate squared distance and things based on it */
217 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
218 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
219 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
220 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
221 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
222 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
223 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
224 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
225 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
227 rinv11 = gmx_invsqrt(rsq11);
228 rinv12 = gmx_invsqrt(rsq12);
229 rinv13 = gmx_invsqrt(rsq13);
230 rinv21 = gmx_invsqrt(rsq21);
231 rinv22 = gmx_invsqrt(rsq22);
232 rinv23 = gmx_invsqrt(rsq23);
233 rinv31 = gmx_invsqrt(rsq31);
234 rinv32 = gmx_invsqrt(rsq32);
235 rinv33 = gmx_invsqrt(rsq33);
237 rinvsq11 = rinv11*rinv11;
238 rinvsq12 = rinv12*rinv12;
239 rinvsq13 = rinv13*rinv13;
240 rinvsq21 = rinv21*rinv21;
241 rinvsq22 = rinv22*rinv22;
242 rinvsq23 = rinv23*rinv23;
243 rinvsq31 = rinv31*rinv31;
244 rinvsq32 = rinv32*rinv32;
245 rinvsq33 = rinv33*rinv33;
247 /**************************
248 * CALCULATE INTERACTIONS *
249 **************************/
256 /* EWALD ELECTROSTATICS */
258 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
259 ewrt = r11*ewtabscale;
263 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
264 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
265 felec = qq11*rinv11*(rinvsq11-felec);
267 /* Update potential sums from outer loop */
272 /* Calculate temporary vectorial force */
277 /* Update vectorial force */
281 f[j_coord_offset+DIM*1+XX] -= tx;
282 f[j_coord_offset+DIM*1+YY] -= ty;
283 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
303 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
304 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
305 felec = qq12*rinv12*(rinvsq12-felec);
307 /* Update potential sums from outer loop */
312 /* Calculate temporary vectorial force */
317 /* Update vectorial force */
321 f[j_coord_offset+DIM*2+XX] -= tx;
322 f[j_coord_offset+DIM*2+YY] -= ty;
323 f[j_coord_offset+DIM*2+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 = r13*ewtabscale;
343 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
344 velec = qq13*((rinv13-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
345 felec = qq13*rinv13*(rinvsq13-felec);
347 /* Update potential sums from outer loop */
352 /* Calculate temporary vectorial force */
357 /* Update vectorial force */
361 f[j_coord_offset+DIM*3+XX] -= tx;
362 f[j_coord_offset+DIM*3+YY] -= ty;
363 f[j_coord_offset+DIM*3+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 = r21*ewtabscale;
383 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
384 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
385 felec = qq21*rinv21*(rinvsq21-felec);
387 /* Update potential sums from outer loop */
392 /* Calculate temporary vectorial force */
397 /* Update vectorial force */
401 f[j_coord_offset+DIM*1+XX] -= tx;
402 f[j_coord_offset+DIM*1+YY] -= ty;
403 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
423 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
424 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
425 felec = qq22*rinv22*(rinvsq22-felec);
427 /* Update potential sums from outer loop */
432 /* Calculate temporary vectorial force */
437 /* Update vectorial force */
441 f[j_coord_offset+DIM*2+XX] -= tx;
442 f[j_coord_offset+DIM*2+YY] -= ty;
443 f[j_coord_offset+DIM*2+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 = r23*ewtabscale;
463 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
464 velec = qq23*((rinv23-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
465 felec = qq23*rinv23*(rinvsq23-felec);
467 /* Update potential sums from outer loop */
472 /* Calculate temporary vectorial force */
477 /* Update vectorial force */
481 f[j_coord_offset+DIM*3+XX] -= tx;
482 f[j_coord_offset+DIM*3+YY] -= ty;
483 f[j_coord_offset+DIM*3+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 = r31*ewtabscale;
503 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
504 velec = qq31*((rinv31-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
505 felec = qq31*rinv31*(rinvsq31-felec);
507 /* Update potential sums from outer loop */
512 /* Calculate temporary vectorial force */
517 /* Update vectorial force */
521 f[j_coord_offset+DIM*1+XX] -= tx;
522 f[j_coord_offset+DIM*1+YY] -= ty;
523 f[j_coord_offset+DIM*1+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 = r32*ewtabscale;
543 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
544 velec = qq32*((rinv32-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
545 felec = qq32*rinv32*(rinvsq32-felec);
547 /* Update potential sums from outer loop */
552 /* Calculate temporary vectorial force */
557 /* Update vectorial force */
561 f[j_coord_offset+DIM*2+XX] -= tx;
562 f[j_coord_offset+DIM*2+YY] -= ty;
563 f[j_coord_offset+DIM*2+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 = r33*ewtabscale;
583 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
584 velec = qq33*((rinv33-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
585 felec = qq33*rinv33*(rinvsq33-felec);
587 /* Update potential sums from outer loop */
592 /* Calculate temporary vectorial force */
597 /* Update vectorial force */
601 f[j_coord_offset+DIM*3+XX] -= tx;
602 f[j_coord_offset+DIM*3+YY] -= ty;
603 f[j_coord_offset+DIM*3+ZZ] -= tz;
607 /* Inner loop uses 369 flops */
609 /* End of innermost loop */
612 f[i_coord_offset+DIM*1+XX] += fix1;
613 f[i_coord_offset+DIM*1+YY] += fiy1;
614 f[i_coord_offset+DIM*1+ZZ] += fiz1;
618 f[i_coord_offset+DIM*2+XX] += fix2;
619 f[i_coord_offset+DIM*2+YY] += fiy2;
620 f[i_coord_offset+DIM*2+ZZ] += fiz2;
624 f[i_coord_offset+DIM*3+XX] += fix3;
625 f[i_coord_offset+DIM*3+YY] += fiy3;
626 f[i_coord_offset+DIM*3+ZZ] += fiz3;
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_W4W4_VF,outeriter*31 + inneriter*369);
652 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW4W4_F_c
653 * Electrostatics interaction: Ewald
654 * VdW interaction: None
655 * Geometry: Water4-Water4
656 * Calculate force/pot: Force
659 nb_kernel_ElecEwSh_VdwNone_GeomW4W4_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
677 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
679 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
681 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
683 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
685 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
686 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
687 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
688 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
689 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
690 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
691 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
692 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
693 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
694 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
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 iq1 = facel*charge[inr+1];
723 iq2 = facel*charge[inr+2];
724 iq3 = facel*charge[inr+3];
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 ix1 = shX + x[i_coord_offset+DIM*1+XX];
765 iy1 = shY + x[i_coord_offset+DIM*1+YY];
766 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
767 ix2 = shX + x[i_coord_offset+DIM*2+XX];
768 iy2 = shY + x[i_coord_offset+DIM*2+YY];
769 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
770 ix3 = shX + x[i_coord_offset+DIM*3+XX];
771 iy3 = shY + x[i_coord_offset+DIM*3+YY];
772 iz3 = shZ + x[i_coord_offset+DIM*3+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 jx1 = x[j_coord_offset+DIM*1+XX];
793 jy1 = x[j_coord_offset+DIM*1+YY];
794 jz1 = x[j_coord_offset+DIM*1+ZZ];
795 jx2 = x[j_coord_offset+DIM*2+XX];
796 jy2 = x[j_coord_offset+DIM*2+YY];
797 jz2 = x[j_coord_offset+DIM*2+ZZ];
798 jx3 = x[j_coord_offset+DIM*3+XX];
799 jy3 = x[j_coord_offset+DIM*3+YY];
800 jz3 = x[j_coord_offset+DIM*3+ZZ];
802 /* Calculate displacement vector */
831 /* Calculate squared distance and things based on it */
832 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
833 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
834 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
835 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
836 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
837 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
838 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
839 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
840 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
842 rinv11 = gmx_invsqrt(rsq11);
843 rinv12 = gmx_invsqrt(rsq12);
844 rinv13 = gmx_invsqrt(rsq13);
845 rinv21 = gmx_invsqrt(rsq21);
846 rinv22 = gmx_invsqrt(rsq22);
847 rinv23 = gmx_invsqrt(rsq23);
848 rinv31 = gmx_invsqrt(rsq31);
849 rinv32 = gmx_invsqrt(rsq32);
850 rinv33 = gmx_invsqrt(rsq33);
852 rinvsq11 = rinv11*rinv11;
853 rinvsq12 = rinv12*rinv12;
854 rinvsq13 = rinv13*rinv13;
855 rinvsq21 = rinv21*rinv21;
856 rinvsq22 = rinv22*rinv22;
857 rinvsq23 = rinv23*rinv23;
858 rinvsq31 = rinv31*rinv31;
859 rinvsq32 = rinv32*rinv32;
860 rinvsq33 = rinv33*rinv33;
862 /**************************
863 * CALCULATE INTERACTIONS *
864 **************************/
871 /* EWALD ELECTROSTATICS */
873 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
874 ewrt = r11*ewtabscale;
877 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
878 felec = qq11*rinv11*(rinvsq11-felec);
882 /* Calculate temporary vectorial force */
887 /* Update vectorial force */
891 f[j_coord_offset+DIM*1+XX] -= tx;
892 f[j_coord_offset+DIM*1+YY] -= ty;
893 f[j_coord_offset+DIM*1+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 = r12*ewtabscale;
912 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
913 felec = qq12*rinv12*(rinvsq12-felec);
917 /* Calculate temporary vectorial force */
922 /* Update vectorial force */
926 f[j_coord_offset+DIM*2+XX] -= tx;
927 f[j_coord_offset+DIM*2+YY] -= ty;
928 f[j_coord_offset+DIM*2+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 = r13*ewtabscale;
947 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
948 felec = qq13*rinv13*(rinvsq13-felec);
952 /* Calculate temporary vectorial force */
957 /* Update vectorial force */
961 f[j_coord_offset+DIM*3+XX] -= tx;
962 f[j_coord_offset+DIM*3+YY] -= ty;
963 f[j_coord_offset+DIM*3+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 = r21*ewtabscale;
982 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
983 felec = qq21*rinv21*(rinvsq21-felec);
987 /* Calculate temporary vectorial force */
992 /* Update vectorial force */
996 f[j_coord_offset+DIM*1+XX] -= tx;
997 f[j_coord_offset+DIM*1+YY] -= ty;
998 f[j_coord_offset+DIM*1+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 = r22*ewtabscale;
1016 eweps = ewrt-ewitab;
1017 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1018 felec = qq22*rinv22*(rinvsq22-felec);
1022 /* Calculate temporary vectorial force */
1027 /* Update vectorial force */
1031 f[j_coord_offset+DIM*2+XX] -= tx;
1032 f[j_coord_offset+DIM*2+YY] -= ty;
1033 f[j_coord_offset+DIM*2+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 = r23*ewtabscale;
1051 eweps = ewrt-ewitab;
1052 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1053 felec = qq23*rinv23*(rinvsq23-felec);
1057 /* Calculate temporary vectorial force */
1062 /* Update vectorial force */
1066 f[j_coord_offset+DIM*3+XX] -= tx;
1067 f[j_coord_offset+DIM*3+YY] -= ty;
1068 f[j_coord_offset+DIM*3+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 = r31*ewtabscale;
1086 eweps = ewrt-ewitab;
1087 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1088 felec = qq31*rinv31*(rinvsq31-felec);
1092 /* Calculate temporary vectorial force */
1097 /* Update vectorial force */
1101 f[j_coord_offset+DIM*1+XX] -= tx;
1102 f[j_coord_offset+DIM*1+YY] -= ty;
1103 f[j_coord_offset+DIM*1+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 = r32*ewtabscale;
1121 eweps = ewrt-ewitab;
1122 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1123 felec = qq32*rinv32*(rinvsq32-felec);
1127 /* Calculate temporary vectorial force */
1132 /* Update vectorial force */
1136 f[j_coord_offset+DIM*2+XX] -= tx;
1137 f[j_coord_offset+DIM*2+YY] -= ty;
1138 f[j_coord_offset+DIM*2+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 = r33*ewtabscale;
1156 eweps = ewrt-ewitab;
1157 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1158 felec = qq33*rinv33*(rinvsq33-felec);
1162 /* Calculate temporary vectorial force */
1167 /* Update vectorial force */
1171 f[j_coord_offset+DIM*3+XX] -= tx;
1172 f[j_coord_offset+DIM*3+YY] -= ty;
1173 f[j_coord_offset+DIM*3+ZZ] -= tz;
1177 /* Inner loop uses 297 flops */
1179 /* End of innermost loop */
1182 f[i_coord_offset+DIM*1+XX] += fix1;
1183 f[i_coord_offset+DIM*1+YY] += fiy1;
1184 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1188 f[i_coord_offset+DIM*2+XX] += fix2;
1189 f[i_coord_offset+DIM*2+YY] += fiy2;
1190 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1194 f[i_coord_offset+DIM*3+XX] += fix3;
1195 f[i_coord_offset+DIM*3+YY] += fiy3;
1196 f[i_coord_offset+DIM*3+ZZ] += fiz3;
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_W4W4_F,outeriter*30 + inneriter*297);