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