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