Merge origin/release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_c.c
1 /*
2  * Note: this file was generated by the Gromacs c kernel generator.
3  *
4  *                This source code is part of
5  *
6  *                 G   R   O   M   A   C   S
7  *
8  * Copyright (c) 2001-2012, The GROMACS Development Team
9  *
10  * Gromacs is a library for molecular simulation and trajectory analysis,
11  * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12  * a full list of developers and information, check out http://www.gromacs.org
13  *
14  * This program is free software; you can redistribute it and/or modify it under
15  * the terms of the GNU Lesser General Public License as published by the Free
16  * Software Foundation; either version 2 of the License, or (at your option) any
17  * later version.
18  *
19  * To help fund GROMACS development, we humbly ask that you cite
20  * the papers people have written on it - you can find them on the website.
21  */
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <math.h>
27
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
30 #include "vec.h"
31 #include "nrnb.h"
32
33 /*
34  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_VF_c
35  * Electrostatics interaction: Coulomb
36  * VdW interaction:            CubicSplineTable
37  * Geometry:                   Water3-Particle
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_VF_c
42                     (t_nblist * gmx_restrict                nlist,
43                      rvec * gmx_restrict                    xx,
44                      rvec * gmx_restrict                    ff,
45                      t_forcerec * gmx_restrict              fr,
46                      t_mdatoms * gmx_restrict               mdatoms,
47                      nb_kernel_data_t * gmx_restrict        kernel_data,
48                      t_nrnb * gmx_restrict                  nrnb)
49 {
50     int              i_shift_offset,i_coord_offset,j_coord_offset;
51     int              j_index_start,j_index_end;
52     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
55     real             *shiftvec,*fshift,*x,*f;
56     int              vdwioffset0;
57     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
58     int              vdwioffset1;
59     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
60     int              vdwioffset2;
61     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
62     int              vdwjidx0;
63     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
67     real             velec,felec,velecsum,facel,crf,krf,krf2;
68     real             *charge;
69     int              nvdwtype;
70     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
71     int              *vdwtype;
72     real             *vdwparam;
73     int              vfitab;
74     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
75     real             *vftab;
76
77     x                = xx[0];
78     f                = ff[0];
79
80     nri              = nlist->nri;
81     iinr             = nlist->iinr;
82     jindex           = nlist->jindex;
83     jjnr             = nlist->jjnr;
84     shiftidx         = nlist->shift;
85     gid              = nlist->gid;
86     shiftvec         = fr->shift_vec[0];
87     fshift           = fr->fshift[0];
88     facel            = fr->epsfac;
89     charge           = mdatoms->chargeA;
90     nvdwtype         = fr->ntype;
91     vdwparam         = fr->nbfp;
92     vdwtype          = mdatoms->typeA;
93
94     vftab            = kernel_data->table_vdw->data;
95     vftabscale       = kernel_data->table_vdw->scale;
96
97     /* Setup water-specific parameters */
98     inr              = nlist->iinr[0];
99     iq0              = facel*charge[inr+0];
100     iq1              = facel*charge[inr+1];
101     iq2              = facel*charge[inr+2];
102     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
103
104     outeriter        = 0;
105     inneriter        = 0;
106
107     /* Start outer loop over neighborlists */
108     for(iidx=0; iidx<nri; iidx++)
109     {
110         /* Load shift vector for this list */
111         i_shift_offset   = DIM*shiftidx[iidx];
112         shX              = shiftvec[i_shift_offset+XX];
113         shY              = shiftvec[i_shift_offset+YY];
114         shZ              = shiftvec[i_shift_offset+ZZ];
115
116         /* Load limits for loop over neighbors */
117         j_index_start    = jindex[iidx];
118         j_index_end      = jindex[iidx+1];
119
120         /* Get outer coordinate index */
121         inr              = iinr[iidx];
122         i_coord_offset   = DIM*inr;
123
124         /* Load i particle coords and add shift vector */
125         ix0              = shX + x[i_coord_offset+DIM*0+XX];
126         iy0              = shY + x[i_coord_offset+DIM*0+YY];
127         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
128         ix1              = shX + x[i_coord_offset+DIM*1+XX];
129         iy1              = shY + x[i_coord_offset+DIM*1+YY];
130         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
131         ix2              = shX + x[i_coord_offset+DIM*2+XX];
132         iy2              = shY + x[i_coord_offset+DIM*2+YY];
133         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
134
135         fix0             = 0.0;
136         fiy0             = 0.0;
137         fiz0             = 0.0;
138         fix1             = 0.0;
139         fiy1             = 0.0;
140         fiz1             = 0.0;
141         fix2             = 0.0;
142         fiy2             = 0.0;
143         fiz2             = 0.0;
144
145         /* Reset potential sums */
146         velecsum         = 0.0;
147         vvdwsum          = 0.0;
148
149         /* Start inner kernel loop */
150         for(jidx=j_index_start; jidx<j_index_end; jidx++)
151         {
152             /* Get j neighbor index, and coordinate index */
153             jnr              = jjnr[jidx];
154             j_coord_offset   = DIM*jnr;
155
156             /* load j atom coordinates */
157             jx0              = x[j_coord_offset+DIM*0+XX];
158             jy0              = x[j_coord_offset+DIM*0+YY];
159             jz0              = x[j_coord_offset+DIM*0+ZZ];
160
161             /* Calculate displacement vector */
162             dx00             = ix0 - jx0;
163             dy00             = iy0 - jy0;
164             dz00             = iz0 - jz0;
165             dx10             = ix1 - jx0;
166             dy10             = iy1 - jy0;
167             dz10             = iz1 - jz0;
168             dx20             = ix2 - jx0;
169             dy20             = iy2 - jy0;
170             dz20             = iz2 - jz0;
171
172             /* Calculate squared distance and things based on it */
173             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
174             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
175             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
176
177             rinv00           = gmx_invsqrt(rsq00);
178             rinv10           = gmx_invsqrt(rsq10);
179             rinv20           = gmx_invsqrt(rsq20);
180
181             rinvsq00         = rinv00*rinv00;
182             rinvsq10         = rinv10*rinv10;
183             rinvsq20         = rinv20*rinv20;
184
185             /* Load parameters for j particles */
186             jq0              = charge[jnr+0];
187             vdwjidx0         = 2*vdwtype[jnr+0];
188
189             /**************************
190              * CALCULATE INTERACTIONS *
191              **************************/
192
193             r00              = rsq00*rinv00;
194
195             qq00             = iq0*jq0;
196             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
197             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
198
199             /* Calculate table index by multiplying r with table scale and truncate to integer */
200             rt               = r00*vftabscale;
201             vfitab           = rt;
202             vfeps            = rt-vfitab;
203             vfitab           = 2*4*vfitab;
204
205             /* COULOMB ELECTROSTATICS */
206             velec            = qq00*rinv00;
207             felec            = velec*rinvsq00;
208
209             /* CUBIC SPLINE TABLE DISPERSION */
210             vfitab          += 0;
211             Y                = vftab[vfitab];
212             F                = vftab[vfitab+1];
213             Geps             = vfeps*vftab[vfitab+2];
214             Heps2            = vfeps*vfeps*vftab[vfitab+3];
215             Fp               = F+Geps+Heps2;
216             VV               = Y+vfeps*Fp;
217             vvdw6            = c6_00*VV;
218             FF               = Fp+Geps+2.0*Heps2;
219             fvdw6            = c6_00*FF;
220
221             /* CUBIC SPLINE TABLE REPULSION */
222             Y                = vftab[vfitab+4];
223             F                = vftab[vfitab+5];
224             Geps             = vfeps*vftab[vfitab+6];
225             Heps2            = vfeps*vfeps*vftab[vfitab+7];
226             Fp               = F+Geps+Heps2;
227             VV               = Y+vfeps*Fp;
228             vvdw12           = c12_00*VV;
229             FF               = Fp+Geps+2.0*Heps2;
230             fvdw12           = c12_00*FF;
231             vvdw             = vvdw12+vvdw6;
232             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
233
234             /* Update potential sums from outer loop */
235             velecsum        += velec;
236             vvdwsum         += vvdw;
237
238             fscal            = felec+fvdw;
239
240             /* Calculate temporary vectorial force */
241             tx               = fscal*dx00;
242             ty               = fscal*dy00;
243             tz               = fscal*dz00;
244
245             /* Update vectorial force */
246             fix0            += tx;
247             fiy0            += ty;
248             fiz0            += tz;
249             f[j_coord_offset+DIM*0+XX] -= tx;
250             f[j_coord_offset+DIM*0+YY] -= ty;
251             f[j_coord_offset+DIM*0+ZZ] -= tz;
252
253             /**************************
254              * CALCULATE INTERACTIONS *
255              **************************/
256
257             qq10             = iq1*jq0;
258
259             /* COULOMB ELECTROSTATICS */
260             velec            = qq10*rinv10;
261             felec            = velec*rinvsq10;
262
263             /* Update potential sums from outer loop */
264             velecsum        += velec;
265
266             fscal            = felec;
267
268             /* Calculate temporary vectorial force */
269             tx               = fscal*dx10;
270             ty               = fscal*dy10;
271             tz               = fscal*dz10;
272
273             /* Update vectorial force */
274             fix1            += tx;
275             fiy1            += ty;
276             fiz1            += tz;
277             f[j_coord_offset+DIM*0+XX] -= tx;
278             f[j_coord_offset+DIM*0+YY] -= ty;
279             f[j_coord_offset+DIM*0+ZZ] -= tz;
280
281             /**************************
282              * CALCULATE INTERACTIONS *
283              **************************/
284
285             qq20             = iq2*jq0;
286
287             /* COULOMB ELECTROSTATICS */
288             velec            = qq20*rinv20;
289             felec            = velec*rinvsq20;
290
291             /* Update potential sums from outer loop */
292             velecsum        += velec;
293
294             fscal            = felec;
295
296             /* Calculate temporary vectorial force */
297             tx               = fscal*dx20;
298             ty               = fscal*dy20;
299             tz               = fscal*dz20;
300
301             /* Update vectorial force */
302             fix2            += tx;
303             fiy2            += ty;
304             fiz2            += tz;
305             f[j_coord_offset+DIM*0+XX] -= tx;
306             f[j_coord_offset+DIM*0+YY] -= ty;
307             f[j_coord_offset+DIM*0+ZZ] -= tz;
308
309             /* Inner loop uses 118 flops */
310         }
311         /* End of innermost loop */
312
313         tx = ty = tz = 0;
314         f[i_coord_offset+DIM*0+XX] += fix0;
315         f[i_coord_offset+DIM*0+YY] += fiy0;
316         f[i_coord_offset+DIM*0+ZZ] += fiz0;
317         tx                         += fix0;
318         ty                         += fiy0;
319         tz                         += fiz0;
320         f[i_coord_offset+DIM*1+XX] += fix1;
321         f[i_coord_offset+DIM*1+YY] += fiy1;
322         f[i_coord_offset+DIM*1+ZZ] += fiz1;
323         tx                         += fix1;
324         ty                         += fiy1;
325         tz                         += fiz1;
326         f[i_coord_offset+DIM*2+XX] += fix2;
327         f[i_coord_offset+DIM*2+YY] += fiy2;
328         f[i_coord_offset+DIM*2+ZZ] += fiz2;
329         tx                         += fix2;
330         ty                         += fiy2;
331         tz                         += fiz2;
332         fshift[i_shift_offset+XX]  += tx;
333         fshift[i_shift_offset+YY]  += ty;
334         fshift[i_shift_offset+ZZ]  += tz;
335
336         ggid                        = gid[iidx];
337         /* Update potential energies */
338         kernel_data->energygrp_elec[ggid] += velecsum;
339         kernel_data->energygrp_vdw[ggid] += vvdwsum;
340
341         /* Increment number of inner iterations */
342         inneriter                  += j_index_end - j_index_start;
343
344         /* Outer loop uses 32 flops */
345     }
346
347     /* Increment number of outer iterations */
348     outeriter        += nri;
349
350     /* Update outer/inner flops */
351
352     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*118);
353 }
354 /*
355  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_F_c
356  * Electrostatics interaction: Coulomb
357  * VdW interaction:            CubicSplineTable
358  * Geometry:                   Water3-Particle
359  * Calculate force/pot:        Force
360  */
361 void
362 nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_F_c
363                     (t_nblist * gmx_restrict                nlist,
364                      rvec * gmx_restrict                    xx,
365                      rvec * gmx_restrict                    ff,
366                      t_forcerec * gmx_restrict              fr,
367                      t_mdatoms * gmx_restrict               mdatoms,
368                      nb_kernel_data_t * gmx_restrict        kernel_data,
369                      t_nrnb * gmx_restrict                  nrnb)
370 {
371     int              i_shift_offset,i_coord_offset,j_coord_offset;
372     int              j_index_start,j_index_end;
373     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
374     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
375     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
376     real             *shiftvec,*fshift,*x,*f;
377     int              vdwioffset0;
378     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
379     int              vdwioffset1;
380     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
381     int              vdwioffset2;
382     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
383     int              vdwjidx0;
384     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
385     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
386     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
387     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
388     real             velec,felec,velecsum,facel,crf,krf,krf2;
389     real             *charge;
390     int              nvdwtype;
391     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
392     int              *vdwtype;
393     real             *vdwparam;
394     int              vfitab;
395     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
396     real             *vftab;
397
398     x                = xx[0];
399     f                = ff[0];
400
401     nri              = nlist->nri;
402     iinr             = nlist->iinr;
403     jindex           = nlist->jindex;
404     jjnr             = nlist->jjnr;
405     shiftidx         = nlist->shift;
406     gid              = nlist->gid;
407     shiftvec         = fr->shift_vec[0];
408     fshift           = fr->fshift[0];
409     facel            = fr->epsfac;
410     charge           = mdatoms->chargeA;
411     nvdwtype         = fr->ntype;
412     vdwparam         = fr->nbfp;
413     vdwtype          = mdatoms->typeA;
414
415     vftab            = kernel_data->table_vdw->data;
416     vftabscale       = kernel_data->table_vdw->scale;
417
418     /* Setup water-specific parameters */
419     inr              = nlist->iinr[0];
420     iq0              = facel*charge[inr+0];
421     iq1              = facel*charge[inr+1];
422     iq2              = facel*charge[inr+2];
423     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
424
425     outeriter        = 0;
426     inneriter        = 0;
427
428     /* Start outer loop over neighborlists */
429     for(iidx=0; iidx<nri; iidx++)
430     {
431         /* Load shift vector for this list */
432         i_shift_offset   = DIM*shiftidx[iidx];
433         shX              = shiftvec[i_shift_offset+XX];
434         shY              = shiftvec[i_shift_offset+YY];
435         shZ              = shiftvec[i_shift_offset+ZZ];
436
437         /* Load limits for loop over neighbors */
438         j_index_start    = jindex[iidx];
439         j_index_end      = jindex[iidx+1];
440
441         /* Get outer coordinate index */
442         inr              = iinr[iidx];
443         i_coord_offset   = DIM*inr;
444
445         /* Load i particle coords and add shift vector */
446         ix0              = shX + x[i_coord_offset+DIM*0+XX];
447         iy0              = shY + x[i_coord_offset+DIM*0+YY];
448         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
449         ix1              = shX + x[i_coord_offset+DIM*1+XX];
450         iy1              = shY + x[i_coord_offset+DIM*1+YY];
451         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
452         ix2              = shX + x[i_coord_offset+DIM*2+XX];
453         iy2              = shY + x[i_coord_offset+DIM*2+YY];
454         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
455
456         fix0             = 0.0;
457         fiy0             = 0.0;
458         fiz0             = 0.0;
459         fix1             = 0.0;
460         fiy1             = 0.0;
461         fiz1             = 0.0;
462         fix2             = 0.0;
463         fiy2             = 0.0;
464         fiz2             = 0.0;
465
466         /* Start inner kernel loop */
467         for(jidx=j_index_start; jidx<j_index_end; jidx++)
468         {
469             /* Get j neighbor index, and coordinate index */
470             jnr              = jjnr[jidx];
471             j_coord_offset   = DIM*jnr;
472
473             /* load j atom coordinates */
474             jx0              = x[j_coord_offset+DIM*0+XX];
475             jy0              = x[j_coord_offset+DIM*0+YY];
476             jz0              = x[j_coord_offset+DIM*0+ZZ];
477
478             /* Calculate displacement vector */
479             dx00             = ix0 - jx0;
480             dy00             = iy0 - jy0;
481             dz00             = iz0 - jz0;
482             dx10             = ix1 - jx0;
483             dy10             = iy1 - jy0;
484             dz10             = iz1 - jz0;
485             dx20             = ix2 - jx0;
486             dy20             = iy2 - jy0;
487             dz20             = iz2 - jz0;
488
489             /* Calculate squared distance and things based on it */
490             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
491             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
492             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
493
494             rinv00           = gmx_invsqrt(rsq00);
495             rinv10           = gmx_invsqrt(rsq10);
496             rinv20           = gmx_invsqrt(rsq20);
497
498             rinvsq00         = rinv00*rinv00;
499             rinvsq10         = rinv10*rinv10;
500             rinvsq20         = rinv20*rinv20;
501
502             /* Load parameters for j particles */
503             jq0              = charge[jnr+0];
504             vdwjidx0         = 2*vdwtype[jnr+0];
505
506             /**************************
507              * CALCULATE INTERACTIONS *
508              **************************/
509
510             r00              = rsq00*rinv00;
511
512             qq00             = iq0*jq0;
513             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
514             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
515
516             /* Calculate table index by multiplying r with table scale and truncate to integer */
517             rt               = r00*vftabscale;
518             vfitab           = rt;
519             vfeps            = rt-vfitab;
520             vfitab           = 2*4*vfitab;
521
522             /* COULOMB ELECTROSTATICS */
523             velec            = qq00*rinv00;
524             felec            = velec*rinvsq00;
525
526             /* CUBIC SPLINE TABLE DISPERSION */
527             vfitab          += 0;
528             Y                = vftab[vfitab];
529             F                = vftab[vfitab+1];
530             Geps             = vfeps*vftab[vfitab+2];
531             Heps2            = vfeps*vfeps*vftab[vfitab+3];
532             Fp               = F+Geps+Heps2;
533             FF               = Fp+Geps+2.0*Heps2;
534             fvdw6            = c6_00*FF;
535
536             /* CUBIC SPLINE TABLE REPULSION */
537             Y                = vftab[vfitab+4];
538             F                = vftab[vfitab+5];
539             Geps             = vfeps*vftab[vfitab+6];
540             Heps2            = vfeps*vfeps*vftab[vfitab+7];
541             Fp               = F+Geps+Heps2;
542             FF               = Fp+Geps+2.0*Heps2;
543             fvdw12           = c12_00*FF;
544             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
545
546             fscal            = felec+fvdw;
547
548             /* Calculate temporary vectorial force */
549             tx               = fscal*dx00;
550             ty               = fscal*dy00;
551             tz               = fscal*dz00;
552
553             /* Update vectorial force */
554             fix0            += tx;
555             fiy0            += ty;
556             fiz0            += tz;
557             f[j_coord_offset+DIM*0+XX] -= tx;
558             f[j_coord_offset+DIM*0+YY] -= ty;
559             f[j_coord_offset+DIM*0+ZZ] -= tz;
560
561             /**************************
562              * CALCULATE INTERACTIONS *
563              **************************/
564
565             qq10             = iq1*jq0;
566
567             /* COULOMB ELECTROSTATICS */
568             velec            = qq10*rinv10;
569             felec            = velec*rinvsq10;
570
571             fscal            = felec;
572
573             /* Calculate temporary vectorial force */
574             tx               = fscal*dx10;
575             ty               = fscal*dy10;
576             tz               = fscal*dz10;
577
578             /* Update vectorial force */
579             fix1            += tx;
580             fiy1            += ty;
581             fiz1            += tz;
582             f[j_coord_offset+DIM*0+XX] -= tx;
583             f[j_coord_offset+DIM*0+YY] -= ty;
584             f[j_coord_offset+DIM*0+ZZ] -= tz;
585
586             /**************************
587              * CALCULATE INTERACTIONS *
588              **************************/
589
590             qq20             = iq2*jq0;
591
592             /* COULOMB ELECTROSTATICS */
593             velec            = qq20*rinv20;
594             felec            = velec*rinvsq20;
595
596             fscal            = felec;
597
598             /* Calculate temporary vectorial force */
599             tx               = fscal*dx20;
600             ty               = fscal*dy20;
601             tz               = fscal*dz20;
602
603             /* Update vectorial force */
604             fix2            += tx;
605             fiy2            += ty;
606             fiz2            += tz;
607             f[j_coord_offset+DIM*0+XX] -= tx;
608             f[j_coord_offset+DIM*0+YY] -= ty;
609             f[j_coord_offset+DIM*0+ZZ] -= tz;
610
611             /* Inner loop uses 107 flops */
612         }
613         /* End of innermost loop */
614
615         tx = ty = tz = 0;
616         f[i_coord_offset+DIM*0+XX] += fix0;
617         f[i_coord_offset+DIM*0+YY] += fiy0;
618         f[i_coord_offset+DIM*0+ZZ] += fiz0;
619         tx                         += fix0;
620         ty                         += fiy0;
621         tz                         += fiz0;
622         f[i_coord_offset+DIM*1+XX] += fix1;
623         f[i_coord_offset+DIM*1+YY] += fiy1;
624         f[i_coord_offset+DIM*1+ZZ] += fiz1;
625         tx                         += fix1;
626         ty                         += fiy1;
627         tz                         += fiz1;
628         f[i_coord_offset+DIM*2+XX] += fix2;
629         f[i_coord_offset+DIM*2+YY] += fiy2;
630         f[i_coord_offset+DIM*2+ZZ] += fiz2;
631         tx                         += fix2;
632         ty                         += fiy2;
633         tz                         += fiz2;
634         fshift[i_shift_offset+XX]  += tx;
635         fshift[i_shift_offset+YY]  += ty;
636         fshift[i_shift_offset+ZZ]  += tz;
637
638         /* Increment number of inner iterations */
639         inneriter                  += j_index_end - j_index_start;
640
641         /* Outer loop uses 30 flops */
642     }
643
644     /* Increment number of outer iterations */
645     outeriter        += nri;
646
647     /* Update outer/inner flops */
648
649     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);
650 }