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