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