Fix component for libcudart
[alexxy/gromacs.git] / src / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRFCut_VdwBhamSw_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_VdwBhamSw_GeomW3P1_VF_c
35  * Electrostatics interaction: ReactionField
36  * VdW interaction:            Buckingham
37  * Geometry:                   Water3-Particle
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecRFCut_VdwBhamSw_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      = 3*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         = 3*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             cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
213             cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
214
215             /* REACTION-FIELD ELECTROSTATICS */
216             velec            = qq00*(rinv00+krf*rsq00-crf);
217             felec            = qq00*(rinv00*rinvsq00-krf2);
218
219             /* BUCKINGHAM DISPERSION/REPULSION */
220             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
221             vvdw6            = c6_00*rinvsix;
222             br               = cexp2_00*r00;
223             vvdwexp          = cexp1_00*exp(-br);
224             vvdw             = vvdwexp - vvdw6*(1.0/6.0);
225             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
226
227             d                = r00-rswitch;
228             d                = (d>0.0) ? d : 0.0;
229             d2               = d*d;
230             sw               = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
231
232             dsw              = d2*(swF2+d*(swF3+d*swF4));
233
234             /* Evaluate switch function */
235             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
236             fvdw             = fvdw*sw - rinv00*vvdw*dsw;
237             vvdw            *= sw;
238
239             /* Update potential sums from outer loop */
240             velecsum        += velec;
241             vvdwsum         += vvdw;
242
243             fscal            = felec+fvdw;
244
245             /* Calculate temporary vectorial force */
246             tx               = fscal*dx00;
247             ty               = fscal*dy00;
248             tz               = fscal*dz00;
249
250             /* Update vectorial force */
251             fix0            += tx;
252             fiy0            += ty;
253             fiz0            += tz;
254             f[j_coord_offset+DIM*0+XX] -= tx;
255             f[j_coord_offset+DIM*0+YY] -= ty;
256             f[j_coord_offset+DIM*0+ZZ] -= tz;
257
258             }
259
260             /**************************
261              * CALCULATE INTERACTIONS *
262              **************************/
263
264             if (rsq10<rcutoff2)
265             {
266
267             qq10             = iq1*jq0;
268
269             /* REACTION-FIELD ELECTROSTATICS */
270             velec            = qq10*(rinv10+krf*rsq10-crf);
271             felec            = qq10*(rinv10*rinvsq10-krf2);
272
273             /* Update potential sums from outer loop */
274             velecsum        += velec;
275
276             fscal            = felec;
277
278             /* Calculate temporary vectorial force */
279             tx               = fscal*dx10;
280             ty               = fscal*dy10;
281             tz               = fscal*dz10;
282
283             /* Update vectorial force */
284             fix1            += tx;
285             fiy1            += ty;
286             fiz1            += tz;
287             f[j_coord_offset+DIM*0+XX] -= tx;
288             f[j_coord_offset+DIM*0+YY] -= ty;
289             f[j_coord_offset+DIM*0+ZZ] -= tz;
290
291             }
292
293             /**************************
294              * CALCULATE INTERACTIONS *
295              **************************/
296
297             if (rsq20<rcutoff2)
298             {
299
300             qq20             = iq2*jq0;
301
302             /* REACTION-FIELD ELECTROSTATICS */
303             velec            = qq20*(rinv20+krf*rsq20-crf);
304             felec            = qq20*(rinv20*rinvsq20-krf2);
305
306             /* Update potential sums from outer loop */
307             velecsum        += velec;
308
309             fscal            = felec;
310
311             /* Calculate temporary vectorial force */
312             tx               = fscal*dx20;
313             ty               = fscal*dy20;
314             tz               = fscal*dz20;
315
316             /* Update vectorial force */
317             fix2            += tx;
318             fiy2            += ty;
319             fiz2            += tz;
320             f[j_coord_offset+DIM*0+XX] -= tx;
321             f[j_coord_offset+DIM*0+YY] -= ty;
322             f[j_coord_offset+DIM*0+ZZ] -= tz;
323
324             }
325
326             /* Inner loop uses 153 flops */
327         }
328         /* End of innermost loop */
329
330         tx = ty = tz = 0;
331         f[i_coord_offset+DIM*0+XX] += fix0;
332         f[i_coord_offset+DIM*0+YY] += fiy0;
333         f[i_coord_offset+DIM*0+ZZ] += fiz0;
334         tx                         += fix0;
335         ty                         += fiy0;
336         tz                         += fiz0;
337         f[i_coord_offset+DIM*1+XX] += fix1;
338         f[i_coord_offset+DIM*1+YY] += fiy1;
339         f[i_coord_offset+DIM*1+ZZ] += fiz1;
340         tx                         += fix1;
341         ty                         += fiy1;
342         tz                         += fiz1;
343         f[i_coord_offset+DIM*2+XX] += fix2;
344         f[i_coord_offset+DIM*2+YY] += fiy2;
345         f[i_coord_offset+DIM*2+ZZ] += fiz2;
346         tx                         += fix2;
347         ty                         += fiy2;
348         tz                         += fiz2;
349         fshift[i_shift_offset+XX]  += tx;
350         fshift[i_shift_offset+YY]  += ty;
351         fshift[i_shift_offset+ZZ]  += tz;
352
353         ggid                        = gid[iidx];
354         /* Update potential energies */
355         kernel_data->energygrp_elec[ggid] += velecsum;
356         kernel_data->energygrp_vdw[ggid] += vvdwsum;
357
358         /* Increment number of inner iterations */
359         inneriter                  += j_index_end - j_index_start;
360
361         /* Outer loop uses 32 flops */
362     }
363
364     /* Increment number of outer iterations */
365     outeriter        += nri;
366
367     /* Update outer/inner flops */
368
369     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*153);
370 }
371 /*
372  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwBhamSw_GeomW3P1_F_c
373  * Electrostatics interaction: ReactionField
374  * VdW interaction:            Buckingham
375  * Geometry:                   Water3-Particle
376  * Calculate force/pot:        Force
377  */
378 void
379 nb_kernel_ElecRFCut_VdwBhamSw_GeomW3P1_F_c
380                     (t_nblist * gmx_restrict                nlist,
381                      rvec * gmx_restrict                    xx,
382                      rvec * gmx_restrict                    ff,
383                      t_forcerec * gmx_restrict              fr,
384                      t_mdatoms * gmx_restrict               mdatoms,
385                      nb_kernel_data_t * gmx_restrict        kernel_data,
386                      t_nrnb * gmx_restrict                  nrnb)
387 {
388     int              i_shift_offset,i_coord_offset,j_coord_offset;
389     int              j_index_start,j_index_end;
390     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
391     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
392     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
393     real             *shiftvec,*fshift,*x,*f;
394     int              vdwioffset0;
395     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
396     int              vdwioffset1;
397     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
398     int              vdwioffset2;
399     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
400     int              vdwjidx0;
401     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
402     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
403     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
404     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
405     real             velec,felec,velecsum,facel,crf,krf,krf2;
406     real             *charge;
407     int              nvdwtype;
408     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
409     int              *vdwtype;
410     real             *vdwparam;
411     real             rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
412
413     x                = xx[0];
414     f                = ff[0];
415
416     nri              = nlist->nri;
417     iinr             = nlist->iinr;
418     jindex           = nlist->jindex;
419     jjnr             = nlist->jjnr;
420     shiftidx         = nlist->shift;
421     gid              = nlist->gid;
422     shiftvec         = fr->shift_vec[0];
423     fshift           = fr->fshift[0];
424     facel            = fr->epsfac;
425     charge           = mdatoms->chargeA;
426     krf              = fr->ic->k_rf;
427     krf2             = krf*2.0;
428     crf              = fr->ic->c_rf;
429     nvdwtype         = fr->ntype;
430     vdwparam         = fr->nbfp;
431     vdwtype          = mdatoms->typeA;
432
433     /* Setup water-specific parameters */
434     inr              = nlist->iinr[0];
435     iq0              = facel*charge[inr+0];
436     iq1              = facel*charge[inr+1];
437     iq2              = facel*charge[inr+2];
438     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
439
440     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
441     rcutoff          = fr->rcoulomb;
442     rcutoff2         = rcutoff*rcutoff;
443
444     rswitch          = fr->rvdw_switch;
445     /* Setup switch parameters */
446     d                = rcutoff-rswitch;
447     swV3             = -10.0/(d*d*d);
448     swV4             =  15.0/(d*d*d*d);
449     swV5             =  -6.0/(d*d*d*d*d);
450     swF2             = -30.0/(d*d*d);
451     swF3             =  60.0/(d*d*d*d);
452     swF4             = -30.0/(d*d*d*d*d);
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         = 3*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             cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
547             cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
548
549             /* REACTION-FIELD ELECTROSTATICS */
550             felec            = qq00*(rinv00*rinvsq00-krf2);
551
552             /* BUCKINGHAM DISPERSION/REPULSION */
553             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
554             vvdw6            = c6_00*rinvsix;
555             br               = cexp2_00*r00;
556             vvdwexp          = cexp1_00*exp(-br);
557             vvdw             = vvdwexp - vvdw6*(1.0/6.0);
558             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
559
560             d                = r00-rswitch;
561             d                = (d>0.0) ? d : 0.0;
562             d2               = d*d;
563             sw               = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
564
565             dsw              = d2*(swF2+d*(swF3+d*swF4));
566
567             /* Evaluate switch function */
568             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
569             fvdw             = fvdw*sw - rinv00*vvdw*dsw;
570
571             fscal            = felec+fvdw;
572
573             /* Calculate temporary vectorial force */
574             tx               = fscal*dx00;
575             ty               = fscal*dy00;
576             tz               = fscal*dz00;
577
578             /* Update vectorial force */
579             fix0            += tx;
580             fiy0            += ty;
581             fiz0            += tz;
582             f[j_coord_offset+DIM*0+XX] -= tx;
583             f[j_coord_offset+DIM*0+YY] -= ty;
584             f[j_coord_offset+DIM*0+ZZ] -= tz;
585
586             }
587
588             /**************************
589              * CALCULATE INTERACTIONS *
590              **************************/
591
592             if (rsq10<rcutoff2)
593             {
594
595             qq10             = iq1*jq0;
596
597             /* REACTION-FIELD ELECTROSTATICS */
598             felec            = qq10*(rinv10*rinvsq10-krf2);
599
600             fscal            = felec;
601
602             /* Calculate temporary vectorial force */
603             tx               = fscal*dx10;
604             ty               = fscal*dy10;
605             tz               = fscal*dz10;
606
607             /* Update vectorial force */
608             fix1            += tx;
609             fiy1            += ty;
610             fiz1            += tz;
611             f[j_coord_offset+DIM*0+XX] -= tx;
612             f[j_coord_offset+DIM*0+YY] -= ty;
613             f[j_coord_offset+DIM*0+ZZ] -= tz;
614
615             }
616
617             /**************************
618              * CALCULATE INTERACTIONS *
619              **************************/
620
621             if (rsq20<rcutoff2)
622             {
623
624             qq20             = iq2*jq0;
625
626             /* REACTION-FIELD ELECTROSTATICS */
627             felec            = qq20*(rinv20*rinvsq20-krf2);
628
629             fscal            = felec;
630
631             /* Calculate temporary vectorial force */
632             tx               = fscal*dx20;
633             ty               = fscal*dy20;
634             tz               = fscal*dz20;
635
636             /* Update vectorial force */
637             fix2            += tx;
638             fiy2            += ty;
639             fiz2            += tz;
640             f[j_coord_offset+DIM*0+XX] -= tx;
641             f[j_coord_offset+DIM*0+YY] -= ty;
642             f[j_coord_offset+DIM*0+ZZ] -= tz;
643
644             }
645
646             /* Inner loop uses 136 flops */
647         }
648         /* End of innermost loop */
649
650         tx = ty = tz = 0;
651         f[i_coord_offset+DIM*0+XX] += fix0;
652         f[i_coord_offset+DIM*0+YY] += fiy0;
653         f[i_coord_offset+DIM*0+ZZ] += fiz0;
654         tx                         += fix0;
655         ty                         += fiy0;
656         tz                         += fiz0;
657         f[i_coord_offset+DIM*1+XX] += fix1;
658         f[i_coord_offset+DIM*1+YY] += fiy1;
659         f[i_coord_offset+DIM*1+ZZ] += fiz1;
660         tx                         += fix1;
661         ty                         += fiy1;
662         tz                         += fiz1;
663         f[i_coord_offset+DIM*2+XX] += fix2;
664         f[i_coord_offset+DIM*2+YY] += fiy2;
665         f[i_coord_offset+DIM*2+ZZ] += fiz2;
666         tx                         += fix2;
667         ty                         += fiy2;
668         tz                         += fiz2;
669         fshift[i_shift_offset+XX]  += tx;
670         fshift[i_shift_offset+YY]  += ty;
671         fshift[i_shift_offset+ZZ]  += tz;
672
673         /* Increment number of inner iterations */
674         inneriter                  += j_index_end - j_index_start;
675
676         /* Outer loop uses 30 flops */
677     }
678
679     /* Increment number of outer iterations */
680     outeriter        += nri;
681
682     /* Update outer/inner flops */
683
684     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*136);
685 }