2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: None
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwNone_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
102 jindex = nlist->jindex;
104 shiftidx = nlist->shift;
106 shiftvec = fr->shift_vec[0];
107 fshift = fr->fshift[0];
109 charge = mdatoms->chargeA;
111 sh_ewald = fr->ic->sh_ewald;
112 ewtab = fr->ic->tabq_coul_FDV0;
113 ewtabscale = fr->ic->tabq_scale;
114 ewtabhalfspace = 0.5/ewtabscale;
116 /* Setup water-specific parameters */
117 inr = nlist->iinr[0];
118 iq0 = facel*charge[inr+0];
119 iq1 = facel*charge[inr+1];
120 iq2 = facel*charge[inr+2];
138 /* Start outer loop over neighborlists */
139 for(iidx=0; iidx<nri; iidx++)
141 /* Load shift vector for this list */
142 i_shift_offset = DIM*shiftidx[iidx];
143 shX = shiftvec[i_shift_offset+XX];
144 shY = shiftvec[i_shift_offset+YY];
145 shZ = shiftvec[i_shift_offset+ZZ];
147 /* Load limits for loop over neighbors */
148 j_index_start = jindex[iidx];
149 j_index_end = jindex[iidx+1];
151 /* Get outer coordinate index */
153 i_coord_offset = DIM*inr;
155 /* Load i particle coords and add shift vector */
156 ix0 = shX + x[i_coord_offset+DIM*0+XX];
157 iy0 = shY + x[i_coord_offset+DIM*0+YY];
158 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
159 ix1 = shX + x[i_coord_offset+DIM*1+XX];
160 iy1 = shY + x[i_coord_offset+DIM*1+YY];
161 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
162 ix2 = shX + x[i_coord_offset+DIM*2+XX];
163 iy2 = shY + x[i_coord_offset+DIM*2+YY];
164 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
176 /* Reset potential sums */
179 /* Start inner kernel loop */
180 for(jidx=j_index_start; jidx<j_index_end; jidx++)
182 /* Get j neighbor index, and coordinate index */
184 j_coord_offset = DIM*jnr;
186 /* load j atom coordinates */
187 jx0 = x[j_coord_offset+DIM*0+XX];
188 jy0 = x[j_coord_offset+DIM*0+YY];
189 jz0 = x[j_coord_offset+DIM*0+ZZ];
190 jx1 = x[j_coord_offset+DIM*1+XX];
191 jy1 = x[j_coord_offset+DIM*1+YY];
192 jz1 = x[j_coord_offset+DIM*1+ZZ];
193 jx2 = x[j_coord_offset+DIM*2+XX];
194 jy2 = x[j_coord_offset+DIM*2+YY];
195 jz2 = x[j_coord_offset+DIM*2+ZZ];
197 /* Calculate displacement vector */
226 /* Calculate squared distance and things based on it */
227 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
228 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
229 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
230 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
231 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
232 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
233 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
234 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
235 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
237 rinv00 = gmx_invsqrt(rsq00);
238 rinv01 = gmx_invsqrt(rsq01);
239 rinv02 = gmx_invsqrt(rsq02);
240 rinv10 = gmx_invsqrt(rsq10);
241 rinv11 = gmx_invsqrt(rsq11);
242 rinv12 = gmx_invsqrt(rsq12);
243 rinv20 = gmx_invsqrt(rsq20);
244 rinv21 = gmx_invsqrt(rsq21);
245 rinv22 = gmx_invsqrt(rsq22);
247 rinvsq00 = rinv00*rinv00;
248 rinvsq01 = rinv01*rinv01;
249 rinvsq02 = rinv02*rinv02;
250 rinvsq10 = rinv10*rinv10;
251 rinvsq11 = rinv11*rinv11;
252 rinvsq12 = rinv12*rinv12;
253 rinvsq20 = rinv20*rinv20;
254 rinvsq21 = rinv21*rinv21;
255 rinvsq22 = rinv22*rinv22;
257 /**************************
258 * CALCULATE INTERACTIONS *
259 **************************/
263 /* EWALD ELECTROSTATICS */
265 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
266 ewrt = r00*ewtabscale;
270 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
271 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
272 felec = qq00*rinv00*(rinvsq00-felec);
274 /* Update potential sums from outer loop */
279 /* Calculate temporary vectorial force */
284 /* Update vectorial force */
288 f[j_coord_offset+DIM*0+XX] -= tx;
289 f[j_coord_offset+DIM*0+YY] -= ty;
290 f[j_coord_offset+DIM*0+ZZ] -= tz;
292 /**************************
293 * CALCULATE INTERACTIONS *
294 **************************/
298 /* EWALD ELECTROSTATICS */
300 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
301 ewrt = r01*ewtabscale;
305 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
306 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
307 felec = qq01*rinv01*(rinvsq01-felec);
309 /* Update potential sums from outer loop */
314 /* Calculate temporary vectorial force */
319 /* Update vectorial force */
323 f[j_coord_offset+DIM*1+XX] -= tx;
324 f[j_coord_offset+DIM*1+YY] -= ty;
325 f[j_coord_offset+DIM*1+ZZ] -= tz;
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
333 /* EWALD ELECTROSTATICS */
335 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
336 ewrt = r02*ewtabscale;
340 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
341 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
342 felec = qq02*rinv02*(rinvsq02-felec);
344 /* Update potential sums from outer loop */
349 /* Calculate temporary vectorial force */
354 /* Update vectorial force */
358 f[j_coord_offset+DIM*2+XX] -= tx;
359 f[j_coord_offset+DIM*2+YY] -= ty;
360 f[j_coord_offset+DIM*2+ZZ] -= tz;
362 /**************************
363 * CALCULATE INTERACTIONS *
364 **************************/
368 /* EWALD ELECTROSTATICS */
370 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
371 ewrt = r10*ewtabscale;
375 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
376 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
377 felec = qq10*rinv10*(rinvsq10-felec);
379 /* Update potential sums from outer loop */
384 /* Calculate temporary vectorial force */
389 /* Update vectorial force */
393 f[j_coord_offset+DIM*0+XX] -= tx;
394 f[j_coord_offset+DIM*0+YY] -= ty;
395 f[j_coord_offset+DIM*0+ZZ] -= tz;
397 /**************************
398 * CALCULATE INTERACTIONS *
399 **************************/
403 /* EWALD ELECTROSTATICS */
405 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
406 ewrt = r11*ewtabscale;
410 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
411 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
412 felec = qq11*rinv11*(rinvsq11-felec);
414 /* Update potential sums from outer loop */
419 /* Calculate temporary vectorial force */
424 /* Update vectorial force */
428 f[j_coord_offset+DIM*1+XX] -= tx;
429 f[j_coord_offset+DIM*1+YY] -= ty;
430 f[j_coord_offset+DIM*1+ZZ] -= tz;
432 /**************************
433 * CALCULATE INTERACTIONS *
434 **************************/
438 /* EWALD ELECTROSTATICS */
440 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
441 ewrt = r12*ewtabscale;
445 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
446 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
447 felec = qq12*rinv12*(rinvsq12-felec);
449 /* Update potential sums from outer loop */
454 /* Calculate temporary vectorial force */
459 /* Update vectorial force */
463 f[j_coord_offset+DIM*2+XX] -= tx;
464 f[j_coord_offset+DIM*2+YY] -= ty;
465 f[j_coord_offset+DIM*2+ZZ] -= tz;
467 /**************************
468 * CALCULATE INTERACTIONS *
469 **************************/
473 /* EWALD ELECTROSTATICS */
475 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
476 ewrt = r20*ewtabscale;
480 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
481 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
482 felec = qq20*rinv20*(rinvsq20-felec);
484 /* Update potential sums from outer loop */
489 /* Calculate temporary vectorial force */
494 /* Update vectorial force */
498 f[j_coord_offset+DIM*0+XX] -= tx;
499 f[j_coord_offset+DIM*0+YY] -= ty;
500 f[j_coord_offset+DIM*0+ZZ] -= tz;
502 /**************************
503 * CALCULATE INTERACTIONS *
504 **************************/
508 /* EWALD ELECTROSTATICS */
510 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
511 ewrt = r21*ewtabscale;
515 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
516 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
517 felec = qq21*rinv21*(rinvsq21-felec);
519 /* Update potential sums from outer loop */
524 /* Calculate temporary vectorial force */
529 /* Update vectorial force */
533 f[j_coord_offset+DIM*1+XX] -= tx;
534 f[j_coord_offset+DIM*1+YY] -= ty;
535 f[j_coord_offset+DIM*1+ZZ] -= tz;
537 /**************************
538 * CALCULATE INTERACTIONS *
539 **************************/
543 /* EWALD ELECTROSTATICS */
545 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
546 ewrt = r22*ewtabscale;
550 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
551 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
552 felec = qq22*rinv22*(rinvsq22-felec);
554 /* Update potential sums from outer loop */
559 /* Calculate temporary vectorial force */
564 /* Update vectorial force */
568 f[j_coord_offset+DIM*2+XX] -= tx;
569 f[j_coord_offset+DIM*2+YY] -= ty;
570 f[j_coord_offset+DIM*2+ZZ] -= tz;
572 /* Inner loop uses 360 flops */
574 /* End of innermost loop */
577 f[i_coord_offset+DIM*0+XX] += fix0;
578 f[i_coord_offset+DIM*0+YY] += fiy0;
579 f[i_coord_offset+DIM*0+ZZ] += fiz0;
583 f[i_coord_offset+DIM*1+XX] += fix1;
584 f[i_coord_offset+DIM*1+YY] += fiy1;
585 f[i_coord_offset+DIM*1+ZZ] += fiz1;
589 f[i_coord_offset+DIM*2+XX] += fix2;
590 f[i_coord_offset+DIM*2+YY] += fiy2;
591 f[i_coord_offset+DIM*2+ZZ] += fiz2;
595 fshift[i_shift_offset+XX] += tx;
596 fshift[i_shift_offset+YY] += ty;
597 fshift[i_shift_offset+ZZ] += tz;
600 /* Update potential energies */
601 kernel_data->energygrp_elec[ggid] += velecsum;
603 /* Increment number of inner iterations */
604 inneriter += j_index_end - j_index_start;
606 /* Outer loop uses 31 flops */
609 /* Increment number of outer iterations */
612 /* Update outer/inner flops */
614 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*31 + inneriter*360);
617 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW3W3_F_c
618 * Electrostatics interaction: Ewald
619 * VdW interaction: None
620 * Geometry: Water3-Water3
621 * Calculate force/pot: Force
624 nb_kernel_ElecEw_VdwNone_GeomW3W3_F_c
625 (t_nblist * gmx_restrict nlist,
626 rvec * gmx_restrict xx,
627 rvec * gmx_restrict ff,
628 t_forcerec * gmx_restrict fr,
629 t_mdatoms * gmx_restrict mdatoms,
630 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
631 t_nrnb * gmx_restrict nrnb)
633 int i_shift_offset,i_coord_offset,j_coord_offset;
634 int j_index_start,j_index_end;
635 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
636 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
637 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
638 real *shiftvec,*fshift,*x,*f;
640 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
642 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
644 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
646 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
648 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
650 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
651 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
652 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
653 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
654 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
655 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
656 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
657 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
658 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
659 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
660 real velec,felec,velecsum,facel,crf,krf,krf2;
663 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
671 jindex = nlist->jindex;
673 shiftidx = nlist->shift;
675 shiftvec = fr->shift_vec[0];
676 fshift = fr->fshift[0];
678 charge = mdatoms->chargeA;
680 sh_ewald = fr->ic->sh_ewald;
681 ewtab = fr->ic->tabq_coul_F;
682 ewtabscale = fr->ic->tabq_scale;
683 ewtabhalfspace = 0.5/ewtabscale;
685 /* Setup water-specific parameters */
686 inr = nlist->iinr[0];
687 iq0 = facel*charge[inr+0];
688 iq1 = facel*charge[inr+1];
689 iq2 = facel*charge[inr+2];
707 /* Start outer loop over neighborlists */
708 for(iidx=0; iidx<nri; iidx++)
710 /* Load shift vector for this list */
711 i_shift_offset = DIM*shiftidx[iidx];
712 shX = shiftvec[i_shift_offset+XX];
713 shY = shiftvec[i_shift_offset+YY];
714 shZ = shiftvec[i_shift_offset+ZZ];
716 /* Load limits for loop over neighbors */
717 j_index_start = jindex[iidx];
718 j_index_end = jindex[iidx+1];
720 /* Get outer coordinate index */
722 i_coord_offset = DIM*inr;
724 /* Load i particle coords and add shift vector */
725 ix0 = shX + x[i_coord_offset+DIM*0+XX];
726 iy0 = shY + x[i_coord_offset+DIM*0+YY];
727 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
728 ix1 = shX + x[i_coord_offset+DIM*1+XX];
729 iy1 = shY + x[i_coord_offset+DIM*1+YY];
730 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
731 ix2 = shX + x[i_coord_offset+DIM*2+XX];
732 iy2 = shY + x[i_coord_offset+DIM*2+YY];
733 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
745 /* Start inner kernel loop */
746 for(jidx=j_index_start; jidx<j_index_end; jidx++)
748 /* Get j neighbor index, and coordinate index */
750 j_coord_offset = DIM*jnr;
752 /* load j atom coordinates */
753 jx0 = x[j_coord_offset+DIM*0+XX];
754 jy0 = x[j_coord_offset+DIM*0+YY];
755 jz0 = x[j_coord_offset+DIM*0+ZZ];
756 jx1 = x[j_coord_offset+DIM*1+XX];
757 jy1 = x[j_coord_offset+DIM*1+YY];
758 jz1 = x[j_coord_offset+DIM*1+ZZ];
759 jx2 = x[j_coord_offset+DIM*2+XX];
760 jy2 = x[j_coord_offset+DIM*2+YY];
761 jz2 = x[j_coord_offset+DIM*2+ZZ];
763 /* Calculate displacement vector */
792 /* Calculate squared distance and things based on it */
793 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
794 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
795 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
796 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
797 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
798 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
799 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
800 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
801 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
803 rinv00 = gmx_invsqrt(rsq00);
804 rinv01 = gmx_invsqrt(rsq01);
805 rinv02 = gmx_invsqrt(rsq02);
806 rinv10 = gmx_invsqrt(rsq10);
807 rinv11 = gmx_invsqrt(rsq11);
808 rinv12 = gmx_invsqrt(rsq12);
809 rinv20 = gmx_invsqrt(rsq20);
810 rinv21 = gmx_invsqrt(rsq21);
811 rinv22 = gmx_invsqrt(rsq22);
813 rinvsq00 = rinv00*rinv00;
814 rinvsq01 = rinv01*rinv01;
815 rinvsq02 = rinv02*rinv02;
816 rinvsq10 = rinv10*rinv10;
817 rinvsq11 = rinv11*rinv11;
818 rinvsq12 = rinv12*rinv12;
819 rinvsq20 = rinv20*rinv20;
820 rinvsq21 = rinv21*rinv21;
821 rinvsq22 = rinv22*rinv22;
823 /**************************
824 * CALCULATE INTERACTIONS *
825 **************************/
829 /* EWALD ELECTROSTATICS */
831 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
832 ewrt = r00*ewtabscale;
835 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
836 felec = qq00*rinv00*(rinvsq00-felec);
840 /* Calculate temporary vectorial force */
845 /* Update vectorial force */
849 f[j_coord_offset+DIM*0+XX] -= tx;
850 f[j_coord_offset+DIM*0+YY] -= ty;
851 f[j_coord_offset+DIM*0+ZZ] -= tz;
853 /**************************
854 * CALCULATE INTERACTIONS *
855 **************************/
859 /* EWALD ELECTROSTATICS */
861 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
862 ewrt = r01*ewtabscale;
865 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
866 felec = qq01*rinv01*(rinvsq01-felec);
870 /* Calculate temporary vectorial force */
875 /* Update vectorial force */
879 f[j_coord_offset+DIM*1+XX] -= tx;
880 f[j_coord_offset+DIM*1+YY] -= ty;
881 f[j_coord_offset+DIM*1+ZZ] -= tz;
883 /**************************
884 * CALCULATE INTERACTIONS *
885 **************************/
889 /* EWALD ELECTROSTATICS */
891 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
892 ewrt = r02*ewtabscale;
895 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
896 felec = qq02*rinv02*(rinvsq02-felec);
900 /* Calculate temporary vectorial force */
905 /* Update vectorial force */
909 f[j_coord_offset+DIM*2+XX] -= tx;
910 f[j_coord_offset+DIM*2+YY] -= ty;
911 f[j_coord_offset+DIM*2+ZZ] -= tz;
913 /**************************
914 * CALCULATE INTERACTIONS *
915 **************************/
919 /* EWALD ELECTROSTATICS */
921 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
922 ewrt = r10*ewtabscale;
925 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
926 felec = qq10*rinv10*(rinvsq10-felec);
930 /* Calculate temporary vectorial force */
935 /* Update vectorial force */
939 f[j_coord_offset+DIM*0+XX] -= tx;
940 f[j_coord_offset+DIM*0+YY] -= ty;
941 f[j_coord_offset+DIM*0+ZZ] -= tz;
943 /**************************
944 * CALCULATE INTERACTIONS *
945 **************************/
949 /* EWALD ELECTROSTATICS */
951 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
952 ewrt = r11*ewtabscale;
955 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
956 felec = qq11*rinv11*(rinvsq11-felec);
960 /* Calculate temporary vectorial force */
965 /* Update vectorial force */
969 f[j_coord_offset+DIM*1+XX] -= tx;
970 f[j_coord_offset+DIM*1+YY] -= ty;
971 f[j_coord_offset+DIM*1+ZZ] -= tz;
973 /**************************
974 * CALCULATE INTERACTIONS *
975 **************************/
979 /* EWALD ELECTROSTATICS */
981 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
982 ewrt = r12*ewtabscale;
985 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
986 felec = qq12*rinv12*(rinvsq12-felec);
990 /* Calculate temporary vectorial force */
995 /* Update vectorial force */
999 f[j_coord_offset+DIM*2+XX] -= tx;
1000 f[j_coord_offset+DIM*2+YY] -= ty;
1001 f[j_coord_offset+DIM*2+ZZ] -= tz;
1003 /**************************
1004 * CALCULATE INTERACTIONS *
1005 **************************/
1009 /* EWALD ELECTROSTATICS */
1011 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1012 ewrt = r20*ewtabscale;
1014 eweps = ewrt-ewitab;
1015 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1016 felec = qq20*rinv20*(rinvsq20-felec);
1020 /* Calculate temporary vectorial force */
1025 /* Update vectorial force */
1029 f[j_coord_offset+DIM*0+XX] -= tx;
1030 f[j_coord_offset+DIM*0+YY] -= ty;
1031 f[j_coord_offset+DIM*0+ZZ] -= tz;
1033 /**************************
1034 * CALCULATE INTERACTIONS *
1035 **************************/
1039 /* EWALD ELECTROSTATICS */
1041 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1042 ewrt = r21*ewtabscale;
1044 eweps = ewrt-ewitab;
1045 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1046 felec = qq21*rinv21*(rinvsq21-felec);
1050 /* Calculate temporary vectorial force */
1055 /* Update vectorial force */
1059 f[j_coord_offset+DIM*1+XX] -= tx;
1060 f[j_coord_offset+DIM*1+YY] -= ty;
1061 f[j_coord_offset+DIM*1+ZZ] -= tz;
1063 /**************************
1064 * CALCULATE INTERACTIONS *
1065 **************************/
1069 /* EWALD ELECTROSTATICS */
1071 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1072 ewrt = r22*ewtabscale;
1074 eweps = ewrt-ewitab;
1075 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1076 felec = qq22*rinv22*(rinvsq22-felec);
1080 /* Calculate temporary vectorial force */
1085 /* Update vectorial force */
1089 f[j_coord_offset+DIM*2+XX] -= tx;
1090 f[j_coord_offset+DIM*2+YY] -= ty;
1091 f[j_coord_offset+DIM*2+ZZ] -= tz;
1093 /* Inner loop uses 297 flops */
1095 /* End of innermost loop */
1098 f[i_coord_offset+DIM*0+XX] += fix0;
1099 f[i_coord_offset+DIM*0+YY] += fiy0;
1100 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1104 f[i_coord_offset+DIM*1+XX] += fix1;
1105 f[i_coord_offset+DIM*1+YY] += fiy1;
1106 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1110 f[i_coord_offset+DIM*2+XX] += fix2;
1111 f[i_coord_offset+DIM*2+YY] += fiy2;
1112 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1116 fshift[i_shift_offset+XX] += tx;
1117 fshift[i_shift_offset+YY] += ty;
1118 fshift[i_shift_offset+ZZ] += tz;
1120 /* Increment number of inner iterations */
1121 inneriter += j_index_end - j_index_start;
1123 /* Outer loop uses 30 flops */
1126 /* Increment number of outer iterations */
1129 /* Update outer/inner flops */
1131 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*30 + inneriter*297);