Fix component for libcudart
[alexxy/gromacs.git] / src / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRFCut_VdwLJSw_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_VdwLJSw_GeomW3P1_VF_c
35  * Electrostatics interaction: ReactionField
36  * VdW interaction:            LennardJones
37  * Geometry:                   Water3-Particle
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecRFCut_VdwLJSw_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     real             rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
74
75     x                = xx[0];
76     f                = ff[0];
77
78     nri              = nlist->nri;
79     iinr             = nlist->iinr;
80     jindex           = nlist->jindex;
81     jjnr             = nlist->jjnr;
82     shiftidx         = nlist->shift;
83     gid              = nlist->gid;
84     shiftvec         = fr->shift_vec[0];
85     fshift           = fr->fshift[0];
86     facel            = fr->epsfac;
87     charge           = mdatoms->chargeA;
88     krf              = fr->ic->k_rf;
89     krf2             = krf*2.0;
90     crf              = fr->ic->c_rf;
91     nvdwtype         = fr->ntype;
92     vdwparam         = fr->nbfp;
93     vdwtype          = mdatoms->typeA;
94
95     /* Setup water-specific parameters */
96     inr              = nlist->iinr[0];
97     iq0              = facel*charge[inr+0];
98     iq1              = facel*charge[inr+1];
99     iq2              = facel*charge[inr+2];
100     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
101
102     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
103     rcutoff          = fr->rcoulomb;
104     rcutoff2         = rcutoff*rcutoff;
105
106     rswitch          = fr->rvdw_switch;
107     /* Setup switch parameters */
108     d                = rcutoff-rswitch;
109     swV3             = -10.0/(d*d*d);
110     swV4             =  15.0/(d*d*d*d);
111     swV5             =  -6.0/(d*d*d*d*d);
112     swF2             = -30.0/(d*d*d);
113     swF3             =  60.0/(d*d*d*d);
114     swF4             = -30.0/(d*d*d*d*d);
115
116     outeriter        = 0;
117     inneriter        = 0;
118
119     /* Start outer loop over neighborlists */
120     for(iidx=0; iidx<nri; iidx++)
121     {
122         /* Load shift vector for this list */
123         i_shift_offset   = DIM*shiftidx[iidx];
124         shX              = shiftvec[i_shift_offset+XX];
125         shY              = shiftvec[i_shift_offset+YY];
126         shZ              = shiftvec[i_shift_offset+ZZ];
127
128         /* Load limits for loop over neighbors */
129         j_index_start    = jindex[iidx];
130         j_index_end      = jindex[iidx+1];
131
132         /* Get outer coordinate index */
133         inr              = iinr[iidx];
134         i_coord_offset   = DIM*inr;
135
136         /* Load i particle coords and add shift vector */
137         ix0              = shX + x[i_coord_offset+DIM*0+XX];
138         iy0              = shY + x[i_coord_offset+DIM*0+YY];
139         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
140         ix1              = shX + x[i_coord_offset+DIM*1+XX];
141         iy1              = shY + x[i_coord_offset+DIM*1+YY];
142         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
143         ix2              = shX + x[i_coord_offset+DIM*2+XX];
144         iy2              = shY + x[i_coord_offset+DIM*2+YY];
145         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
146
147         fix0             = 0.0;
148         fiy0             = 0.0;
149         fiz0             = 0.0;
150         fix1             = 0.0;
151         fiy1             = 0.0;
152         fiz1             = 0.0;
153         fix2             = 0.0;
154         fiy2             = 0.0;
155         fiz2             = 0.0;
156
157         /* Reset potential sums */
158         velecsum         = 0.0;
159         vvdwsum          = 0.0;
160
161         /* Start inner kernel loop */
162         for(jidx=j_index_start; jidx<j_index_end; jidx++)
163         {
164             /* Get j neighbor index, and coordinate index */
165             jnr              = jjnr[jidx];
166             j_coord_offset   = DIM*jnr;
167
168             /* load j atom coordinates */
169             jx0              = x[j_coord_offset+DIM*0+XX];
170             jy0              = x[j_coord_offset+DIM*0+YY];
171             jz0              = x[j_coord_offset+DIM*0+ZZ];
172
173             /* Calculate displacement vector */
174             dx00             = ix0 - jx0;
175             dy00             = iy0 - jy0;
176             dz00             = iz0 - jz0;
177             dx10             = ix1 - jx0;
178             dy10             = iy1 - jy0;
179             dz10             = iz1 - jz0;
180             dx20             = ix2 - jx0;
181             dy20             = iy2 - jy0;
182             dz20             = iz2 - jz0;
183
184             /* Calculate squared distance and things based on it */
185             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
186             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
187             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
188
189             rinv00           = gmx_invsqrt(rsq00);
190             rinv10           = gmx_invsqrt(rsq10);
191             rinv20           = gmx_invsqrt(rsq20);
192
193             rinvsq00         = rinv00*rinv00;
194             rinvsq10         = rinv10*rinv10;
195             rinvsq20         = rinv20*rinv20;
196
197             /* Load parameters for j particles */
198             jq0              = charge[jnr+0];
199             vdwjidx0         = 2*vdwtype[jnr+0];
200
201             /**************************
202              * CALCULATE INTERACTIONS *
203              **************************/
204
205             if (rsq00<rcutoff2)
206             {
207
208             r00              = rsq00*rinv00;
209
210             qq00             = iq0*jq0;
211             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
212             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
213
214             /* REACTION-FIELD ELECTROSTATICS */
215             velec            = qq00*(rinv00+krf*rsq00-crf);
216             felec            = qq00*(rinv00*rinvsq00-krf2);
217
218             /* LENNARD-JONES DISPERSION/REPULSION */
219
220             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
221             vvdw6            = c6_00*rinvsix;
222             vvdw12           = c12_00*rinvsix*rinvsix;
223             vvdw             = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
224             fvdw             = (vvdw12-vvdw6)*rinvsq00;
225
226             d                = r00-rswitch;
227             d                = (d>0.0) ? d : 0.0;
228             d2               = d*d;
229             sw               = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
230
231             dsw              = d2*(swF2+d*(swF3+d*swF4));
232
233             /* Evaluate switch function */
234             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
235             fvdw             = fvdw*sw - rinv00*vvdw*dsw;
236             vvdw            *= sw;
237
238             /* Update potential sums from outer loop */
239             velecsum        += velec;
240             vvdwsum         += vvdw;
241
242             fscal            = felec+fvdw;
243
244             /* Calculate temporary vectorial force */
245             tx               = fscal*dx00;
246             ty               = fscal*dy00;
247             tz               = fscal*dz00;
248
249             /* Update vectorial force */
250             fix0            += tx;
251             fiy0            += ty;
252             fiz0            += tz;
253             f[j_coord_offset+DIM*0+XX] -= tx;
254             f[j_coord_offset+DIM*0+YY] -= ty;
255             f[j_coord_offset+DIM*0+ZZ] -= tz;
256
257             }
258
259             /**************************
260              * CALCULATE INTERACTIONS *
261              **************************/
262
263             if (rsq10<rcutoff2)
264             {
265
266             qq10             = iq1*jq0;
267
268             /* REACTION-FIELD ELECTROSTATICS */
269             velec            = qq10*(rinv10+krf*rsq10-crf);
270             felec            = qq10*(rinv10*rinvsq10-krf2);
271
272             /* Update potential sums from outer loop */
273             velecsum        += velec;
274
275             fscal            = felec;
276
277             /* Calculate temporary vectorial force */
278             tx               = fscal*dx10;
279             ty               = fscal*dy10;
280             tz               = fscal*dz10;
281
282             /* Update vectorial force */
283             fix1            += tx;
284             fiy1            += ty;
285             fiz1            += tz;
286             f[j_coord_offset+DIM*0+XX] -= tx;
287             f[j_coord_offset+DIM*0+YY] -= ty;
288             f[j_coord_offset+DIM*0+ZZ] -= tz;
289
290             }
291
292             /**************************
293              * CALCULATE INTERACTIONS *
294              **************************/
295
296             if (rsq20<rcutoff2)
297             {
298
299             qq20             = iq2*jq0;
300
301             /* REACTION-FIELD ELECTROSTATICS */
302             velec            = qq20*(rinv20+krf*rsq20-crf);
303             felec            = qq20*(rinv20*rinvsq20-krf2);
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             }
324
325             /* Inner loop uses 127 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*127);
369 }
370 /*
371  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSw_GeomW3P1_F_c
372  * Electrostatics interaction: ReactionField
373  * VdW interaction:            LennardJones
374  * Geometry:                   Water3-Particle
375  * Calculate force/pot:        Force
376  */
377 void
378 nb_kernel_ElecRFCut_VdwLJSw_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_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     real             rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
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     krf              = fr->ic->k_rf;
426     krf2             = krf*2.0;
427     crf              = fr->ic->c_rf;
428     nvdwtype         = fr->ntype;
429     vdwparam         = fr->nbfp;
430     vdwtype          = mdatoms->typeA;
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     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
440     rcutoff          = fr->rcoulomb;
441     rcutoff2         = rcutoff*rcutoff;
442
443     rswitch          = fr->rvdw_switch;
444     /* Setup switch parameters */
445     d                = rcutoff-rswitch;
446     swV3             = -10.0/(d*d*d);
447     swV4             =  15.0/(d*d*d*d);
448     swV5             =  -6.0/(d*d*d*d*d);
449     swF2             = -30.0/(d*d*d);
450     swF3             =  60.0/(d*d*d*d);
451     swF4             = -30.0/(d*d*d*d*d);
452
453     outeriter        = 0;
454     inneriter        = 0;
455
456     /* Start outer loop over neighborlists */
457     for(iidx=0; iidx<nri; iidx++)
458     {
459         /* Load shift vector for this list */
460         i_shift_offset   = DIM*shiftidx[iidx];
461         shX              = shiftvec[i_shift_offset+XX];
462         shY              = shiftvec[i_shift_offset+YY];
463         shZ              = shiftvec[i_shift_offset+ZZ];
464
465         /* Load limits for loop over neighbors */
466         j_index_start    = jindex[iidx];
467         j_index_end      = jindex[iidx+1];
468
469         /* Get outer coordinate index */
470         inr              = iinr[iidx];
471         i_coord_offset   = DIM*inr;
472
473         /* Load i particle coords and add shift vector */
474         ix0              = shX + x[i_coord_offset+DIM*0+XX];
475         iy0              = shY + x[i_coord_offset+DIM*0+YY];
476         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
477         ix1              = shX + x[i_coord_offset+DIM*1+XX];
478         iy1              = shY + x[i_coord_offset+DIM*1+YY];
479         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
480         ix2              = shX + x[i_coord_offset+DIM*2+XX];
481         iy2              = shY + x[i_coord_offset+DIM*2+YY];
482         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
483
484         fix0             = 0.0;
485         fiy0             = 0.0;
486         fiz0             = 0.0;
487         fix1             = 0.0;
488         fiy1             = 0.0;
489         fiz1             = 0.0;
490         fix2             = 0.0;
491         fiy2             = 0.0;
492         fiz2             = 0.0;
493
494         /* Start inner kernel loop */
495         for(jidx=j_index_start; jidx<j_index_end; jidx++)
496         {
497             /* Get j neighbor index, and coordinate index */
498             jnr              = jjnr[jidx];
499             j_coord_offset   = DIM*jnr;
500
501             /* load j atom coordinates */
502             jx0              = x[j_coord_offset+DIM*0+XX];
503             jy0              = x[j_coord_offset+DIM*0+YY];
504             jz0              = x[j_coord_offset+DIM*0+ZZ];
505
506             /* Calculate displacement vector */
507             dx00             = ix0 - jx0;
508             dy00             = iy0 - jy0;
509             dz00             = iz0 - jz0;
510             dx10             = ix1 - jx0;
511             dy10             = iy1 - jy0;
512             dz10             = iz1 - jz0;
513             dx20             = ix2 - jx0;
514             dy20             = iy2 - jy0;
515             dz20             = iz2 - jz0;
516
517             /* Calculate squared distance and things based on it */
518             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
519             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
520             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
521
522             rinv00           = gmx_invsqrt(rsq00);
523             rinv10           = gmx_invsqrt(rsq10);
524             rinv20           = gmx_invsqrt(rsq20);
525
526             rinvsq00         = rinv00*rinv00;
527             rinvsq10         = rinv10*rinv10;
528             rinvsq20         = rinv20*rinv20;
529
530             /* Load parameters for j particles */
531             jq0              = charge[jnr+0];
532             vdwjidx0         = 2*vdwtype[jnr+0];
533
534             /**************************
535              * CALCULATE INTERACTIONS *
536              **************************/
537
538             if (rsq00<rcutoff2)
539             {
540
541             r00              = rsq00*rinv00;
542
543             qq00             = iq0*jq0;
544             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
545             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
546
547             /* REACTION-FIELD ELECTROSTATICS */
548             felec            = qq00*(rinv00*rinvsq00-krf2);
549
550             /* LENNARD-JONES DISPERSION/REPULSION */
551
552             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
553             vvdw6            = c6_00*rinvsix;
554             vvdw12           = c12_00*rinvsix*rinvsix;
555             vvdw             = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
556             fvdw             = (vvdw12-vvdw6)*rinvsq00;
557
558             d                = r00-rswitch;
559             d                = (d>0.0) ? d : 0.0;
560             d2               = d*d;
561             sw               = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
562
563             dsw              = d2*(swF2+d*(swF3+d*swF4));
564
565             /* Evaluate switch function */
566             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
567             fvdw             = fvdw*sw - rinv00*vvdw*dsw;
568
569             fscal            = felec+fvdw;
570
571             /* Calculate temporary vectorial force */
572             tx               = fscal*dx00;
573             ty               = fscal*dy00;
574             tz               = fscal*dz00;
575
576             /* Update vectorial force */
577             fix0            += tx;
578             fiy0            += ty;
579             fiz0            += tz;
580             f[j_coord_offset+DIM*0+XX] -= tx;
581             f[j_coord_offset+DIM*0+YY] -= ty;
582             f[j_coord_offset+DIM*0+ZZ] -= tz;
583
584             }
585
586             /**************************
587              * CALCULATE INTERACTIONS *
588              **************************/
589
590             if (rsq10<rcutoff2)
591             {
592
593             qq10             = iq1*jq0;
594
595             /* REACTION-FIELD ELECTROSTATICS */
596             felec            = qq10*(rinv10*rinvsq10-krf2);
597
598             fscal            = felec;
599
600             /* Calculate temporary vectorial force */
601             tx               = fscal*dx10;
602             ty               = fscal*dy10;
603             tz               = fscal*dz10;
604
605             /* Update vectorial force */
606             fix1            += tx;
607             fiy1            += ty;
608             fiz1            += tz;
609             f[j_coord_offset+DIM*0+XX] -= tx;
610             f[j_coord_offset+DIM*0+YY] -= ty;
611             f[j_coord_offset+DIM*0+ZZ] -= tz;
612
613             }
614
615             /**************************
616              * CALCULATE INTERACTIONS *
617              **************************/
618
619             if (rsq20<rcutoff2)
620             {
621
622             qq20             = iq2*jq0;
623
624             /* REACTION-FIELD ELECTROSTATICS */
625             felec            = qq20*(rinv20*rinvsq20-krf2);
626
627             fscal            = felec;
628
629             /* Calculate temporary vectorial force */
630             tx               = fscal*dx20;
631             ty               = fscal*dy20;
632             tz               = fscal*dz20;
633
634             /* Update vectorial force */
635             fix2            += tx;
636             fiy2            += ty;
637             fiz2            += tz;
638             f[j_coord_offset+DIM*0+XX] -= tx;
639             f[j_coord_offset+DIM*0+YY] -= ty;
640             f[j_coord_offset+DIM*0+ZZ] -= tz;
641
642             }
643
644             /* Inner loop uses 110 flops */
645         }
646         /* End of innermost loop */
647
648         tx = ty = tz = 0;
649         f[i_coord_offset+DIM*0+XX] += fix0;
650         f[i_coord_offset+DIM*0+YY] += fiy0;
651         f[i_coord_offset+DIM*0+ZZ] += fiz0;
652         tx                         += fix0;
653         ty                         += fiy0;
654         tz                         += fiz0;
655         f[i_coord_offset+DIM*1+XX] += fix1;
656         f[i_coord_offset+DIM*1+YY] += fiy1;
657         f[i_coord_offset+DIM*1+ZZ] += fiz1;
658         tx                         += fix1;
659         ty                         += fiy1;
660         tz                         += fiz1;
661         f[i_coord_offset+DIM*2+XX] += fix2;
662         f[i_coord_offset+DIM*2+YY] += fiy2;
663         f[i_coord_offset+DIM*2+ZZ] += fiz2;
664         tx                         += fix2;
665         ty                         += fiy2;
666         tz                         += fiz2;
667         fshift[i_shift_offset+XX]  += tx;
668         fshift[i_shift_offset+YY]  += ty;
669         fshift[i_shift_offset+ZZ]  += tz;
670
671         /* Increment number of inner iterations */
672         inneriter                  += j_index_end - j_index_start;
673
674         /* Outer loop uses 30 flops */
675     }
676
677     /* Increment number of outer iterations */
678     outeriter        += nri;
679
680     /* Update outer/inner flops */
681
682     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*110);
683 }