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