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