Introduce gmxpre.h for truly global definitions
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecEwSh_VdwNone_GeomW3W3_c.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35 /*
36  * Note: this file was generated by the GROMACS c kernel generator.
37  */
38 #include "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwNone_GeomW3W3_VF_c
51  * Electrostatics interaction: Ewald
52  * VdW interaction:            None
53  * Geometry:                   Water3-Water3
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecEwSh_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)
65 {
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;
72     int              vdwioffset0;
73     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
74     int              vdwioffset1;
75     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
76     int              vdwioffset2;
77     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
78     int              vdwjidx0;
79     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80     int              vdwjidx1;
81     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
82     int              vdwjidx2;
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;
94     real             *charge;
95     int              ewitab;
96     real             ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
97     real             *ewtab;
98
99     x                = xx[0];
100     f                = ff[0];
101
102     nri              = nlist->nri;
103     iinr             = nlist->iinr;
104     jindex           = nlist->jindex;
105     jjnr             = nlist->jjnr;
106     shiftidx         = nlist->shift;
107     gid              = nlist->gid;
108     shiftvec         = fr->shift_vec[0];
109     fshift           = fr->fshift[0];
110     facel            = fr->epsfac;
111     charge           = mdatoms->chargeA;
112
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;
117
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];
123
124     jq0              = charge[inr+0];
125     jq1              = charge[inr+1];
126     jq2              = charge[inr+2];
127     qq00             = iq0*jq0;
128     qq01             = iq0*jq1;
129     qq02             = iq0*jq2;
130     qq10             = iq1*jq0;
131     qq11             = iq1*jq1;
132     qq12             = iq1*jq2;
133     qq20             = iq2*jq0;
134     qq21             = iq2*jq1;
135     qq22             = iq2*jq2;
136
137     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
138     rcutoff          = fr->rcoulomb;
139     rcutoff2         = rcutoff*rcutoff;
140
141     outeriter        = 0;
142     inneriter        = 0;
143
144     /* Start outer loop over neighborlists */
145     for(iidx=0; iidx<nri; iidx++)
146     {
147         /* Load shift vector for this list */
148         i_shift_offset   = DIM*shiftidx[iidx];
149         shX              = shiftvec[i_shift_offset+XX];
150         shY              = shiftvec[i_shift_offset+YY];
151         shZ              = shiftvec[i_shift_offset+ZZ];
152
153         /* Load limits for loop over neighbors */
154         j_index_start    = jindex[iidx];
155         j_index_end      = jindex[iidx+1];
156
157         /* Get outer coordinate index */
158         inr              = iinr[iidx];
159         i_coord_offset   = DIM*inr;
160
161         /* Load i particle coords and add shift vector */
162         ix0              = shX + x[i_coord_offset+DIM*0+XX];
163         iy0              = shY + x[i_coord_offset+DIM*0+YY];
164         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
165         ix1              = shX + x[i_coord_offset+DIM*1+XX];
166         iy1              = shY + x[i_coord_offset+DIM*1+YY];
167         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
168         ix2              = shX + x[i_coord_offset+DIM*2+XX];
169         iy2              = shY + x[i_coord_offset+DIM*2+YY];
170         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
171
172         fix0             = 0.0;
173         fiy0             = 0.0;
174         fiz0             = 0.0;
175         fix1             = 0.0;
176         fiy1             = 0.0;
177         fiz1             = 0.0;
178         fix2             = 0.0;
179         fiy2             = 0.0;
180         fiz2             = 0.0;
181
182         /* Reset potential sums */
183         velecsum         = 0.0;
184
185         /* Start inner kernel loop */
186         for(jidx=j_index_start; jidx<j_index_end; jidx++)
187         {
188             /* Get j neighbor index, and coordinate index */
189             jnr              = jjnr[jidx];
190             j_coord_offset   = DIM*jnr;
191
192             /* load j atom coordinates */
193             jx0              = x[j_coord_offset+DIM*0+XX];
194             jy0              = x[j_coord_offset+DIM*0+YY];
195             jz0              = x[j_coord_offset+DIM*0+ZZ];
196             jx1              = x[j_coord_offset+DIM*1+XX];
197             jy1              = x[j_coord_offset+DIM*1+YY];
198             jz1              = x[j_coord_offset+DIM*1+ZZ];
199             jx2              = x[j_coord_offset+DIM*2+XX];
200             jy2              = x[j_coord_offset+DIM*2+YY];
201             jz2              = x[j_coord_offset+DIM*2+ZZ];
202
203             /* Calculate displacement vector */
204             dx00             = ix0 - jx0;
205             dy00             = iy0 - jy0;
206             dz00             = iz0 - jz0;
207             dx01             = ix0 - jx1;
208             dy01             = iy0 - jy1;
209             dz01             = iz0 - jz1;
210             dx02             = ix0 - jx2;
211             dy02             = iy0 - jy2;
212             dz02             = iz0 - jz2;
213             dx10             = ix1 - jx0;
214             dy10             = iy1 - jy0;
215             dz10             = iz1 - jz0;
216             dx11             = ix1 - jx1;
217             dy11             = iy1 - jy1;
218             dz11             = iz1 - jz1;
219             dx12             = ix1 - jx2;
220             dy12             = iy1 - jy2;
221             dz12             = iz1 - jz2;
222             dx20             = ix2 - jx0;
223             dy20             = iy2 - jy0;
224             dz20             = iz2 - jz0;
225             dx21             = ix2 - jx1;
226             dy21             = iy2 - jy1;
227             dz21             = iz2 - jz1;
228             dx22             = ix2 - jx2;
229             dy22             = iy2 - jy2;
230             dz22             = iz2 - jz2;
231
232             /* Calculate squared distance and things based on it */
233             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
234             rsq01            = dx01*dx01+dy01*dy01+dz01*dz01;
235             rsq02            = dx02*dx02+dy02*dy02+dz02*dz02;
236             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
237             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
238             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
239             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
240             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
241             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
242
243             rinv00           = gmx_invsqrt(rsq00);
244             rinv01           = gmx_invsqrt(rsq01);
245             rinv02           = gmx_invsqrt(rsq02);
246             rinv10           = gmx_invsqrt(rsq10);
247             rinv11           = gmx_invsqrt(rsq11);
248             rinv12           = gmx_invsqrt(rsq12);
249             rinv20           = gmx_invsqrt(rsq20);
250             rinv21           = gmx_invsqrt(rsq21);
251             rinv22           = gmx_invsqrt(rsq22);
252
253             rinvsq00         = rinv00*rinv00;
254             rinvsq01         = rinv01*rinv01;
255             rinvsq02         = rinv02*rinv02;
256             rinvsq10         = rinv10*rinv10;
257             rinvsq11         = rinv11*rinv11;
258             rinvsq12         = rinv12*rinv12;
259             rinvsq20         = rinv20*rinv20;
260             rinvsq21         = rinv21*rinv21;
261             rinvsq22         = rinv22*rinv22;
262
263             /**************************
264              * CALCULATE INTERACTIONS *
265              **************************/
266
267             if (rsq00<rcutoff2)
268             {
269
270             r00              = rsq00*rinv00;
271
272             /* EWALD ELECTROSTATICS */
273
274             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
275             ewrt             = r00*ewtabscale;
276             ewitab           = ewrt;
277             eweps            = ewrt-ewitab;
278             ewitab           = 4*ewitab;
279             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
280             velec            = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
281             felec            = qq00*rinv00*(rinvsq00-felec);
282
283             /* Update potential sums from outer loop */
284             velecsum        += velec;
285
286             fscal            = felec;
287
288             /* Calculate temporary vectorial force */
289             tx               = fscal*dx00;
290             ty               = fscal*dy00;
291             tz               = fscal*dz00;
292
293             /* Update vectorial force */
294             fix0            += tx;
295             fiy0            += ty;
296             fiz0            += tz;
297             f[j_coord_offset+DIM*0+XX] -= tx;
298             f[j_coord_offset+DIM*0+YY] -= ty;
299             f[j_coord_offset+DIM*0+ZZ] -= tz;
300
301             }
302
303             /**************************
304              * CALCULATE INTERACTIONS *
305              **************************/
306
307             if (rsq01<rcutoff2)
308             {
309
310             r01              = rsq01*rinv01;
311
312             /* EWALD ELECTROSTATICS */
313
314             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
315             ewrt             = r01*ewtabscale;
316             ewitab           = ewrt;
317             eweps            = ewrt-ewitab;
318             ewitab           = 4*ewitab;
319             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
320             velec            = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
321             felec            = qq01*rinv01*(rinvsq01-felec);
322
323             /* Update potential sums from outer loop */
324             velecsum        += velec;
325
326             fscal            = felec;
327
328             /* Calculate temporary vectorial force */
329             tx               = fscal*dx01;
330             ty               = fscal*dy01;
331             tz               = fscal*dz01;
332
333             /* Update vectorial force */
334             fix0            += tx;
335             fiy0            += ty;
336             fiz0            += tz;
337             f[j_coord_offset+DIM*1+XX] -= tx;
338             f[j_coord_offset+DIM*1+YY] -= ty;
339             f[j_coord_offset+DIM*1+ZZ] -= tz;
340
341             }
342
343             /**************************
344              * CALCULATE INTERACTIONS *
345              **************************/
346
347             if (rsq02<rcutoff2)
348             {
349
350             r02              = rsq02*rinv02;
351
352             /* EWALD ELECTROSTATICS */
353
354             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
355             ewrt             = r02*ewtabscale;
356             ewitab           = ewrt;
357             eweps            = ewrt-ewitab;
358             ewitab           = 4*ewitab;
359             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
360             velec            = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
361             felec            = qq02*rinv02*(rinvsq02-felec);
362
363             /* Update potential sums from outer loop */
364             velecsum        += velec;
365
366             fscal            = felec;
367
368             /* Calculate temporary vectorial force */
369             tx               = fscal*dx02;
370             ty               = fscal*dy02;
371             tz               = fscal*dz02;
372
373             /* Update vectorial force */
374             fix0            += tx;
375             fiy0            += ty;
376             fiz0            += tz;
377             f[j_coord_offset+DIM*2+XX] -= tx;
378             f[j_coord_offset+DIM*2+YY] -= ty;
379             f[j_coord_offset+DIM*2+ZZ] -= tz;
380
381             }
382
383             /**************************
384              * CALCULATE INTERACTIONS *
385              **************************/
386
387             if (rsq10<rcutoff2)
388             {
389
390             r10              = rsq10*rinv10;
391
392             /* EWALD ELECTROSTATICS */
393
394             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
395             ewrt             = r10*ewtabscale;
396             ewitab           = ewrt;
397             eweps            = ewrt-ewitab;
398             ewitab           = 4*ewitab;
399             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
400             velec            = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
401             felec            = qq10*rinv10*(rinvsq10-felec);
402
403             /* Update potential sums from outer loop */
404             velecsum        += velec;
405
406             fscal            = felec;
407
408             /* Calculate temporary vectorial force */
409             tx               = fscal*dx10;
410             ty               = fscal*dy10;
411             tz               = fscal*dz10;
412
413             /* Update vectorial force */
414             fix1            += tx;
415             fiy1            += ty;
416             fiz1            += tz;
417             f[j_coord_offset+DIM*0+XX] -= tx;
418             f[j_coord_offset+DIM*0+YY] -= ty;
419             f[j_coord_offset+DIM*0+ZZ] -= tz;
420
421             }
422
423             /**************************
424              * CALCULATE INTERACTIONS *
425              **************************/
426
427             if (rsq11<rcutoff2)
428             {
429
430             r11              = rsq11*rinv11;
431
432             /* EWALD ELECTROSTATICS */
433
434             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
435             ewrt             = r11*ewtabscale;
436             ewitab           = ewrt;
437             eweps            = ewrt-ewitab;
438             ewitab           = 4*ewitab;
439             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
440             velec            = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
441             felec            = qq11*rinv11*(rinvsq11-felec);
442
443             /* Update potential sums from outer loop */
444             velecsum        += velec;
445
446             fscal            = felec;
447
448             /* Calculate temporary vectorial force */
449             tx               = fscal*dx11;
450             ty               = fscal*dy11;
451             tz               = fscal*dz11;
452
453             /* Update vectorial force */
454             fix1            += tx;
455             fiy1            += ty;
456             fiz1            += tz;
457             f[j_coord_offset+DIM*1+XX] -= tx;
458             f[j_coord_offset+DIM*1+YY] -= ty;
459             f[j_coord_offset+DIM*1+ZZ] -= tz;
460
461             }
462
463             /**************************
464              * CALCULATE INTERACTIONS *
465              **************************/
466
467             if (rsq12<rcutoff2)
468             {
469
470             r12              = rsq12*rinv12;
471
472             /* EWALD ELECTROSTATICS */
473
474             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
475             ewrt             = r12*ewtabscale;
476             ewitab           = ewrt;
477             eweps            = ewrt-ewitab;
478             ewitab           = 4*ewitab;
479             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
480             velec            = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
481             felec            = qq12*rinv12*(rinvsq12-felec);
482
483             /* Update potential sums from outer loop */
484             velecsum        += velec;
485
486             fscal            = felec;
487
488             /* Calculate temporary vectorial force */
489             tx               = fscal*dx12;
490             ty               = fscal*dy12;
491             tz               = fscal*dz12;
492
493             /* Update vectorial force */
494             fix1            += tx;
495             fiy1            += ty;
496             fiz1            += tz;
497             f[j_coord_offset+DIM*2+XX] -= tx;
498             f[j_coord_offset+DIM*2+YY] -= ty;
499             f[j_coord_offset+DIM*2+ZZ] -= tz;
500
501             }
502
503             /**************************
504              * CALCULATE INTERACTIONS *
505              **************************/
506
507             if (rsq20<rcutoff2)
508             {
509
510             r20              = rsq20*rinv20;
511
512             /* EWALD ELECTROSTATICS */
513
514             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
515             ewrt             = r20*ewtabscale;
516             ewitab           = ewrt;
517             eweps            = ewrt-ewitab;
518             ewitab           = 4*ewitab;
519             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
520             velec            = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
521             felec            = qq20*rinv20*(rinvsq20-felec);
522
523             /* Update potential sums from outer loop */
524             velecsum        += velec;
525
526             fscal            = felec;
527
528             /* Calculate temporary vectorial force */
529             tx               = fscal*dx20;
530             ty               = fscal*dy20;
531             tz               = fscal*dz20;
532
533             /* Update vectorial force */
534             fix2            += tx;
535             fiy2            += ty;
536             fiz2            += tz;
537             f[j_coord_offset+DIM*0+XX] -= tx;
538             f[j_coord_offset+DIM*0+YY] -= ty;
539             f[j_coord_offset+DIM*0+ZZ] -= tz;
540
541             }
542
543             /**************************
544              * CALCULATE INTERACTIONS *
545              **************************/
546
547             if (rsq21<rcutoff2)
548             {
549
550             r21              = rsq21*rinv21;
551
552             /* EWALD ELECTROSTATICS */
553
554             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
555             ewrt             = r21*ewtabscale;
556             ewitab           = ewrt;
557             eweps            = ewrt-ewitab;
558             ewitab           = 4*ewitab;
559             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
560             velec            = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
561             felec            = qq21*rinv21*(rinvsq21-felec);
562
563             /* Update potential sums from outer loop */
564             velecsum        += velec;
565
566             fscal            = felec;
567
568             /* Calculate temporary vectorial force */
569             tx               = fscal*dx21;
570             ty               = fscal*dy21;
571             tz               = fscal*dz21;
572
573             /* Update vectorial force */
574             fix2            += tx;
575             fiy2            += ty;
576             fiz2            += tz;
577             f[j_coord_offset+DIM*1+XX] -= tx;
578             f[j_coord_offset+DIM*1+YY] -= ty;
579             f[j_coord_offset+DIM*1+ZZ] -= tz;
580
581             }
582
583             /**************************
584              * CALCULATE INTERACTIONS *
585              **************************/
586
587             if (rsq22<rcutoff2)
588             {
589
590             r22              = rsq22*rinv22;
591
592             /* EWALD ELECTROSTATICS */
593
594             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
595             ewrt             = r22*ewtabscale;
596             ewitab           = ewrt;
597             eweps            = ewrt-ewitab;
598             ewitab           = 4*ewitab;
599             felec            = ewtab[ewitab]+eweps*ewtab[ewitab+1];
600             velec            = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
601             felec            = qq22*rinv22*(rinvsq22-felec);
602
603             /* Update potential sums from outer loop */
604             velecsum        += velec;
605
606             fscal            = felec;
607
608             /* Calculate temporary vectorial force */
609             tx               = fscal*dx22;
610             ty               = fscal*dy22;
611             tz               = fscal*dz22;
612
613             /* Update vectorial force */
614             fix2            += tx;
615             fiy2            += ty;
616             fiz2            += tz;
617             f[j_coord_offset+DIM*2+XX] -= tx;
618             f[j_coord_offset+DIM*2+YY] -= ty;
619             f[j_coord_offset+DIM*2+ZZ] -= tz;
620
621             }
622
623             /* Inner loop uses 369 flops */
624         }
625         /* End of innermost loop */
626
627         tx = ty = tz = 0;
628         f[i_coord_offset+DIM*0+XX] += fix0;
629         f[i_coord_offset+DIM*0+YY] += fiy0;
630         f[i_coord_offset+DIM*0+ZZ] += fiz0;
631         tx                         += fix0;
632         ty                         += fiy0;
633         tz                         += fiz0;
634         f[i_coord_offset+DIM*1+XX] += fix1;
635         f[i_coord_offset+DIM*1+YY] += fiy1;
636         f[i_coord_offset+DIM*1+ZZ] += fiz1;
637         tx                         += fix1;
638         ty                         += fiy1;
639         tz                         += fiz1;
640         f[i_coord_offset+DIM*2+XX] += fix2;
641         f[i_coord_offset+DIM*2+YY] += fiy2;
642         f[i_coord_offset+DIM*2+ZZ] += fiz2;
643         tx                         += fix2;
644         ty                         += fiy2;
645         tz                         += fiz2;
646         fshift[i_shift_offset+XX]  += tx;
647         fshift[i_shift_offset+YY]  += ty;
648         fshift[i_shift_offset+ZZ]  += tz;
649
650         ggid                        = gid[iidx];
651         /* Update potential energies */
652         kernel_data->energygrp_elec[ggid] += velecsum;
653
654         /* Increment number of inner iterations */
655         inneriter                  += j_index_end - j_index_start;
656
657         /* Outer loop uses 31 flops */
658     }
659
660     /* Increment number of outer iterations */
661     outeriter        += nri;
662
663     /* Update outer/inner flops */
664
665     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*31 + inneriter*369);
666 }
667 /*
668  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwNone_GeomW3W3_F_c
669  * Electrostatics interaction: Ewald
670  * VdW interaction:            None
671  * Geometry:                   Water3-Water3
672  * Calculate force/pot:        Force
673  */
674 void
675 nb_kernel_ElecEwSh_VdwNone_GeomW3W3_F_c
676                     (t_nblist                    * gmx_restrict       nlist,
677                      rvec                        * gmx_restrict          xx,
678                      rvec                        * gmx_restrict          ff,
679                      t_forcerec                  * gmx_restrict          fr,
680                      t_mdatoms                   * gmx_restrict     mdatoms,
681                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
682                      t_nrnb                      * gmx_restrict        nrnb)
683 {
684     int              i_shift_offset,i_coord_offset,j_coord_offset;
685     int              j_index_start,j_index_end;
686     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
687     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
688     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
689     real             *shiftvec,*fshift,*x,*f;
690     int              vdwioffset0;
691     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
692     int              vdwioffset1;
693     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
694     int              vdwioffset2;
695     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
696     int              vdwjidx0;
697     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
698     int              vdwjidx1;
699     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
700     int              vdwjidx2;
701     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
702     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
703     real             dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
704     real             dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
705     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
706     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
707     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
708     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
709     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
710     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
711     real             velec,felec,velecsum,facel,crf,krf,krf2;
712     real             *charge;
713     int              ewitab;
714     real             ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
715     real             *ewtab;
716
717     x                = xx[0];
718     f                = ff[0];
719
720     nri              = nlist->nri;
721     iinr             = nlist->iinr;
722     jindex           = nlist->jindex;
723     jjnr             = nlist->jjnr;
724     shiftidx         = nlist->shift;
725     gid              = nlist->gid;
726     shiftvec         = fr->shift_vec[0];
727     fshift           = fr->fshift[0];
728     facel            = fr->epsfac;
729     charge           = mdatoms->chargeA;
730
731     sh_ewald         = fr->ic->sh_ewald;
732     ewtab            = fr->ic->tabq_coul_F;
733     ewtabscale       = fr->ic->tabq_scale;
734     ewtabhalfspace   = 0.5/ewtabscale;
735
736     /* Setup water-specific parameters */
737     inr              = nlist->iinr[0];
738     iq0              = facel*charge[inr+0];
739     iq1              = facel*charge[inr+1];
740     iq2              = facel*charge[inr+2];
741
742     jq0              = charge[inr+0];
743     jq1              = charge[inr+1];
744     jq2              = charge[inr+2];
745     qq00             = iq0*jq0;
746     qq01             = iq0*jq1;
747     qq02             = iq0*jq2;
748     qq10             = iq1*jq0;
749     qq11             = iq1*jq1;
750     qq12             = iq1*jq2;
751     qq20             = iq2*jq0;
752     qq21             = iq2*jq1;
753     qq22             = iq2*jq2;
754
755     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
756     rcutoff          = fr->rcoulomb;
757     rcutoff2         = rcutoff*rcutoff;
758
759     outeriter        = 0;
760     inneriter        = 0;
761
762     /* Start outer loop over neighborlists */
763     for(iidx=0; iidx<nri; iidx++)
764     {
765         /* Load shift vector for this list */
766         i_shift_offset   = DIM*shiftidx[iidx];
767         shX              = shiftvec[i_shift_offset+XX];
768         shY              = shiftvec[i_shift_offset+YY];
769         shZ              = shiftvec[i_shift_offset+ZZ];
770
771         /* Load limits for loop over neighbors */
772         j_index_start    = jindex[iidx];
773         j_index_end      = jindex[iidx+1];
774
775         /* Get outer coordinate index */
776         inr              = iinr[iidx];
777         i_coord_offset   = DIM*inr;
778
779         /* Load i particle coords and add shift vector */
780         ix0              = shX + x[i_coord_offset+DIM*0+XX];
781         iy0              = shY + x[i_coord_offset+DIM*0+YY];
782         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
783         ix1              = shX + x[i_coord_offset+DIM*1+XX];
784         iy1              = shY + x[i_coord_offset+DIM*1+YY];
785         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
786         ix2              = shX + x[i_coord_offset+DIM*2+XX];
787         iy2              = shY + x[i_coord_offset+DIM*2+YY];
788         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
789
790         fix0             = 0.0;
791         fiy0             = 0.0;
792         fiz0             = 0.0;
793         fix1             = 0.0;
794         fiy1             = 0.0;
795         fiz1             = 0.0;
796         fix2             = 0.0;
797         fiy2             = 0.0;
798         fiz2             = 0.0;
799
800         /* Start inner kernel loop */
801         for(jidx=j_index_start; jidx<j_index_end; jidx++)
802         {
803             /* Get j neighbor index, and coordinate index */
804             jnr              = jjnr[jidx];
805             j_coord_offset   = DIM*jnr;
806
807             /* load j atom coordinates */
808             jx0              = x[j_coord_offset+DIM*0+XX];
809             jy0              = x[j_coord_offset+DIM*0+YY];
810             jz0              = x[j_coord_offset+DIM*0+ZZ];
811             jx1              = x[j_coord_offset+DIM*1+XX];
812             jy1              = x[j_coord_offset+DIM*1+YY];
813             jz1              = x[j_coord_offset+DIM*1+ZZ];
814             jx2              = x[j_coord_offset+DIM*2+XX];
815             jy2              = x[j_coord_offset+DIM*2+YY];
816             jz2              = x[j_coord_offset+DIM*2+ZZ];
817
818             /* Calculate displacement vector */
819             dx00             = ix0 - jx0;
820             dy00             = iy0 - jy0;
821             dz00             = iz0 - jz0;
822             dx01             = ix0 - jx1;
823             dy01             = iy0 - jy1;
824             dz01             = iz0 - jz1;
825             dx02             = ix0 - jx2;
826             dy02             = iy0 - jy2;
827             dz02             = iz0 - jz2;
828             dx10             = ix1 - jx0;
829             dy10             = iy1 - jy0;
830             dz10             = iz1 - jz0;
831             dx11             = ix1 - jx1;
832             dy11             = iy1 - jy1;
833             dz11             = iz1 - jz1;
834             dx12             = ix1 - jx2;
835             dy12             = iy1 - jy2;
836             dz12             = iz1 - jz2;
837             dx20             = ix2 - jx0;
838             dy20             = iy2 - jy0;
839             dz20             = iz2 - jz0;
840             dx21             = ix2 - jx1;
841             dy21             = iy2 - jy1;
842             dz21             = iz2 - jz1;
843             dx22             = ix2 - jx2;
844             dy22             = iy2 - jy2;
845             dz22             = iz2 - jz2;
846
847             /* Calculate squared distance and things based on it */
848             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
849             rsq01            = dx01*dx01+dy01*dy01+dz01*dz01;
850             rsq02            = dx02*dx02+dy02*dy02+dz02*dz02;
851             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
852             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
853             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
854             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
855             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
856             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
857
858             rinv00           = gmx_invsqrt(rsq00);
859             rinv01           = gmx_invsqrt(rsq01);
860             rinv02           = gmx_invsqrt(rsq02);
861             rinv10           = gmx_invsqrt(rsq10);
862             rinv11           = gmx_invsqrt(rsq11);
863             rinv12           = gmx_invsqrt(rsq12);
864             rinv20           = gmx_invsqrt(rsq20);
865             rinv21           = gmx_invsqrt(rsq21);
866             rinv22           = gmx_invsqrt(rsq22);
867
868             rinvsq00         = rinv00*rinv00;
869             rinvsq01         = rinv01*rinv01;
870             rinvsq02         = rinv02*rinv02;
871             rinvsq10         = rinv10*rinv10;
872             rinvsq11         = rinv11*rinv11;
873             rinvsq12         = rinv12*rinv12;
874             rinvsq20         = rinv20*rinv20;
875             rinvsq21         = rinv21*rinv21;
876             rinvsq22         = rinv22*rinv22;
877
878             /**************************
879              * CALCULATE INTERACTIONS *
880              **************************/
881
882             if (rsq00<rcutoff2)
883             {
884
885             r00              = rsq00*rinv00;
886
887             /* EWALD ELECTROSTATICS */
888
889             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
890             ewrt             = r00*ewtabscale;
891             ewitab           = ewrt;
892             eweps            = ewrt-ewitab;
893             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
894             felec            = qq00*rinv00*(rinvsq00-felec);
895
896             fscal            = felec;
897
898             /* Calculate temporary vectorial force */
899             tx               = fscal*dx00;
900             ty               = fscal*dy00;
901             tz               = fscal*dz00;
902
903             /* Update vectorial force */
904             fix0            += tx;
905             fiy0            += ty;
906             fiz0            += tz;
907             f[j_coord_offset+DIM*0+XX] -= tx;
908             f[j_coord_offset+DIM*0+YY] -= ty;
909             f[j_coord_offset+DIM*0+ZZ] -= tz;
910
911             }
912
913             /**************************
914              * CALCULATE INTERACTIONS *
915              **************************/
916
917             if (rsq01<rcutoff2)
918             {
919
920             r01              = rsq01*rinv01;
921
922             /* EWALD ELECTROSTATICS */
923
924             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
925             ewrt             = r01*ewtabscale;
926             ewitab           = ewrt;
927             eweps            = ewrt-ewitab;
928             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
929             felec            = qq01*rinv01*(rinvsq01-felec);
930
931             fscal            = felec;
932
933             /* Calculate temporary vectorial force */
934             tx               = fscal*dx01;
935             ty               = fscal*dy01;
936             tz               = fscal*dz01;
937
938             /* Update vectorial force */
939             fix0            += tx;
940             fiy0            += ty;
941             fiz0            += tz;
942             f[j_coord_offset+DIM*1+XX] -= tx;
943             f[j_coord_offset+DIM*1+YY] -= ty;
944             f[j_coord_offset+DIM*1+ZZ] -= tz;
945
946             }
947
948             /**************************
949              * CALCULATE INTERACTIONS *
950              **************************/
951
952             if (rsq02<rcutoff2)
953             {
954
955             r02              = rsq02*rinv02;
956
957             /* EWALD ELECTROSTATICS */
958
959             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
960             ewrt             = r02*ewtabscale;
961             ewitab           = ewrt;
962             eweps            = ewrt-ewitab;
963             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
964             felec            = qq02*rinv02*(rinvsq02-felec);
965
966             fscal            = felec;
967
968             /* Calculate temporary vectorial force */
969             tx               = fscal*dx02;
970             ty               = fscal*dy02;
971             tz               = fscal*dz02;
972
973             /* Update vectorial force */
974             fix0            += tx;
975             fiy0            += ty;
976             fiz0            += tz;
977             f[j_coord_offset+DIM*2+XX] -= tx;
978             f[j_coord_offset+DIM*2+YY] -= ty;
979             f[j_coord_offset+DIM*2+ZZ] -= tz;
980
981             }
982
983             /**************************
984              * CALCULATE INTERACTIONS *
985              **************************/
986
987             if (rsq10<rcutoff2)
988             {
989
990             r10              = rsq10*rinv10;
991
992             /* EWALD ELECTROSTATICS */
993
994             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
995             ewrt             = r10*ewtabscale;
996             ewitab           = ewrt;
997             eweps            = ewrt-ewitab;
998             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
999             felec            = qq10*rinv10*(rinvsq10-felec);
1000
1001             fscal            = felec;
1002
1003             /* Calculate temporary vectorial force */
1004             tx               = fscal*dx10;
1005             ty               = fscal*dy10;
1006             tz               = fscal*dz10;
1007
1008             /* Update vectorial force */
1009             fix1            += tx;
1010             fiy1            += ty;
1011             fiz1            += tz;
1012             f[j_coord_offset+DIM*0+XX] -= tx;
1013             f[j_coord_offset+DIM*0+YY] -= ty;
1014             f[j_coord_offset+DIM*0+ZZ] -= tz;
1015
1016             }
1017
1018             /**************************
1019              * CALCULATE INTERACTIONS *
1020              **************************/
1021
1022             if (rsq11<rcutoff2)
1023             {
1024
1025             r11              = rsq11*rinv11;
1026
1027             /* EWALD ELECTROSTATICS */
1028
1029             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1030             ewrt             = r11*ewtabscale;
1031             ewitab           = ewrt;
1032             eweps            = ewrt-ewitab;
1033             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1034             felec            = qq11*rinv11*(rinvsq11-felec);
1035
1036             fscal            = felec;
1037
1038             /* Calculate temporary vectorial force */
1039             tx               = fscal*dx11;
1040             ty               = fscal*dy11;
1041             tz               = fscal*dz11;
1042
1043             /* Update vectorial force */
1044             fix1            += tx;
1045             fiy1            += ty;
1046             fiz1            += tz;
1047             f[j_coord_offset+DIM*1+XX] -= tx;
1048             f[j_coord_offset+DIM*1+YY] -= ty;
1049             f[j_coord_offset+DIM*1+ZZ] -= tz;
1050
1051             }
1052
1053             /**************************
1054              * CALCULATE INTERACTIONS *
1055              **************************/
1056
1057             if (rsq12<rcutoff2)
1058             {
1059
1060             r12              = rsq12*rinv12;
1061
1062             /* EWALD ELECTROSTATICS */
1063
1064             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1065             ewrt             = r12*ewtabscale;
1066             ewitab           = ewrt;
1067             eweps            = ewrt-ewitab;
1068             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1069             felec            = qq12*rinv12*(rinvsq12-felec);
1070
1071             fscal            = felec;
1072
1073             /* Calculate temporary vectorial force */
1074             tx               = fscal*dx12;
1075             ty               = fscal*dy12;
1076             tz               = fscal*dz12;
1077
1078             /* Update vectorial force */
1079             fix1            += tx;
1080             fiy1            += ty;
1081             fiz1            += tz;
1082             f[j_coord_offset+DIM*2+XX] -= tx;
1083             f[j_coord_offset+DIM*2+YY] -= ty;
1084             f[j_coord_offset+DIM*2+ZZ] -= tz;
1085
1086             }
1087
1088             /**************************
1089              * CALCULATE INTERACTIONS *
1090              **************************/
1091
1092             if (rsq20<rcutoff2)
1093             {
1094
1095             r20              = rsq20*rinv20;
1096
1097             /* EWALD ELECTROSTATICS */
1098
1099             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1100             ewrt             = r20*ewtabscale;
1101             ewitab           = ewrt;
1102             eweps            = ewrt-ewitab;
1103             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1104             felec            = qq20*rinv20*(rinvsq20-felec);
1105
1106             fscal            = felec;
1107
1108             /* Calculate temporary vectorial force */
1109             tx               = fscal*dx20;
1110             ty               = fscal*dy20;
1111             tz               = fscal*dz20;
1112
1113             /* Update vectorial force */
1114             fix2            += tx;
1115             fiy2            += ty;
1116             fiz2            += tz;
1117             f[j_coord_offset+DIM*0+XX] -= tx;
1118             f[j_coord_offset+DIM*0+YY] -= ty;
1119             f[j_coord_offset+DIM*0+ZZ] -= tz;
1120
1121             }
1122
1123             /**************************
1124              * CALCULATE INTERACTIONS *
1125              **************************/
1126
1127             if (rsq21<rcutoff2)
1128             {
1129
1130             r21              = rsq21*rinv21;
1131
1132             /* EWALD ELECTROSTATICS */
1133
1134             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1135             ewrt             = r21*ewtabscale;
1136             ewitab           = ewrt;
1137             eweps            = ewrt-ewitab;
1138             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1139             felec            = qq21*rinv21*(rinvsq21-felec);
1140
1141             fscal            = felec;
1142
1143             /* Calculate temporary vectorial force */
1144             tx               = fscal*dx21;
1145             ty               = fscal*dy21;
1146             tz               = fscal*dz21;
1147
1148             /* Update vectorial force */
1149             fix2            += tx;
1150             fiy2            += ty;
1151             fiz2            += tz;
1152             f[j_coord_offset+DIM*1+XX] -= tx;
1153             f[j_coord_offset+DIM*1+YY] -= ty;
1154             f[j_coord_offset+DIM*1+ZZ] -= tz;
1155
1156             }
1157
1158             /**************************
1159              * CALCULATE INTERACTIONS *
1160              **************************/
1161
1162             if (rsq22<rcutoff2)
1163             {
1164
1165             r22              = rsq22*rinv22;
1166
1167             /* EWALD ELECTROSTATICS */
1168
1169             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1170             ewrt             = r22*ewtabscale;
1171             ewitab           = ewrt;
1172             eweps            = ewrt-ewitab;
1173             felec            = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1174             felec            = qq22*rinv22*(rinvsq22-felec);
1175
1176             fscal            = felec;
1177
1178             /* Calculate temporary vectorial force */
1179             tx               = fscal*dx22;
1180             ty               = fscal*dy22;
1181             tz               = fscal*dz22;
1182
1183             /* Update vectorial force */
1184             fix2            += tx;
1185             fiy2            += ty;
1186             fiz2            += tz;
1187             f[j_coord_offset+DIM*2+XX] -= tx;
1188             f[j_coord_offset+DIM*2+YY] -= ty;
1189             f[j_coord_offset+DIM*2+ZZ] -= tz;
1190
1191             }
1192
1193             /* Inner loop uses 297 flops */
1194         }
1195         /* End of innermost loop */
1196
1197         tx = ty = tz = 0;
1198         f[i_coord_offset+DIM*0+XX] += fix0;
1199         f[i_coord_offset+DIM*0+YY] += fiy0;
1200         f[i_coord_offset+DIM*0+ZZ] += fiz0;
1201         tx                         += fix0;
1202         ty                         += fiy0;
1203         tz                         += fiz0;
1204         f[i_coord_offset+DIM*1+XX] += fix1;
1205         f[i_coord_offset+DIM*1+YY] += fiy1;
1206         f[i_coord_offset+DIM*1+ZZ] += fiz1;
1207         tx                         += fix1;
1208         ty                         += fiy1;
1209         tz                         += fiz1;
1210         f[i_coord_offset+DIM*2+XX] += fix2;
1211         f[i_coord_offset+DIM*2+YY] += fiy2;
1212         f[i_coord_offset+DIM*2+ZZ] += fiz2;
1213         tx                         += fix2;
1214         ty                         += fiy2;
1215         tz                         += fiz2;
1216         fshift[i_shift_offset+XX]  += tx;
1217         fshift[i_shift_offset+YY]  += ty;
1218         fshift[i_shift_offset+ZZ]  += tz;
1219
1220         /* Increment number of inner iterations */
1221         inneriter                  += j_index_end - j_index_start;
1222
1223         /* Outer loop uses 30 flops */
1224     }
1225
1226     /* Increment number of outer iterations */
1227     outeriter        += nri;
1228
1229     /* Update outer/inner flops */
1230
1231     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*30 + inneriter*297);
1232 }