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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW3W3_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwNone_GeomW3W3_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
111 charge = mdatoms->chargeA;
113 sh_ewald = fr->ic->sh_ewald;
114 ewtab = fr->ic->tabq_coul_FDV0;
115 ewtabscale = fr->ic->tabq_scale;
116 ewtabhalfspace = 0.5/ewtabscale;
118 /* Setup water-specific parameters */
119 inr = nlist->iinr[0];
120 iq0 = facel*charge[inr+0];
121 iq1 = facel*charge[inr+1];
122 iq2 = facel*charge[inr+2];
140 /* Start outer loop over neighborlists */
141 for(iidx=0; iidx<nri; iidx++)
143 /* Load shift vector for this list */
144 i_shift_offset = DIM*shiftidx[iidx];
145 shX = shiftvec[i_shift_offset+XX];
146 shY = shiftvec[i_shift_offset+YY];
147 shZ = shiftvec[i_shift_offset+ZZ];
149 /* Load limits for loop over neighbors */
150 j_index_start = jindex[iidx];
151 j_index_end = jindex[iidx+1];
153 /* Get outer coordinate index */
155 i_coord_offset = DIM*inr;
157 /* Load i particle coords and add shift vector */
158 ix0 = shX + x[i_coord_offset+DIM*0+XX];
159 iy0 = shY + x[i_coord_offset+DIM*0+YY];
160 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
161 ix1 = shX + x[i_coord_offset+DIM*1+XX];
162 iy1 = shY + x[i_coord_offset+DIM*1+YY];
163 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
164 ix2 = shX + x[i_coord_offset+DIM*2+XX];
165 iy2 = shY + x[i_coord_offset+DIM*2+YY];
166 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
178 /* Reset potential sums */
181 /* Start inner kernel loop */
182 for(jidx=j_index_start; jidx<j_index_end; jidx++)
184 /* Get j neighbor index, and coordinate index */
186 j_coord_offset = DIM*jnr;
188 /* load j atom coordinates */
189 jx0 = x[j_coord_offset+DIM*0+XX];
190 jy0 = x[j_coord_offset+DIM*0+YY];
191 jz0 = x[j_coord_offset+DIM*0+ZZ];
192 jx1 = x[j_coord_offset+DIM*1+XX];
193 jy1 = x[j_coord_offset+DIM*1+YY];
194 jz1 = x[j_coord_offset+DIM*1+ZZ];
195 jx2 = x[j_coord_offset+DIM*2+XX];
196 jy2 = x[j_coord_offset+DIM*2+YY];
197 jz2 = x[j_coord_offset+DIM*2+ZZ];
199 /* Calculate displacement vector */
228 /* Calculate squared distance and things based on it */
229 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
230 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
231 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
232 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
233 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
234 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
235 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
236 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
237 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
239 rinv00 = gmx_invsqrt(rsq00);
240 rinv01 = gmx_invsqrt(rsq01);
241 rinv02 = gmx_invsqrt(rsq02);
242 rinv10 = gmx_invsqrt(rsq10);
243 rinv11 = gmx_invsqrt(rsq11);
244 rinv12 = gmx_invsqrt(rsq12);
245 rinv20 = gmx_invsqrt(rsq20);
246 rinv21 = gmx_invsqrt(rsq21);
247 rinv22 = gmx_invsqrt(rsq22);
249 rinvsq00 = rinv00*rinv00;
250 rinvsq01 = rinv01*rinv01;
251 rinvsq02 = rinv02*rinv02;
252 rinvsq10 = rinv10*rinv10;
253 rinvsq11 = rinv11*rinv11;
254 rinvsq12 = rinv12*rinv12;
255 rinvsq20 = rinv20*rinv20;
256 rinvsq21 = rinv21*rinv21;
257 rinvsq22 = rinv22*rinv22;
259 /**************************
260 * CALCULATE INTERACTIONS *
261 **************************/
265 /* EWALD ELECTROSTATICS */
267 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
268 ewrt = r00*ewtabscale;
272 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
273 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
274 felec = qq00*rinv00*(rinvsq00-felec);
276 /* Update potential sums from outer loop */
281 /* Calculate temporary vectorial force */
286 /* Update vectorial force */
290 f[j_coord_offset+DIM*0+XX] -= tx;
291 f[j_coord_offset+DIM*0+YY] -= ty;
292 f[j_coord_offset+DIM*0+ZZ] -= tz;
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
300 /* EWALD ELECTROSTATICS */
302 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
303 ewrt = r01*ewtabscale;
307 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
308 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
309 felec = qq01*rinv01*(rinvsq01-felec);
311 /* Update potential sums from outer loop */
316 /* Calculate temporary vectorial force */
321 /* Update vectorial force */
325 f[j_coord_offset+DIM*1+XX] -= tx;
326 f[j_coord_offset+DIM*1+YY] -= ty;
327 f[j_coord_offset+DIM*1+ZZ] -= tz;
329 /**************************
330 * CALCULATE INTERACTIONS *
331 **************************/
335 /* EWALD ELECTROSTATICS */
337 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
338 ewrt = r02*ewtabscale;
342 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
343 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
344 felec = qq02*rinv02*(rinvsq02-felec);
346 /* Update potential sums from outer loop */
351 /* Calculate temporary vectorial force */
356 /* Update vectorial force */
360 f[j_coord_offset+DIM*2+XX] -= tx;
361 f[j_coord_offset+DIM*2+YY] -= ty;
362 f[j_coord_offset+DIM*2+ZZ] -= tz;
364 /**************************
365 * CALCULATE INTERACTIONS *
366 **************************/
370 /* EWALD ELECTROSTATICS */
372 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
373 ewrt = r10*ewtabscale;
377 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
378 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
379 felec = qq10*rinv10*(rinvsq10-felec);
381 /* Update potential sums from outer loop */
386 /* Calculate temporary vectorial force */
391 /* Update vectorial force */
395 f[j_coord_offset+DIM*0+XX] -= tx;
396 f[j_coord_offset+DIM*0+YY] -= ty;
397 f[j_coord_offset+DIM*0+ZZ] -= tz;
399 /**************************
400 * CALCULATE INTERACTIONS *
401 **************************/
405 /* EWALD ELECTROSTATICS */
407 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
408 ewrt = r11*ewtabscale;
412 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
413 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
414 felec = qq11*rinv11*(rinvsq11-felec);
416 /* Update potential sums from outer loop */
421 /* Calculate temporary vectorial force */
426 /* Update vectorial force */
430 f[j_coord_offset+DIM*1+XX] -= tx;
431 f[j_coord_offset+DIM*1+YY] -= ty;
432 f[j_coord_offset+DIM*1+ZZ] -= tz;
434 /**************************
435 * CALCULATE INTERACTIONS *
436 **************************/
440 /* EWALD ELECTROSTATICS */
442 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
443 ewrt = r12*ewtabscale;
447 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
448 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
449 felec = qq12*rinv12*(rinvsq12-felec);
451 /* Update potential sums from outer loop */
456 /* Calculate temporary vectorial force */
461 /* Update vectorial force */
465 f[j_coord_offset+DIM*2+XX] -= tx;
466 f[j_coord_offset+DIM*2+YY] -= ty;
467 f[j_coord_offset+DIM*2+ZZ] -= tz;
469 /**************************
470 * CALCULATE INTERACTIONS *
471 **************************/
475 /* EWALD ELECTROSTATICS */
477 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
478 ewrt = r20*ewtabscale;
482 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
483 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
484 felec = qq20*rinv20*(rinvsq20-felec);
486 /* Update potential sums from outer loop */
491 /* Calculate temporary vectorial force */
496 /* Update vectorial force */
500 f[j_coord_offset+DIM*0+XX] -= tx;
501 f[j_coord_offset+DIM*0+YY] -= ty;
502 f[j_coord_offset+DIM*0+ZZ] -= tz;
504 /**************************
505 * CALCULATE INTERACTIONS *
506 **************************/
510 /* EWALD ELECTROSTATICS */
512 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
513 ewrt = r21*ewtabscale;
517 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
518 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
519 felec = qq21*rinv21*(rinvsq21-felec);
521 /* Update potential sums from outer loop */
526 /* Calculate temporary vectorial force */
531 /* Update vectorial force */
535 f[j_coord_offset+DIM*1+XX] -= tx;
536 f[j_coord_offset+DIM*1+YY] -= ty;
537 f[j_coord_offset+DIM*1+ZZ] -= tz;
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
545 /* EWALD ELECTROSTATICS */
547 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
548 ewrt = r22*ewtabscale;
552 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
553 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
554 felec = qq22*rinv22*(rinvsq22-felec);
556 /* Update potential sums from outer loop */
561 /* Calculate temporary vectorial force */
566 /* Update vectorial force */
570 f[j_coord_offset+DIM*2+XX] -= tx;
571 f[j_coord_offset+DIM*2+YY] -= ty;
572 f[j_coord_offset+DIM*2+ZZ] -= tz;
574 /* Inner loop uses 360 flops */
576 /* End of innermost loop */
579 f[i_coord_offset+DIM*0+XX] += fix0;
580 f[i_coord_offset+DIM*0+YY] += fiy0;
581 f[i_coord_offset+DIM*0+ZZ] += fiz0;
585 f[i_coord_offset+DIM*1+XX] += fix1;
586 f[i_coord_offset+DIM*1+YY] += fiy1;
587 f[i_coord_offset+DIM*1+ZZ] += fiz1;
591 f[i_coord_offset+DIM*2+XX] += fix2;
592 f[i_coord_offset+DIM*2+YY] += fiy2;
593 f[i_coord_offset+DIM*2+ZZ] += fiz2;
597 fshift[i_shift_offset+XX] += tx;
598 fshift[i_shift_offset+YY] += ty;
599 fshift[i_shift_offset+ZZ] += tz;
602 /* Update potential energies */
603 kernel_data->energygrp_elec[ggid] += velecsum;
605 /* Increment number of inner iterations */
606 inneriter += j_index_end - j_index_start;
608 /* Outer loop uses 31 flops */
611 /* Increment number of outer iterations */
614 /* Update outer/inner flops */
616 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*31 + inneriter*360);
619 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW3W3_F_c
620 * Electrostatics interaction: Ewald
621 * VdW interaction: None
622 * Geometry: Water3-Water3
623 * Calculate force/pot: Force
626 nb_kernel_ElecEw_VdwNone_GeomW3W3_F_c
627 (t_nblist * gmx_restrict nlist,
628 rvec * gmx_restrict xx,
629 rvec * gmx_restrict ff,
630 t_forcerec * gmx_restrict fr,
631 t_mdatoms * gmx_restrict mdatoms,
632 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
633 t_nrnb * gmx_restrict nrnb)
635 int i_shift_offset,i_coord_offset,j_coord_offset;
636 int j_index_start,j_index_end;
637 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
638 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
639 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
640 real *shiftvec,*fshift,*x,*f;
642 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
644 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
646 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
648 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
650 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
652 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
653 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
654 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
655 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
656 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
657 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
658 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
659 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
660 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
661 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
662 real velec,felec,velecsum,facel,crf,krf,krf2;
665 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
673 jindex = nlist->jindex;
675 shiftidx = nlist->shift;
677 shiftvec = fr->shift_vec[0];
678 fshift = fr->fshift[0];
680 charge = mdatoms->chargeA;
682 sh_ewald = fr->ic->sh_ewald;
683 ewtab = fr->ic->tabq_coul_F;
684 ewtabscale = fr->ic->tabq_scale;
685 ewtabhalfspace = 0.5/ewtabscale;
687 /* Setup water-specific parameters */
688 inr = nlist->iinr[0];
689 iq0 = facel*charge[inr+0];
690 iq1 = facel*charge[inr+1];
691 iq2 = facel*charge[inr+2];
709 /* Start outer loop over neighborlists */
710 for(iidx=0; iidx<nri; iidx++)
712 /* Load shift vector for this list */
713 i_shift_offset = DIM*shiftidx[iidx];
714 shX = shiftvec[i_shift_offset+XX];
715 shY = shiftvec[i_shift_offset+YY];
716 shZ = shiftvec[i_shift_offset+ZZ];
718 /* Load limits for loop over neighbors */
719 j_index_start = jindex[iidx];
720 j_index_end = jindex[iidx+1];
722 /* Get outer coordinate index */
724 i_coord_offset = DIM*inr;
726 /* Load i particle coords and add shift vector */
727 ix0 = shX + x[i_coord_offset+DIM*0+XX];
728 iy0 = shY + x[i_coord_offset+DIM*0+YY];
729 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
730 ix1 = shX + x[i_coord_offset+DIM*1+XX];
731 iy1 = shY + x[i_coord_offset+DIM*1+YY];
732 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
733 ix2 = shX + x[i_coord_offset+DIM*2+XX];
734 iy2 = shY + x[i_coord_offset+DIM*2+YY];
735 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
747 /* Start inner kernel loop */
748 for(jidx=j_index_start; jidx<j_index_end; jidx++)
750 /* Get j neighbor index, and coordinate index */
752 j_coord_offset = DIM*jnr;
754 /* load j atom coordinates */
755 jx0 = x[j_coord_offset+DIM*0+XX];
756 jy0 = x[j_coord_offset+DIM*0+YY];
757 jz0 = x[j_coord_offset+DIM*0+ZZ];
758 jx1 = x[j_coord_offset+DIM*1+XX];
759 jy1 = x[j_coord_offset+DIM*1+YY];
760 jz1 = x[j_coord_offset+DIM*1+ZZ];
761 jx2 = x[j_coord_offset+DIM*2+XX];
762 jy2 = x[j_coord_offset+DIM*2+YY];
763 jz2 = x[j_coord_offset+DIM*2+ZZ];
765 /* Calculate displacement vector */
794 /* Calculate squared distance and things based on it */
795 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
796 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
797 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
798 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
799 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
800 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
801 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
802 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
803 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
805 rinv00 = gmx_invsqrt(rsq00);
806 rinv01 = gmx_invsqrt(rsq01);
807 rinv02 = gmx_invsqrt(rsq02);
808 rinv10 = gmx_invsqrt(rsq10);
809 rinv11 = gmx_invsqrt(rsq11);
810 rinv12 = gmx_invsqrt(rsq12);
811 rinv20 = gmx_invsqrt(rsq20);
812 rinv21 = gmx_invsqrt(rsq21);
813 rinv22 = gmx_invsqrt(rsq22);
815 rinvsq00 = rinv00*rinv00;
816 rinvsq01 = rinv01*rinv01;
817 rinvsq02 = rinv02*rinv02;
818 rinvsq10 = rinv10*rinv10;
819 rinvsq11 = rinv11*rinv11;
820 rinvsq12 = rinv12*rinv12;
821 rinvsq20 = rinv20*rinv20;
822 rinvsq21 = rinv21*rinv21;
823 rinvsq22 = rinv22*rinv22;
825 /**************************
826 * CALCULATE INTERACTIONS *
827 **************************/
831 /* EWALD ELECTROSTATICS */
833 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
834 ewrt = r00*ewtabscale;
837 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
838 felec = qq00*rinv00*(rinvsq00-felec);
842 /* Calculate temporary vectorial force */
847 /* Update vectorial force */
851 f[j_coord_offset+DIM*0+XX] -= tx;
852 f[j_coord_offset+DIM*0+YY] -= ty;
853 f[j_coord_offset+DIM*0+ZZ] -= tz;
855 /**************************
856 * CALCULATE INTERACTIONS *
857 **************************/
861 /* EWALD ELECTROSTATICS */
863 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
864 ewrt = r01*ewtabscale;
867 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
868 felec = qq01*rinv01*(rinvsq01-felec);
872 /* Calculate temporary vectorial force */
877 /* Update vectorial force */
881 f[j_coord_offset+DIM*1+XX] -= tx;
882 f[j_coord_offset+DIM*1+YY] -= ty;
883 f[j_coord_offset+DIM*1+ZZ] -= tz;
885 /**************************
886 * CALCULATE INTERACTIONS *
887 **************************/
891 /* EWALD ELECTROSTATICS */
893 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
894 ewrt = r02*ewtabscale;
897 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
898 felec = qq02*rinv02*(rinvsq02-felec);
902 /* Calculate temporary vectorial force */
907 /* Update vectorial force */
911 f[j_coord_offset+DIM*2+XX] -= tx;
912 f[j_coord_offset+DIM*2+YY] -= ty;
913 f[j_coord_offset+DIM*2+ZZ] -= tz;
915 /**************************
916 * CALCULATE INTERACTIONS *
917 **************************/
921 /* EWALD ELECTROSTATICS */
923 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
924 ewrt = r10*ewtabscale;
927 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
928 felec = qq10*rinv10*(rinvsq10-felec);
932 /* Calculate temporary vectorial force */
937 /* Update vectorial force */
941 f[j_coord_offset+DIM*0+XX] -= tx;
942 f[j_coord_offset+DIM*0+YY] -= ty;
943 f[j_coord_offset+DIM*0+ZZ] -= tz;
945 /**************************
946 * CALCULATE INTERACTIONS *
947 **************************/
951 /* EWALD ELECTROSTATICS */
953 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
954 ewrt = r11*ewtabscale;
957 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
958 felec = qq11*rinv11*(rinvsq11-felec);
962 /* Calculate temporary vectorial force */
967 /* Update vectorial force */
971 f[j_coord_offset+DIM*1+XX] -= tx;
972 f[j_coord_offset+DIM*1+YY] -= ty;
973 f[j_coord_offset+DIM*1+ZZ] -= tz;
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
981 /* EWALD ELECTROSTATICS */
983 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
984 ewrt = r12*ewtabscale;
987 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
988 felec = qq12*rinv12*(rinvsq12-felec);
992 /* Calculate temporary vectorial force */
997 /* Update vectorial force */
1001 f[j_coord_offset+DIM*2+XX] -= tx;
1002 f[j_coord_offset+DIM*2+YY] -= ty;
1003 f[j_coord_offset+DIM*2+ZZ] -= tz;
1005 /**************************
1006 * CALCULATE INTERACTIONS *
1007 **************************/
1011 /* EWALD ELECTROSTATICS */
1013 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1014 ewrt = r20*ewtabscale;
1016 eweps = ewrt-ewitab;
1017 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1018 felec = qq20*rinv20*(rinvsq20-felec);
1022 /* Calculate temporary vectorial force */
1027 /* Update vectorial force */
1031 f[j_coord_offset+DIM*0+XX] -= tx;
1032 f[j_coord_offset+DIM*0+YY] -= ty;
1033 f[j_coord_offset+DIM*0+ZZ] -= tz;
1035 /**************************
1036 * CALCULATE INTERACTIONS *
1037 **************************/
1041 /* EWALD ELECTROSTATICS */
1043 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1044 ewrt = r21*ewtabscale;
1046 eweps = ewrt-ewitab;
1047 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1048 felec = qq21*rinv21*(rinvsq21-felec);
1052 /* Calculate temporary vectorial force */
1057 /* Update vectorial force */
1061 f[j_coord_offset+DIM*1+XX] -= tx;
1062 f[j_coord_offset+DIM*1+YY] -= ty;
1063 f[j_coord_offset+DIM*1+ZZ] -= tz;
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1071 /* EWALD ELECTROSTATICS */
1073 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1074 ewrt = r22*ewtabscale;
1076 eweps = ewrt-ewitab;
1077 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1078 felec = qq22*rinv22*(rinvsq22-felec);
1082 /* Calculate temporary vectorial force */
1087 /* Update vectorial force */
1091 f[j_coord_offset+DIM*2+XX] -= tx;
1092 f[j_coord_offset+DIM*2+YY] -= ty;
1093 f[j_coord_offset+DIM*2+ZZ] -= tz;
1095 /* Inner loop uses 297 flops */
1097 /* End of innermost loop */
1100 f[i_coord_offset+DIM*0+XX] += fix0;
1101 f[i_coord_offset+DIM*0+YY] += fiy0;
1102 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1106 f[i_coord_offset+DIM*1+XX] += fix1;
1107 f[i_coord_offset+DIM*1+YY] += fiy1;
1108 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1112 f[i_coord_offset+DIM*2+XX] += fix2;
1113 f[i_coord_offset+DIM*2+YY] += fiy2;
1114 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1118 fshift[i_shift_offset+XX] += tx;
1119 fshift[i_shift_offset+YY] += ty;
1120 fshift[i_shift_offset+ZZ] += tz;
1122 /* Increment number of inner iterations */
1123 inneriter += j_index_end - j_index_start;
1125 /* Outer loop uses 30 flops */
1128 /* Increment number of outer iterations */
1131 /* Update outer/inner flops */
1133 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*30 + inneriter*297);