Merge '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             F                = vftab[vfitab+1];
529             Geps             = vfeps*vftab[vfitab+2];
530             Heps2            = vfeps*vfeps*vftab[vfitab+3];
531             Fp               = F+Geps+Heps2;
532             FF               = Fp+Geps+2.0*Heps2;
533             fvdw6            = c6_00*FF;
534
535             /* CUBIC SPLINE TABLE REPULSION */
536             F                = vftab[vfitab+5];
537             Geps             = vfeps*vftab[vfitab+6];
538             Heps2            = vfeps*vfeps*vftab[vfitab+7];
539             Fp               = F+Geps+Heps2;
540             FF               = Fp+Geps+2.0*Heps2;
541             fvdw12           = c12_00*FF;
542             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
543
544             fscal            = felec+fvdw;
545
546             /* Calculate temporary vectorial force */
547             tx               = fscal*dx00;
548             ty               = fscal*dy00;
549             tz               = fscal*dz00;
550
551             /* Update vectorial force */
552             fix0            += tx;
553             fiy0            += ty;
554             fiz0            += tz;
555             f[j_coord_offset+DIM*0+XX] -= tx;
556             f[j_coord_offset+DIM*0+YY] -= ty;
557             f[j_coord_offset+DIM*0+ZZ] -= tz;
558
559             /**************************
560              * CALCULATE INTERACTIONS *
561              **************************/
562
563             qq10             = iq1*jq0;
564
565             /* COULOMB ELECTROSTATICS */
566             velec            = qq10*rinv10;
567             felec            = velec*rinvsq10;
568
569             fscal            = felec;
570
571             /* Calculate temporary vectorial force */
572             tx               = fscal*dx10;
573             ty               = fscal*dy10;
574             tz               = fscal*dz10;
575
576             /* Update vectorial force */
577             fix1            += tx;
578             fiy1            += ty;
579             fiz1            += tz;
580             f[j_coord_offset+DIM*0+XX] -= tx;
581             f[j_coord_offset+DIM*0+YY] -= ty;
582             f[j_coord_offset+DIM*0+ZZ] -= tz;
583
584             /**************************
585              * CALCULATE INTERACTIONS *
586              **************************/
587
588             qq20             = iq2*jq0;
589
590             /* COULOMB ELECTROSTATICS */
591             velec            = qq20*rinv20;
592             felec            = velec*rinvsq20;
593
594             fscal            = felec;
595
596             /* Calculate temporary vectorial force */
597             tx               = fscal*dx20;
598             ty               = fscal*dy20;
599             tz               = fscal*dz20;
600
601             /* Update vectorial force */
602             fix2            += tx;
603             fiy2            += ty;
604             fiz2            += tz;
605             f[j_coord_offset+DIM*0+XX] -= tx;
606             f[j_coord_offset+DIM*0+YY] -= ty;
607             f[j_coord_offset+DIM*0+ZZ] -= tz;
608
609             /* Inner loop uses 107 flops */
610         }
611         /* End of innermost loop */
612
613         tx = ty = tz = 0;
614         f[i_coord_offset+DIM*0+XX] += fix0;
615         f[i_coord_offset+DIM*0+YY] += fiy0;
616         f[i_coord_offset+DIM*0+ZZ] += fiz0;
617         tx                         += fix0;
618         ty                         += fiy0;
619         tz                         += fiz0;
620         f[i_coord_offset+DIM*1+XX] += fix1;
621         f[i_coord_offset+DIM*1+YY] += fiy1;
622         f[i_coord_offset+DIM*1+ZZ] += fiz1;
623         tx                         += fix1;
624         ty                         += fiy1;
625         tz                         += fiz1;
626         f[i_coord_offset+DIM*2+XX] += fix2;
627         f[i_coord_offset+DIM*2+YY] += fiy2;
628         f[i_coord_offset+DIM*2+ZZ] += fiz2;
629         tx                         += fix2;
630         ty                         += fiy2;
631         tz                         += fiz2;
632         fshift[i_shift_offset+XX]  += tx;
633         fshift[i_shift_offset+YY]  += ty;
634         fshift[i_shift_offset+ZZ]  += tz;
635
636         /* Increment number of inner iterations */
637         inneriter                  += j_index_end - j_index_start;
638
639         /* Outer loop uses 30 flops */
640     }
641
642     /* Increment number of outer iterations */
643     outeriter        += nri;
644
645     /* Update outer/inner flops */
646
647     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);
648 }