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