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