db775e61e280f7f9d31e89a6cf543e028584c43c
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_c.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS c kernel generator.
37  */
38 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
46
47 /*
48  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_VF_c
49  * Electrostatics interaction: ReactionField
50  * VdW interaction:            Buckingham
51  * Geometry:                   Water3-Particle
52  * Calculate force/pot:        PotentialAndForce
53  */
54 void
55 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_VF_c
56                     (t_nblist                    * gmx_restrict       nlist,
57                      rvec                        * gmx_restrict          xx,
58                      rvec                        * gmx_restrict          ff,
59                      t_forcerec                  * gmx_restrict          fr,
60                      t_mdatoms                   * gmx_restrict     mdatoms,
61                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62                      t_nrnb                      * gmx_restrict        nrnb)
63 {
64     int              i_shift_offset,i_coord_offset,j_coord_offset;
65     int              j_index_start,j_index_end;
66     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
69     real             *shiftvec,*fshift,*x,*f;
70     int              vdwioffset0;
71     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
72     int              vdwioffset1;
73     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74     int              vdwioffset2;
75     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
76     int              vdwjidx0;
77     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81     real             velec,felec,velecsum,facel,crf,krf,krf2;
82     real             *charge;
83     int              nvdwtype;
84     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
85     int              *vdwtype;
86     real             *vdwparam;
87
88     x                = xx[0];
89     f                = ff[0];
90
91     nri              = nlist->nri;
92     iinr             = nlist->iinr;
93     jindex           = nlist->jindex;
94     jjnr             = nlist->jjnr;
95     shiftidx         = nlist->shift;
96     gid              = nlist->gid;
97     shiftvec         = fr->shift_vec[0];
98     fshift           = fr->fshift[0];
99     facel            = fr->epsfac;
100     charge           = mdatoms->chargeA;
101     krf              = fr->ic->k_rf;
102     krf2             = krf*2.0;
103     crf              = fr->ic->c_rf;
104     nvdwtype         = fr->ntype;
105     vdwparam         = fr->nbfp;
106     vdwtype          = mdatoms->typeA;
107
108     /* Setup water-specific parameters */
109     inr              = nlist->iinr[0];
110     iq0              = facel*charge[inr+0];
111     iq1              = facel*charge[inr+1];
112     iq2              = facel*charge[inr+2];
113     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
114
115     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
116     rcutoff          = fr->rcoulomb;
117     rcutoff2         = rcutoff*rcutoff;
118
119     sh_vdw_invrcut6  = fr->ic->sh_invrc6;
120     rvdw             = fr->rvdw;
121
122     outeriter        = 0;
123     inneriter        = 0;
124
125     /* Start outer loop over neighborlists */
126     for(iidx=0; iidx<nri; iidx++)
127     {
128         /* Load shift vector for this list */
129         i_shift_offset   = DIM*shiftidx[iidx];
130         shX              = shiftvec[i_shift_offset+XX];
131         shY              = shiftvec[i_shift_offset+YY];
132         shZ              = shiftvec[i_shift_offset+ZZ];
133
134         /* Load limits for loop over neighbors */
135         j_index_start    = jindex[iidx];
136         j_index_end      = jindex[iidx+1];
137
138         /* Get outer coordinate index */
139         inr              = iinr[iidx];
140         i_coord_offset   = DIM*inr;
141
142         /* Load i particle coords and add shift vector */
143         ix0              = shX + x[i_coord_offset+DIM*0+XX];
144         iy0              = shY + x[i_coord_offset+DIM*0+YY];
145         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
146         ix1              = shX + x[i_coord_offset+DIM*1+XX];
147         iy1              = shY + x[i_coord_offset+DIM*1+YY];
148         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
149         ix2              = shX + x[i_coord_offset+DIM*2+XX];
150         iy2              = shY + x[i_coord_offset+DIM*2+YY];
151         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
152
153         fix0             = 0.0;
154         fiy0             = 0.0;
155         fiz0             = 0.0;
156         fix1             = 0.0;
157         fiy1             = 0.0;
158         fiz1             = 0.0;
159         fix2             = 0.0;
160         fiy2             = 0.0;
161         fiz2             = 0.0;
162
163         /* Reset potential sums */
164         velecsum         = 0.0;
165         vvdwsum          = 0.0;
166
167         /* Start inner kernel loop */
168         for(jidx=j_index_start; jidx<j_index_end; jidx++)
169         {
170             /* Get j neighbor index, and coordinate index */
171             jnr              = jjnr[jidx];
172             j_coord_offset   = DIM*jnr;
173
174             /* load j atom coordinates */
175             jx0              = x[j_coord_offset+DIM*0+XX];
176             jy0              = x[j_coord_offset+DIM*0+YY];
177             jz0              = x[j_coord_offset+DIM*0+ZZ];
178
179             /* Calculate displacement vector */
180             dx00             = ix0 - jx0;
181             dy00             = iy0 - jy0;
182             dz00             = iz0 - jz0;
183             dx10             = ix1 - jx0;
184             dy10             = iy1 - jy0;
185             dz10             = iz1 - jz0;
186             dx20             = ix2 - jx0;
187             dy20             = iy2 - jy0;
188             dz20             = iz2 - jz0;
189
190             /* Calculate squared distance and things based on it */
191             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
192             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
193             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
194
195             rinv00           = gmx_invsqrt(rsq00);
196             rinv10           = gmx_invsqrt(rsq10);
197             rinv20           = gmx_invsqrt(rsq20);
198
199             rinvsq00         = rinv00*rinv00;
200             rinvsq10         = rinv10*rinv10;
201             rinvsq20         = rinv20*rinv20;
202
203             /* Load parameters for j particles */
204             jq0              = charge[jnr+0];
205             vdwjidx0         = 3*vdwtype[jnr+0];
206
207             /**************************
208              * CALCULATE INTERACTIONS *
209              **************************/
210
211             if (rsq00<rcutoff2)
212             {
213
214             r00              = rsq00*rinv00;
215
216             qq00             = iq0*jq0;
217             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
218             cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
219             cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
220
221             /* REACTION-FIELD ELECTROSTATICS */
222             velec            = qq00*(rinv00+krf*rsq00-crf);
223             felec            = qq00*(rinv00*rinvsq00-krf2);
224
225             /* BUCKINGHAM DISPERSION/REPULSION */
226             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
227             vvdw6            = c6_00*rinvsix;
228             br               = cexp2_00*r00;
229             vvdwexp          = cexp1_00*exp(-br);
230             vvdw             = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
231             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
232
233             /* Update potential sums from outer loop */
234             velecsum        += velec;
235             vvdwsum         += vvdw;
236
237             fscal            = felec+fvdw;
238
239             /* Calculate temporary vectorial force */
240             tx               = fscal*dx00;
241             ty               = fscal*dy00;
242             tz               = fscal*dz00;
243
244             /* Update vectorial force */
245             fix0            += tx;
246             fiy0            += ty;
247             fiz0            += tz;
248             f[j_coord_offset+DIM*0+XX] -= tx;
249             f[j_coord_offset+DIM*0+YY] -= ty;
250             f[j_coord_offset+DIM*0+ZZ] -= tz;
251
252             }
253
254             /**************************
255              * CALCULATE INTERACTIONS *
256              **************************/
257
258             if (rsq10<rcutoff2)
259             {
260
261             qq10             = iq1*jq0;
262
263             /* REACTION-FIELD ELECTROSTATICS */
264             velec            = qq10*(rinv10+krf*rsq10-crf);
265             felec            = qq10*(rinv10*rinvsq10-krf2);
266
267             /* Update potential sums from outer loop */
268             velecsum        += velec;
269
270             fscal            = felec;
271
272             /* Calculate temporary vectorial force */
273             tx               = fscal*dx10;
274             ty               = fscal*dy10;
275             tz               = fscal*dz10;
276
277             /* Update vectorial force */
278             fix1            += tx;
279             fiy1            += ty;
280             fiz1            += tz;
281             f[j_coord_offset+DIM*0+XX] -= tx;
282             f[j_coord_offset+DIM*0+YY] -= ty;
283             f[j_coord_offset+DIM*0+ZZ] -= tz;
284
285             }
286
287             /**************************
288              * CALCULATE INTERACTIONS *
289              **************************/
290
291             if (rsq20<rcutoff2)
292             {
293
294             qq20             = iq2*jq0;
295
296             /* REACTION-FIELD ELECTROSTATICS */
297             velec            = qq20*(rinv20+krf*rsq20-crf);
298             felec            = qq20*(rinv20*rinvsq20-krf2);
299
300             /* Update potential sums from outer loop */
301             velecsum        += velec;
302
303             fscal            = felec;
304
305             /* Calculate temporary vectorial force */
306             tx               = fscal*dx20;
307             ty               = fscal*dy20;
308             tz               = fscal*dz20;
309
310             /* Update vectorial force */
311             fix2            += tx;
312             fiy2            += ty;
313             fiz2            += tz;
314             f[j_coord_offset+DIM*0+XX] -= tx;
315             f[j_coord_offset+DIM*0+YY] -= ty;
316             f[j_coord_offset+DIM*0+ZZ] -= tz;
317
318             }
319
320             /* Inner loop uses 166 flops */
321         }
322         /* End of innermost loop */
323
324         tx = ty = tz = 0;
325         f[i_coord_offset+DIM*0+XX] += fix0;
326         f[i_coord_offset+DIM*0+YY] += fiy0;
327         f[i_coord_offset+DIM*0+ZZ] += fiz0;
328         tx                         += fix0;
329         ty                         += fiy0;
330         tz                         += fiz0;
331         f[i_coord_offset+DIM*1+XX] += fix1;
332         f[i_coord_offset+DIM*1+YY] += fiy1;
333         f[i_coord_offset+DIM*1+ZZ] += fiz1;
334         tx                         += fix1;
335         ty                         += fiy1;
336         tz                         += fiz1;
337         f[i_coord_offset+DIM*2+XX] += fix2;
338         f[i_coord_offset+DIM*2+YY] += fiy2;
339         f[i_coord_offset+DIM*2+ZZ] += fiz2;
340         tx                         += fix2;
341         ty                         += fiy2;
342         tz                         += fiz2;
343         fshift[i_shift_offset+XX]  += tx;
344         fshift[i_shift_offset+YY]  += ty;
345         fshift[i_shift_offset+ZZ]  += tz;
346
347         ggid                        = gid[iidx];
348         /* Update potential energies */
349         kernel_data->energygrp_elec[ggid] += velecsum;
350         kernel_data->energygrp_vdw[ggid] += vvdwsum;
351
352         /* Increment number of inner iterations */
353         inneriter                  += j_index_end - j_index_start;
354
355         /* Outer loop uses 32 flops */
356     }
357
358     /* Increment number of outer iterations */
359     outeriter        += nri;
360
361     /* Update outer/inner flops */
362
363     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*166);
364 }
365 /*
366  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_F_c
367  * Electrostatics interaction: ReactionField
368  * VdW interaction:            Buckingham
369  * Geometry:                   Water3-Particle
370  * Calculate force/pot:        Force
371  */
372 void
373 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_F_c
374                     (t_nblist                    * gmx_restrict       nlist,
375                      rvec                        * gmx_restrict          xx,
376                      rvec                        * gmx_restrict          ff,
377                      t_forcerec                  * gmx_restrict          fr,
378                      t_mdatoms                   * gmx_restrict     mdatoms,
379                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
380                      t_nrnb                      * gmx_restrict        nrnb)
381 {
382     int              i_shift_offset,i_coord_offset,j_coord_offset;
383     int              j_index_start,j_index_end;
384     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
385     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
386     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
387     real             *shiftvec,*fshift,*x,*f;
388     int              vdwioffset0;
389     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
390     int              vdwioffset1;
391     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
392     int              vdwioffset2;
393     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
394     int              vdwjidx0;
395     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
396     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
397     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
398     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
399     real             velec,felec,velecsum,facel,crf,krf,krf2;
400     real             *charge;
401     int              nvdwtype;
402     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
403     int              *vdwtype;
404     real             *vdwparam;
405
406     x                = xx[0];
407     f                = ff[0];
408
409     nri              = nlist->nri;
410     iinr             = nlist->iinr;
411     jindex           = nlist->jindex;
412     jjnr             = nlist->jjnr;
413     shiftidx         = nlist->shift;
414     gid              = nlist->gid;
415     shiftvec         = fr->shift_vec[0];
416     fshift           = fr->fshift[0];
417     facel            = fr->epsfac;
418     charge           = mdatoms->chargeA;
419     krf              = fr->ic->k_rf;
420     krf2             = krf*2.0;
421     crf              = fr->ic->c_rf;
422     nvdwtype         = fr->ntype;
423     vdwparam         = fr->nbfp;
424     vdwtype          = mdatoms->typeA;
425
426     /* Setup water-specific parameters */
427     inr              = nlist->iinr[0];
428     iq0              = facel*charge[inr+0];
429     iq1              = facel*charge[inr+1];
430     iq2              = facel*charge[inr+2];
431     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
432
433     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
434     rcutoff          = fr->rcoulomb;
435     rcutoff2         = rcutoff*rcutoff;
436
437     sh_vdw_invrcut6  = fr->ic->sh_invrc6;
438     rvdw             = fr->rvdw;
439
440     outeriter        = 0;
441     inneriter        = 0;
442
443     /* Start outer loop over neighborlists */
444     for(iidx=0; iidx<nri; iidx++)
445     {
446         /* Load shift vector for this list */
447         i_shift_offset   = DIM*shiftidx[iidx];
448         shX              = shiftvec[i_shift_offset+XX];
449         shY              = shiftvec[i_shift_offset+YY];
450         shZ              = shiftvec[i_shift_offset+ZZ];
451
452         /* Load limits for loop over neighbors */
453         j_index_start    = jindex[iidx];
454         j_index_end      = jindex[iidx+1];
455
456         /* Get outer coordinate index */
457         inr              = iinr[iidx];
458         i_coord_offset   = DIM*inr;
459
460         /* Load i particle coords and add shift vector */
461         ix0              = shX + x[i_coord_offset+DIM*0+XX];
462         iy0              = shY + x[i_coord_offset+DIM*0+YY];
463         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
464         ix1              = shX + x[i_coord_offset+DIM*1+XX];
465         iy1              = shY + x[i_coord_offset+DIM*1+YY];
466         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
467         ix2              = shX + x[i_coord_offset+DIM*2+XX];
468         iy2              = shY + x[i_coord_offset+DIM*2+YY];
469         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
470
471         fix0             = 0.0;
472         fiy0             = 0.0;
473         fiz0             = 0.0;
474         fix1             = 0.0;
475         fiy1             = 0.0;
476         fiz1             = 0.0;
477         fix2             = 0.0;
478         fiy2             = 0.0;
479         fiz2             = 0.0;
480
481         /* Start inner kernel loop */
482         for(jidx=j_index_start; jidx<j_index_end; jidx++)
483         {
484             /* Get j neighbor index, and coordinate index */
485             jnr              = jjnr[jidx];
486             j_coord_offset   = DIM*jnr;
487
488             /* load j atom coordinates */
489             jx0              = x[j_coord_offset+DIM*0+XX];
490             jy0              = x[j_coord_offset+DIM*0+YY];
491             jz0              = x[j_coord_offset+DIM*0+ZZ];
492
493             /* Calculate displacement vector */
494             dx00             = ix0 - jx0;
495             dy00             = iy0 - jy0;
496             dz00             = iz0 - jz0;
497             dx10             = ix1 - jx0;
498             dy10             = iy1 - jy0;
499             dz10             = iz1 - jz0;
500             dx20             = ix2 - jx0;
501             dy20             = iy2 - jy0;
502             dz20             = iz2 - jz0;
503
504             /* Calculate squared distance and things based on it */
505             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
506             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
507             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
508
509             rinv00           = gmx_invsqrt(rsq00);
510             rinv10           = gmx_invsqrt(rsq10);
511             rinv20           = gmx_invsqrt(rsq20);
512
513             rinvsq00         = rinv00*rinv00;
514             rinvsq10         = rinv10*rinv10;
515             rinvsq20         = rinv20*rinv20;
516
517             /* Load parameters for j particles */
518             jq0              = charge[jnr+0];
519             vdwjidx0         = 3*vdwtype[jnr+0];
520
521             /**************************
522              * CALCULATE INTERACTIONS *
523              **************************/
524
525             if (rsq00<rcutoff2)
526             {
527
528             r00              = rsq00*rinv00;
529
530             qq00             = iq0*jq0;
531             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
532             cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
533             cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
534
535             /* REACTION-FIELD ELECTROSTATICS */
536             felec            = qq00*(rinv00*rinvsq00-krf2);
537
538             /* BUCKINGHAM DISPERSION/REPULSION */
539             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
540             vvdw6            = c6_00*rinvsix;
541             br               = cexp2_00*r00;
542             vvdwexp          = cexp1_00*exp(-br);
543             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
544
545             fscal            = felec+fvdw;
546
547             /* Calculate temporary vectorial force */
548             tx               = fscal*dx00;
549             ty               = fscal*dy00;
550             tz               = fscal*dz00;
551
552             /* Update vectorial force */
553             fix0            += tx;
554             fiy0            += ty;
555             fiz0            += tz;
556             f[j_coord_offset+DIM*0+XX] -= tx;
557             f[j_coord_offset+DIM*0+YY] -= ty;
558             f[j_coord_offset+DIM*0+ZZ] -= tz;
559
560             }
561
562             /**************************
563              * CALCULATE INTERACTIONS *
564              **************************/
565
566             if (rsq10<rcutoff2)
567             {
568
569             qq10             = iq1*jq0;
570
571             /* REACTION-FIELD ELECTROSTATICS */
572             felec            = qq10*(rinv10*rinvsq10-krf2);
573
574             fscal            = felec;
575
576             /* Calculate temporary vectorial force */
577             tx               = fscal*dx10;
578             ty               = fscal*dy10;
579             tz               = fscal*dz10;
580
581             /* Update vectorial force */
582             fix1            += tx;
583             fiy1            += ty;
584             fiz1            += tz;
585             f[j_coord_offset+DIM*0+XX] -= tx;
586             f[j_coord_offset+DIM*0+YY] -= ty;
587             f[j_coord_offset+DIM*0+ZZ] -= tz;
588
589             }
590
591             /**************************
592              * CALCULATE INTERACTIONS *
593              **************************/
594
595             if (rsq20<rcutoff2)
596             {
597
598             qq20             = iq2*jq0;
599
600             /* REACTION-FIELD ELECTROSTATICS */
601             felec            = qq20*(rinv20*rinvsq20-krf2);
602
603             fscal            = felec;
604
605             /* Calculate temporary vectorial force */
606             tx               = fscal*dx20;
607             ty               = fscal*dy20;
608             tz               = fscal*dz20;
609
610             /* Update vectorial force */
611             fix2            += tx;
612             fiy2            += ty;
613             fiz2            += tz;
614             f[j_coord_offset+DIM*0+XX] -= tx;
615             f[j_coord_offset+DIM*0+YY] -= ty;
616             f[j_coord_offset+DIM*0+ZZ] -= tz;
617
618             }
619
620             /* Inner loop uses 117 flops */
621         }
622         /* End of innermost loop */
623
624         tx = ty = tz = 0;
625         f[i_coord_offset+DIM*0+XX] += fix0;
626         f[i_coord_offset+DIM*0+YY] += fiy0;
627         f[i_coord_offset+DIM*0+ZZ] += fiz0;
628         tx                         += fix0;
629         ty                         += fiy0;
630         tz                         += fiz0;
631         f[i_coord_offset+DIM*1+XX] += fix1;
632         f[i_coord_offset+DIM*1+YY] += fiy1;
633         f[i_coord_offset+DIM*1+ZZ] += fiz1;
634         tx                         += fix1;
635         ty                         += fiy1;
636         tz                         += fiz1;
637         f[i_coord_offset+DIM*2+XX] += fix2;
638         f[i_coord_offset+DIM*2+YY] += fiy2;
639         f[i_coord_offset+DIM*2+ZZ] += fiz2;
640         tx                         += fix2;
641         ty                         += fiy2;
642         tz                         += fiz2;
643         fshift[i_shift_offset+XX]  += tx;
644         fshift[i_shift_offset+YY]  += ty;
645         fshift[i_shift_offset+ZZ]  += tz;
646
647         /* Increment number of inner iterations */
648         inneriter                  += j_index_end - j_index_start;
649
650         /* Outer loop uses 30 flops */
651     }
652
653     /* Increment number of outer iterations */
654     outeriter        += nri;
655
656     /* Update outer/inner flops */
657
658     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);
659 }