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