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